libxkbfile-1.1.0/Makefile.in 0000644 0143106 0000012 00000072237 13443241027 0016164 0 ustar 00alanc staff 0000266 0200014 # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 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@
#
# Copyright 2005 Red Hat, Inc.
#
# 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 Red Hat not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Red Hat makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL RED HAT 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.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
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 = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = xkbfile.pc
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-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 \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
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__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
DATA = $(pkgconfig_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/xkbfile.pc.in COPYING ChangeLog INSTALL compile \
config.guess config.sub install-sh ltmain.sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
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"
DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2
GZIP_ENV = --best
DIST_TARGETS = dist-bzip2 dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
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@
BASE_CFLAGS = @BASE_CFLAGS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHANGELOG_CMD = @CHANGELOG_CMD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CWARNFLAGS = @CWARNFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILE_MAN_DIR = @FILE_MAN_DIR@
FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_CMD = @INSTALL_CMD@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_MAN_DIR = @LIB_MAN_DIR@
LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MAN_SUBSTS = @MAN_SUBSTS@
MISC_MAN_DIR = @MISC_MAN_DIR@
MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
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@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRICT_CFLAGS = @STRICT_CFLAGS@
STRIP = @STRIP@
VERSION = @VERSION@
XKBFILE_CFLAGS = @XKBFILE_CFLAGS@
XKBFILE_LIBS = @XKBFILE_LIBS@
XORG_MAN_PAGE = @XORG_MAN_PAGE@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
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 = src
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xkbfile.pc
MAINTAINERCLEANFILES = ChangeLog INSTALL
EXTRA_DIST = README.md
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
config.h: stamp-h1
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
xkbfile.pc: $(top_builddir)/config.status $(srcdir)/xkbfile.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool config.lt
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
done
uninstall-pkgconfigDATA:
@$(NORMAL_UNINSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
# 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.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
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"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
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; \
$(am__define_uniq_tagged_files); \
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-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
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"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@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 \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
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
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(DATA) config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
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:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
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."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-pkgconfigDATA
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 $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-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: uninstall-pkgconfigDATA
.MAKE: $(am__recursive_targets) all install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
dist-tarZ dist-xz dist-zip distcheck distclean \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck 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-pkgconfigDATA 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-am uninstall uninstall-am \
uninstall-pkgconfigDATA
.PRECIOUS: Makefile
.PHONY: ChangeLog INSTALL
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
# 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:
" | 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 libxkbfile-1.1.0/config.guess 0000555 0143106 0000012 00000126212 13443241027 0016426 0 ustar 00alanc staff 0000266 0200014 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2018 Free Software Foundation, Inc.
timestamp='2018-03-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
#
# Please send patches to .
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > "$dummy.c" ;
for c in cc gcc c89 c99 ; do
if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "$UNAME_SYSTEM" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval "$set_cc_for_build"
cat <<-EOF > "$dummy.c"
#include
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
# If ldd exists, use it to detect musl libc.
if command -v ldd >/dev/null && \
ldd --version 2>&1 | grep -q ^musl
then
LIBC=musl
fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
"/sbin/$sysctl" 2>/dev/null || \
"/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
case "$UNAME_MACHINE_ARCH" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
machine="${arch}${endian}"-unknown
;;
*) machine="$UNAME_MACHINE_ARCH"-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
case "$UNAME_MACHINE_ARCH" in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval "$set_cc_for_build"
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# Determine ABI tags.
case "$UNAME_MACHINE_ARCH" in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "$UNAME_VERSION" in
Debian*)
release='-gnu'
;;
*)
release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "$machine-${os}${release}${abi}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
exit ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
exit ;;
*:MidnightBSD:*:*)
echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
exit ;;
*:ekkoBSD:*:*)
echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
exit ;;
*:SolidBSD:*:*)
echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
*:MirBSD:*:*)
echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
*:Sortix:*:*)
echo "$UNAME_MACHINE"-unknown-sortix
exit ;;
*:Redox:*:*)
echo "$UNAME_MACHINE"-unknown-redox
exit ;;
mips:OSF1:*.*)
echo mips-dec-osf1
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE=alpha ;;
"EV4.5 (21064)")
UNAME_MACHINE=alpha ;;
"LCA4 (21066/21068)")
UNAME_MACHINE=alpha ;;
"EV5 (21164)")
UNAME_MACHINE=alphaev5 ;;
"EV5.6 (21164A)")
UNAME_MACHINE=alphaev56 ;;
"EV5.6 (21164PC)")
UNAME_MACHINE=alphapca56 ;;
"EV5.7 (21164PC)")
UNAME_MACHINE=alphapca57 ;;
"EV6 (21264)")
UNAME_MACHINE=alphaev6 ;;
"EV6.7 (21264A)")
UNAME_MACHINE=alphaev67 ;;
"EV6.8CB (21264C)")
UNAME_MACHINE=alphaev68 ;;
"EV6.8AL (21264B)")
UNAME_MACHINE=alphaev68 ;;
"EV6.8CX (21264D)")
UNAME_MACHINE=alphaev68 ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE=alphaev69 ;;
"EV7 (21364)")
UNAME_MACHINE=alphaev7 ;;
"EV7.9 (21364A)")
UNAME_MACHINE=alphaev79 ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo "$UNAME_MACHINE"-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo "$UNAME_MACHINE"-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix"$UNAME_RELEASE"
exit ;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval "$set_cc_for_build"
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH=x86_64
fi
fi
echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos"$UNAME_RELEASE"
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos"$UNAME_RELEASE"
;;
sun4)
echo sparc-sun-sunos"$UNAME_RELEASE"
;;
esac
exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos"$UNAME_RELEASE"
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint"$UNAME_RELEASE"
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint"$UNAME_RELEASE"
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint"$UNAME_RELEASE"
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint"$UNAME_RELEASE"
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten"$UNAME_RELEASE"
exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten"$UNAME_RELEASE"
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix"$UNAME_RELEASE"
exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix"$UNAME_RELEASE"
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix"$UNAME_RELEASE"
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos"$UNAME_RELEASE"
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
then
if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
[ "$TARGET_BINARY_INTERFACE"x = x ]
then
echo m88k-dg-dgux"$UNAME_RELEASE"
else
echo m88k-dg-dguxbcs"$UNAME_RELEASE"
fi
else
echo i586-dg-dgux"$UNAME_RELEASE"
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
then
echo "$SYSTEM_NAME"
else
echo rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/lslpp ] ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
case "$UNAME_MACHINE" in
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "$sc_cpu_version" in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "$sc_kernel_bits" in
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "$HP_ARCH" = "" ]; then
eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ "$HP_ARCH" = hppa2.0w ]
then
eval "$set_cc_for_build"
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
grep -q __LP64__
then
HP_ARCH=hppa2.0w
else
HP_ARCH=hppa64
fi
fi
echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux"$HPUX_REV"
exit ;;
3050*:HI-UX:*:*)
eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo "$UNAME_MACHINE"-unknown-osf1mk
else
echo "$UNAME_MACHINE"-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi"$UNAME_RELEASE"
exit ;;
*:BSD/OS:*:*)
echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
case "$UNAME_PROCESSOR" in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
exit ;;
i*:CYGWIN*:*)
echo "$UNAME_MACHINE"-pc-cygwin
exit ;;
*:MINGW64*:*)
echo "$UNAME_MACHINE"-pc-mingw64
exit ;;
*:MINGW*:*)
echo "$UNAME_MACHINE"-pc-mingw32
exit ;;
*:MSYS*:*)
echo "$UNAME_MACHINE"-pc-msys
exit ;;
i*:PW*:*)
echo "$UNAME_MACHINE"-pc-pw32
exit ;;
*:Interix*:*)
case "$UNAME_MACHINE" in
x86)
echo i586-pc-interix"$UNAME_RELEASE"
exit ;;
authenticamd | genuineintel | EM64T)
echo x86_64-unknown-interix"$UNAME_RELEASE"
exit ;;
IA64)
echo ia64-unknown-interix"$UNAME_RELEASE"
exit ;;
esac ;;
i*:UWIN*:*)
echo "$UNAME_MACHINE"-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
*:GNU:*:*)
# the GNU system
echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
exit ;;
i*86:Minix:*:*)
echo "$UNAME_MACHINE"-pc-minix
exit ;;
aarch64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arm*:Linux:*:*)
eval "$set_cc_for_build"
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
else
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
cris:Linux:*:*)
echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
exit ;;
crisv32:Linux:*:*)
echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
exit ;;
e2k:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
frv:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
hexagon:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
i*86:Linux:*:*)
echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
exit ;;
ia64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
k1om:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
m32r*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
m68*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval "$set_cc_for_build"
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
;;
mips64el:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
openrisc*:Linux:*:*)
echo or1k-unknown-linux-"$LIBC"
exit ;;
or32:Linux:*:* | or1k*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-"$LIBC"
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-"$LIBC"
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
*) echo hppa-unknown-linux-"$LIBC" ;;
esac
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-"$LIBC"
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-"$LIBC"
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-"$LIBC"
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-"$LIBC"
exit ;;
riscv32:Linux:*:* | riscv64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
exit ;;
sh64*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
sh*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
tile*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
vax:Linux:*:*)
echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;;
x86_64:Linux:*:*)
echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
exit ;;
xtensa*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo "$UNAME_MACHINE"-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
echo "$UNAME_MACHINE"-unknown-stop
exit ;;
i*86:atheos:*:*)
echo "$UNAME_MACHINE"-unknown-atheos
exit ;;
i*86:syllable:*:*)
echo "$UNAME_MACHINE"-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos"$UNAME_RELEASE"
exit ;;
i*86:*DOS:*:*)
echo "$UNAME_MACHINE"-pc-msdosdjgpp
exit ;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
else
echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
else
echo "$UNAME_MACHINE"-pc-sysv32
fi
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos"$UNAME_RELEASE"
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos"$UNAME_RELEASE"
exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos"$UNAME_RELEASE"
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos"$UNAME_RELEASE"
exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv"$UNAME_RELEASE"
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo "$UNAME_MACHINE"-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
echo "$UNAME_MACHINE"-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux"$UNAME_RELEASE"
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv"$UNAME_RELEASE"
else
echo mips-unknown-sysv"$UNAME_RELEASE"
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux"$UNAME_RELEASE"
exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux"$UNAME_RELEASE"
exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux"$UNAME_RELEASE"
exit ;;
SX-7:SUPER-UX:*:*)
echo sx7-nec-superux"$UNAME_RELEASE"
exit ;;
SX-8:SUPER-UX:*:*)
echo sx8-nec-superux"$UNAME_RELEASE"
exit ;;
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux"$UNAME_RELEASE"
exit ;;
SX-ACE:SUPER-UX:*:*)
echo sxace-nec-superux"$UNAME_RELEASE"
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody"$UNAME_RELEASE"
exit ;;
*:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
eval "$set_cc_for_build"
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_PPC >/dev/null
then
UNAME_PROCESSOR=powerpc
fi
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
# that puts up a graphical alert prompting to install
# developer tools. Any system running Mac OS X 10.7 or
# later (Darwin 11 and later) is required to have a 64-bit
# processor. This is not true of the ARM version of Darwin
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NEO-*:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk"$UNAME_RELEASE"
exit ;;
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk"$UNAME_RELEASE"
exit ;;
NSR-*:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk"$UNAME_RELEASE"
exit ;;
NSV-*:NONSTOP_KERNEL:*:*)
echo nsv-tandem-nsk"$UNAME_RELEASE"
exit ;;
NSX-*:NONSTOP_KERNEL:*:*)
echo nsx-tandem-nsk"$UNAME_RELEASE"
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = 386; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo "$UNAME_MACHINE"-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux"$UNAME_RELEASE"
exit ;;
*:DragonFly:*:*)
echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "$UNAME_MACHINE" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
exit ;;
i*86:rdos:*:*)
echo "$UNAME_MACHINE"-pc-rdos
exit ;;
i*86:AROS:*:*)
echo "$UNAME_MACHINE"-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo "$UNAME_MACHINE"-unknown-esx
exit ;;
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;;
esac
echo "$0: unable to guess system type" >&2
case "$UNAME_MACHINE:$UNAME_SYSTEM" in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <&2 </dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = "$UNAME_MACHINE"
UNAME_RELEASE = "$UNAME_RELEASE"
UNAME_SYSTEM = "$UNAME_SYSTEM"
UNAME_VERSION = "$UNAME_VERSION"
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-functions 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
cho i586-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo libxkbfile-1.1.0/Makefile.am 0000644 0143106 0000012 00000002551 13443241017 0016142 0 ustar 00alanc staff 0000266 0200014 #
# Copyright 2005 Red Hat, Inc.
#
# 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 Red Hat not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Red Hat makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL RED HAT 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.
SUBDIRS = src
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xkbfile.pc
MAINTAINERCLEANFILES = ChangeLog INSTALL
.PHONY: ChangeLog INSTALL
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
EXTRA_DIST = README.md
libxkbfile-1.1.0/src/XKBfileInt.h 0000644 0143106 0000012 00000005021 13443241017 0017000 0 ustar 00alanc staff 0000266 0200014 #ifndef _XKBFILEINT_H_
#define _XKBFILEINT_H_ 1
/************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#include "XKBfile.h"
#include
#ifdef DEBUG
#define _XkbLibError(c,l,d) \
{ fprintf(stderr,"xkbfile: %s in %s\n",_XkbErrMessages[c],(l)); \
_XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }
#else
#define _XkbLibError(c,l,d) \
{ _XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }
#endif
#define _XkbAlloc(s) malloc((s))
#define _XkbCalloc(n,s) calloc((n),(s))
#define _XkbRealloc(o,s) realloc((o),(s))
#define _XkbTypedAlloc(t) ((t *)malloc(sizeof(t)))
#define _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
#define _XkbTypedRealloc(o,n,t) \
((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
#define _XkbFree(p) free(p)
#ifndef PATH_MAX
#ifdef MAXPATHLEN
#define PATH_MAX MAXPATHLEN
#else
#define PATH_MAX 1024
#endif
#endif
_XFUNCPROTOBEGIN
static inline char *
_XkbDupString(const char *s)
{
return s ? strdup(s) : NULL;
}
#define _XkbStrCaseEqual(s1,s2) (_XkbStrCaseCmp(s1,s2)==0)
#ifdef NEED_STRCASECMP
extern int _XkbStrCaseCmp(char *s1, char *s2);
#else
#define _XkbStrCaseCmp strcasecmp
#include
#endif
_XFUNCPROTOEND
#endif /* _XKBFILEINT_H_ */
libxkbfile-1.1.0/src/xkmout.c 0000644 0143106 0000012 00000132453 13443241017 0016375 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
typedef struct _XkmInfo {
unsigned short bound_vmods;
unsigned short named_vmods;
unsigned char num_bound;
unsigned char group_compat;
unsigned short num_group_compat;
unsigned short num_leds;
int total_vmodmaps;
} XkmInfo;
/***====================================================================***/
#define xkmPutCARD8(f,v) (putc(v,f),1)
static int
xkmPutCARD16(FILE *file, unsigned val)
{
CARD16 tmp = val;
fwrite(&tmp, 2, 1, file);
return 2;
}
static int
xkmPutCARD32(FILE *file, unsigned long val)
{
CARD32 tmp = val;
fwrite(&tmp, 4, 1, file);
return 4;
}
static int
xkmPutPadding(FILE *file, unsigned pad)
{
int i;
for (i = 0; i < pad; i++) {
putc('\0', file);
}
return pad;
}
static int
xkmPutCountedBytes(FILE *file, char *ptr, unsigned count)
{
register int nOut;
register unsigned pad;
if (count == 0)
return xkmPutCARD32(file, (unsigned long) 0);
xkmPutCARD16(file, count);
nOut = fwrite(ptr, 1, count, file);
if (nOut < 0)
return 2;
nOut = count + 2;
pad = XkbPaddedSize(nOut) - nOut;
if (pad)
xkmPutPadding(file, pad);
return nOut + pad;
}
static unsigned
xkmSizeCountedString(char *str)
{
if (str == NULL)
return 4;
return XkbPaddedSize(strlen(str) + 2);
}
static int
xkmPutCountedString(FILE *file, char *str)
{
if (str == NULL)
return xkmPutCARD32(file, (unsigned long) 0);
return xkmPutCountedBytes(file, str, strlen(str));
}
#define xkmSizeCountedAtomString(d,a) \
xkmSizeCountedString(XkbAtomGetString((d),(a)))
#define xkmPutCountedAtomString(d,f,a) \
xkmPutCountedString((f),XkbAtomGetString((d),(a)))
/***====================================================================***/
static unsigned
SizeXKMVirtualMods(XkbFileInfo *result, XkmInfo *info,
xkmSectionInfo *toc, int *offset_inout)
{
Display *dpy;
XkbDescPtr xkb;
unsigned nBound, bound;
unsigned nNamed, named, szNames;
register unsigned i, bit;
xkb = result->xkb;
if ((!xkb) || (!xkb->names) || (!xkb->server)) {
_XkbLibError(_XkbErrMissingVMods, "SizeXKMVirtualMods", 0);
return 0;
}
dpy = xkb->dpy;
bound = named = 0;
for (i = nBound = nNamed = szNames = 0, bit = 1; i < XkbNumVirtualMods;
i++, bit <<= 1) {
if (xkb->server->vmods[i] != XkbNoModifierMask) {
bound |= bit;
nBound++;
}
if (xkb->names->vmods[i] != None) {
named |= bit;
szNames += xkmSizeCountedAtomString(dpy, xkb->names->vmods[i]);
nNamed++;
}
}
info->num_bound = nBound;
info->bound_vmods = bound;
info->named_vmods = named;
if ((nBound == 0) && (nNamed == 0))
return 0;
toc->type = XkmVirtualModsIndex;
toc->format = MSBFirst;
toc->size = 4 + XkbPaddedSize(nBound) + szNames + SIZEOF(xkmSectionInfo);
toc->offset = *offset_inout;
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMVirtualMods(FILE *file, XkbFileInfo *result, XkmInfo *info)
{
register unsigned int i, bit;
XkbDescPtr xkb;
Display *dpy;
unsigned size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
size += xkmPutCARD16(file, info->bound_vmods);
size += xkmPutCARD16(file, info->named_vmods);
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if (info->bound_vmods & bit)
size += xkmPutCARD8(file, xkb->server->vmods[i]);
}
if ((i = XkbPaddedSize(info->num_bound) - info->num_bound) > 0)
size += xkmPutPadding(file, i);
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if (info->named_vmods & bit) {
register char *name;
name = XkbAtomGetString(dpy, xkb->names->vmods[i]);
size += xkmPutCountedString(file, name);
}
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMKeycodes(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
{
XkbDescPtr xkb;
Atom kcName;
int size = 0;
Display *dpy;
xkb = result->xkb;
if ((!xkb) || (!xkb->names) || (!xkb->names->keys)) {
_XkbLibError(_XkbErrMissingNames, "SizeXKMKeycodes", 0);
return 0;
}
dpy = xkb->dpy;
kcName = xkb->names->keycodes;
size += 4; /* min and max keycode */
size += xkmSizeCountedAtomString(dpy, kcName);
size += XkbNumKeys(xkb) * sizeof(XkbKeyNameRec);
if (xkb->names->num_key_aliases > 0) {
if (xkb->names->key_aliases != NULL)
size += xkb->names->num_key_aliases * sizeof(XkbKeyAliasRec);
else
xkb->names->num_key_aliases = 0;
}
toc->type = XkmKeyNamesIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMKeycodes(FILE *file, XkbFileInfo *result)
{
XkbDescPtr xkb;
Atom kcName;
char *start;
Display *dpy;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
kcName = xkb->names->keycodes;
start = xkb->names->keys[xkb->min_key_code].name;
size += xkmPutCountedString(file, XkbAtomGetString(dpy, kcName));
size += xkmPutCARD8(file, xkb->min_key_code);
size += xkmPutCARD8(file, xkb->max_key_code);
size += xkmPutCARD8(file, xkb->names->num_key_aliases);
size += xkmPutPadding(file, 1);
tmp = fwrite(start, sizeof(XkbKeyNameRec), XkbNumKeys(xkb), file);
size += tmp * sizeof(XkbKeyNameRec);
if (xkb->names->num_key_aliases > 0) {
tmp = fwrite((char *) xkb->names->key_aliases,
sizeof(XkbKeyAliasRec), xkb->names->num_key_aliases, file);
size += tmp * sizeof(XkbKeyAliasRec);
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMKeyTypes(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
{
register unsigned i, n, size;
XkbKeyTypePtr type;
XkbDescPtr xkb;
Display *dpy;
char *name;
xkb = result->xkb;
if ((!xkb) || (!xkb->map) || (!xkb->map->types)) {
_XkbLibError(_XkbErrMissingTypes, "SizeXKBKeyTypes", 0);
return 0;
}
dpy = xkb->dpy;
if (xkb->map->num_types < XkbNumRequiredTypes) {
_XkbLibError(_XkbErrMissingReqTypes, "SizeXKBKeyTypes", 0);
return 0;
}
if (xkb->names)
name = XkbAtomGetString(dpy, xkb->names->types);
else
name = NULL;
size = xkmSizeCountedString(name);
size += 4; /* room for # of key types + padding */
for (i = 0, type = xkb->map->types; i < xkb->map->num_types; i++, type++) {
size += SIZEOF(xkmKeyTypeDesc);
size += SIZEOF(xkmKTMapEntryDesc) * type->map_count;
size += xkmSizeCountedAtomString(dpy, type->name);
if (type->preserve)
size += SIZEOF(xkmModsDesc) * type->map_count;
if (type->level_names) {
Atom *names;
names = type->level_names;
for (n = 0; n < (unsigned) type->num_levels; n++) {
size += xkmSizeCountedAtomString(dpy, names[n]);
}
}
}
toc->type = XkmTypesIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMKeyTypes(FILE *file, XkbFileInfo *result)
{
register unsigned i, n;
XkbDescPtr xkb;
XkbKeyTypePtr type;
xkmKeyTypeDesc wire;
XkbKTMapEntryPtr entry;
xkmKTMapEntryDesc wire_entry;
Atom *names;
Display *dpy;
unsigned tmp, size = 0;
char *name;
xkb = result->xkb;
dpy = xkb->dpy;
if (xkb->names)
name = XkbAtomGetString(dpy, xkb->names->types);
else
name = NULL;
size += xkmPutCountedString(file, name);
size += xkmPutCARD16(file, xkb->map->num_types);
size += xkmPutPadding(file, 2);
type = xkb->map->types;
for (i = 0; i < xkb->map->num_types; i++, type++) {
wire.realMods = type->mods.real_mods;
wire.virtualMods = type->mods.vmods;
wire.numLevels = type->num_levels;
wire.nMapEntries = type->map_count;
wire.preserve = (type->preserve != NULL);
if (type->level_names != NULL)
wire.nLevelNames = type->num_levels;
else
wire.nLevelNames = 0;
tmp = fwrite(&wire, SIZEOF(xkmKeyTypeDesc), 1, file);
size += tmp * SIZEOF(xkmKeyTypeDesc);
for (n = 0, entry = type->map; n < type->map_count; n++, entry++) {
wire_entry.level = entry->level;
wire_entry.realMods = entry->mods.real_mods;
wire_entry.virtualMods = entry->mods.vmods;
tmp = fwrite(&wire_entry, SIZEOF(xkmKTMapEntryDesc), 1, file);
size += tmp * SIZEOF(xkmKTMapEntryDesc);
}
size += xkmPutCountedString(file, XkbAtomGetString(dpy, type->name));
if (type->preserve) {
xkmModsDesc p_entry;
XkbModsPtr pre;
for (n = 0, pre = type->preserve; n < type->map_count; n++, pre++) {
p_entry.realMods = pre->real_mods;
p_entry.virtualMods = pre->vmods;
tmp = fwrite(&p_entry, SIZEOF(xkmModsDesc), 1, file);
size += tmp * SIZEOF(xkmModsDesc);
}
}
if (type->level_names != NULL) {
names = type->level_names;
for (n = 0; n < wire.nLevelNames; n++) {
size +=
xkmPutCountedString(file, XkbAtomGetString(dpy, names[n]));
}
}
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMCompatMap(XkbFileInfo *result, XkmInfo *info,
xkmSectionInfo *toc, int *offset_inout)
{
XkbDescPtr xkb;
char *name;
int size;
register int i;
unsigned groups, nGroups;
Display *dpy;
xkb = result->xkb;
if ((!xkb) || (!xkb->compat) || (!xkb->compat->sym_interpret)) {
_XkbLibError(_XkbErrMissingCompatMap, "SizeXKMCompatMap", 0);
return 0;
}
dpy = xkb->dpy;
if (xkb->names)
name = XkbAtomGetString(dpy, xkb->names->compat);
else
name = NULL;
for (i = groups = nGroups = 0; i < XkbNumKbdGroups; i++) {
if ((xkb->compat->groups[i].real_mods != 0) ||
(xkb->compat->groups[i].vmods != 0)) {
groups |= (1 << i);
nGroups++;
}
}
info->group_compat = groups;
info->num_group_compat = nGroups;
size = 4; /* room for num_si and group_compat mask */
size += xkmSizeCountedString(name);
size += (SIZEOF(xkmSymInterpretDesc) * xkb->compat->num_si);
size += (SIZEOF(xkmModsDesc) * nGroups);
toc->type = XkmCompatMapIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMCompatMap(FILE *file, XkbFileInfo *result, XkmInfo *info)
{
register unsigned i;
char *name;
XkbDescPtr xkb;
XkbSymInterpretPtr interp;
xkmSymInterpretDesc wire;
Display *dpy;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
if (xkb->names)
name = XkbAtomGetString(dpy, xkb->names->compat);
else
name = NULL;
size += xkmPutCountedString(file, name);
size += xkmPutCARD16(file, xkb->compat->num_si);
size += xkmPutCARD8(file, info->group_compat);
size += xkmPutPadding(file, 1);
interp = xkb->compat->sym_interpret;
for (i = 0; i < xkb->compat->num_si; i++, interp++) {
wire.sym = interp->sym;
wire.mods = interp->mods;
wire.match = interp->match;
wire.virtualMod = interp->virtual_mod;
wire.flags = interp->flags;
wire.actionType = interp->act.type;
wire.actionData[0] = interp->act.data[0];
wire.actionData[1] = interp->act.data[1];
wire.actionData[2] = interp->act.data[2];
wire.actionData[3] = interp->act.data[3];
wire.actionData[4] = interp->act.data[4];
wire.actionData[5] = interp->act.data[5];
wire.actionData[6] = interp->act.data[6];
tmp = fwrite(&wire, SIZEOF(xkmSymInterpretDesc), 1, file);
size += tmp * SIZEOF(xkmSymInterpretDesc);
}
if (info->group_compat) {
register unsigned bit;
xkmModsDesc modsWire;
for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
if (info->group_compat & bit) {
modsWire.realMods = xkb->compat->groups[i].real_mods;
modsWire.virtualMods = xkb->compat->groups[i].vmods;
fwrite(&modsWire, SIZEOF(xkmModsDesc), 1, file);
size += SIZEOF(xkmModsDesc);
}
}
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMSymbols(XkbFileInfo *result, XkmInfo *info,
xkmSectionInfo *toc, int *offset_inout)
{
Display *dpy;
XkbDescPtr xkb;
unsigned size;
register int i, nSyms;
char *name;
xkb = result->xkb;
if ((!xkb) || (!xkb->map) || ((!xkb->map->syms))) {
_XkbLibError(_XkbErrMissingSymbols, "SizeXKMSymbols", 0);
return 0;
}
dpy = xkb->dpy;
if (xkb->names && (xkb->names->symbols != None))
name = XkbAtomGetString(dpy, xkb->names->symbols);
else
name = NULL;
size = xkmSizeCountedString(name);
size += 4; /* min and max keycode, group names mask */
for (i = 0; i < XkbNumKbdGroups; i++) {
if (xkb->names->groups[i] != None)
size += xkmSizeCountedAtomString(dpy, xkb->names->groups[i]);
}
info->total_vmodmaps = 0;
for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++) {
nSyms = XkbKeyNumSyms(xkb, i);
size += SIZEOF(xkmKeySymMapDesc) + (nSyms * 4);
if (xkb->server) {
if (xkb->server->explicit[i] & XkbExplicitKeyTypesMask) {
register int g;
for (g = XkbKeyNumGroups(xkb, i) - 1; g >= 0; g--) {
if (xkb->server->explicit[i] & (1 << g)) {
XkbKeyTypePtr type;
char *name;
type = XkbKeyKeyType(xkb, i, g);
name = XkbAtomGetString(dpy, type->name);
if (name != NULL)
size += xkmSizeCountedString(name);
}
}
}
if (XkbKeyHasActions(xkb, i))
size += nSyms * SIZEOF(xkmActionDesc);
if (xkb->server->behaviors[i].type != XkbKB_Default)
size += SIZEOF(xkmBehaviorDesc);
if (xkb->server->vmodmap && (xkb->server->vmodmap[i] != 0))
info->total_vmodmaps++;
}
}
size += info->total_vmodmaps * SIZEOF(xkmVModMapDesc);
toc->type = XkmSymbolsIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMSymbols(FILE *file, XkbFileInfo *result, XkmInfo *info)
{
Display *dpy;
XkbDescPtr xkb;
register int i, n;
xkmKeySymMapDesc wireMap;
char *name;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
if (xkb->names && (xkb->names->symbols != None))
name = XkbAtomGetString(dpy, xkb->names->symbols);
else
name = NULL;
size += xkmPutCountedString(file, name);
for (tmp = i = 0; i < XkbNumKbdGroups; i++) {
if (xkb->names->groups[i] != None)
tmp |= (1 << i);
}
size += xkmPutCARD8(file, xkb->min_key_code);
size += xkmPutCARD8(file, xkb->max_key_code);
size += xkmPutCARD8(file, tmp);
size += xkmPutCARD8(file, info->total_vmodmaps);
for (i = 0, n = 1; i < XkbNumKbdGroups; i++, n <<= 1) {
if ((tmp & n) == 0)
continue;
size += xkmPutCountedAtomString(dpy, file, xkb->names->groups[i]);
}
for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++) {
char *typeName[XkbNumKbdGroups];
wireMap.width = XkbKeyGroupsWidth(xkb, i);
wireMap.num_groups = XkbKeyGroupInfo(xkb, i);
if (xkb->map && xkb->map->modmap)
wireMap.modifier_map = xkb->map->modmap[i];
else
wireMap.modifier_map = 0;
wireMap.flags = 0;
bzero((char *) typeName, XkbNumKbdGroups * sizeof(char *));
if (xkb->server) {
if (xkb->server->explicit[i] & XkbExplicitKeyTypesMask) {
register int g;
for (g = 0; g < XkbKeyNumGroups(xkb, i); g++) {
if (xkb->server->explicit[i] & (1 << g)) {
XkbKeyTypePtr type;
type = XkbKeyKeyType(xkb, i, g);
typeName[g] = XkbAtomGetString(dpy, type->name);
if (typeName[g] != NULL)
wireMap.flags |= (1 << g);
}
}
}
if (XkbKeyHasActions(xkb, i))
wireMap.flags |= XkmKeyHasActions;
if (xkb->server->behaviors[i].type != XkbKB_Default)
wireMap.flags |= XkmKeyHasBehavior;
if ((xkb->server->explicit[i] & XkbExplicitAutoRepeatMask) &&
(xkb->ctrls != NULL)) {
if (xkb->ctrls->per_key_repeat[(i / 8)] & (1 << (i % 8)))
wireMap.flags |= XkmRepeatingKey;
else
wireMap.flags |= XkmNonRepeatingKey;
}
}
tmp = fwrite(&wireMap, SIZEOF(xkmKeySymMapDesc), 1, file);
size += tmp * SIZEOF(xkmKeySymMapDesc);
if (xkb->server->explicit[i] & XkbExplicitKeyTypesMask) {
register int g;
for (g = 0; g < XkbNumKbdGroups; g++) {
if (typeName[g] != NULL)
size += xkmPutCountedString(file, typeName[g]);
}
}
if (XkbNumGroups(wireMap.num_groups) > 0) {
KeySym *sym;
sym = XkbKeySymsPtr(xkb, i);
for (n = XkbKeyNumSyms(xkb, i); n > 0; n--, sym++) {
size += xkmPutCARD32(file, (CARD32) *sym);
}
if (wireMap.flags & XkmKeyHasActions) {
XkbAction *act;
act = XkbKeyActionsPtr(xkb, i);
for (n = XkbKeyNumActions(xkb, i); n > 0; n--, act++) {
tmp = fwrite(act, SIZEOF(xkmActionDesc), 1, file);
size += tmp * SIZEOF(xkmActionDesc);
}
}
}
if (wireMap.flags & XkmKeyHasBehavior) {
xkmBehaviorDesc b;
b.type = xkb->server->behaviors[i].type;
b.data = xkb->server->behaviors[i].data;
tmp = fwrite(&b, SIZEOF(xkmBehaviorDesc), 1, file);
size += tmp * SIZEOF(xkmBehaviorDesc);
}
}
if (info->total_vmodmaps > 0) {
xkmVModMapDesc v;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
if (xkb->server->vmodmap[i] != 0) {
v.key = i;
v.vmods = xkb->server->vmodmap[i];
tmp = fwrite(&v, SIZEOF(xkmVModMapDesc), 1, file);
size += tmp * SIZEOF(xkmVModMapDesc);
}
}
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMIndicators(XkbFileInfo *result, XkmInfo *info,
xkmSectionInfo *toc, int *offset_inout)
{
Display *dpy;
XkbDescPtr xkb;
unsigned size;
register unsigned i, nLEDs;
xkb = result->xkb;
if ((xkb == NULL) || (xkb->indicators == NULL)) {
/* _XkbLibError(_XkbErrMissingIndicators,"SizeXKMIndicators",0);*/
return 0;
}
dpy = xkb->dpy;
nLEDs = 0;
size = 8; /* number of indicator maps/physical indicators */
if (xkb->indicators != NULL) {
for (i = 0; i < XkbNumIndicators; i++) {
XkbIndicatorMapPtr map = &xkb->indicators->maps[i];
if ((map->flags != 0) || (map->which_groups != 0) ||
(map->groups != 0) || (map->which_mods != 0) ||
(map->mods.real_mods != 0) || (map->mods.vmods != 0) ||
(map->ctrls != 0) ||
(xkb->names && (xkb->names->indicators[i] != None))) {
char *name;
if (xkb->names && xkb->names->indicators[i] != None) {
name = XkbAtomGetString(dpy, xkb->names->indicators[i]);
}
else
name = NULL;
size += xkmSizeCountedString(name);
size += SIZEOF(xkmIndicatorMapDesc);
nLEDs++;
}
}
}
info->num_leds = nLEDs;
toc->type = XkmIndicatorsIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMIndicators(FILE *file, XkbFileInfo *result, XkmInfo *info)
{
Display *dpy;
XkbDescPtr xkb;
register unsigned i;
xkmIndicatorMapDesc wire;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
size += xkmPutCARD8(file, info->num_leds);
size += xkmPutPadding(file, 3);
size += xkmPutCARD32(file, xkb->indicators->phys_indicators);
if (xkb->indicators != NULL) {
for (i = 0; i < XkbNumIndicators; i++) {
XkbIndicatorMapPtr map = &xkb->indicators->maps[i];
if ((map->flags != 0) || (map->which_groups != 0) ||
(map->groups != 0) || (map->which_mods != 0) ||
(map->mods.real_mods != 0) || (map->mods.vmods != 0) ||
(map->ctrls != 0) || (xkb->names &&
(xkb->names->indicators[i] != None))) {
char *name;
if (xkb->names && xkb->names->indicators[i] != None) {
name = XkbAtomGetString(dpy, xkb->names->indicators[i]);
}
else
name = NULL;
size += xkmPutCountedString(file, name);
wire.indicator = i + 1;
wire.flags = map->flags;
wire.which_mods = map->which_mods;
wire.real_mods = map->mods.real_mods;
wire.vmods = map->mods.vmods;
wire.which_groups = map->which_groups;
wire.groups = map->groups;
wire.ctrls = map->ctrls;
tmp = fwrite(&wire, SIZEOF(xkmIndicatorMapDesc), 1, file);
size += tmp * SIZEOF(xkmIndicatorMapDesc);
}
}
}
return size;
}
/***====================================================================***/
static unsigned
SizeXKMGeomDoodad(XkbFileInfo *result, XkbDoodadPtr doodad)
{
unsigned size;
size = SIZEOF(xkmAnyDoodadDesc);
size += xkmSizeCountedAtomString(result->xkb->dpy, doodad->any.name);
if (doodad->any.type == XkbTextDoodad) {
size += xkmSizeCountedString(doodad->text.text);
size += xkmSizeCountedString(doodad->text.font);
}
else if (doodad->any.type == XkbLogoDoodad) {
size += xkmSizeCountedString(doodad->logo.logo_name);
}
return size;
}
static unsigned
SizeXKMGeomSection(XkbFileInfo *result, XkbSectionPtr section)
{
register int i;
unsigned size;
size = SIZEOF(xkmSectionDesc);
size += xkmSizeCountedAtomString(result->xkb->dpy, section->name);
if (section->rows) {
XkbRowPtr row;
for (row = section->rows, i = 0; i < section->num_rows; i++, row++) {
size += SIZEOF(xkmRowDesc);
size += row->num_keys * SIZEOF(xkmKeyDesc);
}
}
if (section->doodads) {
XkbDoodadPtr doodad;
for (doodad = section->doodads, i = 0; i < section->num_doodads;
i++, doodad++) {
size += SizeXKMGeomDoodad(result, doodad);
}
}
if (section->overlays) {
XkbOverlayPtr ol;
for (ol = section->overlays, i = 0; i < section->num_overlays;
i++, ol++) {
register int r;
XkbOverlayRowPtr row;
size += xkmSizeCountedAtomString(result->xkb->dpy, ol->name);
size += SIZEOF(xkmOverlayDesc);
for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
size += SIZEOF(xkmOverlayRowDesc);
size += row->num_keys * SIZEOF(xkmOverlayKeyDesc);
}
}
}
return size;
}
static unsigned
SizeXKMGeometry(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
{
register int i;
Display *dpy;
XkbDescPtr xkb;
XkbGeometryPtr geom;
unsigned size;
xkb = result->xkb;
if ((!xkb) || (!xkb->geom))
return 0;
dpy = xkb->dpy;
geom = xkb->geom;
size = xkmSizeCountedAtomString(dpy, geom->name);
size += SIZEOF(xkmGeometryDesc);
size += xkmSizeCountedString(geom->label_font);
if (geom->properties) {
XkbPropertyPtr prop;
for (i = 0, prop = geom->properties; i < geom->num_properties;
i++, prop++) {
size += xkmSizeCountedString(prop->name);
size += xkmSizeCountedString(prop->value);
}
}
if (geom->colors) {
XkbColorPtr color;
for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) {
size += xkmSizeCountedString(color->spec);
}
}
if (geom->shapes) {
XkbShapePtr shape;
for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) {
register int n;
register XkbOutlinePtr ol;
size += xkmSizeCountedAtomString(dpy, shape->name);
size += SIZEOF(xkmShapeDesc);
for (n = 0, ol = shape->outlines; n < shape->num_outlines;
n++, ol++) {
size += SIZEOF(xkmOutlineDesc);
size += ol->num_points * SIZEOF(xkmPointDesc);
}
}
}
if (geom->sections) {
XkbSectionPtr section;
for (i = 0, section = geom->sections; i < geom->num_sections;
i++, section++) {
size += SizeXKMGeomSection(result, section);
}
}
if (geom->doodads) {
XkbDoodadPtr doodad;
for (i = 0, doodad = geom->doodads; i < geom->num_doodads;
i++, doodad++) {
size += SizeXKMGeomDoodad(result, doodad);
}
}
if (geom->key_aliases) {
size += geom->num_key_aliases * (XkbKeyNameLength * 2);
}
toc->type = XkmGeometryIndex;
toc->format = MSBFirst;
toc->size = size + SIZEOF(xkmSectionInfo);
toc->offset = (*offset_inout);
(*offset_inout) += toc->size;
return 1;
}
static unsigned
WriteXKMGeomDoodad(FILE *file, XkbFileInfo *result, XkbDoodadPtr doodad)
{
Display *dpy;
XkbDescPtr xkb;
xkmDoodadDesc doodadWire;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
bzero((char *) &doodadWire, sizeof(doodadWire));
doodadWire.any.type = doodad->any.type;
doodadWire.any.priority = doodad->any.priority;
doodadWire.any.top = doodad->any.top;
doodadWire.any.left = doodad->any.left;
switch (doodad->any.type) {
case XkbOutlineDoodad:
case XkbSolidDoodad:
doodadWire.shape.angle = doodad->shape.angle;
doodadWire.shape.color_ndx = doodad->shape.color_ndx;
doodadWire.shape.shape_ndx = doodad->shape.shape_ndx;
break;
case XkbTextDoodad:
doodadWire.text.angle = doodad->text.angle;
doodadWire.text.width = doodad->text.width;
doodadWire.text.height = doodad->text.height;
doodadWire.text.color_ndx = doodad->text.color_ndx;
break;
case XkbIndicatorDoodad:
doodadWire.indicator.shape_ndx = doodad->indicator.shape_ndx;
doodadWire.indicator.on_color_ndx = doodad->indicator.on_color_ndx;
doodadWire.indicator.off_color_ndx = doodad->indicator.off_color_ndx;
break;
case XkbLogoDoodad:
doodadWire.logo.angle = doodad->logo.angle;
doodadWire.logo.color_ndx = doodad->logo.color_ndx;
doodadWire.logo.shape_ndx = doodad->logo.shape_ndx;
break;
default:
_XkbLibError(_XkbErrIllegalDoodad, "WriteXKMGeomDoodad",
doodad->any.type);
return 0;
}
size += xkmPutCountedAtomString(dpy, file, doodad->any.name);
tmp = fwrite(&doodadWire, SIZEOF(xkmDoodadDesc), 1, file);
size += tmp * SIZEOF(xkmDoodadDesc);
if (doodad->any.type == XkbTextDoodad) {
size += xkmPutCountedString(file, doodad->text.text);
size += xkmPutCountedString(file, doodad->text.font);
}
else if (doodad->any.type == XkbLogoDoodad) {
size += xkmPutCountedString(file, doodad->logo.logo_name);
}
return size;
}
static unsigned
WriteXKMGeomOverlay(FILE *file, XkbFileInfo *result, XkbOverlayPtr ol)
{
register int r, k;
Display *dpy;
XkbDescPtr xkb;
XkbOverlayRowPtr row;
xkmOverlayDesc olWire;
xkmOverlayRowDesc rowWire;
xkmOverlayKeyDesc keyWire;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
bzero((char *) &olWire, sizeof(olWire));
bzero((char *) &rowWire, sizeof(rowWire));
bzero((char *) &keyWire, sizeof(keyWire));
size += xkmPutCountedAtomString(dpy, file, ol->name);
olWire.num_rows = ol->num_rows;
tmp = fwrite(&olWire, SIZEOF(xkmOverlayDesc), 1, file);
size += tmp * SIZEOF(xkmOverlayDesc);
for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
XkbOverlayKeyPtr key;
rowWire.row_under = row->row_under;
rowWire.num_keys = row->num_keys;
tmp = fwrite(&rowWire, SIZEOF(xkmOverlayRowDesc), 1, file);
size += tmp * SIZEOF(xkmOverlayRowDesc);
for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
memcpy(keyWire.over, key->over.name, XkbKeyNameLength);
memcpy(keyWire.under, key->under.name, XkbKeyNameLength);
tmp = fwrite(&keyWire, SIZEOF(xkmOverlayKeyDesc), 1, file);
size += tmp * SIZEOF(xkmOverlayKeyDesc);
}
}
return size;
}
static unsigned
WriteXKMGeomSection(FILE *file, XkbFileInfo *result, XkbSectionPtr section)
{
register int i;
Display *dpy;
XkbDescPtr xkb;
xkmSectionDesc sectionWire;
unsigned tmp, size = 0;
xkb = result->xkb;
dpy = xkb->dpy;
size += xkmPutCountedAtomString(dpy, file, section->name);
sectionWire.top = section->top;
sectionWire.left = section->left;
sectionWire.width = section->width;
sectionWire.height = section->height;
sectionWire.angle = section->angle;
sectionWire.priority = section->priority;
sectionWire.num_rows = section->num_rows;
sectionWire.num_doodads = section->num_doodads;
sectionWire.num_overlays = section->num_overlays;
tmp = fwrite(§ionWire, SIZEOF(xkmSectionDesc), 1, file);
size += tmp * SIZEOF(xkmSectionDesc);
if (section->rows) {
register unsigned k;
XkbRowPtr row;
xkmRowDesc rowWire;
XkbKeyPtr key;
xkmKeyDesc keyWire;
for (i = 0, row = section->rows; i < section->num_rows; i++, row++) {
rowWire.top = row->top;
rowWire.left = row->left;
rowWire.num_keys = row->num_keys;
rowWire.vertical = row->vertical;
tmp = fwrite(&rowWire, SIZEOF(xkmRowDesc), 1, file);
size += tmp * SIZEOF(xkmRowDesc);
for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
memcpy(keyWire.name, key->name.name, XkbKeyNameLength);
keyWire.gap = key->gap;
keyWire.shape_ndx = key->shape_ndx;
keyWire.color_ndx = key->color_ndx;
tmp = fwrite(&keyWire, SIZEOF(xkmKeyDesc), 1, file);
size += tmp * SIZEOF(xkmKeyDesc);
}
}
}
if (section->doodads) {
XkbDoodadPtr doodad;
for (i = 0, doodad = section->doodads; i < section->num_doodads;
i++, doodad++) {
size += WriteXKMGeomDoodad(file, result, doodad);
}
}
if (section->overlays) {
XkbOverlayPtr ol;
for (i = 0, ol = section->overlays; i < section->num_overlays;
i++, ol++) {
size += WriteXKMGeomOverlay(file, result, ol);
}
}
return size;
}
static unsigned
WriteXKMGeometry(FILE *file, XkbFileInfo *result)
{
register int i;
Display *dpy;
XkbDescPtr xkb;
XkbGeometryPtr geom;
xkmGeometryDesc wire;
unsigned tmp, size = 0;
xkb = result->xkb;
if ((!xkb) || (!xkb->geom))
return 0;
dpy = xkb->dpy;
geom = xkb->geom;
wire.width_mm = geom->width_mm;
wire.height_mm = geom->height_mm;
wire.base_color_ndx = XkbGeomColorIndex(geom, geom->base_color);
wire.label_color_ndx = XkbGeomColorIndex(geom, geom->label_color);
wire.num_properties = geom->num_properties;
wire.num_colors = geom->num_colors;
wire.num_shapes = geom->num_shapes;
wire.num_sections = geom->num_sections;
wire.num_doodads = geom->num_doodads;
wire.num_key_aliases = geom->num_key_aliases;
size += xkmPutCountedAtomString(dpy, file, geom->name);
tmp = fwrite(&wire, SIZEOF(xkmGeometryDesc), 1, file);
size += tmp * SIZEOF(xkmGeometryDesc);
size += xkmPutCountedString(file, geom->label_font);
if (geom->properties) {
XkbPropertyPtr prop;
for (i = 0, prop = geom->properties; i < geom->num_properties;
i++, prop++) {
size += xkmPutCountedString(file, prop->name);
size += xkmPutCountedString(file, prop->value);
}
}
if (geom->colors) {
XkbColorPtr color;
for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) {
size += xkmPutCountedString(file, color->spec);
}
}
if (geom->shapes) {
XkbShapePtr shape;
xkmShapeDesc shapeWire;
for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) {
register int n;
XkbOutlinePtr ol;
xkmOutlineDesc olWire;
bzero((char *) &shapeWire, sizeof(xkmShapeDesc));
size += xkmPutCountedAtomString(dpy, file, shape->name);
shapeWire.num_outlines = shape->num_outlines;
if (shape->primary != NULL)
shapeWire.primary_ndx = XkbOutlineIndex(shape, shape->primary);
else
shapeWire.primary_ndx = XkbNoShape;
if (shape->approx != NULL)
shapeWire.approx_ndx = XkbOutlineIndex(shape, shape->approx);
else
shapeWire.approx_ndx = XkbNoShape;
tmp = fwrite(&shapeWire, SIZEOF(xkmShapeDesc), 1, file);
size += tmp * SIZEOF(xkmShapeDesc);
for (n = 0, ol = shape->outlines; n < shape->num_outlines;
n++, ol++) {
register int p;
XkbPointPtr pt;
xkmPointDesc ptWire;
olWire.num_points = ol->num_points;
olWire.corner_radius = ol->corner_radius;
tmp = fwrite(&olWire, SIZEOF(xkmOutlineDesc), 1, file);
size += tmp * SIZEOF(xkmOutlineDesc);
for (p = 0, pt = ol->points; p < ol->num_points; p++, pt++) {
ptWire.x = pt->x;
ptWire.y = pt->y;
tmp = fwrite(&ptWire, SIZEOF(xkmPointDesc), 1, file);
size += tmp * SIZEOF(xkmPointDesc);
}
}
}
}
if (geom->sections) {
XkbSectionPtr section;
for (i = 0, section = geom->sections; i < geom->num_sections;
i++, section++) {
size += WriteXKMGeomSection(file, result, section);
}
}
if (geom->doodads) {
XkbDoodadPtr doodad;
for (i = 0, doodad = geom->doodads; i < geom->num_doodads;
i++, doodad++) {
size += WriteXKMGeomDoodad(file, result, doodad);
}
}
if (geom->key_aliases) {
tmp =
fwrite(geom->key_aliases, 2 * XkbKeyNameLength,
geom->num_key_aliases, file);
size += tmp * (2 * XkbKeyNameLength);
}
return size;
}
/***====================================================================***/
/*ARGSUSED*/
static int
GetXKMKeyNamesTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMKeycodes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMIndicators(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMTypesTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMVirtualMods(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeyTypes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMCompatMapTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMVirtualMods(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMCompatMap(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMIndicators(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMSemanticsTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMVirtualMods(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeyTypes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMCompatMap(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMIndicators(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMLayoutTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMVirtualMods(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeycodes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeyTypes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMSymbols(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMIndicators(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMGeometry(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMKeymapTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMVirtualMods(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeycodes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMKeyTypes(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMCompatMap(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMSymbols(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMIndicators(result, info, &toc_rtrn[num_toc], &total_size))
num_toc++;
if (SizeXKMGeometry(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
/*ARGSUSED*/
static int
GetXKMGeometryTOC(XkbFileInfo *result, XkmInfo *info,
int max_toc, xkmSectionInfo *toc_rtrn)
{
int num_toc;
int total_size;
total_size = num_toc = 0;
if (SizeXKMGeometry(result, &toc_rtrn[num_toc], &total_size))
num_toc++;
return num_toc;
}
static Bool
WriteXKMFile(FILE *file, XkbFileInfo *result,
int num_toc, xkmSectionInfo *toc, XkmInfo *info)
{
register int i;
unsigned tmp, size, total = 0;
for (i = 0; i < num_toc; i++) {
tmp = fwrite(&toc[i], SIZEOF(xkmSectionInfo), 1, file);
total += tmp * SIZEOF(xkmSectionInfo);
switch (toc[i].type) {
case XkmTypesIndex:
size = WriteXKMKeyTypes(file, result);
break;
case XkmCompatMapIndex:
size = WriteXKMCompatMap(file, result, info);
break;
case XkmSymbolsIndex:
size = WriteXKMSymbols(file, result, info);
break;
case XkmIndicatorsIndex:
size = WriteXKMIndicators(file, result, info);
break;
case XkmKeyNamesIndex:
size = WriteXKMKeycodes(file, result);
break;
case XkmGeometryIndex:
size = WriteXKMGeometry(file, result);
break;
case XkmVirtualModsIndex:
size = WriteXKMVirtualMods(file, result, info);
break;
default:
_XkbLibError(_XkbErrIllegalTOCType, "WriteXKMFile", toc[i].type);
return False;
}
size += SIZEOF(xkmSectionInfo);
if (size != toc[i].size) {
_XkbLibError(_XkbErrBadLength,
XkbConfigText(toc[i].type, XkbMessage),
size - toc[i].size);
return False;
}
}
return True;
}
#define MAX_TOC 16
Bool
XkbWriteXKMFile(FILE *out, XkbFileInfo *result)
{
Bool ok;
XkbDescPtr xkb;
XkmInfo info;
int size_toc, i;
unsigned hdr, present;
xkmFileInfo fileInfo;
xkmSectionInfo toc[MAX_TOC];
int (*getTOC) (XkbFileInfo * /* result */ ,
XkmInfo * /* info */ ,
int /* max_to */ ,
xkmSectionInfo * /* toc_rtrn */
);
switch (result->type) {
case XkmKeyNamesIndex:
getTOC = GetXKMKeyNamesTOC;
break;
case XkmTypesIndex:
getTOC = GetXKMTypesTOC;
break;
case XkmCompatMapIndex:
getTOC = GetXKMCompatMapTOC;
break;
case XkmSemanticsFile:
getTOC = GetXKMSemanticsTOC;
break;
case XkmLayoutFile:
getTOC = GetXKMLayoutTOC;
break;
case XkmKeymapFile:
getTOC = GetXKMKeymapTOC;
break;
case XkmGeometryFile:
case XkmGeometryIndex:
getTOC = GetXKMGeometryTOC;
break;
default:
_XkbLibError(_XkbErrIllegalContents,
XkbConfigText(result->type, XkbMessage), 0);
return False;
}
xkb = result->xkb;
bzero((char *) &info, sizeof(XkmInfo));
size_toc = (*getTOC) (result, &info, MAX_TOC, toc);
if (size_toc < 1) {
_XkbLibError(_XkbErrEmptyFile, "XkbWriteXKMFile", 0);
return False;
}
if (out == NULL) {
_XkbLibError(_XkbErrFileCannotOpen, "XkbWriteXKMFile", 0);
return False;
}
for (i = present = 0; i < size_toc; i++) {
toc[i].offset += 4 + SIZEOF(xkmFileInfo);
toc[i].offset += (size_toc * SIZEOF(xkmSectionInfo));
if (toc[i].type <= XkmLastIndex) {
present |= (1 << toc[i].type);
}
#ifdef DEBUG
else {
fprintf(stderr, "Illegal section type %d\n", toc[i].type);
fprintf(stderr, "Ignored\n");
}
#endif
}
hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
xkmPutCARD32(out, (unsigned long) hdr);
fileInfo.type = result->type;
fileInfo.min_kc = xkb->min_key_code;
fileInfo.max_kc = xkb->max_key_code;
fileInfo.num_toc = size_toc;
fileInfo.present = present;
fileInfo.pad = 0;
fwrite(&fileInfo, SIZEOF(xkmFileInfo), 1, out);
fwrite(toc, SIZEOF(xkmSectionInfo), size_toc, out);
ok = WriteXKMFile(out, result, size_toc, toc, &info);
return ok;
}
mShapeDesc shapeWire;
for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) {
register int n;
XkbOutlinePtr ol;
xkmOutlineDesc olWire;
bzerlibxkbfile-1.1.0/src/xkmread.c 0000644 0143106 0000012 00000126204 13443241017 0016476 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
/***====================================================================***/
static XPointer
XkmInsureSize(XPointer oldPtr, int oldCount, int *newCountRtrn, int elemSize)
{
int newCount = *newCountRtrn;
if (oldPtr == NULL) {
if (newCount == 0)
return NULL;
oldPtr = (XPointer) _XkbCalloc(newCount, elemSize);
}
else if (oldCount < newCount) {
oldPtr = (XPointer) _XkbRealloc(oldPtr, newCount * elemSize);
if (oldPtr != NULL) {
char *tmp = (char *) oldPtr;
bzero(&tmp[oldCount * elemSize], (newCount - oldCount) * elemSize);
}
}
else if (newCount < oldCount) {
*newCountRtrn = oldCount;
}
return oldPtr;
}
#define XkmInsureTypedSize(p,o,n,t) ((p)=((t *)XkmInsureSize((char *)(p),(o),(n),sizeof(t))))
static CARD8
XkmGetCARD8(FILE * file, int *pNRead)
{
int tmp;
tmp = getc(file);
if (pNRead && (tmp != EOF))
(*pNRead) += 1;
return tmp;
}
static CARD16
XkmGetCARD16(FILE * file, int *pNRead)
{
CARD16 val;
if ((fread(&val, 2, 1, file) == 1) && (pNRead))
(*pNRead) += 2;
return val;
}
static CARD32
XkmGetCARD32(FILE * file, int *pNRead)
{
CARD32 val;
if ((fread(&val, 4, 1, file) == 1) && (pNRead))
(*pNRead) += 4;
return val;
}
static int
XkmSkipPadding(FILE * file, unsigned pad)
{
register int i, nRead = 0;
for (i = 0; i < pad; i++) {
if (getc(file) != EOF)
nRead++;
}
return nRead;
}
static int
XkmGetCountedString(FILE * file, char *str, int max_len)
{
int count, nRead = 0;
count = XkmGetCARD16(file, &nRead);
if (count > 0) {
int tmp;
if (count > max_len) {
tmp = fread(str, 1, max_len, file);
while (tmp < count) {
if ((getc(file)) != EOF)
tmp++;
else
break;
}
}
else {
tmp = fread(str, 1, count, file);
}
nRead += tmp;
}
if (count >= max_len)
str[max_len - 1] = '\0';
else
str[count] = '\0';
count = XkbPaddedSize(nRead) - nRead;
if (count > 0)
nRead += XkmSkipPadding(file, count);
return nRead;
}
/***====================================================================***/
static int
ReadXkmVirtualMods(FILE *file, XkbFileInfo *result, XkbChangesPtr changes)
{
register unsigned int i, bit;
unsigned int bound, named, tmp;
int nRead = 0;
XkbDescPtr xkb;
xkb = result->xkb;
if (XkbAllocServerMap(xkb, XkbVirtualModsMask, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmVirtualMods", 0);
return -1;
}
bound = XkmGetCARD16(file, &nRead);
named = XkmGetCARD16(file, &nRead);
for (i = tmp = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if (bound & bit) {
xkb->server->vmods[i] = XkmGetCARD8(file, &nRead);
if (changes)
changes->map.vmods |= bit;
tmp++;
}
}
if ((i = XkbPaddedSize(tmp) - tmp) > 0)
nRead += XkmSkipPadding(file, i);
if (XkbAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmVirtualMods", 0);
return -1;
}
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
char name[100];
if (named & bit) {
if (nRead += XkmGetCountedString(file, name, 100)) {
xkb->names->vmods[i] = XkbInternAtom(xkb->dpy, name, False);
if (changes)
changes->names.changed_vmods |= bit;
}
}
}
return nRead;
}
/***====================================================================***/
static int
ReadXkmKeycodes(FILE *file, XkbFileInfo *result, XkbChangesPtr changes)
{
register int i;
unsigned minKC, maxKC, nAl;
int nRead = 0;
char name[100];
XkbKeyNamePtr pN;
XkbDescPtr xkb;
xkb = result->xkb;
name[0] = '\0';
nRead += XkmGetCountedString(file, name, 100);
minKC = XkmGetCARD8(file, &nRead);
maxKC = XkmGetCARD8(file, &nRead);
if (xkb->min_key_code == 0) {
xkb->min_key_code = minKC;
xkb->max_key_code = maxKC;
}
else {
if (minKC < xkb->min_key_code)
xkb->min_key_code = minKC;
if (maxKC > xkb->max_key_code) {
_XkbLibError(_XkbErrBadValue, "ReadXkmKeycodes", maxKC);
return -1;
}
}
nAl = XkmGetCARD8(file, &nRead);
nRead += XkmSkipPadding(file, 1);
#define WANTED (XkbKeycodesNameMask|XkbKeyNamesMask|XkbKeyAliasesMask)
if (XkbAllocNames(xkb, WANTED, 0, nAl) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeycodes", 0);
return -1;
}
if (name[0] != '\0') {
xkb->names->keycodes = XkbInternAtom(xkb->dpy, name, False);
}
for (pN = &xkb->names->keys[minKC], i = minKC; i <= (int) maxKC; i++, pN++) {
if (fread(pN, 1, XkbKeyNameLength, file) != XkbKeyNameLength) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
return -1;
}
nRead += XkbKeyNameLength;
}
if (nAl > 0) {
XkbKeyAliasPtr pAl;
for (pAl = xkb->names->key_aliases, i = 0; i < nAl; i++, pAl++) {
int tmp;
tmp = fread(pAl, 1, 2 * XkbKeyNameLength, file);
if (tmp != 2 * XkbKeyNameLength) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
return -1;
}
nRead += 2 * XkbKeyNameLength;
}
if (changes)
changes->names.changed |= XkbKeyAliasesMask;
}
if (changes)
changes->names.changed |= XkbKeyNamesMask;
return nRead;
}
/***====================================================================***/
static int
ReadXkmKeyTypes(FILE *file, XkbFileInfo *result, XkbChangesPtr changes)
{
register unsigned i, n;
unsigned num_types;
int nRead = 0;
int tmp;
XkbKeyTypePtr type;
xkmKeyTypeDesc wire;
XkbKTMapEntryPtr entry;
xkmKTMapEntryDesc wire_entry;
char buf[100];
XkbDescPtr xkb;
xkb = result->xkb;
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
return -1;
}
nRead += tmp;
if (buf[0] != '\0') {
if (XkbAllocNames(xkb, XkbTypesNameMask, 0, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeyTypes", 0);
return -1;
}
xkb->names->types = XkbInternAtom(xkb->dpy, buf, False);
}
num_types = XkmGetCARD16(file, &nRead);
nRead += XkmSkipPadding(file, 2);
if (num_types < 1)
return nRead;
if (XkbAllocClientMap(xkb, XkbKeyTypesMask, num_types) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeyTypes", 0);
return nRead;
}
xkb->map->num_types = num_types;
if (num_types < XkbNumRequiredTypes) {
_XkbLibError(_XkbErrMissingReqTypes, "ReadXkmKeyTypes", 0);
return -1;
}
type = xkb->map->types;
for (i = 0; i < num_types; i++, type++) {
if ((int) fread(&wire, SIZEOF(xkmKeyTypeDesc), 1, file) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
return -1;
}
nRead += SIZEOF(xkmKeyTypeDesc);
if (((i == XkbOneLevelIndex) && (wire.numLevels != 1)) ||
(((i == XkbTwoLevelIndex) || (i == XkbAlphabeticIndex) ||
((i) == XkbKeypadIndex)) && (wire.numLevels != 2))) {
_XkbLibError(_XkbErrBadTypeWidth, "ReadXkmKeyTypes", i);
return -1;
}
tmp = wire.nMapEntries;
XkmInsureTypedSize(type->map, type->map_count, &tmp, XkbKTMapEntryRec);
if ((wire.nMapEntries > 0) && (type->map == NULL)) {
_XkbLibError(_XkbErrBadValue, "ReadXkmKeyTypes", wire.nMapEntries);
return -1;
}
for (n = 0, entry = type->map; n < wire.nMapEntries; n++, entry++) {
if (fread(&wire_entry, SIZEOF(xkmKTMapEntryDesc), 1, file) <
(int) 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
return -1;
}
nRead += SIZEOF(xkmKTMapEntryDesc);
entry->active = (wire_entry.virtualMods == 0);
entry->level = wire_entry.level;
entry->mods.mask = wire_entry.realMods;
entry->mods.real_mods = wire_entry.realMods;
entry->mods.vmods = wire_entry.virtualMods;
}
nRead += XkmGetCountedString(file, buf, 100);
if (((i == XkbOneLevelIndex) && (strcmp(buf, "ONE_LEVEL") != 0)) ||
((i == XkbTwoLevelIndex) && (strcmp(buf, "TWO_LEVEL") != 0)) ||
((i == XkbAlphabeticIndex) && (strcmp(buf, "ALPHABETIC") != 0)) ||
((i == XkbKeypadIndex) && (strcmp(buf, "KEYPAD") != 0))) {
_XkbLibError(_XkbErrBadTypeName, "ReadXkmKeyTypes", 0);
return -1;
}
if (buf[0] != '\0') {
type->name = XkbInternAtom(xkb->dpy, buf, False);
}
else
type->name = None;
if (wire.preserve) {
xkmModsDesc p_entry;
XkbModsPtr pre;
XkmInsureTypedSize(type->preserve, type->map_count, &tmp,
XkbModsRec);
if (type->preserve == NULL) {
_XkbLibError(_XkbErrBadMatch, "ReadXkmKeycodes", 0);
return -1;
}
for (n = 0, pre = type->preserve; n < wire.nMapEntries; n++, pre++) {
if (fread(&p_entry, SIZEOF(xkmModsDesc), 1, file) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
return -1;
}
nRead += SIZEOF(xkmModsDesc);
pre->mask = p_entry.realMods;
pre->real_mods = p_entry.realMods;
pre->vmods = p_entry.virtualMods;
}
}
if (wire.nLevelNames > 0) {
int width = wire.numLevels;
if (wire.nLevelNames > (unsigned) width) {
_XkbLibError(_XkbErrBadMatch, "ReadXkmKeycodes", 0);
return -1;
}
XkmInsureTypedSize(type->level_names, type->num_levels, &width,
Atom);
if (type->level_names != NULL) {
for (n = 0; n < wire.nLevelNames; n++) {
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
return -1;
nRead += tmp;
if (strlen(buf) == 0)
type->level_names[n] = None;
else
type->level_names[n] = XkbInternAtom(xkb->dpy, buf, 0);
}
}
}
type->mods.mask = wire.realMods;
type->mods.real_mods = wire.realMods;
type->mods.vmods = wire.virtualMods;
type->num_levels = wire.numLevels;
type->map_count = wire.nMapEntries;
}
if (changes) {
changes->map.changed |= XkbKeyTypesMask;
changes->map.first_type = 0;
changes->map.num_types = xkb->map->num_types;
}
return nRead;
}
/***====================================================================***/
static int
ReadXkmCompatMap(FILE *file, XkbFileInfo *result, XkbChangesPtr changes)
{
register int i;
unsigned num_si, groups;
char name[100];
XkbSymInterpretPtr interp;
xkmSymInterpretDesc wire;
unsigned tmp;
int nRead = 0;
XkbDescPtr xkb;
XkbCompatMapPtr compat;
xkb = result->xkb;
if ((tmp = XkmGetCountedString(file, name, 100)) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmCompatMap", 0);
return -1;
}
nRead += tmp;
if (name[0] != '\0') {
if (XkbAllocNames(xkb, XkbCompatNameMask, 0, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmCompatMap", 0);
return -1;
}
xkb->names->compat = XkbInternAtom(xkb->dpy, name, False);
}
num_si = XkmGetCARD16(file, &nRead);
groups = XkmGetCARD8(file, &nRead);
nRead += XkmSkipPadding(file, 1);
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, num_si) != Success)
return -1;
compat = xkb->compat;
compat->num_si = num_si;
interp = compat->sym_interpret;
for (i = 0; i < num_si; i++, interp++) {
tmp = fread(&wire, SIZEOF(xkmSymInterpretDesc), 1, file);
nRead += tmp * SIZEOF(xkmSymInterpretDesc);
interp->sym = wire.sym;
interp->mods = wire.mods;
interp->match = wire.match;
interp->virtual_mod = wire.virtualMod;
interp->flags = wire.flags;
interp->act.type = wire.actionType;
interp->act.data[0] = wire.actionData[0];
interp->act.data[1] = wire.actionData[1];
interp->act.data[2] = wire.actionData[2];
interp->act.data[3] = wire.actionData[3];
interp->act.data[4] = wire.actionData[4];
interp->act.data[5] = wire.actionData[5];
interp->act.data[6] = wire.actionData[6];
}
if ((num_si > 0) && (changes)) {
changes->compat.first_si = 0;
changes->compat.num_si = num_si;
}
if (groups) {
register unsigned bit;
for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
xkmModsDesc md;
if (groups & bit) {
tmp = fread(&md, SIZEOF(xkmModsDesc), 1, file);
nRead += tmp * SIZEOF(xkmModsDesc);
xkb->compat->groups[i].real_mods = md.realMods;
xkb->compat->groups[i].vmods = md.virtualMods;
if (md.virtualMods != 0) {
unsigned mask;
if (XkbVirtualModsToReal(xkb, md.virtualMods, &mask))
xkb->compat->groups[i].mask = md.realMods | mask;
}
else
xkb->compat->groups[i].mask = md.realMods;
}
}
if (changes)
changes->compat.changed_groups |= groups;
}
return nRead;
}
static int
ReadXkmIndicators(FILE *file, XkbFileInfo *result, XkbChangesPtr changes)
{
register unsigned nLEDs;
xkmIndicatorMapDesc wire;
char buf[100];
unsigned tmp;
int nRead = 0;
XkbDescPtr xkb;
xkb = result->xkb;
if ((xkb->indicators == NULL) && (XkbAllocIndicatorMaps(xkb) != Success)) {
_XkbLibError(_XkbErrBadAlloc, "indicator rec", 0);
return -1;
}
if (XkbAllocNames(xkb, XkbIndicatorNamesMask, 0, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "indicator names", 0);
return -1;
}
nLEDs = XkmGetCARD8(file, &nRead);
nRead += XkmSkipPadding(file, 3);
xkb->indicators->phys_indicators = XkmGetCARD32(file, &nRead);
while (nLEDs-- > 0) {
Atom name;
XkbIndicatorMapPtr map;
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmIndicators", 0);
return -1;
}
nRead += tmp;
if (buf[0] != '\0')
name = XkbInternAtom(xkb->dpy, buf, False);
else
name = None;
if ((tmp = fread(&wire, SIZEOF(xkmIndicatorMapDesc), 1, file)) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmIndicators", 0);
return -1;
}
nRead += tmp * SIZEOF(xkmIndicatorMapDesc);
if (xkb->names) {
xkb->names->indicators[wire.indicator - 1] = name;
if (changes)
changes->names.changed_indicators |=
(1 << (wire.indicator - 1));
}
map = &xkb->indicators->maps[wire.indicator - 1];
map->flags = wire.flags;
map->which_groups = wire.which_groups;
map->groups = wire.groups;
map->which_mods = wire.which_mods;
map->mods.mask = wire.real_mods;
map->mods.real_mods = wire.real_mods;
map->mods.vmods = wire.vmods;
map->ctrls = wire.ctrls;
}
return nRead;
}
static XkbKeyTypePtr
FindTypeForKey(XkbDescPtr xkb, Atom name, unsigned width, KeySym *syms)
{
if ((!xkb) || (!xkb->map))
return NULL;
if (name != None) {
register unsigned i;
for (i = 0; i < xkb->map->num_types; i++) {
if (xkb->map->types[i].name == name) {
#ifdef DEBUG
if (xkb->map->types[i].num_levels != width)
fprintf(stderr,
"Group width mismatch between key and type\n");
#endif
return &xkb->map->types[i];
}
}
}
if ((width < 2) || ((syms != NULL) && (syms[1] == NoSymbol)))
return &xkb->map->types[XkbOneLevelIndex];
if (syms != NULL) {
if (XkbKSIsLower(syms[0]) && XkbKSIsUpper(syms[1]))
return &xkb->map->types[XkbAlphabeticIndex];
else if (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1]))
return &xkb->map->types[XkbKeypadIndex];
}
return &xkb->map->types[XkbTwoLevelIndex];
}
static int
ReadXkmSymbols(FILE *file, XkbFileInfo *result)
{
register int i, g, s, totalVModMaps;
xkmKeySymMapDesc wireMap;
char buf[100];
unsigned minKC, maxKC, groupNames, tmp;
int nRead = 0;
XkbDescPtr xkb;
xkb = result->xkb;
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
return -1;
nRead += tmp;
minKC = XkmGetCARD8(file, &nRead);
maxKC = XkmGetCARD8(file, &nRead);
groupNames = XkmGetCARD8(file, &nRead);
totalVModMaps = XkmGetCARD8(file, &nRead);
if (XkbAllocNames(xkb,
XkbSymbolsNameMask | XkbPhysSymbolsNameMask |
XkbGroupNamesMask, 0, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "physical names", 0);
return -1;
}
if ((buf[0] != '\0') && (xkb->names)) {
Atom name;
name = XkbInternAtom(xkb->dpy, buf, 0);
xkb->names->symbols = name;
xkb->names->phys_symbols = name;
}
for (i = 0, g = 1; i < XkbNumKbdGroups; i++, g <<= 1) {
if (groupNames & g) {
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
return -1;
nRead += tmp;
if ((buf[0] != '\0') && (xkb->names)) {
Atom name;
name = XkbInternAtom(xkb->dpy, buf, 0);
xkb->names->groups[i] = name;
}
else
xkb->names->groups[i] = None;
}
}
if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "server map", 0);
return -1;
}
if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success) {
_XkbLibError(_XkbErrBadAlloc, "client map", 0);
return -1;
}
if (XkbAllocControls(xkb, XkbAllControlsMask) != Success) {
_XkbLibError(_XkbErrBadAlloc, "controls", 0);
return -1;
}
if ((xkb->map == NULL) || (xkb->server == NULL))
return -1;
if (xkb->min_key_code < 8)
xkb->min_key_code = minKC;
if (xkb->max_key_code < 8)
xkb->max_key_code = maxKC;
if ((minKC >= 8) && (minKC < xkb->min_key_code))
xkb->min_key_code = minKC;
if ((maxKC >= 8) && (maxKC > xkb->max_key_code)) {
_XkbLibError(_XkbErrBadValue, "keys in symbol map", maxKC);
return -1;
}
for (i = minKC; i <= (int) maxKC; i++) {
Atom typeName[XkbNumKbdGroups];
XkbKeyTypePtr type[XkbNumKbdGroups];
if ((tmp = fread(&wireMap, SIZEOF(xkmKeySymMapDesc), 1, file)) < 1) {
_XkbLibError(_XkbErrBadLength, "ReadXkmSymbols", 0);
return -1;
}
nRead += tmp * SIZEOF(xkmKeySymMapDesc);
bzero((char *) typeName, XkbNumKbdGroups * sizeof(Atom));
bzero((char *) type, XkbNumKbdGroups * sizeof(XkbKeyTypePtr));
if (wireMap.flags & XkmKeyHasTypes) {
register int g;
for (g = 0; g < XkbNumKbdGroups; g++) {
if ((wireMap.flags & (1 << g)) &&
((tmp = XkmGetCountedString(file, buf, 100)) > 0)) {
typeName[g] = XkbInternAtom(xkb->dpy, buf, 1);
nRead += tmp;
}
type[g] = FindTypeForKey(xkb, typeName[g], wireMap.width, NULL);
if (type[g] == NULL) {
_XkbLibError(_XkbErrMissingTypes, "ReadXkmSymbols", 0);
return -1;
}
if (typeName[g] == type[g]->name)
xkb->server->explicit[i] |= (1 << g);
}
}
if (wireMap.flags & XkmRepeatingKey) {
xkb->ctrls->per_key_repeat[i / 8] |= (1 << (i % 8));
xkb->server->explicit[i] |= XkbExplicitAutoRepeatMask;
}
else if (wireMap.flags & XkmNonRepeatingKey) {
xkb->ctrls->per_key_repeat[i / 8] &= ~(1 << (i % 8));
xkb->server->explicit[i] |= XkbExplicitAutoRepeatMask;
}
xkb->map->modmap[i] = wireMap.modifier_map;
if (XkbNumGroups(wireMap.num_groups) > 0) {
KeySym *sym;
int nSyms;
if (XkbNumGroups(wireMap.num_groups) > xkb->ctrls->num_groups)
xkb->ctrls->num_groups = wireMap.num_groups;
nSyms = XkbNumGroups(wireMap.num_groups) * wireMap.width;
sym = XkbResizeKeySyms(xkb, i, nSyms);
if (!sym)
return -1;
for (s = 0; s < nSyms; s++) {
*sym++ = XkmGetCARD32(file, &nRead);
}
if (wireMap.flags & XkmKeyHasActions) {
XkbAction *act;
act = XkbResizeKeyActions(xkb, i, nSyms);
for (s = 0; s < nSyms; s++, act++) {
tmp = fread(act, SIZEOF(xkmActionDesc), 1, file);
nRead += tmp * SIZEOF(xkmActionDesc);
}
xkb->server->explicit[i] |= XkbExplicitInterpretMask;
}
}
for (g = 0; g < XkbNumGroups(wireMap.num_groups); g++) {
if (((xkb->server->explicit[i] & (1 << g)) == 0) ||
(type[g] == NULL)) {
KeySym *tmpSyms;
tmpSyms = XkbKeySymsPtr(xkb, i) + (wireMap.width * g);
type[g] = FindTypeForKey(xkb, None, wireMap.width, tmpSyms);
}
xkb->map->key_sym_map[i].kt_index[g] =
type[g] - (&xkb->map->types[0]);
}
xkb->map->key_sym_map[i].group_info = wireMap.num_groups;
xkb->map->key_sym_map[i].width = wireMap.width;
if (wireMap.flags & XkmKeyHasBehavior) {
xkmBehaviorDesc b;
tmp = fread(&b, SIZEOF(xkmBehaviorDesc), 1, file);
nRead += tmp * SIZEOF(xkmBehaviorDesc);
xkb->server->behaviors[i].type = b.type;
xkb->server->behaviors[i].data = b.data;
xkb->server->explicit[i] |= XkbExplicitBehaviorMask;
}
}
if (totalVModMaps > 0) {
xkmVModMapDesc v;
for (i = 0; i < totalVModMaps; i++) {
tmp = fread(&v, SIZEOF(xkmVModMapDesc), 1, file);
nRead += tmp * SIZEOF(xkmVModMapDesc);
if (tmp > 0)
xkb->server->vmodmap[v.key] = v.vmods;
}
}
return nRead;
}
static int
ReadXkmGeomDoodad(FILE *file, Display *dpy,
XkbGeometryPtr geom, XkbSectionPtr section)
{
XkbDoodadPtr doodad;
xkmDoodadDesc doodadWire;
char buf[100];
unsigned tmp;
int nRead = 0;
nRead += XkmGetCountedString(file, buf, 100);
tmp = fread(&doodadWire, SIZEOF(xkmDoodadDesc), 1, file);
nRead += SIZEOF(xkmDoodadDesc) * tmp;
doodad = XkbAddGeomDoodad(geom, section, XkbInternAtom(dpy, buf, False));
if (!doodad)
return nRead;
doodad->any.type = doodadWire.any.type;
doodad->any.priority = doodadWire.any.priority;
doodad->any.top = doodadWire.any.top;
doodad->any.left = doodadWire.any.left;
switch (doodadWire.any.type) {
case XkbOutlineDoodad:
case XkbSolidDoodad:
doodad->shape.angle = doodadWire.shape.angle;
doodad->shape.color_ndx = doodadWire.shape.color_ndx;
doodad->shape.shape_ndx = doodadWire.shape.shape_ndx;
break;
case XkbTextDoodad:
doodad->text.angle = doodadWire.text.angle;
doodad->text.width = doodadWire.text.width;
doodad->text.height = doodadWire.text.height;
doodad->text.color_ndx = doodadWire.text.color_ndx;
nRead += XkmGetCountedString(file, buf, 100);
doodad->text.text = _XkbDupString(buf);
nRead += XkmGetCountedString(file, buf, 100);
doodad->text.font = _XkbDupString(buf);
break;
case XkbIndicatorDoodad:
doodad->indicator.shape_ndx = doodadWire.indicator.shape_ndx;
doodad->indicator.on_color_ndx = doodadWire.indicator.on_color_ndx;
doodad->indicator.off_color_ndx = doodadWire.indicator.off_color_ndx;
break;
case XkbLogoDoodad:
doodad->logo.angle = doodadWire.logo.angle;
doodad->logo.color_ndx = doodadWire.logo.color_ndx;
doodad->logo.shape_ndx = doodadWire.logo.shape_ndx;
nRead += XkmGetCountedString(file, buf, 100);
doodad->logo.logo_name = _XkbDupString(buf);
break;
default:
/* report error? */
return nRead;
}
return nRead;
}
static int
ReadXkmGeomOverlay(FILE *file, Display *dpy,
XkbGeometryPtr geom, XkbSectionPtr section)
{
char buf[100];
unsigned tmp;
int nRead = 0;
XkbOverlayPtr ol;
XkbOverlayRowPtr row;
xkmOverlayDesc olWire;
xkmOverlayRowDesc rowWire;
register int r;
nRead += XkmGetCountedString(file, buf, 100);
tmp = fread(&olWire, SIZEOF(xkmOverlayDesc), 1, file);
nRead += tmp * SIZEOF(xkmOverlayDesc);
ol = XkbAddGeomOverlay(section, XkbInternAtom(dpy, buf, False),
olWire.num_rows);
if (!ol)
return nRead;
for (r = 0; r < olWire.num_rows; r++) {
int k;
xkmOverlayKeyDesc keyWire;
tmp = fread(&rowWire, SIZEOF(xkmOverlayRowDesc), 1, file);
nRead += tmp * SIZEOF(xkmOverlayRowDesc);
row = XkbAddGeomOverlayRow(ol, rowWire.row_under, rowWire.num_keys);
if (!row) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomOverlay", 0);
return nRead;
}
for (k = 0; k < rowWire.num_keys; k++) {
tmp = fread(&keyWire, SIZEOF(xkmOverlayKeyDesc), 1, file);
nRead += tmp * SIZEOF(xkmOverlayKeyDesc);
memcpy(row->keys[k].over.name, keyWire.over, XkbKeyNameLength);
memcpy(row->keys[k].under.name, keyWire.under, XkbKeyNameLength);
}
row->num_keys = rowWire.num_keys;
}
return nRead;
}
static int
ReadXkmGeomSection(FILE *file, Display *dpy, XkbGeometryPtr geom)
{
register int i;
XkbSectionPtr section;
xkmSectionDesc sectionWire;
unsigned tmp;
int nRead = 0;
char buf[100];
Atom nameAtom;
nRead += XkmGetCountedString(file, buf, 100);
nameAtom = XkbInternAtom(dpy, buf, False);
tmp = fread(§ionWire, SIZEOF(xkmSectionDesc), 1, file);
nRead += SIZEOF(xkmSectionDesc) * tmp;
section = XkbAddGeomSection(geom, nameAtom, sectionWire.num_rows,
sectionWire.num_doodads,
sectionWire.num_overlays);
if (!section) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomSection", 0);
return nRead;
}
section->top = sectionWire.top;
section->left = sectionWire.left;
section->width = sectionWire.width;
section->height = sectionWire.height;
section->angle = sectionWire.angle;
section->priority = sectionWire.priority;
if (sectionWire.num_rows > 0) {
register int k;
XkbRowPtr row;
xkmRowDesc rowWire;
XkbKeyPtr key;
xkmKeyDesc keyWire;
for (i = 0; i < sectionWire.num_rows; i++) {
tmp = fread(&rowWire, SIZEOF(xkmRowDesc), 1, file);
nRead += SIZEOF(xkmRowDesc) * tmp;
row = XkbAddGeomRow(section, rowWire.num_keys);
if (!row) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeycodes", 0);
return nRead;
}
row->top = rowWire.top;
row->left = rowWire.left;
row->vertical = rowWire.vertical;
for (k = 0; k < rowWire.num_keys; k++) {
tmp = fread(&keyWire, SIZEOF(xkmKeyDesc), 1, file);
nRead += SIZEOF(xkmKeyDesc) * tmp;
key = XkbAddGeomKey(row);
if (!key) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomSection", 0);
return nRead;
}
memcpy(key->name.name, keyWire.name, XkbKeyNameLength);
key->gap = keyWire.gap;
key->shape_ndx = keyWire.shape_ndx;
key->color_ndx = keyWire.color_ndx;
}
}
}
if (sectionWire.num_doodads > 0) {
for (i = 0; i < sectionWire.num_doodads; i++) {
tmp = ReadXkmGeomDoodad(file, dpy, geom, section);
nRead += tmp;
if (tmp < 1)
return nRead;
}
}
if (sectionWire.num_overlays > 0) {
for (i = 0; i < sectionWire.num_overlays; i++) {
tmp = ReadXkmGeomOverlay(file, dpy, geom, section);
nRead += tmp;
if (tmp < 1)
return nRead;
}
}
return nRead;
}
static int
ReadXkmGeometry(FILE *file, XkbFileInfo *result)
{
register int i;
char buf[100];
unsigned tmp;
int nRead = 0;
xkmGeometryDesc wireGeom;
XkbGeometryPtr geom;
XkbGeometrySizesRec sizes;
nRead += XkmGetCountedString(file, buf, 100);
tmp = fread(&wireGeom, SIZEOF(xkmGeometryDesc), 1, file);
nRead += tmp * SIZEOF(xkmGeometryDesc);
sizes.which = XkbGeomAllMask;
sizes.num_properties = wireGeom.num_properties;
sizes.num_colors = wireGeom.num_colors;
sizes.num_shapes = wireGeom.num_shapes;
sizes.num_sections = wireGeom.num_sections;
sizes.num_doodads = wireGeom.num_doodads;
sizes.num_key_aliases = wireGeom.num_key_aliases;
if (XkbAllocGeometry(result->xkb, &sizes) != Success) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
geom = result->xkb->geom;
geom->name = XkbInternAtom(result->xkb->dpy, buf, False);
geom->width_mm = wireGeom.width_mm;
geom->height_mm = wireGeom.height_mm;
nRead += XkmGetCountedString(file, buf, 100);
geom->label_font = _XkbDupString(buf);
if (wireGeom.num_properties > 0) {
char val[1024];
for (i = 0; i < wireGeom.num_properties; i++) {
nRead += XkmGetCountedString(file, buf, 100);
nRead += XkmGetCountedString(file, val, 1024);
if (XkbAddGeomProperty(geom, buf, val) == NULL) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
}
}
if (wireGeom.num_colors > 0) {
for (i = 0; i < wireGeom.num_colors; i++) {
nRead += XkmGetCountedString(file, buf, 100);
if (XkbAddGeomColor(geom, buf, i) == NULL) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
}
}
geom->base_color = &geom->colors[wireGeom.base_color_ndx];
geom->label_color = &geom->colors[wireGeom.label_color_ndx];
if (wireGeom.num_shapes > 0) {
XkbShapePtr shape;
xkmShapeDesc shapeWire;
Atom nameAtom;
for (i = 0; i < wireGeom.num_shapes; i++) {
register int n;
XkbOutlinePtr ol;
xkmOutlineDesc olWire;
nRead += XkmGetCountedString(file, buf, 100);
nameAtom = XkbInternAtom(result->xkb->dpy, buf, False);
tmp = fread(&shapeWire, SIZEOF(xkmShapeDesc), 1, file);
nRead += tmp * SIZEOF(xkmShapeDesc);
shape = XkbAddGeomShape(geom, nameAtom, shapeWire.num_outlines);
if (!shape) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
for (n = 0; n < shapeWire.num_outlines; n++) {
register int p;
xkmPointDesc ptWire;
tmp = fread(&olWire, SIZEOF(xkmOutlineDesc), 1, file);
nRead += tmp * SIZEOF(xkmOutlineDesc);
ol = XkbAddGeomOutline(shape, olWire.num_points);
if (!ol) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
ol->num_points = olWire.num_points;
ol->corner_radius = olWire.corner_radius;
for (p = 0; p < olWire.num_points; p++) {
tmp = fread(&ptWire, SIZEOF(xkmPointDesc), 1, file);
nRead += tmp * SIZEOF(xkmPointDesc);
ol->points[p].x = ptWire.x;
ol->points[p].y = ptWire.y;
if (ptWire.x < shape->bounds.x1)
shape->bounds.x1 = ptWire.x;
if (ptWire.x > shape->bounds.x2)
shape->bounds.x2 = ptWire.x;
if (ptWire.y < shape->bounds.y1)
shape->bounds.y1 = ptWire.y;
if (ptWire.y > shape->bounds.y2)
shape->bounds.y2 = ptWire.y;
}
}
if (shapeWire.primary_ndx != XkbNoShape)
shape->primary = &shape->outlines[shapeWire.primary_ndx];
if (shapeWire.approx_ndx != XkbNoShape)
shape->approx = &shape->outlines[shapeWire.approx_ndx];
}
}
if (wireGeom.num_sections > 0) {
for (i = 0; i < wireGeom.num_sections; i++) {
tmp = ReadXkmGeomSection(file, result->xkb->dpy, geom);
nRead += tmp;
if (tmp == 0)
return nRead;
}
}
if (wireGeom.num_doodads > 0) {
for (i = 0; i < wireGeom.num_doodads; i++) {
tmp = ReadXkmGeomDoodad(file, result->xkb->dpy, geom, NULL);
nRead += tmp;
if (tmp == 0)
return nRead;
}
}
if ((wireGeom.num_key_aliases > 0) && (geom->key_aliases)) {
int sz = XkbKeyNameLength * 2;
int num = wireGeom.num_key_aliases;
if (fread(geom->key_aliases, sz, num, file) != num) {
_XkbLibError(_XkbErrBadLength, "ReadXkmGeometry", 0);
return -1;
}
nRead += (num * sz);
geom->num_key_aliases = num;
}
return nRead;
}
Bool
XkmProbe(FILE *file)
{
unsigned hdr, tmp;
int nRead = 0;
hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
tmp = XkmGetCARD32(file, &nRead);
if (tmp != hdr) {
if ((tmp & (~0xff)) == (hdr & (~0xff))) {
_XkbLibError(_XkbErrBadFileVersion, "XkmProbe", tmp & 0xff);
}
return 0;
}
return 1;
}
Bool
XkmReadTOC(FILE *file, xkmFileInfo *file_info,
int max_toc, xkmSectionInfo *toc)
{
unsigned hdr, tmp;
int nRead = 0;
unsigned i, size_toc;
hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
tmp = XkmGetCARD32(file, &nRead);
if (tmp != hdr) {
if ((tmp & (~0xff)) == (hdr & (~0xff))) {
_XkbLibError(_XkbErrBadFileVersion, "XkmReadTOC", tmp & 0xff);
}
else {
_XkbLibError(_XkbErrBadFileType, "XkmReadTOC", tmp);
}
return 0;
}
fread(file_info, SIZEOF(xkmFileInfo), 1, file);
size_toc = file_info->num_toc;
if (size_toc > max_toc) {
#ifdef DEBUG
fprintf(stderr, "Warning! Too many TOC entries; last %d ignored\n",
size_toc - max_toc);
#endif
size_toc = max_toc;
}
for (i = 0; i < size_toc; i++) {
fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file);
}
return 1;
}
xkmSectionInfo *
XkmFindTOCEntry(xkmFileInfo *finfo, xkmSectionInfo *toc, unsigned type)
{
register int i;
for (i = 0; i < finfo->num_toc; i++) {
if (toc[i].type == type)
return &toc[i];
}
return NULL;
}
Bool
XkmReadFileSection(FILE * file,
xkmSectionInfo * toc,
XkbFileInfo * result,
unsigned * loaded_rtrn)
{
xkmSectionInfo tmpTOC;
int nRead;
if ((!result) || (!result->xkb)) {
_XkbLibError(_XkbErrBadMatch, "XkmReadFileSection", 0);
return 0;
}
fseek(file, toc->offset, SEEK_SET);
fread(&tmpTOC, SIZEOF(xkmSectionInfo), 1, file);
nRead = SIZEOF(xkmSectionInfo);
if ((tmpTOC.type != toc->type) || (tmpTOC.format != toc->format) ||
(tmpTOC.size != toc->size) || (tmpTOC.offset != toc->offset)) {
_XkbLibError(_XkbErrIllegalContents, "XkmReadFileSection", 0);
return 0;
}
switch (tmpTOC.type) {
case XkmVirtualModsIndex:
nRead += ReadXkmVirtualMods(file, result, NULL);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmVirtualModsMask;
break;
case XkmTypesIndex:
nRead += ReadXkmKeyTypes(file, result, NULL);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmTypesMask;
break;
case XkmCompatMapIndex:
nRead += ReadXkmCompatMap(file, result, NULL);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmCompatMapMask;
break;
case XkmKeyNamesIndex:
nRead += ReadXkmKeycodes(file, result, NULL);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmKeyNamesMask;
break;
case XkmSymbolsIndex:
nRead += ReadXkmSymbols(file, result);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmSymbolsMask;
break;
case XkmIndicatorsIndex:
nRead += ReadXkmIndicators(file, result, NULL);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmIndicatorsMask;
break;
case XkmGeometryIndex:
nRead += ReadXkmGeometry(file, result);
if ((loaded_rtrn) && (nRead >= 0))
*loaded_rtrn |= XkmGeometryMask;
break;
default:
_XkbLibError(_XkbErrBadImplementation,
XkbConfigText(tmpTOC.type, XkbMessage), 0);
nRead = 0;
break;
}
if (nRead != tmpTOC.size) {
_XkbLibError(_XkbErrBadLength, XkbConfigText(tmpTOC.type, XkbMessage),
nRead - tmpTOC.size);
return 0;
}
return (nRead >= 0);
}
char *
XkmReadFileSectionName(FILE *file, xkmSectionInfo *toc)
{
xkmSectionInfo tmpTOC;
char name[100];
if ((!file) || (!toc))
return NULL;
switch (toc->type) {
case XkmVirtualModsIndex:
case XkmIndicatorsIndex:
break;
case XkmTypesIndex:
case XkmCompatMapIndex:
case XkmKeyNamesIndex:
case XkmSymbolsIndex:
case XkmGeometryIndex:
fseek(file, toc->offset, SEEK_SET);
fread(&tmpTOC, SIZEOF(xkmSectionInfo), 1, file);
if ((tmpTOC.type != toc->type) || (tmpTOC.format != toc->format) ||
(tmpTOC.size != toc->size) || (tmpTOC.offset != toc->offset)) {
_XkbLibError(_XkbErrIllegalContents, "XkmReadFileSectionName", 0);
return NULL;
}
if (XkmGetCountedString(file, name, 100) > 0)
return _XkbDupString(name);
break;
default:
_XkbLibError(_XkbErrBadImplementation,
XkbConfigText(tmpTOC.type, XkbMessage), 0);
break;
}
return NULL;
}
/***====================================================================***/
#define MAX_TOC 16
unsigned
XkmReadFile(FILE *file, unsigned need, unsigned want, XkbFileInfo *result)
{
register unsigned i;
xkmSectionInfo toc[MAX_TOC], tmpTOC;
xkmFileInfo fileInfo;
unsigned tmp, nRead = 0;
unsigned which = need | want;
if (!XkmReadTOC(file, &fileInfo, MAX_TOC, toc))
return which;
if ((fileInfo.present & need) != need) {
_XkbLibError(_XkbErrIllegalContents, "XkmReadFile",
need & (~fileInfo.present));
return which;
}
result->type = fileInfo.type;
if (result->xkb == NULL)
result->xkb = XkbAllocKeyboard();
for (i = 0; i < fileInfo.num_toc; i++) {
fseek(file, toc[i].offset, SEEK_SET);
tmp = fread(&tmpTOC, SIZEOF(xkmSectionInfo), 1, file);
nRead = tmp * SIZEOF(xkmSectionInfo);
if ((tmpTOC.type != toc[i].type) || (tmpTOC.format != toc[i].format) ||
(tmpTOC.size != toc[i].size) || (tmpTOC.offset != toc[i].offset)) {
return which;
}
if ((which & (1 << tmpTOC.type)) == 0) {
continue;
}
switch (tmpTOC.type) {
case XkmVirtualModsIndex:
tmp = ReadXkmVirtualMods(file, result, NULL);
break;
case XkmTypesIndex:
tmp = ReadXkmKeyTypes(file, result, NULL);
break;
case XkmCompatMapIndex:
tmp = ReadXkmCompatMap(file, result, NULL);
break;
case XkmKeyNamesIndex:
tmp = ReadXkmKeycodes(file, result, NULL);
break;
case XkmIndicatorsIndex:
tmp = ReadXkmIndicators(file, result, NULL);
break;
case XkmSymbolsIndex:
tmp = ReadXkmSymbols(file, result);
break;
case XkmGeometryIndex:
tmp = ReadXkmGeometry(file, result);
break;
default:
_XkbLibError(_XkbErrBadImplementation,
XkbConfigText(tmpTOC.type, XkbMessage), 0);
tmp = 0;
break;
}
if (tmp > 0) {
nRead += tmp;
which &= ~(1 << toc[i].type);
result->defined |= (1 << toc[i].type);
}
if (nRead != tmpTOC.size) {
_XkbLibError(_XkbErrBadLength,
XkbConfigText(tmpTOC.type, XkbMessage),
nRead - tmpTOC.size);
}
}
return which;
}
eDesc);
shape = XkbAddGeomShape(geom, nameAtom, shapeWire.num_outlines);
if (!shape) {
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
return nRead;
}
for (n = 0; n < shapeWire.num_outlines; n++) {
register int p;
xkmPointDesc ptWire;
tmp = freadlibxkbfile-1.1.0/src/maprules.c 0000644 0143106 0000012 00000124733 13443241017 0016700 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
#include "XKBrules.h"
#ifdef DEBUG
#define PR_DEBUG(s) fprintf(stderr,s)
#define PR_DEBUG1(s,a) fprintf(stderr,s,a)
#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b)
#else
#define PR_DEBUG(s)
#define PR_DEBUG1(s,a)
#define PR_DEBUG2(s,a,b)
#endif
/***====================================================================***/
#define DFLT_LINE_SIZE 128
typedef struct {
int line_num;
int sz_line;
int num_line;
char buf[DFLT_LINE_SIZE];
char * line;
} InputLine;
static void
InitInputLine(InputLine *line)
{
line->line_num = 1;
line->num_line = 0;
line->sz_line = DFLT_LINE_SIZE;
line->line = line->buf;
return;
}
static void
FreeInputLine(InputLine *line)
{
if (line->line != line->buf)
_XkbFree(line->line);
line->line_num = 1;
line->num_line = 0;
line->sz_line = DFLT_LINE_SIZE;
line->line = line->buf;
return;
}
static int
InputLineAddChar(InputLine *line, int ch)
{
if (line->num_line >= line->sz_line) {
if (line->line == line->buf) {
line->line = (char *) _XkbAlloc(line->sz_line * 2);
memcpy(line->line, line->buf, line->sz_line);
}
else {
line->line =
(char *) _XkbRealloc((char *) line->line, line->sz_line * 2);
}
line->sz_line *= 2;
}
line->line[line->num_line++] = ch;
return ch;
}
#define ADD_CHAR(l,c) ((l)->num_line<(l)->sz_line?\
(int)((l)->line[(l)->num_line++]= (c)):\
InputLineAddChar(l,c))
#ifdef HAVE_UNLOCKED_STDIO
#undef getc
#define getc(x) getc_unlocked(x)
#else
#define flockfile(x) do {} while (0)
#define funlockfile(x) do {} while (0)
#endif
static Bool
GetInputLine(FILE *file, InputLine *line, Bool checkbang)
{
int ch;
Bool endOfFile, spacePending, slashPending, inComment;
endOfFile = False;
flockfile(file);
while ((!endOfFile) && (line->num_line == 0)) {
spacePending = slashPending = inComment = False;
while (((ch = getc(file)) != '\n') && (ch != EOF)) {
if (ch == '\\') {
if ((ch = getc(file)) == EOF)
break;
if (ch == '\n') {
inComment = False;
ch = ' ';
line->line_num++;
}
}
if (inComment)
continue;
if (ch == '/') {
if (slashPending) {
inComment = True;
slashPending = False;
}
else {
slashPending = True;
}
continue;
}
else if (slashPending) {
if (spacePending) {
ADD_CHAR(line, ' ');
spacePending = False;
}
ADD_CHAR(line, '/');
slashPending = False;
}
if (isspace(ch)) {
while (isspace(ch) && (ch != '\n') && (ch != EOF)) {
ch = getc(file);
}
if (ch == EOF)
break;
if ((ch != '\n') && (line->num_line > 0))
spacePending = True;
ungetc(ch, file);
}
else {
if (spacePending) {
ADD_CHAR(line, ' ');
spacePending = False;
}
if (checkbang && ch == '!') {
if (line->num_line != 0) {
PR_DEBUG("The '!' legal only at start of line\n");
PR_DEBUG("Line containing '!' ignored\n");
line->num_line = 0;
inComment = 0;
break;
}
}
ADD_CHAR(line, ch);
}
}
if (ch == EOF)
endOfFile = True;
/* else line->num_line++;*/
}
funlockfile(file);
if ((line->num_line == 0) && (endOfFile))
return False;
ADD_CHAR(line, '\0');
return True;
}
/***====================================================================***/
#define MODEL 0
#define LAYOUT 1
#define VARIANT 2
#define OPTION 3
#define KEYCODES 4
#define SYMBOLS 5
#define TYPES 6
#define COMPAT 7
#define GEOMETRY 8
#define KEYMAP 9
#define MAX_WORDS 10
#define PART_MASK 0x000F
#define COMPONENT_MASK 0x03F0
static const char *cname[MAX_WORDS] = {
"model", "layout", "variant", "option",
"keycodes", "symbols", "types", "compat", "geometry", "keymap"
};
typedef struct _RemapSpec {
int number;
int num_remap;
struct {
int word;
int index;
} remap[MAX_WORDS];
} RemapSpec;
typedef struct _FileSpec {
char *name[MAX_WORDS];
struct _FileSpec *pending;
} FileSpec;
typedef struct {
char *model;
char *layout[XkbNumKbdGroups + 1];
char *variant[XkbNumKbdGroups + 1];
char *options;
} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
#define NDX_BUFF_SIZE 4
/***====================================================================***/
static char *
get_index(char *str, int *ndx)
{
char ndx_buf[NDX_BUFF_SIZE];
char *end;
if (*str != '[') {
*ndx = 0;
return str;
}
str++;
end = strchr(str, ']');
if (end == NULL) {
*ndx = -1;
return str - 1;
}
if ((end - str) >= NDX_BUFF_SIZE) {
*ndx = -1;
return end + 1;
}
strncpy(ndx_buf, str, end - str);
ndx_buf[end - str] = '\0';
*ndx = atoi(ndx_buf);
return end + 1;
}
static void
SetUpRemap(InputLine *line, RemapSpec *remap)
{
char *tok, *str;
unsigned present, l_ndx_present, v_ndx_present;
register int i;
int len, ndx;
_Xstrtokparams strtok_buf;
#ifdef DEBUG
Bool found;
#endif
l_ndx_present = v_ndx_present = present = 0;
str = &line->line[1];
len = remap->number;
bzero((char *) remap, sizeof(RemapSpec));
remap->number = len;
while ((tok = _XStrtok(str, " ", strtok_buf)) != NULL) {
#ifdef DEBUG
found = False;
#endif
str = NULL;
if (strcmp(tok, "=") == 0)
continue;
for (i = 0; i < MAX_WORDS; i++) {
len = strlen(cname[i]);
if (strncmp(cname[i], tok, len) == 0) {
if (strlen(tok) > len) {
char *end = get_index(tok + len, &ndx);
if ((i != LAYOUT && i != VARIANT) ||
*end != '\0' || ndx == -1)
break;
if (ndx < 1 || ndx > XkbNumKbdGroups) {
PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx);
PR_DEBUG1("Index must be in range 1..%d\n",
XkbNumKbdGroups);
break;
}
}
else {
ndx = 0;
}
#ifdef DEBUG
found = True;
#endif
if (present & (1 << i)) {
if ((i == LAYOUT && l_ndx_present & (1 << ndx)) ||
(i == VARIANT && v_ndx_present & (1 << ndx))) {
PR_DEBUG1("Component \"%s\" listed twice\n", tok);
PR_DEBUG("Second definition ignored\n");
break;
}
}
present |= (1 << i);
if (i == LAYOUT)
l_ndx_present |= 1 << ndx;
if (i == VARIANT)
v_ndx_present |= 1 << ndx;
remap->remap[remap->num_remap].word = i;
remap->remap[remap->num_remap++].index = ndx;
break;
}
}
#ifdef DEBUG
if (!found) {
fprintf(stderr, "Unknown component \"%s\" ignored\n", tok);
}
#endif
}
if ((present & PART_MASK) == 0) {
#ifdef DEBUG
unsigned mask = PART_MASK;
fprintf(stderr, "Mapping needs at least one of ");
for (i = 0; (i < MAX_WORDS); i++) {
if ((1L << i) & mask) {
mask &= ~(1L << i);
if (mask)
fprintf(stderr, "\"%s,\" ", cname[i]);
else
fprintf(stderr, "or \"%s\"\n", cname[i]);
}
}
fprintf(stderr, "Illegal mapping ignored\n");
#endif
remap->num_remap = 0;
return;
}
if ((present & COMPONENT_MASK) == 0) {
PR_DEBUG("Mapping needs at least one component\n");
PR_DEBUG("Illegal mapping ignored\n");
remap->num_remap = 0;
return;
}
if (((present & COMPONENT_MASK) & (1 << KEYMAP)) &&
((present & COMPONENT_MASK) != (1 << KEYMAP))) {
PR_DEBUG("Keymap cannot appear with other components\n");
PR_DEBUG("Illegal mapping ignored\n");
remap->num_remap = 0;
return;
}
remap->number++;
return;
}
static Bool
MatchOneOf(char *wanted, char *vals_defined)
{
char *str, *next;
int want_len = strlen(wanted);
for (str = vals_defined, next = NULL; str != NULL; str = next) {
int len;
next = strchr(str, ',');
if (next) {
len = next - str;
next++;
}
else {
len = strlen(str);
}
if ((len == want_len) && (strncmp(wanted, str, len) == 0))
return True;
}
return False;
}
/***====================================================================***/
static Bool
CheckLine(InputLine * line,
RemapSpec * remap,
XkbRF_RulePtr rule,
XkbRF_GroupPtr group)
{
char *str, *tok;
register int nread, i;
FileSpec tmp;
_Xstrtokparams strtok_buf;
Bool append = False;
if (line->line[0] == '!') {
if (line->line[1] == '$' ||
(line->line[1] == ' ' && line->line[2] == '$')) {
char *gname = strchr(line->line, '$');
char *words = strchr(gname, ' ');
if (!words)
return False;
*words++ = '\0';
for (; *words; words++) {
if (*words != '=' && *words != ' ')
break;
}
if (*words == '\0')
return False;
group->name = _XkbDupString(gname);
group->words = _XkbDupString(words);
for (i = 1, words = group->words; *words; words++) {
if (*words == ' ') {
*words++ = '\0';
i++;
}
}
group->number = i;
return True;
}
else {
SetUpRemap(line, remap);
return False;
}
}
if (remap->num_remap == 0) {
PR_DEBUG("Must have a mapping before first line of data\n");
PR_DEBUG("Illegal line of data ignored\n");
return False;
}
bzero((char *) &tmp, sizeof(FileSpec));
str = line->line;
for (nread = 0; (tok = _XStrtok(str, " ", strtok_buf)) != NULL; nread++) {
str = NULL;
if (strcmp(tok, "=") == 0) {
nread--;
continue;
}
if (nread > remap->num_remap) {
PR_DEBUG("Too many words on a line\n");
PR_DEBUG1("Extra word \"%s\" ignored\n", tok);
continue;
}
tmp.name[remap->remap[nread].word] = tok;
if (*tok == '+' || *tok == '|')
append = True;
}
if (nread < remap->num_remap) {
PR_DEBUG1("Too few words on a line: %s\n", line->line);
PR_DEBUG("line ignored\n");
return False;
}
rule->flags = 0;
rule->number = remap->number;
if (tmp.name[OPTION])
rule->flags |= XkbRF_Option;
else if (append)
rule->flags |= XkbRF_Append;
else
rule->flags |= XkbRF_Normal;
rule->model = _XkbDupString(tmp.name[MODEL]);
rule->layout = _XkbDupString(tmp.name[LAYOUT]);
rule->variant = _XkbDupString(tmp.name[VARIANT]);
rule->option = _XkbDupString(tmp.name[OPTION]);
rule->keycodes = _XkbDupString(tmp.name[KEYCODES]);
rule->symbols = _XkbDupString(tmp.name[SYMBOLS]);
rule->types = _XkbDupString(tmp.name[TYPES]);
rule->compat = _XkbDupString(tmp.name[COMPAT]);
rule->geometry = _XkbDupString(tmp.name[GEOMETRY]);
rule->keymap = _XkbDupString(tmp.name[KEYMAP]);
rule->layout_num = rule->variant_num = 0;
for (i = 0; i < nread; i++) {
if (remap->remap[i].index) {
if (remap->remap[i].word == LAYOUT)
rule->layout_num = remap->remap[i].index;
if (remap->remap[i].word == VARIANT)
rule->variant_num = remap->remap[i].index;
}
}
return True;
}
static char *
_Concat(char *str1, char *str2)
{
int len;
if ((!str1) || (!str2))
return str1;
len = strlen(str1) + strlen(str2) + 1;
str1 = _XkbTypedRealloc(str1, len, char);
if (str1)
strcat(str1, str2);
return str1;
}
static void
squeeze_spaces(char *p1)
{
char *p2;
for (p2 = p1; *p2; p2++) {
*p1 = *p2;
if (*p1 != ' ')
p1++;
}
*p1 = '\0';
}
static Bool
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
{
bzero((char *) mdefs, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
mdefs->options = _XkbDupString(defs->options);
if (mdefs->options)
squeeze_spaces(mdefs->options);
if (defs->layout) {
if (!strchr(defs->layout, ',')) {
mdefs->layout[0] = defs->layout;
}
else {
char *p;
int i;
mdefs->layout[1] = _XkbDupString(defs->layout);
if (mdefs->layout[1] == NULL)
return False;
squeeze_spaces(mdefs->layout[1]);
p = mdefs->layout[1];
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
mdefs->layout[i] = p;
}
else {
break;
}
}
if (p && (p = strchr(p, ',')))
*p = '\0';
}
}
if (defs->variant) {
if (!strchr(defs->variant, ',')) {
mdefs->variant[0] = defs->variant;
}
else {
char *p;
int i;
mdefs->variant[1] = _XkbDupString(defs->variant);
if (mdefs->variant[1] == NULL)
return False;
squeeze_spaces(mdefs->variant[1]);
p = mdefs->variant[1];
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
mdefs->variant[i] = p;
}
else {
break;
}
}
if (p && (p = strchr(p, ',')))
*p = '\0';
}
}
return True;
}
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
if (defs->options)
_XkbFree(defs->options);
if (defs->layout[1])
_XkbFree(defs->layout[1]);
if (defs->variant[1])
_XkbFree(defs->variant[1]);
}
static void
Apply(char *src, char **dst)
{
if (src) {
if (*src == '+' || *src == '!') {
*dst = _Concat(*dst, src);
}
else {
if (*dst == NULL)
*dst = _XkbDupString(src);
}
}
}
static void
XkbRF_ApplyRule(XkbRF_RulePtr rule, XkbComponentNamesPtr names)
{
rule->flags &= ~XkbRF_PendingMatch; /* clear the flag because it's applied */
Apply(rule->keycodes, &names->keycodes);
Apply(rule->symbols, &names->symbols);
Apply(rule->types, &names->types);
Apply(rule->compat, &names->compat);
Apply(rule->geometry, &names->geometry);
Apply(rule->keymap, &names->keymap);
}
static Bool
CheckGroup(XkbRF_RulesPtr rules, char *group_name, char *name)
{
int i;
char *p;
XkbRF_GroupPtr group;
for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
if (!strcmp(group->name, group_name)) {
break;
}
}
if (i == rules->num_groups)
return False;
for (i = 0, p = group->words; i < group->number; i++, p += strlen(p) + 1) {
if (!strcmp(p, name)) {
return True;
}
}
return False;
}
static int
XkbRF_CheckApplyRule(XkbRF_RulePtr rule,
XkbRF_MultiDefsPtr mdefs,
XkbComponentNamesPtr names,
XkbRF_RulesPtr rules)
{
Bool pending = False;
if (rule->model != NULL) {
if (mdefs->model == NULL)
return 0;
if (strcmp(rule->model, "*") == 0) {
pending = True;
}
else {
if (rule->model[0] == '$') {
if (!CheckGroup(rules, rule->model, mdefs->model))
return 0;
}
else {
if (strcmp(rule->model, mdefs->model) != 0)
return 0;
}
}
}
if (rule->option != NULL) {
if (mdefs->options == NULL)
return 0;
if ((!MatchOneOf(rule->option, mdefs->options)))
return 0;
}
if (rule->layout != NULL) {
if (mdefs->layout[rule->layout_num] == NULL ||
*mdefs->layout[rule->layout_num] == '\0')
return 0;
if (strcmp(rule->layout, "*") == 0) {
pending = True;
}
else {
if (rule->layout[0] == '$') {
if (!CheckGroup(rules, rule->layout,
mdefs->layout[rule->layout_num]))
return 0;
}
else {
if (strcmp(rule->layout, mdefs->layout[rule->layout_num]) != 0)
return 0;
}
}
}
if (rule->variant != NULL) {
if (mdefs->variant[rule->variant_num] == NULL ||
*mdefs->variant[rule->variant_num] == '\0')
return 0;
if (strcmp(rule->variant, "*") == 0) {
pending = True;
}
else {
if (rule->variant[0] == '$') {
if (!CheckGroup(rules, rule->variant,
mdefs->variant[rule->variant_num]))
return 0;
}
else {
if (strcmp(rule->variant,
mdefs->variant[rule->variant_num]) != 0)
return 0;
}
}
}
if (pending) {
rule->flags |= XkbRF_PendingMatch;
return rule->number;
}
/* exact match, apply it now */
XkbRF_ApplyRule(rule, names);
return rule->number;
}
static void
XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
{
register int i;
XkbRF_RulePtr rule;
for (i = 0, rule = rules->rules; i < rules->num_rules; i++, rule++) {
rule->flags &= ~XkbRF_PendingMatch;
}
}
static void
XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules, XkbComponentNamesPtr names)
{
int i;
XkbRF_RulePtr rule;
for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) {
if ((rule->flags & XkbRF_PendingMatch) == 0)
continue;
XkbRF_ApplyRule(rule, names);
}
}
static void
XkbRF_CheckApplyRules(XkbRF_RulesPtr rules,
XkbRF_MultiDefsPtr mdefs,
XkbComponentNamesPtr names,
int flags)
{
int i;
XkbRF_RulePtr rule;
int skip;
for (rule = rules->rules, i = 0; i < rules->num_rules; rule++, i++) {
if ((rule->flags & flags) != flags)
continue;
skip = XkbRF_CheckApplyRule(rule, mdefs, names, rules);
if (skip && !(flags & XkbRF_Option)) {
for (; (i < rules->num_rules) && (rule->number == skip);
rule++, i++);
rule--;
i--;
}
}
}
/***====================================================================***/
static char *
XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
{
char *str, *outstr, *orig, *var;
int len, ndx;
orig = name;
str = index(name, '%');
if (str == NULL)
return name;
len = strlen(name);
while (str != NULL) {
char pfx = str[1];
int extra_len = 0;
if ((pfx == '+') || (pfx == '|') || (pfx == '_') || (pfx == '-')) {
extra_len = 1;
str++;
}
else if (pfx == '(') {
extra_len = 2;
str++;
}
var = str + 1;
str = get_index(var + 1, &ndx);
if (ndx == -1) {
str = index(str, '%');
continue;
}
if ((*var == 'l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
len += strlen(mdefs->layout[ndx]) + extra_len;
else if ((*var == 'm') && mdefs->model)
len += strlen(mdefs->model) + extra_len;
else if ((*var == 'v') && mdefs->variant[ndx] && *mdefs->variant[ndx])
len += strlen(mdefs->variant[ndx]) + extra_len;
if ((pfx == '(') && (*str == ')')) {
str++;
}
str = index(&str[0], '%');
}
name = (char *) _XkbAlloc(len + 1);
str = orig;
outstr = name;
while (*str != '\0') {
if (str[0] == '%') {
char pfx, sfx;
str++;
pfx = str[0];
sfx = '\0';
if ((pfx == '+') || (pfx == '|') || (pfx == '_') || (pfx == '-')) {
str++;
}
else if (pfx == '(') {
sfx = ')';
str++;
}
else
pfx = '\0';
var = str;
str = get_index(var + 1, &ndx);
if (ndx == -1) {
continue;
}
if ((*var == 'l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) {
if (pfx)
*outstr++ = pfx;
strcpy(outstr, mdefs->layout[ndx]);
outstr += strlen(mdefs->layout[ndx]);
if (sfx)
*outstr++ = sfx;
}
else if ((*var == 'm') && (mdefs->model)) {
if (pfx)
*outstr++ = pfx;
strcpy(outstr, mdefs->model);
outstr += strlen(mdefs->model);
if (sfx)
*outstr++ = sfx;
}
else if ((*var == 'v') && mdefs->variant[ndx] &&
*mdefs->variant[ndx]) {
if (pfx)
*outstr++ = pfx;
strcpy(outstr, mdefs->variant[ndx]);
outstr += strlen(mdefs->variant[ndx]);
if (sfx)
*outstr++ = sfx;
}
if ((pfx == '(') && (*str == ')'))
str++;
}
else {
*outstr++ = *str++;
}
}
*outstr++ = '\0';
if (orig != name)
_XkbFree(orig);
return name;
}
/***====================================================================***/
Bool
XkbRF_GetComponents(XkbRF_RulesPtr rules,
XkbRF_VarDefsPtr defs,
XkbComponentNamesPtr names)
{
XkbRF_MultiDefsRec mdefs;
MakeMultiDefs(&mdefs, defs);
bzero((char *) names, sizeof(XkbComponentNamesRec));
XkbRF_ClearPartialMatches(rules);
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
XkbRF_ApplyPartialMatches(rules, names);
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Append);
XkbRF_ApplyPartialMatches(rules, names);
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option);
XkbRF_ApplyPartialMatches(rules, names);
if (names->keycodes)
names->keycodes = XkbRF_SubstituteVars(names->keycodes, &mdefs);
if (names->symbols)
names->symbols = XkbRF_SubstituteVars(names->symbols, &mdefs);
if (names->types)
names->types = XkbRF_SubstituteVars(names->types, &mdefs);
if (names->compat)
names->compat = XkbRF_SubstituteVars(names->compat, &mdefs);
if (names->geometry)
names->geometry = XkbRF_SubstituteVars(names->geometry, &mdefs);
if (names->keymap)
names->keymap = XkbRF_SubstituteVars(names->keymap, &mdefs);
FreeMultiDefs(&mdefs);
return (names->keycodes && names->symbols && names->types &&
names->compat && names->geometry) || names->keymap;
}
XkbRF_RulePtr
XkbRF_AddRule(XkbRF_RulesPtr rules)
{
if (rules->sz_rules < 1) {
rules->sz_rules = 16;
rules->num_rules = 0;
rules->rules = _XkbTypedCalloc(rules->sz_rules, XkbRF_RuleRec);
}
else if (rules->num_rules >= rules->sz_rules) {
rules->sz_rules *= 2;
rules->rules = _XkbTypedRealloc(rules->rules, rules->sz_rules,
XkbRF_RuleRec);
}
if (!rules->rules) {
rules->sz_rules = rules->num_rules = 0;
#ifdef DEBUG
fprintf(stderr, "Allocation failure in XkbRF_AddRule\n");
#endif
return NULL;
}
bzero((char *) &rules->rules[rules->num_rules], sizeof(XkbRF_RuleRec));
return &rules->rules[rules->num_rules++];
}
XkbRF_GroupPtr
XkbRF_AddGroup(XkbRF_RulesPtr rules)
{
if (rules->sz_groups < 1) {
rules->sz_groups = 16;
rules->num_groups = 0;
rules->groups = _XkbTypedCalloc(rules->sz_groups, XkbRF_GroupRec);
}
else if (rules->num_groups >= rules->sz_groups) {
rules->sz_groups *= 2;
rules->groups = _XkbTypedRealloc(rules->groups, rules->sz_groups,
XkbRF_GroupRec);
}
if (!rules->groups) {
rules->sz_groups = rules->num_groups = 0;
return NULL;
}
bzero((char *) &rules->groups[rules->num_groups], sizeof(XkbRF_GroupRec));
return &rules->groups[rules->num_groups++];
}
Bool
XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules)
{
InputLine line;
RemapSpec remap;
XkbRF_RuleRec trule, *rule;
XkbRF_GroupRec tgroup, *group;
if (!(rules && file))
return False;
bzero((char *) &remap, sizeof(RemapSpec));
bzero((char *) &tgroup, sizeof(XkbRF_GroupRec));
InitInputLine(&line);
while (GetInputLine(file, &line, True)) {
if (CheckLine(&line, &remap, &trule, &tgroup)) {
if (tgroup.number) {
if ((group = XkbRF_AddGroup(rules)) != NULL) {
*group = tgroup;
bzero((char *) &tgroup, sizeof(XkbRF_GroupRec));
}
}
else {
if ((rule = XkbRF_AddRule(rules)) != NULL) {
*rule = trule;
bzero((char *) &trule, sizeof(XkbRF_RuleRec));
}
}
}
line.num_line = 0;
}
FreeInputLine(&line);
return True;
}
Bool
XkbRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules)
{
FILE *file;
char buf[PATH_MAX];
Bool ok;
if ((!base) || (!rules))
return False;
if (locale) {
if (strlen(base) + strlen(locale) + 2 > PATH_MAX)
return False;
snprintf(buf, sizeof(buf), "%s-%s", base, locale);
}
else {
if (strlen(base) + 1 > PATH_MAX)
return False;
strcpy(buf, base);
}
file = fopen(buf, "r");
if ((!file) && (locale)) { /* fallback if locale was specified */
strcpy(buf, base);
file = fopen(buf, "r");
}
if (!file)
return False;
ok = XkbRF_LoadRules(file, rules);
fclose(file);
return ok;
}
/***====================================================================***/
#define HEAD_NONE 0
#define HEAD_MODEL 1
#define HEAD_LAYOUT 2
#define HEAD_VARIANT 3
#define HEAD_OPTION 4
#define HEAD_EXTRA 5
XkbRF_VarDescPtr
XkbRF_AddVarDesc(XkbRF_DescribeVarsPtr vars)
{
if (vars->sz_desc < 1) {
vars->sz_desc = 16;
vars->num_desc = 0;
vars->desc = _XkbTypedCalloc(vars->sz_desc, XkbRF_VarDescRec);
}
else if (vars->num_desc >= vars->sz_desc) {
vars->sz_desc *= 2;
vars->desc =
_XkbTypedRealloc(vars->desc, vars->sz_desc, XkbRF_VarDescRec);
}
if (!vars->desc) {
vars->sz_desc = vars->num_desc = 0;
PR_DEBUG("Allocation failure in XkbRF_AddVarDesc\n");
return NULL;
}
vars->desc[vars->num_desc].name = NULL;
vars->desc[vars->num_desc].desc = NULL;
return &vars->desc[vars->num_desc++];
}
XkbRF_VarDescPtr
XkbRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from)
{
XkbRF_VarDescPtr nd;
if ((nd = XkbRF_AddVarDesc(vars)) != NULL) {
nd->name = _XkbDupString(from->name);
nd->desc = _XkbDupString(from->desc);
}
return nd;
}
XkbRF_DescribeVarsPtr
XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name)
{
if (rules->sz_extra < 1) {
rules->num_extra = 0;
rules->sz_extra = 1;
rules->extra_names = _XkbTypedCalloc(rules->sz_extra, char *);
rules->extra = _XkbTypedCalloc(rules->sz_extra, XkbRF_DescribeVarsRec);
}
else if (rules->num_extra >= rules->sz_extra) {
rules->sz_extra *= 2;
rules->extra_names =
_XkbTypedRealloc(rules->extra_names, rules->sz_extra, char *);
rules->extra =
_XkbTypedRealloc(rules->extra, rules->sz_extra,
XkbRF_DescribeVarsRec);
}
if ((!rules->extra_names) || (!rules->extra)) {
PR_DEBUG("allocation error in extra parts\n");
rules->sz_extra = rules->num_extra = 0;
rules->extra_names = NULL;
rules->extra = NULL;
return NULL;
}
rules->extra_names[rules->num_extra] = _XkbDupString(name);
bzero(&rules->extra[rules->num_extra], sizeof(XkbRF_DescribeVarsRec));
return &rules->extra[rules->num_extra++];
}
Bool
XkbRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules)
{
InputLine line;
XkbRF_VarDescRec tmp;
char *tok;
int len, headingtype, extra_ndx = 0;
bzero((char *) &tmp, sizeof(XkbRF_VarDescRec));
headingtype = HEAD_NONE;
InitInputLine(&line);
for (; GetInputLine(file, &line, False); line.num_line = 0) {
if (line.line[0] == '!') {
tok = strtok(&(line.line[1]), " \t");
if (strcmp(tok, "model") == 0)
headingtype = HEAD_MODEL;
else if (_XkbStrCaseCmp(tok, "layout") == 0)
headingtype = HEAD_LAYOUT;
else if (_XkbStrCaseCmp(tok, "variant") == 0)
headingtype = HEAD_VARIANT;
else if (_XkbStrCaseCmp(tok, "option") == 0)
headingtype = HEAD_OPTION;
else {
int i;
headingtype = HEAD_EXTRA;
extra_ndx = -1;
for (i = 0; (i < rules->num_extra) && (extra_ndx < 0); i++) {
if (_XkbStrCaseCmp(tok, rules->extra_names[i]))
extra_ndx = i;
}
if (extra_ndx < 0) {
XkbRF_DescribeVarsPtr var;
PR_DEBUG1("Extra heading \"%s\" encountered\n", tok);
var = XkbRF_AddVarToDescribe(rules, tok);
if (var)
extra_ndx = var - rules->extra;
else
headingtype = HEAD_NONE;
}
}
continue;
}
if (headingtype == HEAD_NONE) {
PR_DEBUG("Must have a heading before first line of data\n");
PR_DEBUG("Illegal line of data ignored\n");
continue;
}
len = strlen(line.line);
if ((tmp.name = strtok(line.line, " \t")) == NULL) {
PR_DEBUG("Huh? No token on line\n");
PR_DEBUG("Illegal line of data ignored\n");
continue;
}
if (strlen(tmp.name) == len) {
PR_DEBUG("No description found\n");
PR_DEBUG("Illegal line of data ignored\n");
continue;
}
tok = line.line + strlen(tmp.name) + 1;
while ((*tok != '\n') && isspace(*tok))
tok++;
if (*tok == '\0') {
PR_DEBUG("No description found\n");
PR_DEBUG("Illegal line of data ignored\n");
continue;
}
tmp.desc = tok;
switch (headingtype) {
case HEAD_MODEL:
XkbRF_AddVarDescCopy(&rules->models, &tmp);
break;
case HEAD_LAYOUT:
XkbRF_AddVarDescCopy(&rules->layouts, &tmp);
break;
case HEAD_VARIANT:
XkbRF_AddVarDescCopy(&rules->variants, &tmp);
break;
case HEAD_OPTION:
XkbRF_AddVarDescCopy(&rules->options, &tmp);
break;
case HEAD_EXTRA:
XkbRF_AddVarDescCopy(&rules->extra[extra_ndx], &tmp);
break;
}
}
FreeInputLine(&line);
if ((rules->models.num_desc == 0) && (rules->layouts.num_desc == 0) &&
(rules->variants.num_desc == 0) && (rules->options.num_desc == 0) &&
(rules->num_extra == 0)) {
return False;
}
return True;
}
Bool
XkbRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules)
{
FILE *file;
char buf[PATH_MAX];
Bool ok;
if ((!base) || (!rules))
return False;
if (locale) {
if (strlen(base) + strlen(locale) + 6 > PATH_MAX)
return False;
snprintf(buf, sizeof(buf), "%s-%s.lst", base, locale);
}
else {
if (strlen(base) + 5 > PATH_MAX)
return False;
snprintf(buf, sizeof(buf), "%s.lst", base);
}
file = fopen(buf, "r");
if ((!file) && (locale)) { /* fallback if locale was specified */
snprintf(buf, sizeof(buf), "%s.lst", base);
file = fopen(buf, "r");
}
if (!file)
return False;
ok = XkbRF_LoadDescriptions(file, rules);
fclose(file);
return ok;
}
/***====================================================================***/
XkbRF_RulesPtr
XkbRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules)
{
XkbRF_RulesPtr rules;
if ((!base) || ((!wantDesc) && (!wantRules)))
return NULL;
if ((rules = _XkbTypedCalloc(1, XkbRF_RulesRec)) == NULL)
return NULL;
if (wantDesc && (!XkbRF_LoadDescriptionsByName(base, locale, rules))) {
XkbRF_Free(rules, True);
return NULL;
}
if (wantRules && (!XkbRF_LoadRulesByName(base, locale, rules))) {
XkbRF_Free(rules, True);
return NULL;
}
return rules;
}
XkbRF_RulesPtr
XkbRF_Create(int szRules, int szExtra)
{
XkbRF_RulesPtr rules;
if ((rules = _XkbTypedCalloc(1, XkbRF_RulesRec)) == NULL)
return NULL;
if (szRules > 0) {
rules->sz_rules = szRules;
rules->rules = _XkbTypedCalloc(rules->sz_rules, XkbRF_RuleRec);
if (!rules->rules) {
_XkbFree(rules);
return NULL;
}
}
if (szExtra > 0) {
rules->sz_extra = szExtra;
rules->extra = _XkbTypedCalloc(rules->sz_extra, XkbRF_DescribeVarsRec);
if (!rules->extra) {
if (rules->rules)
_XkbFree(rules->rules);
_XkbFree(rules);
return NULL;
}
}
return rules;
}
/***====================================================================***/
static void
XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
{
register int i;
for (i = 0; i < var->num_desc; i++) {
if (var->desc[i].name)
_XkbFree(var->desc[i].name);
if (var->desc[i].desc)
_XkbFree(var->desc[i].desc);
var->desc[i].name = var->desc[i].desc = NULL;
}
if (var->desc)
_XkbFree(var->desc);
var->desc = NULL;
return;
}
void
XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
{
int i;
XkbRF_RulePtr rule;
XkbRF_GroupPtr group;
if (!rules)
return;
XkbRF_ClearVarDescriptions(&rules->models);
XkbRF_ClearVarDescriptions(&rules->layouts);
XkbRF_ClearVarDescriptions(&rules->variants);
XkbRF_ClearVarDescriptions(&rules->options);
if (rules->extra) {
for (i = 0; i < rules->num_extra; i++) {
XkbRF_ClearVarDescriptions(&rules->extra[i]);
}
_XkbFree(rules->extra);
rules->num_extra = rules->sz_extra = 0;
rules->extra = NULL;
}
if (rules->rules) {
for (i = 0, rule = rules->rules; i < rules->num_rules; i++, rule++) {
if (rule->model)
_XkbFree(rule->model);
if (rule->layout)
_XkbFree(rule->layout);
if (rule->variant)
_XkbFree(rule->variant);
if (rule->option)
_XkbFree(rule->option);
if (rule->keycodes)
_XkbFree(rule->keycodes);
if (rule->symbols)
_XkbFree(rule->symbols);
if (rule->types)
_XkbFree(rule->types);
if (rule->compat)
_XkbFree(rule->compat);
if (rule->geometry)
_XkbFree(rule->geometry);
if (rule->keymap)
_XkbFree(rule->keymap);
bzero((char *) rule, sizeof(XkbRF_RuleRec));
}
_XkbFree(rules->rules);
rules->num_rules = rules->sz_rules = 0;
rules->rules = NULL;
}
if (rules->groups) {
for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
if (group->name)
_XkbFree(group->name);
if (group->words)
_XkbFree(group->words);
}
_XkbFree(rules->groups);
rules->num_groups = 0;
rules->groups = NULL;
}
if (freeRules)
_XkbFree(rules);
return;
}
Bool
XkbRF_GetNamesProp(Display * dpy, char **rf_rtrn, XkbRF_VarDefsPtr vd_rtrn)
{
Atom rules_atom, actual_type;
int fmt;
unsigned long nitems, bytes_after;
unsigned char *data;
char *out, *end;
Status rtrn;
rules_atom = XInternAtom(dpy, _XKB_RF_NAMES_PROP_ATOM, True);
if (rules_atom == None) /* property cannot exist */
return False;
rtrn = XGetWindowProperty(dpy, DefaultRootWindow(dpy), rules_atom,
0L, _XKB_RF_NAMES_PROP_MAXLEN, False,
XA_STRING, &actual_type,
&fmt, &nitems, &bytes_after,
(unsigned char **) &data);
if (rtrn != Success)
return False;
if (rf_rtrn)
*rf_rtrn = NULL;
(void) bzero((char *) vd_rtrn, sizeof(XkbRF_VarDefsRec));
if ((bytes_after > 0) || (actual_type != XA_STRING) || (fmt != 8)) {
if (data)
XFree(data);
return (fmt == 0 ? True : False);
}
out = (char *) data;
end = out + nitems;
if (out && (*out) && rf_rtrn)
*rf_rtrn = _XkbDupString(out);
out += strlen(out) + 1;
if (out < end) {
if (*out)
vd_rtrn->model = _XkbDupString(out);
out += strlen(out) + 1;
}
if (out < end) {
if (*out)
vd_rtrn->layout = _XkbDupString(out);
out += strlen(out) + 1;
}
if (out < end) {
if (*out)
vd_rtrn->variant = _XkbDupString(out);
out += strlen(out) + 1;
}
if (out < end) {
if (*out)
vd_rtrn->options = _XkbDupString(out);
out += strlen(out) + 1;
}
XFree(data);
return True;
}
Bool
XkbRF_SetNamesProp(Display *dpy, char *rules_file, XkbRF_VarDefsPtr var_defs)
{
int len, out;
Atom name;
char *pval;
len = (rules_file ? strlen(rules_file) : 0);
len += (var_defs->model ? strlen(var_defs->model) : 0);
len += (var_defs->layout ? strlen(var_defs->layout) : 0);
len += (var_defs->variant ? strlen(var_defs->variant) : 0);
len += (var_defs->options ? strlen(var_defs->options) : 0);
if (len < 1)
return True;
len += 5; /* trailing NULs */
name = XInternAtom(dpy, _XKB_RF_NAMES_PROP_ATOM, False);
if (name == None) { /* should never happen */
_XkbLibError(_XkbErrXReqFailure, "XkbRF_SetNamesProp", X_InternAtom);
return False;
}
pval = (char *) _XkbAlloc(len);
if (!pval) {
_XkbLibError(_XkbErrBadAlloc, "XkbRF_SetNamesProp", len);
return False;
}
out = 0;
if (rules_file) {
strcpy(&pval[out], rules_file);
out += strlen(rules_file);
}
pval[out++] = '\0';
if (var_defs->model) {
strcpy(&pval[out], var_defs->model);
out += strlen(var_defs->model);
}
pval[out++] = '\0';
if (var_defs->layout) {
strcpy(&pval[out], var_defs->layout);
out += strlen(var_defs->layout);
}
pval[out++] = '\0';
if (var_defs->variant) {
strcpy(&pval[out], var_defs->variant);
out += strlen(var_defs->variant);
}
pval[out++] = '\0';
if (var_defs->options) {
strcpy(&pval[out], var_defs->options);
out += strlen(var_defs->options);
}
pval[out++] = '\0';
if (out != len) {
_XkbLibError(_XkbErrBadLength, "XkbRF_SetNamesProp", out);
_XkbFree(pval);
return False;
}
XChangeProperty(dpy, DefaultRootWindow(dpy), name, XA_STRING, 8,
PropModeReplace, (unsigned char *) pval, len);
_XkbFree(pval);
return True;
}
extra_ndx = var - rullibxkbfile-1.1.0/src/xkberrs.c 0000644 0143106 0000012 00000007520 13443241017 0016522 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
const char *_XkbErrMessages[] = {
"success", /* _XkbSuccess */
"key names not defined", /* _XkbErrMissingNames */
"key types not defined", /* _XkbErrMissingTypes */
"required key types not present", /* _XkbErrMissingReqTypes */
"symbols not defined", /* _XkbErrMissingSymbols */
"virtual modifier bindings not defined", /* _XkbErrMissingVMods */
"indicators not defined", /* _XkbErrMissingIndicators */
"compatibility map not defined", /* _XkbErrMissingCompatMap */
"symbol interpretations not defined", /* _XkbErrMissingSymInterps */
"geometry not defined", /* _XkbErrMissingGeometry */
"illegal doodad type", /* _XkbErrIllegalDoodad */
"illegal TOC type", /* _XkbErrIllegalTOCType */
"illegal contents", /* _XkbErrIllegalContents */
"empty file", /* _XkbErrEmptyFile */
"file not found", /* _XkbErrFileNotFound */
"cannot open", /* _XkbErrFileCannotOpen */
"bad value", /* _XkbErrBadValue */
"bad match", /* _XkbErrBadMatch */
"illegal name for type", /* _XkbErrBadTypeName */
"illegal width for type", /* _XkbErrBadTypeWidth */
"bad file type", /* _XkbErrBadFileType */
"bad file version", /* _XkbErrBadFileVersion */
"error in Xkm file", /* _XkbErrBadFileFormat */
"allocation failed", /* _XkbErrBadAlloc */
"bad length", /* _XkbErrBadLength */
"X request failed", /* _XkbErrXReqFailure */
"not implemented" /* _XkbErrBadImplementation */
};
unsigned _XkbErrCode;
const char * _XkbErrLocation = NULL;
unsigned _XkbErrData;
libxkbfile-1.1.0/src/xkbmisc.c 0000644 0143106 0000012 00000053010 13443241017 0016475 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
unsigned
_XkbKSCheckCase(KeySym ks)
{
unsigned set, rtrn;
set = (ks & (~0xff)) >> 8;
rtrn = 0;
switch (set) {
case 0: /* latin 1 */
if (((ks >= XK_A) && (ks <= XK_Z)) ||
((ks >= XK_Agrave) && (ks <= XK_THORN) && (ks != XK_multiply))) {
rtrn |= _XkbKSUpper;
}
if (((ks >= XK_a) && (ks <= XK_z)) ||
((ks >= XK_agrave) && (ks <= XK_ydiaeresis))) {
rtrn |= _XkbKSLower;
}
break;
case 1: /* latin 2 */
if (((ks >= XK_Aogonek) && (ks <= XK_Zabovedot) && (ks != XK_breve)) ||
((ks >= XK_Racute) && (ks <= XK_Tcedilla))) {
rtrn |= _XkbKSUpper;
}
if (((ks >= XK_aogonek) && (ks <= XK_zabovedot) && (ks != XK_caron)) ||
((ks >= XK_racute) && (ks <= XK_tcedilla))) {
rtrn |= _XkbKSLower;
}
break;
case 2: /* latin 3 */
if (((ks >= XK_Hstroke) && (ks <= XK_Jcircumflex)) ||
((ks >= XK_Cabovedot) && (ks <= XK_Scircumflex))) {
rtrn |= _XkbKSUpper;
}
if (((ks >= XK_hstroke) && (ks <= XK_jcircumflex)) ||
((ks >= XK_cabovedot) && (ks <= XK_scircumflex))) {
rtrn |= _XkbKSLower;
}
break;
case 3: /* latin 4 */
if (((ks >= XK_Rcedilla) && (ks <= XK_Tslash)) ||
(ks == XK_ENG) || ((ks >= XK_Amacron) && (ks <= XK_Umacron))) {
rtrn |= _XkbKSUpper;
}
if (((ks >= XK_rcedilla) && (ks <= XK_tslash)) ||
(ks == XK_eng) || ((ks >= XK_amacron) && (ks <= XK_umacron))) {
rtrn |= _XkbKSLower;
}
break;
case 18: /* latin 8 */
if ((ks == XK_Babovedot) ||
((ks >= XK_Dabovedot) && (ks <= XK_Wacute)) ||
((ks >= XK_Ygrave) && (ks <= XK_Fabovedot)) ||
(ks == XK_Mabovedot) ||
(ks == XK_Pabovedot) ||
(ks == XK_Sabovedot) ||
(ks == XK_Wdiaeresis) ||
((ks >= XK_Wcircumflex) && (ks <= XK_Ycircumflex))) {
rtrn |= _XkbKSUpper;
}
if ((ks == XK_babovedot) ||
(ks == XK_dabovedot) ||
(ks == XK_fabovedot) ||
(ks == XK_mabovedot) ||
((ks >= XK_wgrave) && (ks <= XK_wacute)) ||
(ks == XK_ygrave) ||
((ks >= XK_wdiaeresis) && (ks <= XK_ycircumflex))) {
rtrn |= _XkbKSLower;
}
break;
case 19: /* latin 9 */
if ((ks == XK_OE) || (ks == XK_Ydiaeresis)) {
rtrn |= _XkbKSUpper;
}
if (ks == XK_oe) {
rtrn |= _XkbKSLower;
}
break;
}
return rtrn;
}
/***===================================================================***/
Bool
XkbLookupGroupAndLevel(XkbDescPtr xkb,
int key,
int * mods_inout,
int * grp_inout,
int * lvl_rtrn)
{
int nG, eG;
if ((!xkb) || (!XkbKeycodeInRange(xkb, key)) || (!grp_inout))
return False;
nG = XkbKeyNumGroups(xkb, key);
eG = *grp_inout;
if (nG == 0) {
*grp_inout = 0;
if (lvl_rtrn != NULL)
*lvl_rtrn = 0;
return False;
}
else if (nG == 1) {
eG = 0;
}
else if (eG >= nG) {
unsigned gI = XkbKeyGroupInfo(xkb, key);
switch (XkbOutOfRangeGroupAction(gI)) {
default:
eG %= nG;
break;
case XkbClampIntoRange:
eG = nG - 1;
break;
case XkbRedirectIntoRange:
eG = XkbOutOfRangeGroupNumber(gI);
if (eG >= nG)
eG = 0;
break;
}
}
*grp_inout = eG;
if (mods_inout != NULL) {
XkbKeyTypePtr type;
int preserve;
type = XkbKeyKeyType(xkb, key, eG);
if (lvl_rtrn != NULL)
*lvl_rtrn = 0;
preserve = 0;
if (type->map) { /* find the shift level */
register int i;
register XkbKTMapEntryPtr entry;
for (i = 0, entry = type->map; i < type->map_count; i++, entry++) {
if ((entry->active) &&
(((*mods_inout) & type->mods.mask) == entry->mods.mask)) {
if (lvl_rtrn != NULL)
*lvl_rtrn = entry->level;
if (type->preserve)
preserve = type->preserve[i].mask;
break;
}
}
}
(*mods_inout) &= ~(type->mods.mask & (~preserve));
}
return True;
}
/***===================================================================***/
static Bool
XkbWriteSectionFromName(FILE *file, const char *sectionName, const char *name)
{
fprintf(file, " xkb_%-20s { include \"%s\" };\n", sectionName, name);
return True;
}
#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
/* ARGSUSED */
static void
_AddIncl(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
int index,
void * priv)
{
if ((priv) && (strcmp((char *) priv, "%") != 0))
fprintf(file, " include \"%s\"\n", (char *) priv);
return;
}
Bool
XkbWriteXKBKeymapForNames(FILE * file,
XkbComponentNamesPtr names,
Display * dpy,
XkbDescPtr xkb,
unsigned want,
unsigned need)
{
char *name, *tmp;
unsigned complete;
XkbNamesPtr old_names;
int multi_section;
unsigned wantNames, wantConfig, wantDflts;
XkbFileInfo finfo;
bzero(&finfo, sizeof(XkbFileInfo));
complete = 0;
if ((name = names->keymap) == NULL)
name = "default";
if (COMPLETE(names->keycodes))
complete |= XkmKeyNamesMask;
if (COMPLETE(names->types))
complete |= XkmTypesMask;
if (COMPLETE(names->compat))
complete |= XkmCompatMapMask;
if (COMPLETE(names->symbols))
complete |= XkmSymbolsMask;
if (COMPLETE(names->geometry))
complete |= XkmGeometryMask;
want |= (complete | need);
if (want & XkmSymbolsMask)
want |= XkmKeyNamesMask | XkmTypesMask;
if (want == 0)
return False;
if (xkb != NULL) {
old_names = xkb->names;
finfo.type = 0;
finfo.defined = 0;
finfo.xkb = xkb;
if (!XkbDetermineFileType(&finfo, XkbXKBFile, NULL))
return False;
}
else
old_names = NULL;
wantConfig = want & (~complete);
if (xkb != NULL) {
if (wantConfig & XkmTypesMask) {
if ((!xkb->map) || (xkb->map->num_types < XkbNumRequiredTypes))
wantConfig &= ~XkmTypesMask;
}
if (wantConfig & XkmCompatMapMask) {
if ((!xkb->compat) || (xkb->compat->num_si < 1))
wantConfig &= ~XkmCompatMapMask;
}
if (wantConfig & XkmSymbolsMask) {
if ((!xkb->map) || (!xkb->map->key_sym_map))
wantConfig &= ~XkmSymbolsMask;
}
if (wantConfig & XkmIndicatorsMask) {
if (!xkb->indicators)
wantConfig &= ~XkmIndicatorsMask;
}
if (wantConfig & XkmKeyNamesMask) {
if ((!xkb->names) || (!xkb->names->keys))
wantConfig &= ~XkmKeyNamesMask;
}
if ((wantConfig & XkmGeometryMask) && (!xkb->geom))
wantConfig &= ~XkmGeometryMask;
}
else {
wantConfig = 0;
}
complete |= wantConfig;
wantDflts = 0;
wantNames = want & (~complete);
if ((xkb != NULL) && (old_names != NULL)) {
if (wantNames & XkmTypesMask) {
if (old_names->types != None) {
tmp = XkbAtomGetString(dpy, old_names->types);
names->types = tmp;
}
else {
wantDflts |= XkmTypesMask;
}
complete |= XkmTypesMask;
}
if (wantNames & XkmCompatMapMask) {
if (old_names->compat != None) {
tmp = XkbAtomGetString(dpy, old_names->compat);
names->compat = tmp;
}
else
wantDflts |= XkmCompatMapMask;
complete |= XkmCompatMapMask;
}
if (wantNames & XkmSymbolsMask) {
if (old_names->symbols == None)
return False;
tmp = XkbAtomGetString(dpy, old_names->symbols);
names->symbols = tmp;
complete |= XkmSymbolsMask;
}
if (wantNames & XkmKeyNamesMask) {
if (old_names->keycodes != None) {
tmp = XkbAtomGetString(dpy, old_names->keycodes);
names->keycodes = tmp;
}
else
wantDflts |= XkmKeyNamesMask;
complete |= XkmKeyNamesMask;
}
if (wantNames & XkmGeometryMask) {
if (old_names->geometry == None)
return False;
tmp = XkbAtomGetString(dpy, old_names->geometry);
names->geometry = tmp;
complete |= XkmGeometryMask;
wantNames &= ~XkmGeometryMask;
}
}
if (complete & XkmCompatMapMask)
complete |= XkmIndicatorsMask | XkmVirtualModsMask;
else if (complete & (XkmSymbolsMask | XkmTypesMask))
complete |= XkmVirtualModsMask;
if (need & (~complete))
return False;
if ((complete & XkmSymbolsMask) &&
((XkmKeyNamesMask | XkmTypesMask) & (~complete)))
return False;
multi_section = 1;
if (((complete & XkmKeymapRequired) == XkmKeymapRequired) &&
((complete & (~XkmKeymapLegal)) == 0)) {
fprintf(file, "xkb_keymap \"%s\" {\n", name);
}
else if (((complete & XkmSemanticsRequired) == XkmSemanticsRequired) &&
((complete & (~XkmSemanticsLegal)) == 0)) {
fprintf(file, "xkb_semantics \"%s\" {\n", name);
}
else if (((complete & XkmLayoutRequired) == XkmLayoutRequired) &&
((complete & (~XkmLayoutLegal)) == 0)) {
fprintf(file, "xkb_layout \"%s\" {\n", name);
}
else if (XkmSingleSection(complete & (~XkmVirtualModsMask))) {
multi_section = 0;
}
else {
return False;
}
wantNames = complete & (~(wantConfig | wantDflts));
name = names->keycodes;
if (wantConfig & XkmKeyNamesMask)
XkbWriteXKBKeycodes(file, &finfo, False, False, _AddIncl, name);
else if (wantDflts & XkmKeyNamesMask)
fprintf(stderr, "Default symbols not implemented yet!\n");
else if (wantNames & XkmKeyNamesMask)
XkbWriteSectionFromName(file, "keycodes", name);
name = names->types;
if (wantConfig & XkmTypesMask)
XkbWriteXKBKeyTypes(file, &finfo, False, False, _AddIncl, name);
else if (wantDflts & XkmTypesMask)
fprintf(stderr, "Default types not implemented yet!\n");
else if (wantNames & XkmTypesMask)
XkbWriteSectionFromName(file, "types", name);
name = names->compat;
if (wantConfig & XkmCompatMapMask)
XkbWriteXKBCompatMap(file, &finfo, False, False, _AddIncl, name);
else if (wantDflts & XkmCompatMapMask)
fprintf(stderr, "Default interps not implemented yet!\n");
else if (wantNames & XkmCompatMapMask)
XkbWriteSectionFromName(file, "compatibility", name);
name = names->symbols;
if (wantConfig & XkmSymbolsMask)
XkbWriteXKBSymbols(file, &finfo, False, False, _AddIncl, name);
else if (wantNames & XkmSymbolsMask)
XkbWriteSectionFromName(file, "symbols", name);
name = names->geometry;
if (wantConfig & XkmGeometryMask)
XkbWriteXKBGeometry(file, &finfo, False, False, _AddIncl, name);
else if (wantNames & XkmGeometryMask)
XkbWriteSectionFromName(file, "geometry", name);
if (multi_section)
fprintf(file, "};\n");
return True;
}
/***====================================================================***/
/*ARGSUSED*/
Status
XkbMergeFile(XkbDescPtr xkb, XkbFileInfo finfo)
{
return BadImplementation;
}
/***====================================================================***/
int
XkbFindKeycodeByName(XkbDescPtr xkb, char *name, Bool use_aliases)
{
register int i;
if ((!xkb) || (!xkb->names) || (!xkb->names->keys))
return 0;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
if (strncmp(xkb->names->keys[i].name, name, XkbKeyNameLength) == 0)
return i;
}
if (!use_aliases)
return 0;
if (xkb->geom && xkb->geom->key_aliases) {
XkbKeyAliasPtr a;
a = xkb->geom->key_aliases;
for (i = 0; i < xkb->geom->num_key_aliases; i++, a++) {
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
return XkbFindKeycodeByName(xkb, a->real, False);
}
}
if (xkb->names && xkb->names->key_aliases) {
XkbKeyAliasPtr a;
a = xkb->names->key_aliases;
for (i = 0; i < xkb->names->num_key_aliases; i++, a++) {
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
return XkbFindKeycodeByName(xkb, a->real, False);
}
}
return 0;
}
unsigned
XkbConvertGetByNameComponents(Bool toXkm, unsigned orig)
{
unsigned rtrn;
rtrn = 0;
if (toXkm) {
if (orig & XkbGBN_TypesMask)
rtrn |= XkmTypesMask;
if (orig & XkbGBN_CompatMapMask)
rtrn |= XkmCompatMapMask;
if (orig & XkbGBN_SymbolsMask)
rtrn |= XkmSymbolsMask;
if (orig & XkbGBN_IndicatorMapMask)
rtrn |= XkmIndicatorsMask;
if (orig & XkbGBN_KeyNamesMask)
rtrn |= XkmKeyNamesMask;
if (orig & XkbGBN_GeometryMask)
rtrn |= XkmGeometryMask;
}
else {
if (orig & XkmTypesMask)
rtrn |= XkbGBN_TypesMask;
if (orig & XkmCompatMapMask)
rtrn |= XkbGBN_CompatMapMask;
if (orig & XkmSymbolsMask)
rtrn |= XkbGBN_SymbolsMask;
if (orig & XkmIndicatorsMask)
rtrn |= XkbGBN_IndicatorMapMask;
if (orig & XkmKeyNamesMask)
rtrn |= XkbGBN_KeyNamesMask;
if (orig & XkmGeometryMask)
rtrn |= XkbGBN_GeometryMask;
if (orig != 0)
rtrn |= XkbGBN_OtherNamesMask;
}
return rtrn;
}
unsigned
XkbConvertXkbComponents(Bool toXkm, unsigned orig)
{
unsigned rtrn;
rtrn = 0;
if (toXkm) {
if (orig & XkbClientMapMask)
rtrn |= XkmTypesMask | XkmSymbolsMask;
if (orig & XkbServerMapMask)
rtrn |= XkmTypesMask | XkmSymbolsMask;
if (orig & XkbCompatMapMask)
rtrn |= XkmCompatMapMask;
if (orig & XkbIndicatorMapMask)
rtrn |= XkmIndicatorsMask;
if (orig & XkbNamesMask)
rtrn |= XkmKeyNamesMask;
if (orig & XkbGeometryMask)
rtrn |= XkmGeometryMask;
}
else {
if (orig != 0)
rtrn |= XkbNamesMask;
if (orig & XkmTypesMask)
rtrn |= XkbClientMapMask;
if (orig & XkmCompatMapMask)
rtrn |= XkbCompatMapMask | XkbIndicatorMapMask;
if (orig & XkmSymbolsMask)
rtrn |= XkbClientMapMask | XkbServerMapMask;
if (orig & XkmIndicatorsMask)
rtrn |= XkbIndicatorMapMask;
if (orig & XkmKeyNamesMask)
rtrn |= XkbNamesMask | XkbIndicatorMapMask;
if (orig & XkmGeometryMask)
rtrn |= XkbGeometryMask;
}
return rtrn;
}
Bool
XkbDetermineFileType(XkbFileInfoPtr finfo, int format, int *opts_missing)
{
unsigned present;
XkbDescPtr xkb;
if ((!finfo) || (!finfo->xkb))
return False;
if (opts_missing)
*opts_missing = 0;
xkb = finfo->xkb;
present = 0;
if ((xkb->names) && (xkb->names->keys))
present |= XkmKeyNamesMask;
if ((xkb->map) && (xkb->map->types))
present |= XkmTypesMask;
if (xkb->compat)
present |= XkmCompatMapMask;
if ((xkb->map) && (xkb->map->num_syms > 1))
present |= XkmSymbolsMask;
if (xkb->indicators)
present |= XkmIndicatorsMask;
if (xkb->geom)
present |= XkmGeometryMask;
if (!present)
return False;
else
switch (present) {
case XkmKeyNamesMask:
finfo->type = XkmKeyNamesIndex;
finfo->defined = present;
return True;
case XkmTypesMask:
finfo->type = XkmTypesIndex;
finfo->defined = present;
return True;
case XkmCompatMapMask:
finfo->type = XkmCompatMapIndex;
finfo->defined = present;
return True;
case XkmSymbolsMask:
if (format != XkbXKMFile) {
finfo->type = XkmSymbolsIndex;
finfo->defined = present;
return True;
}
break;
case XkmGeometryMask:
finfo->type = XkmGeometryIndex;
finfo->defined = present;
return True;
}
if ((present & (~XkmSemanticsLegal)) == 0) {
if ((XkmSemanticsRequired & present) == XkmSemanticsRequired) {
if (opts_missing)
*opts_missing = XkmSemanticsOptional & (~present);
finfo->type = XkmSemanticsFile;
finfo->defined = present;
return True;
}
}
else if ((present & (~XkmLayoutLegal)) == 0) {
if ((XkmLayoutRequired & present) == XkmLayoutRequired) {
if (opts_missing)
*opts_missing = XkmLayoutOptional & (~present);
finfo->type = XkmLayoutFile;
finfo->defined = present;
return True;
}
}
else if ((present & (~XkmKeymapLegal)) == 0) {
if ((XkmKeymapRequired & present) == XkmKeymapRequired) {
if (opts_missing)
*opts_missing = XkmKeymapOptional & (~present);
finfo->type = XkmKeymapFile;
finfo->defined = present;
return True;
}
}
return False;
}
/* all latin-1 alphanumerics, plus parens, slash, minus, underscore and */
/* wildcards */
static unsigned char componentSpecLegal[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83,
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
};
void
XkbEnsureSafeMapName(char *name)
{
if (name == NULL)
return;
while (*name != '\0') {
if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0)
*name = '_';
name++;
}
return;
}
/***====================================================================***/
#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
Bool
XkbNameMatchesPattern(char *name, char *ptrn)
{
while (ptrn[0] != '\0') {
if (name[0] == '\0') {
if (ptrn[0] == '*') {
ptrn++;
continue;
}
return False;
}
if (ptrn[0] == '?') {
if (UNMATCHABLE(name[0]))
return False;
}
else if (ptrn[0] == '*') {
if ((!UNMATCHABLE(name[0])) &&
XkbNameMatchesPattern(name + 1, ptrn))
return True;
return XkbNameMatchesPattern(name, ptrn + 1);
}
else if (ptrn[0] != name[0])
return False;
name++;
ptrn++;
}
/* if we get here, the pattern is exhausted (-:just like me:-) */
return (name[0] == '\0');
}
#ifdef NEED_STRCASECMP
_X_HIDDEN int
_XkbStrCaseCmp(char *str1, char *str2)
{
const u_char *us1 = (const u_char *) str1, *us2 = (const u_char *) str2;
while (tolower(*us1) == tolower(*us2)) {
if (*us1++ == '\0')
return (0);
us2++;
}
return (tolower(*us1) - tolower(*us2));
}
#endif
e, "xkb_keymap \"%s\" {\n", name);
}
else if (((complete & XkmSemanticsRequired) == XkmSemanticsRequired) &&
((complete & (~XkmSemanticsLegal)) == 0)) {
fprintf(file, "xkb_semantics \"%s\" {\n", name);
}
else if (((complete & XkmLayoutRequired) == XkmLayoutRequired) &&
((complete & (~XkmLayoutLegal)) == 0)) {
fprintf(file, "xkb_layout \"%s\" {\n", name);
}
else if (XkmSingleSection(complete & (~XkmVirtualModsMask))) {
multi_selibxkbfile-1.1.0/src/xkbtext.c 0000644 0143106 0000012 00000132642 13443241017 0016537 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
/***====================================================================***/
#define BUFFER_SIZE 512
static char textBuffer[BUFFER_SIZE];
static int tbNext = 0;
static char *
tbGetBuffer(unsigned size)
{
char *rtrn;
if (size >= BUFFER_SIZE)
return NULL;
if ((BUFFER_SIZE - tbNext) <= size)
tbNext = 0;
rtrn = &textBuffer[tbNext];
tbNext += size;
return rtrn;
}
/***====================================================================***/
char *
XkbAtomText(Display *dpy, Atom atm, unsigned format)
{
char *rtrn, *tmp;
tmp = XkbAtomGetString(dpy, atm);
if (tmp != NULL) {
int len;
len = strlen(tmp) + 1;
if (len > BUFFER_SIZE)
len = BUFFER_SIZE - 2;
rtrn = tbGetBuffer(len);
strncpy(rtrn, tmp, len);
rtrn[len] = '\0';
_XkbFree(tmp);
}
else {
rtrn = tbGetBuffer(1);
rtrn[0] = '\0';
}
if (format == XkbCFile) {
for (tmp = rtrn; *tmp != '\0'; tmp++) {
if ((tmp == rtrn) && (!isalpha(*tmp)))
*tmp = '_';
else if (!isalnum(*tmp))
*tmp = '_';
}
}
return XkbStringText(rtrn, format);
}
/***====================================================================***/
char *
XkbVModIndexText(Display *dpy, XkbDescPtr xkb, unsigned ndx, unsigned format)
{
register int len;
register Atom *vmodNames;
char *rtrn, *tmp;
if (xkb && xkb->names)
vmodNames = xkb->names->vmods;
else
vmodNames = NULL;
tmp = NULL;
if (ndx >= XkbNumVirtualMods)
tmp = strdup("illegal");
else if (vmodNames && (vmodNames[ndx] != None))
tmp = XkbAtomGetString(dpy, vmodNames[ndx]);
if (tmp == NULL) {
tmp = (char *) _XkbAlloc(20 * sizeof(char));
snprintf(tmp, 20, "%d", ndx);
}
len = strlen(tmp) + 1;
if (format == XkbCFile)
len += 4;
if (len >= BUFFER_SIZE)
len = BUFFER_SIZE - 1;
rtrn = tbGetBuffer(len);
if (format == XkbCFile) {
snprintf(rtrn, len, "vmod_%s", tmp);
}
else
strncpy(rtrn, tmp, len);
_XkbFree(tmp);
return rtrn;
}
char *
XkbVModMaskText(Display * dpy,
XkbDescPtr xkb,
unsigned modMask,
unsigned mask,
unsigned format)
{
register int i, bit;
int len;
char *mm, *rtrn;
char *str, buf[BUFFER_SIZE];
if ((modMask == 0) && (mask == 0)) {
const int rtrnsize = 5;
rtrn = tbGetBuffer(rtrnsize);
if (format == XkbCFile)
snprintf(rtrn, rtrnsize, "0");
else
snprintf(rtrn, rtrnsize, "none");
return rtrn;
}
if (modMask != 0)
mm = XkbModMaskText(modMask, format);
else
mm = NULL;
str = buf;
buf[0] = '\0';
if (mask) {
char *tmp;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if (mask & bit) {
tmp = XkbVModIndexText(dpy, xkb, i, format);
len = strlen(tmp) + 1 + (str == buf ? 0 : 1);
if (format == XkbCFile)
len += 4;
if ((str - (buf + len)) <= BUFFER_SIZE) {
if (str != buf) {
if (format == XkbCFile)
*str++ = '|';
else
*str++ = '+';
len--;
}
}
if (format == XkbCFile)
sprintf(str, "%sMask", tmp);
else
strcpy(str, tmp);
str = &str[len - 1];
}
}
str = buf;
}
else
str = NULL;
if (mm)
len = strlen(mm);
else
len = 0;
if (str)
len += strlen(str) + (mm == NULL ? 0 : 1);
if (len >= BUFFER_SIZE)
len = BUFFER_SIZE - 1;
rtrn = tbGetBuffer(len + 1);
rtrn[0] = '\0';
if (mm != NULL) {
i = strlen(mm);
if (i > len)
i = len;
strcpy(rtrn, mm);
}
else {
i = 0;
}
if (str != NULL) {
if (mm != NULL) {
if (format == XkbCFile)
strcat(rtrn, "|");
else
strcat(rtrn, "+");
}
strncat(rtrn, str, len - i);
}
rtrn[len] = '\0';
return rtrn;
}
static const char *modNames[XkbNumModifiers] = {
"Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5"
};
char *
XkbModIndexText(unsigned ndx, unsigned format)
{
char *rtrn;
char buf[100];
if (format == XkbCFile) {
if (ndx < XkbNumModifiers)
snprintf(buf, sizeof(buf), "%sMapIndex", modNames[ndx]);
else if (ndx == XkbNoModifier)
snprintf(buf, sizeof(buf), "XkbNoModifier");
else
snprintf(buf, sizeof(buf), "0x%02x", ndx);
}
else {
if (ndx < XkbNumModifiers)
strcpy(buf, modNames[ndx]);
else if (ndx == XkbNoModifier)
strcpy(buf, "none");
else
snprintf(buf, sizeof(buf), "ILLEGAL_%02x", ndx);
}
rtrn = tbGetBuffer(strlen(buf) + 1);
strcpy(rtrn, buf);
return rtrn;
}
char *
XkbModMaskText(unsigned mask, unsigned format)
{
register int i, bit;
char buf[64], *rtrn;
if ((mask & 0xff) == 0xff) {
if (format == XkbCFile)
strcpy(buf, "0xff");
else
strcpy(buf, "all");
}
else if ((mask & 0xff) == 0) {
if (format == XkbCFile)
strcpy(buf, "0");
else
strcpy(buf, "none");
}
else {
char *str = buf;
buf[0] = '\0';
for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
if (mask & bit) {
if (str != buf) {
if (format == XkbCFile)
*str++ = '|';
else
*str++ = '+';
}
strcpy(str, modNames[i]);
str = &str[strlen(str)];
if (format == XkbCFile) {
strcpy(str, "Mask");
str += 4;
}
}
}
}
rtrn = tbGetBuffer(strlen(buf) + 1);
strcpy(rtrn, buf);
return rtrn;
}
/***====================================================================***/
/*ARGSUSED*/
char *
XkbConfigText(unsigned config, unsigned format)
{
static char *buf;
const int bufsize = 32;
buf = tbGetBuffer(bufsize);
switch (config) {
case XkmSemanticsFile:
strcpy(buf, "Semantics");
break;
case XkmLayoutFile:
strcpy(buf, "Layout");
break;
case XkmKeymapFile:
strcpy(buf, "Keymap");
break;
case XkmGeometryFile:
case XkmGeometryIndex:
strcpy(buf, "Geometry");
break;
case XkmTypesIndex:
strcpy(buf, "Types");
break;
case XkmCompatMapIndex:
strcpy(buf, "CompatMap");
break;
case XkmSymbolsIndex:
strcpy(buf, "Symbols");
break;
case XkmIndicatorsIndex:
strcpy(buf, "Indicators");
break;
case XkmKeyNamesIndex:
strcpy(buf, "KeyNames");
break;
case XkmVirtualModsIndex:
strcpy(buf, "VirtualMods");
break;
default:
snprintf(buf, bufsize, "unknown(%d)", config);
break;
}
return buf;
}
/***====================================================================***/
char *
XkbKeysymText(KeySym sym, unsigned format)
{
static char buf[32], *rtrn;
if (sym == NoSymbol)
strcpy(rtrn = buf, "NoSymbol");
else if ((rtrn = XKeysymToString(sym)) == NULL) {
snprintf(buf, sizeof(buf), "0x%lx", (long) sym);
rtrn = buf;
}
else if (format == XkbCFile) {
snprintf(buf, sizeof(buf), "XK_%s", rtrn);
rtrn = buf;
}
return rtrn;
}
char *
XkbKeyNameText(char *name, unsigned format)
{
char *buf;
if (format == XkbCFile) {
buf = tbGetBuffer(5);
memcpy(buf, name, 4);
buf[4] = '\0';
}
else {
int len;
buf = tbGetBuffer(7);
buf[0] = '<';
memcpy(&buf[1], name, 4);
buf[5] = '\0';
len = strlen(buf);
buf[len++] = '>';
buf[len] = '\0';
}
return buf;
}
/***====================================================================***/
static char *siMatchText[5] = {
"NoneOf", "AnyOfOrNone", "AnyOf", "AllOf", "Exactly"
};
char *
XkbSIMatchText(unsigned type, unsigned format)
{
static char buf[40];
char *rtrn;
switch (type & XkbSI_OpMask) {
case XkbSI_NoneOf: rtrn = siMatchText[0]; break;
case XkbSI_AnyOfOrNone: rtrn = siMatchText[1]; break;
case XkbSI_AnyOf: rtrn = siMatchText[2]; break;
case XkbSI_AllOf: rtrn = siMatchText[3]; break;
case XkbSI_Exactly: rtrn = siMatchText[4]; break;
default:
snprintf(buf, sizeof(buf), "0x%x", type & XkbSI_OpMask);
return buf;
}
if (format == XkbCFile) {
if (type & XkbSI_LevelOneOnly)
snprintf(buf, sizeof(buf), "XkbSI_LevelOneOnly|XkbSI_%s", rtrn);
else
snprintf(buf, sizeof(buf), "XkbSI_%s", rtrn);
rtrn = buf;
}
return rtrn;
}
/***====================================================================***/
static const char *imWhichNames[] = {
"base",
"latched",
"locked",
"effective",
"compat"
};
char *
XkbIMWhichStateMaskText(unsigned use_which, unsigned format)
{
int len, bufsize;
unsigned i, bit, tmp;
char *buf;
if (use_which == 0) {
buf = tbGetBuffer(2);
strcpy(buf, "0");
return buf;
}
tmp = use_which & XkbIM_UseAnyMods;
for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) {
if (tmp & bit) {
tmp &= ~bit;
len += strlen(imWhichNames[i]) + 1;
if (format == XkbCFile)
len += 9;
}
}
bufsize = len + 1;
buf = tbGetBuffer(bufsize);
tmp = use_which & XkbIM_UseAnyMods;
for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) {
if (tmp & bit) {
tmp &= ~bit;
if (format == XkbCFile) {
if (len != 0)
buf[len++] = '|';
snprintf(&buf[len], bufsize - len,
"XkbIM_Use%s", imWhichNames[i]);
buf[len + 9] = toupper(buf[len + 9]);
}
else {
if (len != 0)
buf[len++] = '+';
snprintf(&buf[len], bufsize - len,
"%s", imWhichNames[i]);
}
len += strlen(&buf[len]);
}
}
return buf;
}
char *
XkbAccessXDetailText(unsigned state, unsigned format)
{
char *buf;
const char *prefix;
const int bufsize = 32;
buf = tbGetBuffer(bufsize);
if (format == XkbMessage)
prefix = "";
else
prefix = "XkbAXN_";
switch (state) {
case XkbAXN_SKPress:
snprintf(buf, bufsize, "%sSKPress", prefix);
break;
case XkbAXN_SKAccept:
snprintf(buf, bufsize, "%sSKAccept", prefix);
break;
case XkbAXN_SKRelease:
snprintf(buf, bufsize, "%sSKRelease", prefix);
break;
case XkbAXN_SKReject:
snprintf(buf, bufsize, "%sSKReject", prefix);
break;
case XkbAXN_BKAccept:
snprintf(buf, bufsize, "%sBKAccept", prefix);
break;
case XkbAXN_BKReject:
snprintf(buf, bufsize, "%sBKReject", prefix);
break;
case XkbAXN_AXKWarning:
snprintf(buf, bufsize, "%sAXKWarning", prefix);
break;
default:
snprintf(buf, bufsize, "ILLEGAL");
break;
}
return buf;
}
static const char *nknNames[] = {
"keycodes", "geometry", "deviceID"
};
#define NUM_NKN (sizeof(nknNames)/sizeof(char *))
char *
XkbNKNDetailMaskText(unsigned detail, unsigned format)
{
char *buf;
const char *prefix, *suffix;
register int i;
register unsigned bit;
int len, plen, slen;
if ((detail & XkbAllNewKeyboardEventsMask) == 0) {
const char *tmp = "";
if (format == XkbCFile)
tmp = "0";
else if (format == XkbMessage)
tmp = "none";
buf = tbGetBuffer(strlen(tmp) + 1);
strcpy(buf, tmp);
return buf;
}
else if ((detail & XkbAllNewKeyboardEventsMask) ==
XkbAllNewKeyboardEventsMask) {
const char *tmp;
if (format == XkbCFile)
tmp = "XkbAllNewKeyboardEventsMask";
else
tmp = "all";
buf = tbGetBuffer(strlen(tmp) + 1);
strcpy(buf, tmp);
return buf;
}
if (format == XkbMessage) {
prefix = "";
suffix = "";
slen = plen = 0;
}
else {
prefix = "XkbNKN_";
plen = 7;
if (format == XkbCFile)
suffix = "Mask";
else
suffix = "";
slen = strlen(suffix);
}
for (len = 0, i = 0, bit = 1; i < NUM_NKN; i++, bit <<= 1) {
if (detail & bit) {
if (len != 0)
len += 1; /* room for '+' or '|' */
len += plen + slen + strlen(nknNames[i]);
}
}
buf = tbGetBuffer(len + 1);
buf[0] = '\0';
for (len = 0, i = 0, bit = 1; i < NUM_NKN; i++, bit <<= 1) {
if (detail & bit) {
if (len != 0) {
if (format == XkbCFile)
buf[len++] = '|';
else
buf[len++] = '+';
}
if (plen) {
strcpy(&buf[len], prefix);
len += plen;
}
strcpy(&buf[len], nknNames[i]);
len += strlen(nknNames[i]);
if (slen) {
strcpy(&buf[len], suffix);
len += slen;
}
}
}
buf[len++] = '\0';
return buf;
}
static const char *ctrlNames[] = {
"repeatKeys",
"slowKeys",
"bounceKeys",
"stickyKeys",
"mouseKeys",
"mouseKeysAccel",
"accessXKeys",
"accessXTimeout",
"accessXFeedback",
"audibleBell",
"overlay1",
"overlay2",
"ignoreGroupLock"
};
char *
XkbControlsMaskText(unsigned ctrls, unsigned format)
{
int len;
unsigned i, bit, tmp;
char *buf;
if (ctrls == 0) {
buf = tbGetBuffer(5);
if (format == XkbCFile)
strcpy(buf, "0");
else
strcpy(buf, "none");
return buf;
}
tmp = ctrls & XkbAllBooleanCtrlsMask;
for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) {
if (tmp & bit) {
tmp &= ~bit;
len += strlen(ctrlNames[i]) + 1;
if (format == XkbCFile)
len += 7;
}
}
buf = tbGetBuffer(len + 1);
tmp = ctrls & XkbAllBooleanCtrlsMask;
for (len = i = 0, bit = 1; tmp != 0; i++, bit <<= 1) {
if (tmp & bit) {
tmp &= ~bit;
if (format == XkbCFile) {
if (len != 0)
buf[len++] = '|';
sprintf(&buf[len], "Xkb%sMask", ctrlNames[i]);
buf[len + 3] = toupper(buf[len + 3]);
}
else {
if (len != 0)
buf[len++] = '+';
sprintf(&buf[len], "%s", ctrlNames[i]);
}
len += strlen(&buf[len]);
}
}
return buf;
}
/***====================================================================***/
char *
XkbStringText(char *str, unsigned format)
{
char *buf;
register char *in, *out;
int len;
Bool ok;
if (str == NULL) {
buf = tbGetBuffer(2);
buf[0] = '\0';
return buf;
}
else if (format == XkbXKMFile)
return str;
for (ok = True, len = 0, in = str; *in != '\0'; in++, len++) {
if (!isprint(*in)) {
ok = False;
switch (*in) {
case '\n':
case '\t':
case '\v':
case '\b':
case '\r':
case '\f':
len++;
break;
default:
len += 4;
break;
}
}
}
if (ok)
return str;
buf = tbGetBuffer(len + 1);
for (in = str, out = buf; *in != '\0'; in++) {
if (isprint(*in))
*out++ = *in;
else {
*out++ = '\\';
if (*in == '\n')
*out++ = 'n';
else if (*in == '\t')
*out++ = 't';
else if (*in == '\v')
*out++ = 'v';
else if (*in == '\b')
*out++ = 'b';
else if (*in == '\r')
*out++ = 'r';
else if (*in == '\f')
*out++ = 'f';
else if ((*in == '\033') && (format == XkbXKMFile)) {
*out++ = 'e';
}
else {
*out++ = '0';
sprintf(out, "%o", *in);
while (*out != '\0')
out++;
}
}
}
*out++ = '\0';
return buf;
}
/***====================================================================***/
char *
XkbGeomFPText(int val, unsigned format)
{
int whole, frac;
char *buf;
const int bufsize = 12;
buf = tbGetBuffer(bufsize);
if (format == XkbCFile) {
snprintf(buf, bufsize, "%d", val);
}
else {
whole = val / XkbGeomPtsPerMM;
frac = abs(val % XkbGeomPtsPerMM);
if (frac != 0) {
if (val < 0)
{
int wholeabs;
wholeabs = abs(whole);
snprintf(buf, bufsize, "-%d.%d", wholeabs, frac);
}
else
snprintf(buf, bufsize, "%d.%d", whole, frac);
}
else
snprintf(buf, bufsize, "%d", whole);
}
return buf;
}
char *
XkbDoodadTypeText(unsigned type, unsigned format)
{
char *buf;
if (format == XkbCFile) {
const int bufsize = 24;
buf = tbGetBuffer(bufsize);
if (type == XkbOutlineDoodad)
strcpy(buf, "XkbOutlineDoodad");
else if (type == XkbSolidDoodad)
strcpy(buf, "XkbSolidDoodad");
else if (type == XkbTextDoodad)
strcpy(buf, "XkbTextDoodad");
else if (type == XkbIndicatorDoodad)
strcpy(buf, "XkbIndicatorDoodad");
else if (type == XkbLogoDoodad)
strcpy(buf, "XkbLogoDoodad");
else
snprintf(buf, bufsize, "UnknownDoodad%d", type);
}
else {
const int bufsize = 12;
buf = tbGetBuffer(bufsize);
if (type == XkbOutlineDoodad)
strcpy(buf, "outline");
else if (type == XkbSolidDoodad)
strcpy(buf, "solid");
else if (type == XkbTextDoodad)
strcpy(buf, "text");
else if (type == XkbIndicatorDoodad)
strcpy(buf, "indicator");
else if (type == XkbLogoDoodad)
strcpy(buf, "logo");
else
snprintf(buf, bufsize, "unknown%d", type);
}
return buf;
}
static char *actionTypeNames[XkbSA_NumActions] = {
"NoAction",
"SetMods", "LatchMods", "LockMods",
"SetGroup", "LatchGroup", "LockGroup",
"MovePtr",
"PtrBtn", "LockPtrBtn",
"SetPtrDflt",
"ISOLock",
"Terminate", "SwitchScreen",
"SetControls", "LockControls",
"ActionMessage",
"RedirectKey",
"DeviceBtn", "LockDeviceBtn"
};
char *
XkbActionTypeText(unsigned type, unsigned format)
{
static char buf[32];
char *rtrn;
if (type <= XkbSA_LastAction) {
rtrn = actionTypeNames[type];
if (format == XkbCFile) {
snprintf(buf, sizeof(buf), "XkbSA_%s", rtrn);
return buf;
}
return rtrn;
}
snprintf(buf, sizeof(buf), "Private");
return buf;
}
/***====================================================================***/
static int
TryCopyStr(char *to, const char *from, int *pLeft)
{
register int len;
if (*pLeft > 0) {
len = strlen(from);
if (len < ((*pLeft) - 3)) {
strcat(to, from);
*pLeft -= len;
return True;
}
}
*pLeft = -1;
return False;
}
/*ARGSUSED*/
static Bool
CopyNoActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
return True;
}
static Bool
CopyModActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbModAction *act;
unsigned tmp;
act = &action->mods;
tmp = XkbModActionVMods(act);
TryCopyStr(buf, "modifiers=", sz);
if (act->flags & XkbSA_UseModMapMods)
TryCopyStr(buf, "modMapMods", sz);
else if (act->real_mods || tmp) {
TryCopyStr(buf,
XkbVModMaskText(dpy, xkb, act->real_mods, tmp, XkbXKBFile),
sz);
}
else
TryCopyStr(buf, "none", sz);
if (act->type == XkbSA_LockMods) {
switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
TryCopyStr(buf, ",affect=unlock", sz);
break;
case XkbSA_LockNoUnlock:
TryCopyStr(buf, ",affect=lock", sz);
break;
case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
TryCopyStr(buf, ",affect=neither", sz);
break;
default:
break;
}
return True;
}
if (act->flags & XkbSA_ClearLocks)
TryCopyStr(buf, ",clearLocks", sz);
if (act->flags & XkbSA_LatchToLock)
TryCopyStr(buf, ",latchToLock", sz);
return True;
}
/*ARGSUSED*/
static Bool
CopyGroupActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbGroupAction *act;
char tbuf[32];
act = &action->group;
TryCopyStr(buf, "group=", sz);
if (act->flags & XkbSA_GroupAbsolute)
snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act) + 1);
else if (XkbSAGroup(act) < 0)
snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act));
else
snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAGroup(act));
TryCopyStr(buf, tbuf, sz);
if (act->type == XkbSA_LockGroup)
return True;
if (act->flags & XkbSA_ClearLocks)
TryCopyStr(buf, ",clearLocks", sz);
if (act->flags & XkbSA_LatchToLock)
TryCopyStr(buf, ",latchToLock", sz);
return True;
}
/*ARGSUSED*/
static Bool
CopyMovePtrArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbPtrAction *act;
int x, y;
char tbuf[32];
act = &action->ptr;
x = XkbPtrActionX(act);
y = XkbPtrActionY(act);
if ((act->flags & XkbSA_MoveAbsoluteX) || (x < 0))
snprintf(tbuf, sizeof(tbuf), "x=%d", x);
else
snprintf(tbuf, sizeof(tbuf), "x=+%d", x);
TryCopyStr(buf, tbuf, sz);
if ((act->flags & XkbSA_MoveAbsoluteY) || (y < 0))
snprintf(tbuf, sizeof(tbuf), ",y=%d", y);
else
snprintf(tbuf, sizeof(tbuf), ",y=+%d", y);
TryCopyStr(buf, tbuf, sz);
if (act->flags & XkbSA_NoAcceleration)
TryCopyStr(buf, ",!accel", sz);
return True;
}
/*ARGSUSED*/
static Bool
CopyPtrBtnArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbPtrBtnAction *act;
char tbuf[32];
act = &action->btn;
TryCopyStr(buf, "button=", sz);
if ((act->button > 0) && (act->button < 6)) {
snprintf(tbuf, sizeof(tbuf), "%d", act->button);
TryCopyStr(buf, tbuf, sz);
}
else
TryCopyStr(buf, "default", sz);
if (act->count > 0) {
snprintf(tbuf, sizeof(tbuf), ",count=%d", act->count);
TryCopyStr(buf, tbuf, sz);
}
if (action->type == XkbSA_LockPtrBtn) {
switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
snprintf(tbuf, sizeof(tbuf), ",affect=unlock");
break;
case XkbSA_LockNoUnlock:
snprintf(tbuf, sizeof(tbuf), ",affect=lock");
break;
case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
snprintf(tbuf, sizeof(tbuf), ",affect=neither");
break;
default:
snprintf(tbuf, sizeof(tbuf), ",affect=both");
break;
}
TryCopyStr(buf, tbuf, sz);
}
return True;
}
/*ARGSUSED*/
static Bool
CopySetPtrDfltArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbPtrDfltAction *act;
char tbuf[32];
act = &action->dflt;
if (act->affect == XkbSA_AffectDfltBtn) {
TryCopyStr(buf, "affect=button,button=", sz);
if ((act->flags & XkbSA_DfltBtnAbsolute) ||
(XkbSAPtrDfltValue(act) < 0))
snprintf(tbuf, sizeof(tbuf), "%d", XkbSAPtrDfltValue(act));
else
snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAPtrDfltValue(act));
TryCopyStr(buf, tbuf, sz);
}
return True;
}
static Bool
CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbISOAction *act;
char tbuf[64];
act = &action->iso;
if (act->flags & XkbSA_ISODfltIsGroup) {
TryCopyStr(tbuf, "group=", sz);
if (act->flags & XkbSA_GroupAbsolute)
snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act) + 1);
else if (XkbSAGroup(act) < 0)
snprintf(tbuf, sizeof(tbuf), "%d", XkbSAGroup(act));
else
snprintf(tbuf, sizeof(tbuf), "+%d", XkbSAGroup(act));
TryCopyStr(buf, tbuf, sz);
}
else {
unsigned tmp;
tmp = XkbModActionVMods(act);
TryCopyStr(buf, "modifiers=", sz);
if (act->flags & XkbSA_UseModMapMods)
TryCopyStr(buf, "modMapMods", sz);
else if (act->real_mods || tmp) {
if (act->real_mods) {
TryCopyStr(buf, XkbModMaskText(act->real_mods, XkbXKBFile), sz);
if (tmp)
TryCopyStr(buf, "+", sz);
}
if (tmp)
TryCopyStr(buf, XkbVModMaskText(dpy, xkb, 0, tmp, XkbXKBFile),
sz);
}
else
TryCopyStr(buf, "none", sz);
}
TryCopyStr(buf, ",affect=", sz);
if ((act->affect & XkbSA_ISOAffectMask) == 0) {
TryCopyStr(buf, "all", sz);
}
else if ((act->affect & XkbSA_ISOAffectMask) == XkbSA_ISOAffectMask) {
TryCopyStr(buf, "none", sz);
}
else {
int nOut = 0;
if ((act->affect & XkbSA_ISONoAffectMods) == 0) {
TryCopyStr(buf, "mods", sz);
nOut++;
}
if ((act->affect & XkbSA_ISONoAffectGroup) == 0) {
snprintf(tbuf, sizeof(tbuf), "%sgroups", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if ((act->affect & XkbSA_ISONoAffectPtr) == 0) {
snprintf(tbuf, sizeof(tbuf), "%spointer", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if ((act->affect & XkbSA_ISONoAffectCtrls) == 0) {
snprintf(tbuf, sizeof(tbuf), "%scontrols", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
}
switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
TryCopyStr(buf, "+unlock", sz);
break;
case XkbSA_LockNoUnlock:
TryCopyStr(buf, "+lock", sz);
break;
case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
TryCopyStr(buf, "+neither", sz);
break;
default: ;
}
return True;
}
/*ARGSUSED*/
static Bool
CopySwitchScreenArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbSwitchScreenAction *act;
char tbuf[32];
act = &action->screen;
if ((act->flags & XkbSA_SwitchAbsolute) || (XkbSAScreen(act) < 0))
snprintf(tbuf, sizeof(tbuf), "screen=%d", XkbSAScreen(act));
else
snprintf(tbuf, sizeof(tbuf), "screen=+%d", XkbSAScreen(act));
TryCopyStr(buf, tbuf, sz);
if (act->flags & XkbSA_SwitchApplication)
TryCopyStr(buf, ",!same", sz);
else
TryCopyStr(buf, ",same", sz);
return True;
}
/*ARGSUSED*/
static Bool
CopySetLockControlsArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbCtrlsAction *act;
unsigned tmp;
char tbuf[32];
act = &action->ctrls;
tmp = XkbActionCtrls(act);
TryCopyStr(buf, "controls=", sz);
if (tmp == 0)
TryCopyStr(buf, "none", sz);
else if ((tmp & XkbAllBooleanCtrlsMask) == XkbAllBooleanCtrlsMask)
TryCopyStr(buf, "all", sz);
else {
int nOut = 0;
if (tmp & XkbRepeatKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sRepeatKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbSlowKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sSlowKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbBounceKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sBounceKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbStickyKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sStickyKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbMouseKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sMouseKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbMouseKeysAccelMask) {
snprintf(tbuf, sizeof(tbuf), "%sMouseKeysAccel", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbAccessXKeysMask) {
snprintf(tbuf, sizeof(tbuf), "%sAccessXKeys", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbAccessXTimeoutMask) {
snprintf(tbuf, sizeof(tbuf), "%sAccessXTimeout", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbAccessXFeedbackMask) {
snprintf(tbuf, sizeof(tbuf), "%sAccessXFeedback", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbAudibleBellMask) {
snprintf(tbuf, sizeof(tbuf), "%sAudibleBell", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbOverlay1Mask) {
snprintf(tbuf, sizeof(tbuf), "%sOverlay1", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbOverlay2Mask) {
snprintf(tbuf, sizeof(tbuf), "%sOverlay2", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
if (tmp & XkbIgnoreGroupLockMask) {
snprintf(tbuf, sizeof(tbuf), "%sIgnoreGroupLock", (nOut > 0 ? "+" : ""));
TryCopyStr(buf, tbuf, sz);
nOut++;
}
}
if (action->type == XkbSA_LockControls) {
switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
TryCopyStr(buf, ",affect=unlock", sz);
break;
case XkbSA_LockNoUnlock:
TryCopyStr(buf, ",affect=lock", sz);
break;
case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
TryCopyStr(buf, ",affect=neither", sz);
break;
default: ;
}
}
return True;
}
/*ARGSUSED*/
static Bool
CopyActionMessageArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbMessageAction *act;
unsigned all;
char tbuf[32];
act = &action->msg;
all = XkbSA_MessageOnPress | XkbSA_MessageOnRelease;
TryCopyStr(buf, "report=", sz);
if ((act->flags & all) == 0)
TryCopyStr(buf, "none", sz);
else if ((act->flags & all) == all)
TryCopyStr(buf, "all", sz);
else if (act->flags & XkbSA_MessageOnPress)
TryCopyStr(buf, "KeyPress", sz);
else
TryCopyStr(buf, "KeyRelease", sz);
snprintf(tbuf, sizeof(tbuf), ",data[0]=0x%02x", act->message[0]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[1]=0x%02x", act->message[1]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[2]=0x%02x", act->message[2]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[3]=0x%02x", act->message[3]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[4]=0x%02x", act->message[4]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[5]=0x%02x", act->message[5]);
TryCopyStr(buf, tbuf, sz);
if (act->flags & XkbSA_MessageGenKeyEvent)
TryCopyStr(buf, ",genKeyEvent", sz);
return True;
}
static Bool
CopyRedirectKeyArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbRedirectKeyAction *act;
char tbuf[32], *tmp;
unsigned kc;
unsigned vmods, vmods_mask;
act = &action->redirect;
kc = act->new_key;
vmods = XkbSARedirectVMods(act);
vmods_mask = XkbSARedirectVModsMask(act);
if (xkb && xkb->names && xkb->names->keys && (kc <= xkb->max_key_code) &&
(xkb->names->keys[kc].name[0] != '\0')) {
char *kn;
kn = XkbKeyNameText(xkb->names->keys[kc].name, XkbXKBFile);
snprintf(tbuf, sizeof(tbuf), "key=%s", kn);
}
else
snprintf(tbuf, sizeof(tbuf), "key=%d", kc);
TryCopyStr(buf, tbuf, sz);
if ((act->mods_mask == 0) && (vmods_mask == 0))
return True;
if ((act->mods_mask == XkbAllModifiersMask) &&
(vmods_mask == XkbAllVirtualModsMask)) {
tmp = XkbVModMaskText(dpy, xkb, act->mods, vmods, XkbXKBFile);
TryCopyStr(buf, ",mods=", sz);
TryCopyStr(buf, tmp, sz);
}
else {
if ((act->mods_mask & act->mods) || (vmods_mask & vmods)) {
tmp = XkbVModMaskText(dpy, xkb, act->mods_mask & act->mods,
vmods_mask & vmods, XkbXKBFile);
TryCopyStr(buf, ",mods= ", sz);
TryCopyStr(buf, tmp, sz);
}
if ((act->mods_mask & (~act->mods)) || (vmods_mask & (~vmods))) {
tmp = XkbVModMaskText(dpy, xkb, act->mods_mask & (~act->mods),
vmods_mask & (~vmods), XkbXKBFile);
TryCopyStr(buf, ",clearMods= ", sz);
TryCopyStr(buf, tmp, sz);
}
}
return True;
}
/*ARGSUSED*/
static Bool
CopyDeviceBtnArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbDeviceBtnAction *act;
char tbuf[32];
act = &action->devbtn;
snprintf(tbuf, sizeof(tbuf), "device= %d", act->device);
TryCopyStr(buf, tbuf, sz);
TryCopyStr(buf, ",button=", sz);
snprintf(tbuf, sizeof(tbuf), "%d", act->button);
TryCopyStr(buf, tbuf, sz);
if (act->count > 0) {
snprintf(tbuf, sizeof(tbuf), ",count=%d", act->count);
TryCopyStr(buf, tbuf, sz);
}
if (action->type == XkbSA_LockDeviceBtn) {
switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoLock:
snprintf(tbuf, sizeof(tbuf), ",affect=unlock");
break;
case XkbSA_LockNoUnlock:
snprintf(tbuf, sizeof(tbuf), ",affect=lock");
break;
case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
snprintf(tbuf, sizeof(tbuf), ",affect=neither");
break;
default:
snprintf(tbuf, sizeof(tbuf), ",affect=both");
break;
}
TryCopyStr(buf, tbuf, sz);
}
return True;
}
/*ARGSUSED*/
static Bool
CopyOtherArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
char *buf, int *sz)
{
XkbAnyAction *act;
char tbuf[32];
act = &action->any;
snprintf(tbuf, sizeof(tbuf), "type=0x%02x", act->type);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[0]=0x%02x", act->data[0]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[1]=0x%02x", act->data[1]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[2]=0x%02x", act->data[2]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[3]=0x%02x", act->data[3]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[4]=0x%02x", act->data[4]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[5]=0x%02x", act->data[5]);
TryCopyStr(buf, tbuf, sz);
snprintf(tbuf, sizeof(tbuf), ",data[6]=0x%02x", act->data[6]);
TryCopyStr(buf, tbuf, sz);
return True;
}
typedef Bool (*actionCopy) (Display * /* dpy */ ,
XkbDescPtr /* xkb */ ,
XkbAction * /* action */ ,
char * /* buf */ ,
int * /* sz */
);
static actionCopy copyActionArgs[XkbSA_NumActions] = {
CopyNoActionArgs /* NoAction */ ,
CopyModActionArgs /* SetMods */ ,
CopyModActionArgs /* LatchMods */ ,
CopyModActionArgs /* LockMods */ ,
CopyGroupActionArgs /* SetGroup */ ,
CopyGroupActionArgs /* LatchGroup */ ,
CopyGroupActionArgs /* LockGroup */ ,
CopyMovePtrArgs /* MovePtr */ ,
CopyPtrBtnArgs /* PtrBtn */ ,
CopyPtrBtnArgs /* LockPtrBtn */ ,
CopySetPtrDfltArgs /* SetPtrDflt */ ,
CopyISOLockArgs /* ISOLock */ ,
CopyNoActionArgs /* Terminate */ ,
CopySwitchScreenArgs /* SwitchScreen */ ,
CopySetLockControlsArgs /* SetControls */ ,
CopySetLockControlsArgs /* LockControls */ ,
CopyActionMessageArgs /* ActionMessage */ ,
CopyRedirectKeyArgs /* RedirectKey */ ,
CopyDeviceBtnArgs /* DeviceBtn */ ,
CopyDeviceBtnArgs /* LockDeviceBtn */
};
#define ACTION_SZ 256
char *
XkbActionText(Display *dpy, XkbDescPtr xkb, XkbAction *action, unsigned format)
{
char buf[ACTION_SZ], *tmp;
int sz;
if (format == XkbCFile) {
snprintf(buf, sizeof(buf),
"{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
XkbActionTypeText(action->type, XkbCFile),
action->any.data[0], action->any.data[1], action->any.data[2],
action->any.data[3], action->any.data[4], action->any.data[5],
action->any.data[6]);
}
else {
snprintf(buf, sizeof(buf),
"%s(", XkbActionTypeText(action->type, XkbXKBFile));
sz = ACTION_SZ - strlen(buf) + 2; /* room for close paren and NULL */
if (action->type < (unsigned) XkbSA_NumActions)
(*copyActionArgs[action->type]) (dpy, xkb, action, buf, &sz);
else
CopyOtherArgs(dpy, xkb, action, buf, &sz);
TryCopyStr(buf, ")", &sz);
}
tmp = tbGetBuffer(strlen(buf) + 1);
if (tmp != NULL)
strcpy(tmp, buf);
return tmp;
}
char *
XkbBehaviorText(XkbDescPtr xkb, XkbBehavior * behavior, unsigned format)
{
char buf[256], *tmp;
if (format == XkbCFile) {
if (behavior->type == XkbKB_Default)
snprintf(buf, sizeof(buf), "{ 0, 0 }");
else
snprintf(buf, sizeof(buf), "{ %3d, 0x%02x }", behavior->type, behavior->data);
}
else {
unsigned type, permanent;
type = behavior->type & XkbKB_OpMask;
permanent = ((behavior->type & XkbKB_Permanent) != 0);
if (type == XkbKB_Lock) {
snprintf(buf, sizeof(buf), "lock= %s", (permanent ? "Permanent" : "True"));
}
else if (type == XkbKB_RadioGroup) {
int g;
char *tmp;
size_t tmpsize;
g = ((behavior->data) & (~XkbKB_RGAllowNone)) + 1;
if (XkbKB_RGAllowNone & behavior->data) {
snprintf(buf, sizeof(buf), "allowNone,");
tmp = &buf[strlen(buf)];
}
else
tmp = buf;
tmpsize = sizeof(buf) - (tmp - buf);
if (permanent)
snprintf(tmp, tmpsize, "permanentRadioGroup= %d", g);
else
snprintf(tmp, tmpsize, "radioGroup= %d", g);
}
else if ((type == XkbKB_Overlay1) || (type == XkbKB_Overlay2)) {
int ndx, kc;
char *kn;
ndx = ((type == XkbKB_Overlay1) ? 1 : 2);
kc = behavior->data;
if ((xkb) && (xkb->names) && (xkb->names->keys))
kn = XkbKeyNameText(xkb->names->keys[kc].name, XkbXKBFile);
else {
static char tbuf[8];
snprintf(tbuf, sizeof(tbuf), "%d", kc);
kn = tbuf;
}
if (permanent)
snprintf(buf, sizeof(buf), "permanentOverlay%d= %s", ndx, kn);
else
snprintf(buf, sizeof(buf), "overlay%d= %s", ndx, kn);
}
}
tmp = tbGetBuffer(strlen(buf) + 1);
if (tmp != NULL)
strcpy(tmp, buf);
return tmp;
}
/***====================================================================***/
char *
XkbIndentText(unsigned size)
{
static char buf[32];
register int i;
if (size > 31)
size = 31;
for (i = 0; i < size; i++) {
buf[i] = ' ';
}
buf[size] = '\0';
return buf;
}
/***====================================================================***/
#define PIXEL_MAX 65535
Bool
XkbLookupCanonicalRGBColor(char *def, XColor *color)
{
int tmp;
if (_XkbStrCaseEqual(def, "black")) {
color->red = color->green = color->blue = 0;
return True;
}
else if (_XkbStrCaseEqual(def, "white")) {
color->red = color->green = color->blue = PIXEL_MAX;
return True;
}
else if ((sscanf(def, "grey%d", &tmp) == 1) ||
(sscanf(def, "gray%d", &tmp) == 1) ||
(sscanf(def, "Grey%d", &tmp) == 1) ||
(sscanf(def, "Gray%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->red = color->green = color->blue = tmp;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "red") * 100)) ||
(sscanf(def, "red%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->red = tmp;
color->green = color->blue = 0;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "green") * 100)) ||
(sscanf(def, "green%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->green = tmp;
color->red = color->blue = 0;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "blue") * 100)) ||
(sscanf(def, "blue%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->blue = tmp;
color->red = color->green = 0;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "magenta") * 100)) ||
(sscanf(def, "magenta%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->green = 0;
color->red = color->blue = tmp;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "cyan") * 100)) ||
(sscanf(def, "cyan%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->red = 0;
color->green = color->blue = tmp;
return True;
}
}
else if ((tmp = (_XkbStrCaseEqual(def, "yellow") * 100)) ||
(sscanf(def, "yellow%d", &tmp) == 1)) {
if ((tmp > 0) && (tmp <= 100)) {
tmp = (PIXEL_MAX * tmp) / 100;
color->blue = 0;
color->red = color->green = tmp;
return True;
}
}
return False;
}
k & vmods, XkbXKBFile);
TryCopyStr(buf, ",mods= ", sz);
TryCopyStr(buflibxkbfile-1.1.0/src/xkbdraw.c 0000644 0143106 0000012 00000010204 13443241017 0016475 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
static void
_XkbAddDrawable(XkbDrawablePtr *pfirst, XkbDrawablePtr *plast,
XkbDrawablePtr tmp)
{
XkbDrawablePtr old;
if (*pfirst == NULL) {
*pfirst = *plast = tmp;
}
else if (tmp->priority >= (*plast)->priority) {
(*plast)->next = tmp;
*plast = tmp;
}
else if (tmp->priority < (*pfirst)->priority) {
tmp->next = (*pfirst);
(*pfirst) = tmp;
}
else {
old = *pfirst;
while ((old->next) && (old->next->priority <= tmp->priority)) {
old = old->next;
}
tmp->next = old->next;
old->next = tmp;
}
return;
}
XkbDrawablePtr
XkbGetOrderedDrawables(XkbGeometryPtr geom, XkbSectionPtr section)
{
XkbDrawablePtr first, last, tmp;
int i;
first = last = NULL;
if (geom != NULL) {
XkbSectionPtr section;
XkbDoodadPtr doodad;
for (i = 0, section = geom->sections; i < geom->num_sections;
i++, section++) {
tmp = _XkbTypedCalloc(1, XkbDrawableRec);
if (!tmp) {
XkbFreeOrderedDrawables(first);
return NULL;
}
tmp->type = XkbDW_Section;
tmp->priority = section->priority;
tmp->u.section = section;
tmp->next = NULL;
_XkbAddDrawable(&first, &last, tmp);
}
for (i = 0, doodad = geom->doodads; i < geom->num_doodads;
i++, doodad++) {
tmp = _XkbTypedCalloc(1, XkbDrawableRec);
if (!tmp) {
XkbFreeOrderedDrawables(first);
return NULL;
}
tmp->type = XkbDW_Doodad;
tmp->priority = doodad->any.priority;
tmp->u.doodad = doodad;
tmp->next = NULL;
_XkbAddDrawable(&first, &last, tmp);
}
}
if (section != NULL) {
XkbDoodadPtr doodad;
for (i = 0, doodad = section->doodads; i < section->num_doodads;
i++, doodad++) {
tmp = _XkbTypedCalloc(1, XkbDrawableRec);
if (!tmp) {
XkbFreeOrderedDrawables(first);
return NULL;
}
tmp->type = XkbDW_Doodad;
tmp->priority = doodad->any.priority;
tmp->u.doodad = doodad;
tmp->next = NULL;
_XkbAddDrawable(&first, &last, tmp);
}
}
return first;
}
void
XkbFreeOrderedDrawables(XkbDrawablePtr draw)
{
XkbDrawablePtr tmp;
for (; draw != NULL; draw = tmp) {
tmp = draw->next;
_XkbFree(draw);
}
return;
}
ssion to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertalibxkbfile-1.1.0/src/xkbout.c 0000644 0143106 0000012 00000116164 13443241017 0016363 0 ustar 00alanc staff 0000266 0200014 /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS 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.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include
#elif defined(HAVE_CONFIG_H)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include "XKMformat.h"
#include "XKBfileInt.h"
#define VMOD_HIDE_VALUE 0
#define VMOD_SHOW_VALUE 1
#define VMOD_COMMENT_VALUE 2
static Bool
WriteXKBVModDecl(FILE *file, Display *dpy, XkbDescPtr xkb, int showValue)
{
register int i, nMods;
Atom *vmodNames;
if (xkb == NULL)
return False;
if (xkb->names != NULL)
vmodNames = xkb->names->vmods;
else
vmodNames = NULL;
for (i = nMods = 0; i < XkbNumVirtualMods; i++) {
if ((vmodNames != NULL) && (vmodNames[i] != None)) {
if (nMods == 0)
fprintf(file, " virtual_modifiers ");
else
fprintf(file, ",");
fprintf(file, "%s", XkbAtomText(dpy, vmodNames[i], XkbXKBFile));
if ((showValue != VMOD_HIDE_VALUE) &&
(xkb->server) && (xkb->server->vmods[i] != XkbNoModifierMask)) {
if (showValue == VMOD_COMMENT_VALUE) {
fprintf(file, "/* = %s */",
XkbModMaskText(xkb->server->vmods[i], XkbXKBFile));
}
else {
fprintf(file, "= %s",
XkbModMaskText(xkb->server->vmods[i], XkbXKBFile));
}
}
nMods++;
}
}
if (nMods > 0)
fprintf(file, ";\n\n");
return True;
}
/***====================================================================***/
static Bool
WriteXKBAction(FILE *file, XkbFileInfo *result, XkbAnyAction *action)
{
XkbDescPtr xkb;
Display *dpy;
xkb = result->xkb;
dpy = xkb->dpy;
fprintf(file, "%s",
XkbActionText(dpy, xkb, (XkbAction *) action, XkbXKBFile));
return True;
}
/***====================================================================***/
Bool
XkbWriteXKBKeycodes(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Atom kcName;
register unsigned i;
XkbDescPtr xkb;
Display *dpy;
const char *alternate;
xkb = result->xkb;
if ((!xkb) || (!xkb->names) || (!xkb->names->keys)) {
_XkbLibError(_XkbErrMissingNames, "XkbWriteXKBKeycodes", 0);
return False;
}
dpy = xkb->dpy;
kcName = xkb->names->keycodes;
if (kcName != None)
fprintf(file, "xkb_keycodes \"%s\" {\n",
XkbAtomText(dpy, kcName, XkbXKBFile));
else
fprintf(file, "xkb_keycodes {\n");
fprintf(file, " minimum = %d;\n", xkb->min_key_code);
fprintf(file, " maximum = %d;\n", xkb->max_key_code);
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
if (xkb->names->keys[i].name[0] != '\0') {
if (XkbFindKeycodeByName(xkb, xkb->names->keys[i].name, True) != i)
alternate = "alternate ";
else
alternate = "";
fprintf(file, " %s%6s = %d;\n", alternate,
XkbKeyNameText(xkb->names->keys[i].name, XkbXKBFile), i);
}
}
if (xkb->indicators != NULL) {
for (i = 0; i < XkbNumIndicators; i++) {
const char *type;
if (xkb->indicators->phys_indicators & (1 << i))
type = " ";
else
type = " virtual ";
if (xkb->names->indicators[i] != None) {
fprintf(file, "%sindicator %d = \"%s\";\n", type, i + 1,
XkbAtomText(dpy, xkb->names->indicators[i],
XkbXKBFile));
}
}
}
if (xkb->names->key_aliases != NULL) {
XkbKeyAliasPtr pAl;
pAl = xkb->names->key_aliases;
for (i = 0; i < xkb->names->num_key_aliases; i++, pAl++) {
fprintf(file, " alias %6s = %6s;\n",
XkbKeyNameText(pAl->alias, XkbXKBFile),
XkbKeyNameText(pAl->real, XkbXKBFile));
}
}
if (addOn)
(*addOn) (file, result, topLevel, showImplicit, XkmKeyNamesIndex, priv);
fprintf(file, "};\n\n");
return True;
}
Bool
XkbWriteXKBKeyTypes(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Display *dpy;
register unsigned i, n;
XkbKeyTypePtr type;
XkbKTMapEntryPtr entry;
XkbDescPtr xkb;
xkb = result->xkb;
if ((!xkb) || (!xkb->map) || (!xkb->map->types)) {
_XkbLibError(_XkbErrMissingTypes, "XkbWriteXKBKeyTypes", 0);
return False;
}
dpy = xkb->dpy;
if (xkb->map->num_types < XkbNumRequiredTypes) {
_XkbLibError(_XkbErrMissingReqTypes, "XkbWriteXKBKeyTypes", 0);
return 0;
}
if ((xkb->names == NULL) || (xkb->names->types == None))
fprintf(file, "xkb_types {\n\n");
else
fprintf(file, "xkb_types \"%s\" {\n\n",
XkbAtomText(dpy, xkb->names->types, XkbXKBFile));
WriteXKBVModDecl(file, dpy, xkb,
(showImplicit ? VMOD_COMMENT_VALUE : VMOD_HIDE_VALUE));
type = xkb->map->types;
for (i = 0; i < xkb->map->num_types; i++, type++) {
fprintf(file, " type \"%s\" {\n",
XkbAtomText(dpy, type->name, XkbXKBFile));
fprintf(file, " modifiers= %s;\n",
XkbVModMaskText(dpy, xkb, type->mods.real_mods,
type->mods.vmods, XkbXKBFile));
entry = type->map;
for (n = 0; n < type->map_count; n++, entry++) {
char *str;
str =
XkbVModMaskText(dpy, xkb, entry->mods.real_mods,
entry->mods.vmods, XkbXKBFile);
fprintf(file, " map[%s]= Level%d;\n", str, entry->level + 1);
if ((type->preserve) && ((type->preserve[n].real_mods) ||
(type->preserve[n].vmods))) {
fprintf(file, " preserve[%s]= ", str);
fprintf(file, "%s;\n", XkbVModMaskText(dpy, xkb,
type->preserve[n].
real_mods,
type->preserve[n].vmods,
XkbXKBFile));
}
}
if (type->level_names != NULL) {
Atom *name = type->level_names;
for (n = 0; n < type->num_levels; n++, name++) {
if ((*name) == None)
continue;
fprintf(file, " level_name[Level%d]= \"%s\";\n", n + 1,
XkbAtomText(dpy, *name, XkbXKBFile));
}
}
fprintf(file, " };\n");
}
if (addOn)
(*addOn) (file, result, topLevel, showImplicit, XkmTypesIndex, priv);
fprintf(file, "};\n\n");
return True;
}
static Bool
WriteXKBIndicatorMap(FILE * file,
XkbFileInfo * result,
Atom name,
XkbIndicatorMapPtr led,
XkbFileAddOnFunc addOn,
void * priv)
{
XkbDescPtr xkb;
char *tmp;
xkb = result->xkb;
tmp = XkbAtomGetString(xkb->dpy, name);
fprintf(file, " indicator \"%s\" {\n", tmp);
_XkbFree(tmp);
if (led->flags & XkbIM_NoExplicit)
fprintf(file, " !allowExplicit;\n");
if (led->flags & XkbIM_LEDDrivesKB)
fprintf(file, " indicatorDrivesKeyboard;\n");
if (led->which_groups != 0) {
if (led->which_groups != XkbIM_UseEffective) {
fprintf(file, " whichGroupState= %s;\n",
XkbIMWhichStateMaskText(led->which_groups, XkbXKBFile));
}
fprintf(file, " groups= 0x%02x;\n", led->groups);
}
if (led->which_mods != 0) {
if (led->which_mods != XkbIM_UseEffective) {
fprintf(file, " whichModState= %s;\n",
XkbIMWhichStateMaskText(led->which_mods, XkbXKBFile));
}
fprintf(file, " modifiers= %s;\n",
XkbVModMaskText(xkb->dpy, xkb,
led->mods.real_mods, led->mods.vmods,
XkbXKBFile));
}
if (led->ctrls != 0) {
fprintf(file, " controls= %s;\n",
XkbControlsMaskText(led->ctrls, XkbXKBFile));
}
if (addOn)
(*addOn) (file, result, False, True, XkmIndicatorsIndex, priv);
fprintf(file, " };\n");
return True;
}
Bool
XkbWriteXKBCompatMap(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Display * dpy;
register unsigned i;
XkbSymInterpretPtr interp;
XkbDescPtr xkb;
xkb = result->xkb;
if ((!xkb) || (!xkb->compat) || (!xkb->compat->sym_interpret)) {
_XkbLibError(_XkbErrMissingCompatMap, "XkbWriteXKBCompatMap", 0);
return False;
}
dpy = xkb->dpy;
if ((xkb->names == NULL) || (xkb->names->compat == None))
fprintf(file, "xkb_compatibility {\n\n");
else
fprintf(file, "xkb_compatibility \"%s\" {\n\n",
XkbAtomText(dpy, xkb->names->compat, XkbXKBFile));
WriteXKBVModDecl(file, dpy, xkb,
(showImplicit ? VMOD_COMMENT_VALUE : VMOD_HIDE_VALUE));
fprintf(file, " interpret.useModMapMods= AnyLevel;\n");
fprintf(file, " interpret.repeat= False;\n");
fprintf(file, " interpret.locking= False;\n");
interp = xkb->compat->sym_interpret;
for (i = 0; i < xkb->compat->num_si; i++, interp++) {
fprintf(file, " interpret %s+%s(%s) {\n",
((interp->sym == NoSymbol) ? "Any" :
XkbKeysymText(interp->sym, XkbXKBFile)),
XkbSIMatchText(interp->match, XkbXKBFile),
XkbModMaskText(interp->mods, XkbXKBFile));
if (interp->virtual_mod != XkbNoModifier) {
fprintf(file, " virtualModifier= %s;\n",
XkbVModIndexText(dpy, xkb, interp->virtual_mod,
XkbXKBFile));
}
if (interp->match & XkbSI_LevelOneOnly)
fprintf(file, " useModMapMods=level1;\n");
if (interp->flags & XkbSI_LockingKey)
fprintf(file, " locking= True;\n");
if (interp->flags & XkbSI_AutoRepeat)
fprintf(file, " repeat= True;\n");
fprintf(file, " action= ");
WriteXKBAction(file, result, &interp->act);
fprintf(file, ";\n");
fprintf(file, " };\n");
}
for (i = 0; i < XkbNumKbdGroups; i++) {
XkbModsPtr gc;
gc = &xkb->compat->groups[i];
if ((gc->real_mods == 0) && (gc->vmods == 0))
continue;
fprintf(file, " group %d = %s;\n", i + 1,
XkbVModMaskText(xkb->dpy, xkb, gc->real_mods, gc->vmods,
XkbXKBFile));
}
if (xkb->indicators) {
for (i = 0; i < XkbNumIndicators; i++) {
XkbIndicatorMapPtr map = &xkb->indicators->maps[i];
if ((map->flags != 0) || (map->which_groups != 0) ||
(map->groups != 0) || (map->which_mods != 0) ||
(map->mods.real_mods != 0) || (map->mods.vmods != 0) ||
(map->ctrls != 0)) {
WriteXKBIndicatorMap(file, result, xkb->names->indicators[i],
map, addOn, priv);
}
}
}
if (addOn)
(*addOn) (file, result, topLevel, showImplicit, XkmCompatMapIndex,
priv);
fprintf(file, "};\n\n");
return True;
}
Bool
XkbWriteXKBSymbols(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Display *dpy;
register unsigned i, tmp;
XkbDescPtr xkb;
XkbClientMapPtr map;
XkbServerMapPtr srv;
Bool showActions;
xkb = result->xkb;
if ((!xkb) || (!xkb->map) || (!xkb->map->syms) || (!xkb->map->key_sym_map)) {
_XkbLibError(_XkbErrMissingSymbols, "XkbWriteXKBSymbols", 0);
return False;
}
if ((!xkb->names) || (!xkb->names->keys)) {
_XkbLibError(_XkbErrMissingNames, "XkbWriteXKBSymbols", 0);
return False;
}
map = xkb->map;
srv = xkb->server;
dpy = xkb->dpy;
if ((xkb->names == NULL) || (xkb->names->symbols == None))
fprintf(file, "xkb_symbols {\n\n");
else
fprintf(file, "xkb_symbols \"%s\" {\n\n",
XkbAtomText(dpy, xkb->names->symbols, XkbXKBFile));
for (tmp = i = 0; i < XkbNumKbdGroups; i++) {
if (xkb->names->groups[i] != None) {
fprintf(file, " name[group%d]=\"%s\";\n", i + 1,
XkbAtomText(dpy, xkb->names->groups[i], XkbXKBFile));
tmp++;
}
}
if (tmp > 0)
fprintf(file, "\n");
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
Bool simple;
if ((int) XkbKeyNumSyms(xkb, i) < 1)
continue;
if (XkbFindKeycodeByName(xkb, xkb->names->keys[i].name, True) != i)
continue;
simple = True;
fprintf(file, " key %6s {",
XkbKeyNameText(xkb->names->keys[i].name, XkbXKBFile));
if (srv->explicit) {
if (((srv->explicit[i] & XkbExplicitKeyTypesMask) != 0) ||
(showImplicit)) {
int typeNdx, g;
Bool multi;
const char *comment = " ";
if ((srv->explicit[i] & XkbExplicitKeyTypesMask) == 0)
comment = "//";
multi = False;
typeNdx = XkbKeyKeyTypeIndex(xkb, i, 0);
for (g = 1; (g < XkbKeyNumGroups(xkb, i)) && (!multi); g++) {
if (XkbKeyKeyTypeIndex(xkb, i, g) != typeNdx)
multi = True;
}
if (multi) {
for (g = 0; g < XkbKeyNumGroups(xkb, i); g++) {
typeNdx = XkbKeyKeyTypeIndex(xkb, i, g);
if (srv->explicit[i] & (1 << g)) {
fprintf(file, "\n%s type[group%d]= \"%s\",",
comment, g + 1,
XkbAtomText(dpy, map->types[typeNdx].name,
XkbXKBFile));
}
else if (showImplicit) {
fprintf(file, "\n// type[group%d]= \"%s\",",
g + 1,
XkbAtomText(dpy, map->types[typeNdx].name,
XkbXKBFile));
}
}
}
else {
fprintf(file, "\n%s type= \"%s\",", comment,
XkbAtomText(dpy, map->types[typeNdx].name,
XkbXKBFile));
}
simple = False;
}
if (((srv->explicit[i] & XkbExplicitAutoRepeatMask) != 0) &&
(xkb->ctrls != NULL)) {
if (xkb->ctrls->per_key_repeat[i / 8] & (1 << (i % 8)))
fprintf(file, "\n repeat= Yes,");
else
fprintf(file, "\n repeat= No,");
simple = False;
}
if ((xkb->server != NULL) && (xkb->server->vmodmap != NULL) &&
(xkb->server->vmodmap[i] != 0)) {
if ((srv->explicit[i] & XkbExplicitVModMapMask) != 0) {
fprintf(file, "\n virtualMods= %s,",
XkbVModMaskText(dpy, xkb, 0,
xkb->server->vmodmap[i],
XkbXKBFile));
}
else if (showImplicit) {
fprintf(file, "\n// virtualMods= %s,",
XkbVModMaskText(dpy, xkb, 0,
xkb->server->vmodmap[i],
XkbXKBFile));
}
}
}
switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(xkb, i))) {
case XkbClampIntoRange:
fprintf(file, "\n groupsClamp,");
break;
case XkbRedirectIntoRange:
fprintf(file, "\n groupsRedirect= Group%d,",
XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(xkb, i)) + 1);
break;
}
if (srv->behaviors != NULL) {
unsigned type;
type = srv->behaviors[i].type & XkbKB_OpMask;
if (type != XkbKB_Default) {
simple = False;
fprintf(file, "\n %s,",
XkbBehaviorText(xkb, &srv->behaviors[i], XkbXKBFile));
}
}
if ((srv->explicit == NULL) || showImplicit ||
((srv->explicit[i] & XkbExplicitInterpretMask) != 0))
showActions = XkbKeyHasActions(xkb, i);
else
showActions = False;
if (((unsigned) XkbKeyNumGroups(xkb, i) > 1) || showActions)
simple = False;
if (simple) {
KeySym *syms;
unsigned s;
syms = XkbKeySymsPtr(xkb, i);
fprintf(file, " [ ");
for (s = 0; s < XkbKeyGroupWidth(xkb, i, XkbGroup1Index); s++) {
if (s != 0)
fprintf(file, ", ");
fprintf(file, "%15s", XkbKeysymText(*syms++, XkbXKBFile));
}
fprintf(file, " ] };\n");
}
else {
unsigned g, s;
KeySym *syms;
XkbAction *acts;
syms = XkbKeySymsPtr(xkb, i);
acts = XkbKeyActionsPtr(xkb, i);
for (g = 0; g < XkbKeyNumGroups(xkb, i); g++) {
if (g != 0)
fprintf(file, ",");
fprintf(file, "\n symbols[Group%d]= [ ", g + 1);
for (s = 0; s < XkbKeyGroupWidth(xkb, i, g); s++) {
if (s != 0)
fprintf(file, ", ");
fprintf(file, "%15s", XkbKeysymText(syms[s], XkbXKBFile));
}
fprintf(file, " ]");
syms += XkbKeyGroupsWidth(xkb, i);
if (showActions) {
fprintf(file, ",\n actions[Group%d]= [ ", g + 1);
for (s = 0; s < XkbKeyGroupWidth(xkb, i, g); s++) {
if (s != 0)
fprintf(file, ", ");
WriteXKBAction(file, result,
(XkbAnyAction *) & acts[s]);
}
fprintf(file, " ]");
acts += XkbKeyGroupsWidth(xkb, i);
}
}
fprintf(file, "\n };\n");
}
}
if (map && map->modmap) {
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
if (map->modmap[i] != 0) {
register int n, bit;
for (bit = 1, n = 0; n < XkbNumModifiers; n++, bit <<= 1) {
if (map->modmap[i] & bit) {
char buf[5];
memcpy(buf, xkb->names->keys[i].name, 4);
buf[4] = '\0';
fprintf(file, " modifier_map %s { <%s> };\n",
XkbModIndexText(n, XkbXKBFile), buf);
}
}
}
}
}
if (addOn)
(*addOn) (file, result, topLevel, showImplicit, XkmSymbolsIndex, priv);
fprintf(file, "};\n\n");
return True;
}
static Bool
WriteXKBOutline(FILE * file,
XkbShapePtr shape,
XkbOutlinePtr outline,
int lastRadius,
int first,
int indent)
{
register int i;
XkbPointPtr pt;
char *iStr;
fprintf(file, "%s", iStr = XkbIndentText(first));
if (first != indent)
iStr = XkbIndentText(indent);
if (outline->corner_radius != lastRadius) {
fprintf(file, "corner= %s,",
XkbGeomFPText(outline->corner_radius, XkbMessage));
if (shape != NULL) {
fprintf(file, "\n%s", iStr);
}
}
if (shape) {
if (outline == shape->approx)
fprintf(file, "approx= ");
else if (outline == shape->primary)
fprintf(file, "primary= ");
}
fprintf(file, "{");
for (pt = outline->points, i = 0; i < outline->num_points; i++, pt++) {
if (i == 0)
fprintf(file, " ");
else if ((i % 4) == 0)
fprintf(file, ",\n%s ", iStr);
else
fprintf(file, ", ");
fprintf(file, "[ %3s, %3s ]", XkbGeomFPText(pt->x, XkbXKBFile),
XkbGeomFPText(pt->y, XkbXKBFile));
}
fprintf(file, " }");
return True;
}
static Bool
WriteXKBDoodad(FILE * file,
Display * dpy,
unsigned indent,
XkbGeometryPtr geom,
XkbDoodadPtr doodad)
{
register char *i_str;
XkbShapePtr shape;
XkbColorPtr color;
i_str = XkbIndentText(indent);
fprintf(file, "%s%s \"%s\" {\n", i_str,
XkbDoodadTypeText(doodad->any.type, XkbMessage),
XkbAtomText(dpy, doodad->any.name, XkbMessage));
fprintf(file, "%s top= %s;\n", i_str,
XkbGeomFPText(doodad->any.top, XkbXKBFile));
fprintf(file, "%s left= %s;\n", i_str,
XkbGeomFPText(doodad->any.left, XkbXKBFile));
fprintf(file, "%s priority= %d;\n", i_str, doodad->any.priority);
switch (doodad->any.type) {
case XkbOutlineDoodad:
case XkbSolidDoodad:
if (doodad->shape.angle != 0) {
fprintf(file, "%s angle= %s;\n", i_str,
XkbGeomFPText(doodad->shape.angle, XkbXKBFile));
}
if (doodad->shape.color_ndx != 0) {
fprintf(file, "%s color= \"%s\";\n", i_str,
XkbShapeDoodadColor(geom, &doodad->shape)->spec);
}
shape = XkbShapeDoodadShape(geom, &doodad->shape);
fprintf(file, "%s shape= \"%s\";\n", i_str,
XkbAtomText(dpy, shape->name, XkbXKBFile));
break;
case XkbTextDoodad:
if (doodad->text.angle != 0) {
fprintf(file, "%s angle= %s;\n", i_str,
XkbGeomFPText(doodad->text.angle, XkbXKBFile));
}
if (doodad->text.width != 0) {
fprintf(file, "%s width= %s;\n", i_str,
XkbGeomFPText(doodad->text.width, XkbXKBFile));
}
if (doodad->text.height != 0) {
fprintf(file, "%s height= %s;\n", i_str,
XkbGeomFPText(doodad->text.height, XkbXKBFile));
}
if (doodad->text.color_ndx != 0) {
color = XkbTextDoodadColor(geom, &doodad->text);
fprintf(file, "%s color= \"%s\";\n", i_str,
XkbStringText(color->spec, XkbXKBFile));
}
fprintf(file, "%s XFont= \"%s\";\n", i_str,
XkbStringText(doodad->text.font, XkbXKBFile));
fprintf(file, "%s text= \"%s\";\n", i_str,
XkbStringText(doodad->text.text, XkbXKBFile));
break;
case XkbIndicatorDoodad:
shape = XkbIndicatorDoodadShape(geom, &doodad->indicator);
color = XkbIndicatorDoodadOnColor(geom, &doodad->indicator);
fprintf(file, "%s onColor= \"%s\";\n", i_str,
XkbStringText(color->spec, XkbXKBFile));
color = XkbIndicatorDoodadOffColor(geom, &doodad->indicator);
fprintf(file, "%s offColor= \"%s\";\n", i_str,
XkbStringText(color->spec, XkbXKBFile));
fprintf(file, "%s shape= \"%s\";\n", i_str,
XkbAtomText(dpy, shape->name, XkbXKBFile));
break;
case XkbLogoDoodad:
fprintf(file, "%s logoName= \"%s\";\n", i_str,
XkbStringText(doodad->logo.logo_name, XkbXKBFile));
if (doodad->shape.angle != 0) {
fprintf(file, "%s angle= %s;\n", i_str,
XkbGeomFPText(doodad->logo.angle, XkbXKBFile));
}
if (doodad->shape.color_ndx != 0) {
fprintf(file, "%s color= \"%s\";\n", i_str,
XkbLogoDoodadColor(geom, &doodad->logo)->spec);
}
shape = XkbLogoDoodadShape(geom, &doodad->logo);
fprintf(file, "%s shape= \"%s\";\n", i_str,
XkbAtomText(dpy, shape->name, XkbXKBFile));
break;
}
fprintf(file, "%s};\n", i_str);
return True;
}
/*ARGSUSED*/
static Bool
WriteXKBOverlay(FILE * file,
Display * dpy,
unsigned indent,
XkbGeometryPtr geom,
XkbOverlayPtr ol)
{
register char *i_str;
int r, k, nOut;
XkbOverlayRowPtr row;
XkbOverlayKeyPtr key;
i_str = XkbIndentText(indent);
if (ol->name != None) {
fprintf(file, "%soverlay \"%s\" {\n", i_str,
XkbAtomText(dpy, ol->name, XkbMessage));
}
else
fprintf(file, "%soverlay {\n", i_str);
for (nOut = r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
char *over, *under;
over = XkbKeyNameText(key->over.name, XkbXKBFile);
under = XkbKeyNameText(key->under.name, XkbXKBFile);
if (nOut == 0)
fprintf(file, "%s %6s=%6s", i_str, under, over);
else if ((nOut % 4) == 0)
fprintf(file, ",\n%s %6s=%6s", i_str, under, over);
else
fprintf(file, ", %6s=%6s", under, over);
nOut++;
}
}
fprintf(file, "\n%s};\n", i_str);
return True;
}
static Bool
WriteXKBSection(FILE * file,
Display * dpy,
XkbSectionPtr s,
XkbGeometryPtr geom)
{
register int i;
XkbRowPtr row;
int dfltKeyColor = 0;
fprintf(file, " section \"%s\" {\n",
XkbAtomText(dpy, s->name, XkbXKBFile));
if (s->rows && (s->rows->num_keys > 0)) {
dfltKeyColor = s->rows->keys[0].color_ndx;
fprintf(file, " key.color= \"%s\";\n",
XkbStringText(geom->colors[dfltKeyColor].spec, XkbXKBFile));
}
fprintf(file, " priority= %d;\n", s->priority);
fprintf(file, " top= %s;\n",
XkbGeomFPText(s->top, XkbXKBFile));
fprintf(file, " left= %s;\n",
XkbGeomFPText(s->left, XkbXKBFile));
fprintf(file, " width= %s;\n",
XkbGeomFPText(s->width, XkbXKBFile));
fprintf(file, " height= %s;\n",
XkbGeomFPText(s->height, XkbXKBFile));
if (s->angle != 0) {
fprintf(file, " angle= %s;\n",
XkbGeomFPText(s->angle, XkbXKBFile));
}
for (i = 0, row = s->rows; row && i < s->num_rows; i++, row++) {
fprintf(file, " row {\n");
fprintf(file, " top= %s;\n",
XkbGeomFPText(row->top, XkbXKBFile));
fprintf(file, " left= %s;\n",
XkbGeomFPText(row->left, XkbXKBFile));
if (row->vertical)
fprintf(file, " vertical;\n");
if (row->num_keys > 0) {
register int k;
register XkbKeyPtr key;
int forceNL = 0;
int nThisLine = 0;
fprintf(file, " keys {\n");
for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
XkbShapePtr shape;
if (key->color_ndx != dfltKeyColor)
forceNL = 1;
if (k == 0) {
fprintf(file, " ");
nThisLine = 0;
}
else if (((nThisLine % 2) == 1) || (forceNL)) {
fprintf(file, ",\n ");
forceNL = nThisLine = 0;
}
else {
fprintf(file, ", ");
nThisLine++;
}
shape = XkbKeyShape(geom, key);
fprintf(file, "{ %6s, \"%s\", %3s",
XkbKeyNameText(key->name.name, XkbXKBFile),
XkbAtomText(dpy, shape->name, XkbXKBFile),
XkbGeomFPText(key->gap, XkbXKBFile));
if (key->color_ndx != dfltKeyColor) {
fprintf(file, ", color=\"%s\"",
XkbKeyColor(geom, key)->spec);
forceNL = 1;
}
fprintf(file, " }");
}
fprintf(file, "\n };\n");
}
fprintf(file, " };\n");
}
if (s->doodads != NULL) {
XkbDoodadPtr doodad;
for (i = 0, doodad = s->doodads; i < s->num_doodads; i++, doodad++) {
WriteXKBDoodad(file, dpy, 8, geom, doodad);
}
}
if (s->overlays != NULL) {
XkbOverlayPtr ol;
for (i = 0, ol = s->overlays; i < s->num_overlays; i++, ol++) {
WriteXKBOverlay(file, dpy, 8, geom, ol);
}
}
fprintf(file, " }; // End of \"%s\" section\n\n",
XkbAtomText(dpy, s->name, XkbXKBFile));
return True;
}
Bool
XkbWriteXKBGeometry(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Display *dpy;
register unsigned i, n;
XkbDescPtr xkb;
XkbGeometryPtr geom;
xkb = result->xkb;
if ((!xkb) || (!xkb->geom)) {
_XkbLibError(_XkbErrMissingGeometry, "XkbWriteXKBGeometry", 0);
return False;
}
dpy = xkb->dpy;
geom = xkb->geom;
if (geom->name == None)
fprintf(file, "xkb_geometry {\n\n");
else
fprintf(file, "xkb_geometry \"%s\" {\n\n",
XkbAtomText(dpy, geom->name, XkbXKBFile));
fprintf(file, " width= %s;\n",
XkbGeomFPText(geom->width_mm, XkbXKBFile));
fprintf(file, " height= %s;\n\n",
XkbGeomFPText(geom->height_mm, XkbXKBFile));
if (geom->key_aliases != NULL) {
XkbKeyAliasPtr pAl;
pAl = geom->key_aliases;
for (i = 0; i < geom->num_key_aliases; i++, pAl++) {
fprintf(file, " alias %6s = %6s;\n",
XkbKeyNameText(pAl->alias, XkbXKBFile),
XkbKeyNameText(pAl->real, XkbXKBFile));
}
fprintf(file, "\n");
}
if (geom->base_color != NULL)
fprintf(file, " baseColor= \"%s\";\n",
XkbStringText(geom->base_color->spec, XkbXKBFile));
if (geom->label_color != NULL)
fprintf(file, " labelColor= \"%s\";\n",
XkbStringText(geom->label_color->spec, XkbXKBFile));
if (geom->label_font != NULL)
fprintf(file, " xfont= \"%s\";\n",
XkbStringText(geom->label_font, XkbXKBFile));
if ((geom->num_colors > 0) && (showImplicit)) {
XkbColorPtr color;
for (color = geom->colors, i = 0; i < geom->num_colors; i++, color++) {
fprintf(file, "// color[%d]= \"%s\"\n", i,
XkbStringText(color->spec, XkbXKBFile));
}
fprintf(file, "\n");
}
if (geom->num_properties > 0) {
XkbPropertyPtr prop;
for (prop = geom->properties, i = 0; i < geom->num_properties;
i++, prop++) {
fprintf(file, " %s= \"%s\";\n", prop->name,
XkbStringText(prop->value, XkbXKBFile));
}
fprintf(file, "\n");
}
if (geom->num_shapes > 0) {
XkbShapePtr shape;
XkbOutlinePtr outline;
int lastR;
for (shape = geom->shapes, i = 0; i < geom->num_shapes; i++, shape++) {
lastR = 0;
fprintf(file, " shape \"%s\" {",
XkbAtomText(dpy, shape->name, XkbXKBFile));
outline = shape->outlines;
if (shape->num_outlines > 1) {
for (n = 0; n < shape->num_outlines; n++, outline++) {
if (n == 0)
fprintf(file, "\n");
else
fprintf(file, ",\n");
WriteXKBOutline(file, shape, outline, lastR, 8, 8);
lastR = outline->corner_radius;
}
fprintf(file, "\n };\n");
}
else {
WriteXKBOutline(file, NULL, outline, lastR, 1, 8);
fprintf(file, " };\n");
}
}
}
if (geom->num_sections > 0) {
XkbSectionPtr section;
for (section = geom->sections, i = 0; i < geom->num_sections;
i++, section++) {
WriteXKBSection(file, dpy, section, geom);
}
}
if (geom->num_doodads > 0) {
XkbDoodadPtr doodad;
for (i = 0, doodad = geom->doodads; i < geom->num_doodads;
i++, doodad++) {
WriteXKBDoodad(file, dpy, 4, geom, doodad);
}
}
if (addOn)
(*addOn) (file, result, topLevel, showImplicit, XkmGeometryIndex, priv);
fprintf(file, "};\n\n");
return True;
}
/*ARGSUSED*/
Bool
XkbWriteXKBSemantics(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Bool ok;
fprintf(file, "xkb_semantics {\n");
ok = XkbWriteXKBKeyTypes(file, result, False, False, addOn, priv);
ok = ok && XkbWriteXKBCompatMap(file, result, False, False, addOn, priv);
fprintf(file, "};\n");
return ok;
}
/*ARGSUSED*/
Bool
XkbWriteXKBLayout(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Bool ok;
XkbDescPtr xkb;
xkb = result->xkb;
fprintf(file, "xkb_layout {\n");
ok = XkbWriteXKBKeycodes(file, result, False, showImplicit, addOn, priv);
ok = ok &&
XkbWriteXKBKeyTypes(file, result, False, showImplicit, addOn, priv);
ok = ok &&
XkbWriteXKBSymbols(file, result, False, showImplicit, addOn, priv);
if (xkb->geom)
ok = ok &&
XkbWriteXKBGeometry(file, result, False, showImplicit, addOn, priv);
fprintf(file, "};\n");
return ok;
}
/*ARGSUSED*/
Bool
XkbWriteXKBKeymap(FILE * file,
XkbFileInfo * result,
Bool topLevel,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Bool ok;
XkbDescPtr xkb;
xkb = result->xkb;
fprintf(file, "xkb_keymap {\n");
ok = XkbWriteXKBKeycodes(file, result, False, showImplicit, addOn, priv);
ok = ok &&
XkbWriteXKBKeyTypes(file, result, False, showImplicit, addOn, priv);
ok = ok &&
XkbWriteXKBCompatMap(file, result, False, showImplicit, addOn, priv);
ok = ok &&
XkbWriteXKBSymbols(file, result, False, showImplicit, addOn, priv);
if (xkb->geom)
ok = ok &&
XkbWriteXKBGeometry(file, result, False, showImplicit, addOn, priv);
fprintf(file, "};\n");
return ok;
}
Bool
XkbWriteXKBFile(FILE * out,
XkbFileInfo * result,
Bool showImplicit,
XkbFileAddOnFunc addOn,
void * priv)
{
Bool ok = False;
Bool (*func) (FILE * /* file */ ,
XkbFileInfo * /* result */ ,
Bool /* topLevel */ ,
Bool /* showImplicit */ ,
XkbFileAddOnFunc /* addOn */ ,
void * /* priv */
) = NULL;
switch (result->type) {
case XkmSemanticsFile:
func = XkbWriteXKBSemantics;
break;
case XkmLayoutFile:
func = XkbWriteXKBLayout;
break;
case XkmKeymapFile:
func = XkbWriteXKBKeymap;
break;
case XkmTypesIndex:
func = XkbWriteXKBKeyTypes;
break;
case XkmCompatMapIndex:
func = XkbWriteXKBCompatMap;
break;
case XkmSymbolsIndex:
func = XkbWriteXKBSymbols;
break;
case XkmKeyNamesIndex:
func = XkbWriteXKBKeycodes;
break;
case XkmGeometryFile:
case XkmGeometryIndex:
func = XkbWriteXKBGeometry;
break;
case XkmVirtualModsIndex:
case XkmIndicatorsIndex:
_XkbLibError(_XkbErrBadImplementation,
XkbConfigText(result->type, XkbMessage), 0);
return False;
}
if (out == NULL) {
_XkbLibError(_XkbErrFileCannotOpen, "XkbWriteXkbFile", 0);
ok = False;
}
else if (func) {
ok = (*func) (out, result, True, showImplicit, addOn, priv);
}
return ok;
}
s;\n",
XkbGeomFPText(row->left, XkbXKBFile));
if (row->vertical)
fprintf(file, " vertical;\n");
if (row->num_keys > 0) {
register int k;
register XkbKeyPtr key;
int forceNL = 0;
int nThisLine = 0;
fprintf(file, " keys {\n");
for (k = 0, key = row->keys; k