diff options
Diffstat (limited to 'libXmu')
74 files changed, 14771 insertions, 14717 deletions
diff --git a/libXmu/Makefile.am b/libXmu/Makefile.am index 9a875e369..8edc16bf0 100644 --- a/libXmu/Makefile.am +++ b/libXmu/Makefile.am @@ -1,22 +1,22 @@ -SUBDIRS = include src doc - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = xmu.pc xmuu.pc - -MAINTAINERCLEANFILES = ChangeLog INSTALL - -.PHONY: ChangeLog INSTALL - -INSTALL: - $(INSTALL_CMD) - -ChangeLog: - $(CHANGELOG_CMD) - -dist-hook: ChangeLog INSTALL - -if LINT -# Check source code with tools like lint & sparse -lint: - (cd src && $(MAKE) $(MFLAGS) lint) -endif LINT +SUBDIRS = include src doc
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xmu.pc xmuu.pc
+
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+ $(INSTALL_CMD)
+
+ChangeLog:
+ $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
+
+if LINT
+# Check source code with tools like lint & sparse
+lint:
+ (cd src && $(MAKE) $(MFLAGS) lint)
+endif LINT
diff --git a/libXmu/README b/libXmu/README index dbf260e11..ff4cea339 100644 --- a/libXmu/README +++ b/libXmu/README @@ -1,37 +1,37 @@ -This library contains miscellaneous utilities and is not part of the Xlib -standard. It contains routines which only use public interfaces so that it -may be layered on top of any proprietary implementation of Xlib or Xt. - -It is intended to support clients in the X.Org distribution; vendors -may choose not to distribute this library if they wish. Therefore, -applications developers who depend on this library should be prepared to -treat it as part of their software base when porting. - -API documentation for this library is provided in the docs directory in -DocBook format. If xmlto is installed, it will be converted to supported -formats and installed in $(docdir) unless --disable-docs is passed to -configure. - -All questions regarding this software should be directed at the -Xorg mailing list: - - http://lists.freedesktop.org/mailman/listinfo/xorg - -Please submit bug reports to the Xorg bugzilla: - - https://bugs.freedesktop.org/enter_bug.cgi?product=xorg - -The master development code repository can be found at: - - git://anongit.freedesktop.org/git/xorg/lib/libXmu - - http://cgit.freedesktop.org/xorg/lib/libXmu - -For patch submission instructions, see: - - http://www.x.org/wiki/Development/Documentation/SubmittingPatches - -For more information on the git code manager, see: - - http://wiki.x.org/wiki/GitPage - +This library contains miscellaneous utilities and is not part of the Xlib
+standard. It contains routines which only use public interfaces so that it
+may be layered on top of any proprietary implementation of Xlib or Xt.
+
+It is intended to support clients in the X.Org distribution; vendors
+may choose not to distribute this library if they wish. Therefore,
+applications developers who depend on this library should be prepared to
+treat it as part of their software base when porting.
+
+API documentation for this library is provided in the docs directory in
+DocBook format. If xmlto is installed, it will be converted to supported
+formats and installed in $(docdir) unless --disable-docs is passed to
+configure.
+
+All questions regarding this software should be directed at the
+Xorg mailing list:
+
+ http://lists.freedesktop.org/mailman/listinfo/xorg
+
+Please submit bug reports to the Xorg bugzilla:
+
+ https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+
+The master development code repository can be found at:
+
+ git://anongit.freedesktop.org/git/xorg/lib/libXmu
+
+ http://cgit.freedesktop.org/xorg/lib/libXmu
+
+For patch submission instructions, see:
+
+ http://www.x.org/wiki/Development/Documentation/SubmittingPatches
+
+For more information on the git code manager, see:
+
+ http://wiki.x.org/wiki/GitPage
+
diff --git a/libXmu/configure.ac b/libXmu/configure.ac index 880fc5a2e..0e2b64e92 100644 --- a/libXmu/configure.ac +++ b/libXmu/configure.ac @@ -1,46 +1,46 @@ - -# Initialize Autoconf -AC_PREREQ([2.60]) -AC_INIT([libXmu], [1.1.0], - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXmu]) -AC_CONFIG_SRCDIR([Makefile.am]) -AC_CONFIG_HEADERS([config.h]) - -# Initialize Automake -AM_INIT_AUTOMAKE([foreign dist-bzip2]) -AM_MAINTAINER_MODE - -# Initialize libtool -AC_PROG_LIBTOOL - -# Require xorg-macros minimum of 1.10 for HAVE_STYLESHEETS in XORG_CHECK_SGML_DOCTOOLS -m4_ifndef([XORG_MACROS_VERSION], - [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) -XORG_MACROS_VERSION(1.10) -XORG_DEFAULT_OPTIONS -XORG_ENABLE_DOCS -XORG_WITH_XMLTO(0.0.20) -XORG_WITH_FOP -XORG_CHECK_SGML_DOCTOOLS(1.5) - -# Obtain compiler/linker options for depedencies -PKG_CHECK_MODULES(XMU, xt xext x11 xextproto) -PKG_CHECK_MODULES(XMUU, x11) - -# CvtStdSel.c needs to know which network transports to build hostname -# conversion routines for -XTRANS_CONNECTION_FLAGS - -# Allow checking code with lint, sparse, etc. -XORG_WITH_LINT -XORG_LINT_LIBRARY([Xmu]) -LINTLIBUU=`echo $LINTLIB | sed s/Xmu/Xmuu/` -AC_SUBST(LINTLIBUU) - -AC_CONFIG_FILES([Makefile - doc/Makefile - include/Makefile - src/Makefile - xmu.pc - xmuu.pc]) -AC_OUTPUT +
+# Initialize Autoconf
+AC_PREREQ([2.60])
+AC_INIT([libXmu], [1.1.0],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXmu])
+AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_HEADERS([config.h])
+
+# Initialize Automake
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+# Initialize libtool
+AC_PROG_LIBTOOL
+
+# Require xorg-macros minimum of 1.10 for HAVE_STYLESHEETS in XORG_CHECK_SGML_DOCTOOLS
+m4_ifndef([XORG_MACROS_VERSION],
+ [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.10)
+XORG_DEFAULT_OPTIONS
+XORG_ENABLE_DOCS
+XORG_WITH_XMLTO(0.0.20)
+XORG_WITH_FOP
+XORG_CHECK_SGML_DOCTOOLS(1.5)
+
+# Obtain compiler/linker options for depedencies
+PKG_CHECK_MODULES(XMU, xt xext x11 xextproto)
+PKG_CHECK_MODULES(XMUU, x11)
+
+# CvtStdSel.c needs to know which network transports to build hostname
+# conversion routines for
+XTRANS_CONNECTION_FLAGS
+
+# Allow checking code with lint, sparse, etc.
+XORG_WITH_LINT
+XORG_LINT_LIBRARY([Xmu])
+LINTLIBUU=`echo $LINTLIB | sed s/Xmu/Xmuu/`
+AC_SUBST(LINTLIBUU)
+
+AC_CONFIG_FILES([Makefile
+ doc/Makefile
+ include/Makefile
+ src/Makefile
+ xmu.pc
+ xmuu.pc])
+AC_OUTPUT
diff --git a/libXmu/include/Makefile.am b/libXmu/include/Makefile.am index 413dd5b87..9c1276904 100644 --- a/libXmu/include/Makefile.am +++ b/libXmu/include/Makefile.am @@ -1,25 +1,25 @@ -xmuincludedir=${includedir}/X11/Xmu -xmuinclude_HEADERS = \ - X11/Xmu/Xmu.h \ - X11/Xmu/Atoms.h \ - X11/Xmu/CharSet.h \ - X11/Xmu/CloseHook.h \ - X11/Xmu/Converters.h \ - X11/Xmu/CurUtil.h \ - X11/Xmu/CvtCache.h \ - X11/Xmu/DisplayQue.h \ - X11/Xmu/Drawing.h \ - X11/Xmu/Editres.h \ - X11/Xmu/EditresP.h \ - X11/Xmu/Error.h \ - X11/Xmu/ExtAgent.h \ - X11/Xmu/Initer.h \ - X11/Xmu/Lookup.h \ - X11/Xmu/Misc.h \ - X11/Xmu/StdSel.h \ - X11/Xmu/StdCmap.h \ - X11/Xmu/SysUtil.h \ - X11/Xmu/WidgetNode.h \ - X11/Xmu/WinUtil.h \ - X11/Xmu/Xct.h \ - X11/Xmu/WhitePoint.h +xmuincludedir=${includedir}/X11/Xmu
+xmuinclude_HEADERS = \
+ X11/Xmu/Xmu.h \
+ X11/Xmu/Atoms.h \
+ X11/Xmu/CharSet.h \
+ X11/Xmu/CloseHook.h \
+ X11/Xmu/Converters.h \
+ X11/Xmu/CurUtil.h \
+ X11/Xmu/CvtCache.h \
+ X11/Xmu/DisplayQue.h \
+ X11/Xmu/Drawing.h \
+ X11/Xmu/Editres.h \
+ X11/Xmu/EditresP.h \
+ X11/Xmu/Error.h \
+ X11/Xmu/ExtAgent.h \
+ X11/Xmu/Initer.h \
+ X11/Xmu/Lookup.h \
+ X11/Xmu/Misc.h \
+ X11/Xmu/StdSel.h \
+ X11/Xmu/StdCmap.h \
+ X11/Xmu/SysUtil.h \
+ X11/Xmu/WidgetNode.h \
+ X11/Xmu/WinUtil.h \
+ X11/Xmu/Xct.h \
+ X11/Xmu/WhitePoint.h
diff --git a/libXmu/include/X11/Xmu/Atoms.h b/libXmu/include/X11/Xmu/Atoms.h index 3d8691025..2292edb4a 100644 --- a/libXmu/include/X11/Xmu/Atoms.h +++ b/libXmu/include/X11/Xmu/Atoms.h @@ -1,123 +1,123 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_ATOMS_H_ -#define _XMU_ATOMS_H_ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -typedef struct _AtomRec *AtomPtr; - -extern AtomPtr - _XA_ATOM_PAIR, - _XA_CHARACTER_POSITION, - _XA_CLASS, - _XA_CLIENT_WINDOW, - _XA_CLIPBOARD, - _XA_COMPOUND_TEXT, - _XA_DECNET_ADDRESS, - _XA_DELETE, - _XA_FILENAME, - _XA_HOSTNAME, - _XA_IP_ADDRESS, - _XA_LENGTH, - _XA_LIST_LENGTH, - _XA_NAME, - _XA_NET_ADDRESS, - _XA_NULL, - _XA_OWNER_OS, - _XA_SPAN, - _XA_TARGETS, - _XA_TEXT, - _XA_TIMESTAMP, - _XA_USER, - _XA_UTF8_STRING; - -#define XA_ATOM_PAIR(d) XmuInternAtom(d, _XA_ATOM_PAIR) -#define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION) -#define XA_CLASS(d) XmuInternAtom(d, _XA_CLASS) -#define XA_CLIENT_WINDOW(d) XmuInternAtom(d, _XA_CLIENT_WINDOW) -#define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD) -#define XA_COMPOUND_TEXT(d) XmuInternAtom(d, _XA_COMPOUND_TEXT) -#define XA_DECNET_ADDRESS(d) XmuInternAtom(d, _XA_DECNET_ADDRESS) -#define XA_DELETE(d) XmuInternAtom(d, _XA_DELETE) -#define XA_FILENAME(d) XmuInternAtom(d, _XA_FILENAME) -#define XA_HOSTNAME(d) XmuInternAtom(d, _XA_HOSTNAME) -#define XA_IP_ADDRESS(d) XmuInternAtom(d, _XA_IP_ADDRESS) -#define XA_LENGTH(d) XmuInternAtom(d, _XA_LENGTH) -#define XA_LIST_LENGTH(d) XmuInternAtom(d, _XA_LIST_LENGTH) -#define XA_NAME(d) XmuInternAtom(d, _XA_NAME) -#define XA_NET_ADDRESS(d) XmuInternAtom(d, _XA_NET_ADDRESS) -#define XA_NULL(d) XmuInternAtom(d, _XA_NULL) -#define XA_OWNER_OS(d) XmuInternAtom(d, _XA_OWNER_OS) -#define XA_SPAN(d) XmuInternAtom(d, _XA_SPAN) -#define XA_TARGETS(d) XmuInternAtom(d, _XA_TARGETS) -#define XA_TEXT(d) XmuInternAtom(d, _XA_TEXT) -#define XA_TIMESTAMP(d) XmuInternAtom(d, _XA_TIMESTAMP) -#define XA_USER(d) XmuInternAtom(d, _XA_USER) -#define XA_UTF8_STRING(d) XmuInternAtom(d, _XA_UTF8_STRING) - -_XFUNCPROTOBEGIN - -char *XmuGetAtomName -( - Display *dpy, - Atom atom - ); - -Atom XmuInternAtom -( - Display *dpy, - AtomPtr atom_ptr - ); - -void XmuInternStrings -( - Display *dpy, - String *names, - Cardinal count, - Atom *atoms_return -); - -AtomPtr XmuMakeAtom -( - _Xconst char *name - ); - -char *XmuNameOfAtom -( - AtomPtr atom_ptr - ); - -_XFUNCPROTOEND - -#endif /* _XMU_ATOMS_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ATOMS_H_
+#define _XMU_ATOMS_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _AtomRec *AtomPtr;
+
+extern AtomPtr
+ _XA_ATOM_PAIR,
+ _XA_CHARACTER_POSITION,
+ _XA_CLASS,
+ _XA_CLIENT_WINDOW,
+ _XA_CLIPBOARD,
+ _XA_COMPOUND_TEXT,
+ _XA_DECNET_ADDRESS,
+ _XA_DELETE,
+ _XA_FILENAME,
+ _XA_HOSTNAME,
+ _XA_IP_ADDRESS,
+ _XA_LENGTH,
+ _XA_LIST_LENGTH,
+ _XA_NAME,
+ _XA_NET_ADDRESS,
+ _XA_NULL,
+ _XA_OWNER_OS,
+ _XA_SPAN,
+ _XA_TARGETS,
+ _XA_TEXT,
+ _XA_TIMESTAMP,
+ _XA_USER,
+ _XA_UTF8_STRING;
+
+#define XA_ATOM_PAIR(d) XmuInternAtom(d, _XA_ATOM_PAIR)
+#define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION)
+#define XA_CLASS(d) XmuInternAtom(d, _XA_CLASS)
+#define XA_CLIENT_WINDOW(d) XmuInternAtom(d, _XA_CLIENT_WINDOW)
+#define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD)
+#define XA_COMPOUND_TEXT(d) XmuInternAtom(d, _XA_COMPOUND_TEXT)
+#define XA_DECNET_ADDRESS(d) XmuInternAtom(d, _XA_DECNET_ADDRESS)
+#define XA_DELETE(d) XmuInternAtom(d, _XA_DELETE)
+#define XA_FILENAME(d) XmuInternAtom(d, _XA_FILENAME)
+#define XA_HOSTNAME(d) XmuInternAtom(d, _XA_HOSTNAME)
+#define XA_IP_ADDRESS(d) XmuInternAtom(d, _XA_IP_ADDRESS)
+#define XA_LENGTH(d) XmuInternAtom(d, _XA_LENGTH)
+#define XA_LIST_LENGTH(d) XmuInternAtom(d, _XA_LIST_LENGTH)
+#define XA_NAME(d) XmuInternAtom(d, _XA_NAME)
+#define XA_NET_ADDRESS(d) XmuInternAtom(d, _XA_NET_ADDRESS)
+#define XA_NULL(d) XmuInternAtom(d, _XA_NULL)
+#define XA_OWNER_OS(d) XmuInternAtom(d, _XA_OWNER_OS)
+#define XA_SPAN(d) XmuInternAtom(d, _XA_SPAN)
+#define XA_TARGETS(d) XmuInternAtom(d, _XA_TARGETS)
+#define XA_TEXT(d) XmuInternAtom(d, _XA_TEXT)
+#define XA_TIMESTAMP(d) XmuInternAtom(d, _XA_TIMESTAMP)
+#define XA_USER(d) XmuInternAtom(d, _XA_USER)
+#define XA_UTF8_STRING(d) XmuInternAtom(d, _XA_UTF8_STRING)
+
+_XFUNCPROTOBEGIN
+
+char *XmuGetAtomName
+(
+ Display *dpy,
+ Atom atom
+ );
+
+Atom XmuInternAtom
+(
+ Display *dpy,
+ AtomPtr atom_ptr
+ );
+
+void XmuInternStrings
+(
+ Display *dpy,
+ String *names,
+ Cardinal count,
+ Atom *atoms_return
+);
+
+AtomPtr XmuMakeAtom
+(
+ _Xconst char *name
+ );
+
+char *XmuNameOfAtom
+(
+ AtomPtr atom_ptr
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ATOMS_H_ */
diff --git a/libXmu/include/X11/Xmu/CharSet.h b/libXmu/include/X11/Xmu/CharSet.h index 1ce9166a0..8bf4b7b4c 100644 --- a/libXmu/include/X11/Xmu/CharSet.h +++ b/libXmu/include/X11/Xmu/CharSet.h @@ -1,73 +1,73 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_CHARSET_H_ -#define _XMU_CHARSET_H_ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -void XmuCopyISOLatin1Lowered -( - char *dst_return, - _Xconst char *src - ); - -void XmuCopyISOLatin1Uppered -( - char *dst_return, - _Xconst char *src - ); - -int XmuCompareISOLatin1 -( - _Xconst char *first, - _Xconst char *second - ); - -void XmuNCopyISOLatin1Lowered -( - char *dst_return, - _Xconst char *src, - int size - ); - -void XmuNCopyISOLatin1Uppered -( - char *dst_return, - _Xconst char *src, - int size - ); - -_XFUNCPROTOEND - -#endif /* _XMU_CHARSET_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CHARSET_H_
+#define _XMU_CHARSET_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void XmuCopyISOLatin1Lowered
+(
+ char *dst_return,
+ _Xconst char *src
+ );
+
+void XmuCopyISOLatin1Uppered
+(
+ char *dst_return,
+ _Xconst char *src
+ );
+
+int XmuCompareISOLatin1
+(
+ _Xconst char *first,
+ _Xconst char *second
+ );
+
+void XmuNCopyISOLatin1Lowered
+(
+ char *dst_return,
+ _Xconst char *src,
+ int size
+ );
+
+void XmuNCopyISOLatin1Uppered
+(
+ char *dst_return,
+ _Xconst char *src,
+ int size
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CHARSET_H_ */
diff --git a/libXmu/include/X11/Xmu/CloseHook.h b/libXmu/include/X11/Xmu/CloseHook.h index 2481ebf3e..cbe1857bb 100644 --- a/libXmu/include/X11/Xmu/CloseHook.h +++ b/libXmu/include/X11/Xmu/CloseHook.h @@ -1,70 +1,70 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_CLOSEHOOK_H_ -#define _XMU_CLOSEHOOK_H_ - -#include <X11/Xlib.h> -#include <X11/Xfuncproto.h> -#include <X11/Xlibint.h> - -typedef XPointer CloseHook; - -typedef int (*XmuCloseHookProc)(Display *dpy, XPointer data); - -_XFUNCPROTOBEGIN - -CloseHook XmuAddCloseDisplayHook -( - Display *dpy, - XmuCloseHookProc proc, - XPointer arg - ); - -Bool XmuLookupCloseDisplayHook -( - Display *dpy, - CloseHook handle, - XmuCloseHookProc proc, - XPointer arg - ); - -Bool XmuRemoveCloseDisplayHook -( - Display *dpy, - CloseHook handle, - XmuCloseHookProc proc, - XPointer arg - ); - -_XFUNCPROTOEND - -#endif /* _XMU_CLOSEHOOK_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CLOSEHOOK_H_
+#define _XMU_CLOSEHOOK_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xlibint.h>
+
+typedef XPointer CloseHook;
+
+typedef int (*XmuCloseHookProc)(Display *dpy, XPointer data);
+
+_XFUNCPROTOBEGIN
+
+CloseHook XmuAddCloseDisplayHook
+(
+ Display *dpy,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+Bool XmuLookupCloseDisplayHook
+(
+ Display *dpy,
+ CloseHook handle,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+Bool XmuRemoveCloseDisplayHook
+(
+ Display *dpy,
+ CloseHook handle,
+ XmuCloseHookProc proc,
+ XPointer arg
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CLOSEHOOK_H_ */
diff --git a/libXmu/include/X11/Xmu/Converters.h b/libXmu/include/X11/Xmu/Converters.h index 3779750c6..083fdebbf 100644 --- a/libXmu/include/X11/Xmu/Converters.h +++ b/libXmu/include/X11/Xmu/Converters.h @@ -1,277 +1,277 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_STRCONVERT_H_ -#define _XMU_STRCONVERT_H_ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -void XmuCvtFunctionToCallback -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -#define XtNbackingStore "backingStore" -#define XtCBackingStore "BackingStore" -#define XtRBackingStore "BackingStore" -#define XtEnotUseful "notUseful" -#define XtEwhenMapped "whenMapped" -#define XtEalways "always" -#define XtEdefault "default" -void XmuCvtStringToBackingStore -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -Boolean XmuCvtBackingStoreToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -void XmuCvtStringToCursor -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -#define XtRColorCursor "ColorCursor" -#define XtNpointerColor "pointerColor" -#define XtNpointerColorBackground "pointerColorBackground" -Boolean XmuCvtStringToColorCursor -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -typedef int XtGravity; - -#ifndef XtRGravity -#define XtRGravity "Gravity" -#endif -#define XtEForget "forget" -#define XtENorthWest "northwest" -#define XtENorth "north" -#define XtENorthEast "northeast" -#define XtEWest "west" -#define XtECenter "center" -#define XtEEast "east" -#define XtESouthWest "southwest" -#define XtESouth "south" -#define XtESouthEast "southeast" -#define XtEStatic "static" -#define XtEUnmap "unmap" -void XmuCvtStringToGravity -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -Boolean XmuCvtGravityToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -typedef enum { - XtJustifyLeft, /* justify text to left side of button */ - XtJustifyCenter, /* justify text in center of button */ - XtJustifyRight /* justify text to right side of button */ -} XtJustify; -#ifndef XtRJustify -#define XtRJustify "Justify" -#endif -#define XtEleft "left" -#define XtEcenter "center" -#define XtEright "right" -#define XtEtop "top" -#define XtEbottom "bottom" -void XmuCvtStringToJustify -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -Boolean XmuCvtJustifyToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -#define XtRLong "Long" -void XmuCvtStringToLong -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); -Boolean XmuCvtLongToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -typedef enum { - XtorientHorizontal, - XtorientVertical -} XtOrientation; -void XmuCvtStringToOrientation -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -Boolean XmuCvtOrientationToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -void XmuCvtStringToBitmap -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -#define XtRShapeStyle "ShapeStyle" -#define XtERectangle "Rectangle" -#define XtEOval "Oval" -#define XtEEllipse "Ellipse" -#define XtERoundedRectangle "RoundedRectangle" - -#define XmuShapeRectangle 1 -#define XmuShapeOval 2 -#define XmuShapeEllipse 3 -#define XmuShapeRoundedRectangle 4 - -Boolean XmuCvtStringToShapeStyle -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -Boolean XmuCvtShapeStyleToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal, - XtPointer *converter_data - ); - -Boolean XmuReshapeWidget -( - Widget w, - int shape_style, - int corner_width, - int corner_height - ); - -void XmuCvtStringToWidget -( - XrmValue *args, - Cardinal *num_args, - XrmValuePtr fromVal, - XrmValuePtr toVal - ); - -Boolean XmuNewCvtStringToWidget -( - Display *display, - XrmValue *args, - Cardinal *num_args, - XrmValue *fromVal, - XrmValue *toVal, - XtPointer *converter_data - ); - -Boolean XmuCvtWidgetToString -( - Display *dpy, - XrmValue *args, - Cardinal *num_args, - XrmValue *fromVal, - XrmValue *toVal, - XtPointer *converter_data - ); - -_XFUNCPROTOEND - -#endif /* _XMU_STRCONVERT_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STRCONVERT_H_
+#define _XMU_STRCONVERT_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void XmuCvtFunctionToCallback
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtNbackingStore "backingStore"
+#define XtCBackingStore "BackingStore"
+#define XtRBackingStore "BackingStore"
+#define XtEnotUseful "notUseful"
+#define XtEwhenMapped "whenMapped"
+#define XtEalways "always"
+#define XtEdefault "default"
+void XmuCvtStringToBackingStore
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtBackingStoreToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+void XmuCvtStringToCursor
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtRColorCursor "ColorCursor"
+#define XtNpointerColor "pointerColor"
+#define XtNpointerColorBackground "pointerColorBackground"
+Boolean XmuCvtStringToColorCursor
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef int XtGravity;
+
+#ifndef XtRGravity
+#define XtRGravity "Gravity"
+#endif
+#define XtEForget "forget"
+#define XtENorthWest "northwest"
+#define XtENorth "north"
+#define XtENorthEast "northeast"
+#define XtEWest "west"
+#define XtECenter "center"
+#define XtEEast "east"
+#define XtESouthWest "southwest"
+#define XtESouth "south"
+#define XtESouthEast "southeast"
+#define XtEStatic "static"
+#define XtEUnmap "unmap"
+void XmuCvtStringToGravity
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtGravityToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef enum {
+ XtJustifyLeft, /* justify text to left side of button */
+ XtJustifyCenter, /* justify text in center of button */
+ XtJustifyRight /* justify text to right side of button */
+} XtJustify;
+#ifndef XtRJustify
+#define XtRJustify "Justify"
+#endif
+#define XtEleft "left"
+#define XtEcenter "center"
+#define XtEright "right"
+#define XtEtop "top"
+#define XtEbottom "bottom"
+void XmuCvtStringToJustify
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtJustifyToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+#define XtRLong "Long"
+void XmuCvtStringToLong
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+Boolean XmuCvtLongToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+typedef enum {
+ XtorientHorizontal,
+ XtorientVertical
+} XtOrientation;
+void XmuCvtStringToOrientation
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuCvtOrientationToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+void XmuCvtStringToBitmap
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+#define XtRShapeStyle "ShapeStyle"
+#define XtERectangle "Rectangle"
+#define XtEOval "Oval"
+#define XtEEllipse "Ellipse"
+#define XtERoundedRectangle "RoundedRectangle"
+
+#define XmuShapeRectangle 1
+#define XmuShapeOval 2
+#define XmuShapeEllipse 3
+#define XmuShapeRoundedRectangle 4
+
+Boolean XmuCvtStringToShapeStyle
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuCvtShapeStyleToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuReshapeWidget
+(
+ Widget w,
+ int shape_style,
+ int corner_width,
+ int corner_height
+ );
+
+void XmuCvtStringToWidget
+(
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal
+ );
+
+Boolean XmuNewCvtStringToWidget
+(
+ Display *display,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValue *fromVal,
+ XrmValue *toVal,
+ XtPointer *converter_data
+ );
+
+Boolean XmuCvtWidgetToString
+(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValue *fromVal,
+ XrmValue *toVal,
+ XtPointer *converter_data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STRCONVERT_H_ */
diff --git a/libXmu/include/X11/Xmu/CurUtil.h b/libXmu/include/X11/Xmu/CurUtil.h index 3524d7704..ce3d344c8 100644 --- a/libXmu/include/X11/Xmu/CurUtil.h +++ b/libXmu/include/X11/Xmu/CurUtil.h @@ -1,46 +1,46 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_CURUTIL_H_ -#define _XMU_CURUTIL_H_ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -int XmuCursorNameToIndex -( - _Xconst char *name - ); - -_XFUNCPROTOEND - -#endif /* _XMU_CURUTIL_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CURUTIL_H_
+#define _XMU_CURUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuCursorNameToIndex
+(
+ _Xconst char *name
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CURUTIL_H_ */
diff --git a/libXmu/include/X11/Xmu/CvtCache.h b/libXmu/include/X11/Xmu/CvtCache.h index 7441e2f2e..8ebec3722 100644 --- a/libXmu/include/X11/Xmu/CvtCache.h +++ b/libXmu/include/X11/Xmu/CvtCache.h @@ -1,59 +1,59 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Public Interfaces - * - * XmuCvtCache *XmuCvtCacheLookupDisplay (dpy) - * Display *dpy; - */ - -#ifndef _XMU_CVTCACHE_H_ -#define _XMU_CVTCACHE_H_ - -#include <X11/Xmu/DisplayQue.h> -#include <X11/Xfuncproto.h> - -typedef struct _XmuCvtCache { - struct { - char **bitmapFilePath; - } string_to_bitmap; - /* add other per-display data that needs to be cached */ -} XmuCvtCache; - -_XFUNCPROTOBEGIN - -XmuCvtCache *_XmuCCLookupDisplay -( - Display *dpy - ); - -extern void _XmuStringToBitmapInitCache(XmuCvtCache *c); -extern void _XmuStringToBitmapFreeCache(XmuCvtCache *c); - -_XFUNCPROTOEND - -#endif /* _XMU_CVTCACHE_H_ */ +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Public Interfaces
+ *
+ * XmuCvtCache *XmuCvtCacheLookupDisplay (dpy)
+ * Display *dpy;
+ */
+
+#ifndef _XMU_CVTCACHE_H_
+#define _XMU_CVTCACHE_H_
+
+#include <X11/Xmu/DisplayQue.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _XmuCvtCache {
+ struct {
+ char **bitmapFilePath;
+ } string_to_bitmap;
+ /* add other per-display data that needs to be cached */
+} XmuCvtCache;
+
+_XFUNCPROTOBEGIN
+
+XmuCvtCache *_XmuCCLookupDisplay
+(
+ Display *dpy
+ );
+
+extern void _XmuStringToBitmapInitCache(XmuCvtCache *c);
+extern void _XmuStringToBitmapFreeCache(XmuCvtCache *c);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CVTCACHE_H_ */
diff --git a/libXmu/include/X11/Xmu/DisplayQue.h b/libXmu/include/X11/Xmu/DisplayQue.h index b37a58133..099844f59 100644 --- a/libXmu/include/X11/Xmu/DisplayQue.h +++ b/libXmu/include/X11/Xmu/DisplayQue.h @@ -1,152 +1,152 @@ -/* - -Copyright 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifndef _XMU_DISPLAYQUE_H_ -#define _XMU_DISPLAYQUE_H_ - -#include <X11/Xmu/CloseHook.h> -#include <X11/Xfuncproto.h> - -/* - * Public Entry Points - * - * - * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data) - * XmuCloseDisplayQueueProc closefunc; - * XmuFreeDisplayQueueProc freefunc; - * XPointer data; - * - * Creates and returns a queue into which displays may be placed. When - * the display is closed, the closefunc (if non-NULL) is upcalled with - * as follows: - * - * (*closefunc) (queue, entry) - * - * The freeproc, if non-NULL, is called whenever the last display is - * closed, notifying the creator that display queue may be released - * using XmuDQDestroy. - * - * - * Bool XmuDQDestroy (q, docallbacks) - * XmuDisplayQueue *q; - * Bool docallbacks; - * - * Releases all memory for the indicated display queue. If docallbacks - * is true, then the closefunc (if non-NULL) is called for each - * display. - * - * - * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy) - * XmuDisplayQueue *q; - * Display *dpy; - * - * Returns the queue entry for the specified display or NULL if the - * display is not in the queue. - * - * - * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data) - * XmuDisplayQueue *q; - * Display *dpy; - * XPointer data; - * - * Adds the indicated display to the end of the queue or NULL if it - * is unable to allocate memory. The data field may be used by the - * caller to attach arbitrary data to this display in this queue. The - * caller should use XmuDQLookupDisplay to make sure that the display - * hasn't already been added. - * - * - * Bool XmuDQRemoveDisplay (q, dpy) - * XmuDisplayQueue *q; - * Display *dpy; - * - * Removes the specified display from the given queue. If the - * indicated display is not found on this queue, False is returned, - * otherwise True is returned. - */ - -typedef struct _XmuDisplayQueue XmuDisplayQueue; -typedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry; - -typedef int (*XmuCloseDisplayQueueProc)(XmuDisplayQueue *queue, - XmuDisplayQueueEntry *entry); - -typedef int (*XmuFreeDisplayQueueProc)(XmuDisplayQueue *queue); - -struct _XmuDisplayQueueEntry { - struct _XmuDisplayQueueEntry *prev, *next; - Display *display; - CloseHook closehook; - XPointer data; -}; - -struct _XmuDisplayQueue { - int nentries; - XmuDisplayQueueEntry *head, *tail; - XmuCloseDisplayQueueProc closefunc; - XmuFreeDisplayQueueProc freefunc; - XPointer data; -}; - -_XFUNCPROTOBEGIN - -XmuDisplayQueue *XmuDQCreate -( - XmuCloseDisplayQueueProc closefunc, - XmuFreeDisplayQueueProc freefunc, - XPointer data - ); - -Bool XmuDQDestroy -( - XmuDisplayQueue *q, - Bool docallbacks - ); - -XmuDisplayQueueEntry *XmuDQLookupDisplay -( - XmuDisplayQueue *q, - Display *dpy - ); - -XmuDisplayQueueEntry *XmuDQAddDisplay -( - XmuDisplayQueue *q, - Display *dpy, - XPointer data - ); - -Bool XmuDQRemoveDisplay -( - XmuDisplayQueue *q, - Display *dpy - ); - -_XFUNCPROTOEND - -#define XmuDQNDisplays(q) ((q)->nentries) - -#endif /* _XMU_DISPLAYQUE_H_ */ +/*
+
+Copyright 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifndef _XMU_DISPLAYQUE_H_
+#define _XMU_DISPLAYQUE_H_
+
+#include <X11/Xmu/CloseHook.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * Public Entry Points
+ *
+ *
+ * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data)
+ * XmuCloseDisplayQueueProc closefunc;
+ * XmuFreeDisplayQueueProc freefunc;
+ * XPointer data;
+ *
+ * Creates and returns a queue into which displays may be placed. When
+ * the display is closed, the closefunc (if non-NULL) is upcalled with
+ * as follows:
+ *
+ * (*closefunc) (queue, entry)
+ *
+ * The freeproc, if non-NULL, is called whenever the last display is
+ * closed, notifying the creator that display queue may be released
+ * using XmuDQDestroy.
+ *
+ *
+ * Bool XmuDQDestroy (q, docallbacks)
+ * XmuDisplayQueue *q;
+ * Bool docallbacks;
+ *
+ * Releases all memory for the indicated display queue. If docallbacks
+ * is true, then the closefunc (if non-NULL) is called for each
+ * display.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Returns the queue entry for the specified display or NULL if the
+ * display is not in the queue.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ * XPointer data;
+ *
+ * Adds the indicated display to the end of the queue or NULL if it
+ * is unable to allocate memory. The data field may be used by the
+ * caller to attach arbitrary data to this display in this queue. The
+ * caller should use XmuDQLookupDisplay to make sure that the display
+ * hasn't already been added.
+ *
+ *
+ * Bool XmuDQRemoveDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Removes the specified display from the given queue. If the
+ * indicated display is not found on this queue, False is returned,
+ * otherwise True is returned.
+ */
+
+typedef struct _XmuDisplayQueue XmuDisplayQueue;
+typedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry;
+
+typedef int (*XmuCloseDisplayQueueProc)(XmuDisplayQueue *queue,
+ XmuDisplayQueueEntry *entry);
+
+typedef int (*XmuFreeDisplayQueueProc)(XmuDisplayQueue *queue);
+
+struct _XmuDisplayQueueEntry {
+ struct _XmuDisplayQueueEntry *prev, *next;
+ Display *display;
+ CloseHook closehook;
+ XPointer data;
+};
+
+struct _XmuDisplayQueue {
+ int nentries;
+ XmuDisplayQueueEntry *head, *tail;
+ XmuCloseDisplayQueueProc closefunc;
+ XmuFreeDisplayQueueProc freefunc;
+ XPointer data;
+};
+
+_XFUNCPROTOBEGIN
+
+XmuDisplayQueue *XmuDQCreate
+(
+ XmuCloseDisplayQueueProc closefunc,
+ XmuFreeDisplayQueueProc freefunc,
+ XPointer data
+ );
+
+Bool XmuDQDestroy
+(
+ XmuDisplayQueue *q,
+ Bool docallbacks
+ );
+
+XmuDisplayQueueEntry *XmuDQLookupDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy
+ );
+
+XmuDisplayQueueEntry *XmuDQAddDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy,
+ XPointer data
+ );
+
+Bool XmuDQRemoveDisplay
+(
+ XmuDisplayQueue *q,
+ Display *dpy
+ );
+
+_XFUNCPROTOEND
+
+#define XmuDQNDisplays(q) ((q)->nentries)
+
+#endif /* _XMU_DISPLAYQUE_H_ */
diff --git a/libXmu/include/X11/Xmu/Drawing.h b/libXmu/include/X11/Xmu/Drawing.h index 91d764b77..a99b4c1c4 100644 --- a/libXmu/include/X11/Xmu/Drawing.h +++ b/libXmu/include/X11/Xmu/Drawing.h @@ -1,158 +1,158 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_DRAWING_H_ -#define _XMU_DRAWING_H_ - -#include <X11/Xlib.h> -#include <X11/Xfuncproto.h> - -#include <stdio.h> -#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED) -typedef unsigned long Pixel; -#endif - -_XFUNCPROTOBEGIN - -void XmuDrawRoundedRectangle -( - Display *dpy, - Drawable draw, - GC gc, - int x, - int y, - int w, - int h, - int ew, - int eh - ); - -void XmuFillRoundedRectangle -( - Display *dpy, - Drawable draw, - GC gc, - int x, - int y, - int w, - int h, - int ew, - int eh - ); - -void XmuDrawLogo -( - Display *dpy, - Drawable drawable, - GC gcFore, - GC gcBack, - int x, - int y, - unsigned int width, - unsigned int height - ); - -Pixmap XmuCreatePixmapFromBitmap -( - Display *dpy, - Drawable d, - Pixmap bitmap, - unsigned int width, - unsigned int height, - unsigned int depth, - unsigned long fore, - unsigned long back -); - -Pixmap XmuCreateStippledPixmap -( - Screen *screen, - Pixel fore, - Pixel back, - unsigned int depth - ); - -void XmuReleaseStippledPixmap -( - Screen *screen, - Pixmap pixmap - ); - -Pixmap XmuLocateBitmapFile -( - Screen *screen, - _Xconst char *name, - char *srcname_return, - int srcnamelen, - int *width_return, - int *height_return, - int *xhot_return, - int *yhot_return - ); - -Pixmap XmuLocatePixmapFile -( - Screen *screen, - _Xconst char *name, - unsigned long fore, - unsigned long back, - unsigned int depth, - char *srcname_return, - int srcnamelen, - int *width_return, - int *height_return, - int *xhot_return, - int *yhot_return - ); - -int XmuReadBitmapData -( - FILE *fstream, - unsigned int *width_return, - unsigned int *height_return, - unsigned char **datap_return, - int *xhot_return, - int *yhot_return -); - -int XmuReadBitmapDataFromFile -( - _Xconst char *filename, - unsigned int *width_return, - unsigned int *height_return, - unsigned char **datap_return, - int *xhot_return, - int *yhot_return - ); - -_XFUNCPROTOEND - -#endif /* _XMU_DRAWING_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_DRAWING_H_
+#define _XMU_DRAWING_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+#include <stdio.h>
+#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
+typedef unsigned long Pixel;
+#endif
+
+_XFUNCPROTOBEGIN
+
+void XmuDrawRoundedRectangle
+(
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ int w,
+ int h,
+ int ew,
+ int eh
+ );
+
+void XmuFillRoundedRectangle
+(
+ Display *dpy,
+ Drawable draw,
+ GC gc,
+ int x,
+ int y,
+ int w,
+ int h,
+ int ew,
+ int eh
+ );
+
+void XmuDrawLogo
+(
+ Display *dpy,
+ Drawable drawable,
+ GC gcFore,
+ GC gcBack,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height
+ );
+
+Pixmap XmuCreatePixmapFromBitmap
+(
+ Display *dpy,
+ Drawable d,
+ Pixmap bitmap,
+ unsigned int width,
+ unsigned int height,
+ unsigned int depth,
+ unsigned long fore,
+ unsigned long back
+);
+
+Pixmap XmuCreateStippledPixmap
+(
+ Screen *screen,
+ Pixel fore,
+ Pixel back,
+ unsigned int depth
+ );
+
+void XmuReleaseStippledPixmap
+(
+ Screen *screen,
+ Pixmap pixmap
+ );
+
+Pixmap XmuLocateBitmapFile
+(
+ Screen *screen,
+ _Xconst char *name,
+ char *srcname_return,
+ int srcnamelen,
+ int *width_return,
+ int *height_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+Pixmap XmuLocatePixmapFile
+(
+ Screen *screen,
+ _Xconst char *name,
+ unsigned long fore,
+ unsigned long back,
+ unsigned int depth,
+ char *srcname_return,
+ int srcnamelen,
+ int *width_return,
+ int *height_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+int XmuReadBitmapData
+(
+ FILE *fstream,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned char **datap_return,
+ int *xhot_return,
+ int *yhot_return
+);
+
+int XmuReadBitmapDataFromFile
+(
+ _Xconst char *filename,
+ unsigned int *width_return,
+ unsigned int *height_return,
+ unsigned char **datap_return,
+ int *xhot_return,
+ int *yhot_return
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_DRAWING_H_ */
diff --git a/libXmu/include/X11/Xmu/Editres.h b/libXmu/include/X11/Xmu/Editres.h index 0c1ffe075..52aa239a9 100644 --- a/libXmu/include/X11/Xmu/Editres.h +++ b/libXmu/include/X11/Xmu/Editres.h @@ -1,39 +1,39 @@ -/* - -Copyright 1991, 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -void _XEditResCheckMessages -( - Widget w, - XtPointer data, - XEvent *event, - Boolean *cont -); - -_XFUNCPROTOEND +/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void _XEditResCheckMessages
+(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *cont
+);
+
+_XFUNCPROTOEND
diff --git a/libXmu/include/X11/Xmu/EditresP.h b/libXmu/include/X11/Xmu/EditresP.h index 6f7c739ab..0f1dd1260 100644 --- a/libXmu/include/X11/Xmu/EditresP.h +++ b/libXmu/include/X11/Xmu/EditresP.h @@ -1,406 +1,406 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Chris D. Peterson, MIT X Consortium - */ - -/************************************************************ - - The Editres Protocol - - - The Client message sent to the application is: - - ATOM = "ResEditor" --- RES_EDITOR_NAME - - FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT - - l[0] = timestamp - l[1] = command atom name - l[2] = ident of command - l[3] = protocol version number to use - - - - The binary protocol has the following format: - - Card8: 8-bit unsingned integer - Card16: 16-bit unsingned integer - Card32: 32-bit unsingned integer - Int16: 16-bit signed integer - Window: 32-bit value - Widget: 32-bit value - String8: ListOfCard8 - - [a][b][c] represent an exclusive list of choices. - - All widgets are passed as a list of widgets, containing the - full instance heirarch of this widget. The hierarchy is ordered - from parent to child. Thus the first element of each list is - the root of the widget tree (this makes verifying that the widget - still exists, MUCH faster). - - ListOfFoo comprises a list of things in the following format: - - number: Card16 - <number> things: ???? - - This is a synchronous protocol, every request MUST be followed by a - reply. - - Request: - - Serial Number: Card8 - Op Code: Card8 - { SendWidgetTree = 0, - SetValues = 1, - GetResources = 2, - GetGeometry = 3, - FindChild = 4, - GetValues = 5 } - Length: Card32 - Data: - - Reply: - - Serial Number: Card8 - Type: Card8 - { Formatted = 0, - Unformatted = 1, - ProtocolMismatch = 2 - } - Length: Card32 - - - Byte Order: - - All Fields are MSB -> LSB - - Data: - - Formatted: - - The data contains the reply information for the request as - specified below if the reply type is "Formatted". The return - values for the other reply types are shown below. - - Unformatted: - - Message: String8 - - ProtocolMismatch: - - RequestedVersion: Card8 - ------------------------------------------------------------- - - SendWidgetTree: - - ---> - - Number of Entries: Card16 - Entry: - widget: ListOfWidgets - name: String8 - class: String8 - window: Card32 - toolkit: String8 - - Send Widget Tree returns the toolkit type, and a fuly specified list - of widgets for each widget in the tree. This is enough information - to completely reconstruct the entire widget heirarchy. - - The window return value contains the Xid of the window currently - used by this widget. If the widget is unrealized then 0 is returned, - and if widget is a non-windowed object a value of 2 is returned. - - SetValues: - - name: String8 - type: String8 - value: String8 - Number of Entries: Card16 - Entry: - widget: ListOfWidgets - - ---> - - Number of Entries: Card16 - Entry: - widget: ListOfWidgets - message: String8 - - SetValues will allow the same resource to be set on a number of - widgets. This function will return an error message if the SetValues - request caused an Xt error. - - GetValues: - - names: ListOfString8 - widget: Widget - - ---> - novalues: ListOfCard16 - values: ListOfString8 - - GetValues will allow a number of resource values to be read - on a particular widget. The request specifies the names of - the resources wanted and the widget id these resources are - from. The reply returns a list of indices from the requests - name list of resources for which a value can not be returned. - It also returns a list of returned values, in the order of the - requests names list, skipping those indices present in novalues. - - GetResources: - - Number of Entries: Card16 - Entry - widget: ListOfWidgets: - - ----> - - Number of Entries: Card16 - Entry - Widget: ListOfWidgets: - Error: Bool - - [ Message: String 8 ] - [ Number of Resources: Card16 - Resource: - Kind: {normal, constraint} - Name: String8 - Class: String8 - Type: String8 ] - - GetResource retrieves the kind, name, class and type for every - widget passed to it. If an error occured with the resource fetch - Error will be set to True for the given widget and a message - is returned rather than the resource info. - - GetGeometry: - - Number of Entries: Card16 - Entry - Widget: ListOfWidgets: - - ----> - - Number of Entries: Card16 - Entry - Widget: ListOfWidgets: - Error: Bool - - [ message: String 8 ] - [ mapped: Boolean - X: Int16 - Y: Int16 - Width: Card16 - Height: Card16 - BorderWidth: Card16 ] - - GetGeometry retreives the mapping state, x, y, width, height - and border width for each widget specified. If an error occured - with the geometry fetch "Error" will be set to True for the given - widget and a message is returned rather than the geometry info. - X an Y corrospond to the root coordinates of the upper left corner - of the widget (outside the window border). - - FindChild: - - Widget: ListOfWidgets - X: Int16 - Y: Int16 - - ---> - - Widget: ListOfWidgets - - Find Child returns a descendent of the widget specified that - is at the root coordinates specified. - - NOTE: - - The returned widget is undefined if the point is contained in - two or more mapped widgets, or in two overlapping Rect objs. - - GetValues: - - names: ListOfString8 - widget: Widget - - ---> - - values: ListOfString8 - - GetValues will allow a number of resource values to be read - on a particular widget. Currently only InterViews 3.0.1 Styles - and their attributes are supported. In addition, the current - user interface only supports the return of 1 resource. The ability - to specify and return multiple resources is defined for future editres - interfaces where some or all of a widgets resource values are returned - and displayed at once. - - -************************************************************/ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -#define XER_NBBY 8 /* number of bits in a byte */ -#define BYTE_MASK 255 - -#define HEADER_SIZE 6 - -#define EDITRES_IS_OBJECT 2 -#define EDITRES_IS_UNREALIZED 0 - -/* - * Format for atoms - */ -#define EDITRES_FORMAT 8 -#define EDITRES_SEND_EVENT_FORMAT 32 - -/* - * Atoms - */ -#define EDITRES_NAME "Editres" -#define EDITRES_COMMAND_ATOM "EditresCommand" -#define EDITRES_COMM_ATOM "EditresComm" -#define EDITRES_CLIENT_VALUE "EditresClientVal" -#define EDITRES_PROTOCOL_ATOM "EditresProtocol" - -typedef enum { - SendWidgetTree = 0, - SetValues = 1, - GetResources = 2, - GetGeometry = 3, - FindChild = 4, - GetValues = 5 -} EditresCommand; - -typedef enum { - NormalResource = 0, - ConstraintResource = 1 -} ResourceType; - -/* - * The type of a resource identifier - */ -typedef unsigned char ResIdent; - -typedef enum { - PartialSuccess = 0, - Failure = 1, - ProtocolMismatch = 2 -} EditResError; - -typedef struct _WidgetInfo { - unsigned short num_widgets; - unsigned long *ids; - Widget real_widget; -} WidgetInfo; - -typedef struct _ProtocolStream { - unsigned long size, alloc; - unsigned char *real_top, *top, *current; -} ProtocolStream; - -/************************************************************ - * Function definitions for reading and writing protocol requests - ************************************************************/ -_XFUNCPROTOBEGIN - -void _XEditResPutString8 -( - ProtocolStream *stream, - char *str - ); - -void _XEditResPut8 -( - ProtocolStream *stream, - unsigned int value - ); - -void _XEditResPut16 -( - ProtocolStream *stream, - unsigned int value - ); - -void _XEditResPut32 -( - ProtocolStream *stream, - unsigned long value - ); - -void _XEditResPutWidgetInfo -( - ProtocolStream *stream, - WidgetInfo *info - ); - -void _XEditResResetStream -( - ProtocolStream *stream - ); - -Bool _XEditResGet8 -( - ProtocolStream *stream, - unsigned char *value - ); - -Bool _XEditResGet16 -( - ProtocolStream *stream, - unsigned short *value - ); - -Bool _XEditResGetSigned16 -( - ProtocolStream *stream, - short *value - ); - -Bool _XEditResGet32 -( - ProtocolStream *stream, - unsigned long *value - ); - -Bool _XEditResGetString8 -( - ProtocolStream *stream, - char **str - ); - -Bool _XEditResGetWidgetInfo -( - ProtocolStream *stream, - WidgetInfo *info - ); - -_XFUNCPROTOEND +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/************************************************************
+
+ The Editres Protocol
+
+
+ The Client message sent to the application is:
+
+ ATOM = "ResEditor" --- RES_EDITOR_NAME
+
+ FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT
+
+ l[0] = timestamp
+ l[1] = command atom name
+ l[2] = ident of command
+ l[3] = protocol version number to use
+
+
+
+ The binary protocol has the following format:
+
+ Card8: 8-bit unsingned integer
+ Card16: 16-bit unsingned integer
+ Card32: 32-bit unsingned integer
+ Int16: 16-bit signed integer
+ Window: 32-bit value
+ Widget: 32-bit value
+ String8: ListOfCard8
+
+ [a][b][c] represent an exclusive list of choices.
+
+ All widgets are passed as a list of widgets, containing the
+ full instance heirarch of this widget. The hierarchy is ordered
+ from parent to child. Thus the first element of each list is
+ the root of the widget tree (this makes verifying that the widget
+ still exists, MUCH faster).
+
+ ListOfFoo comprises a list of things in the following format:
+
+ number: Card16
+ <number> things: ????
+
+ This is a synchronous protocol, every request MUST be followed by a
+ reply.
+
+ Request:
+
+ Serial Number: Card8
+ Op Code: Card8 - { SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5 }
+ Length: Card32
+ Data:
+
+ Reply:
+
+ Serial Number: Card8
+ Type: Card8 - { Formatted = 0,
+ Unformatted = 1,
+ ProtocolMismatch = 2
+ }
+ Length: Card32
+
+
+ Byte Order:
+
+ All Fields are MSB -> LSB
+
+ Data:
+
+ Formatted:
+
+ The data contains the reply information for the request as
+ specified below if the reply type is "Formatted". The return
+ values for the other reply types are shown below.
+
+ Unformatted:
+
+ Message: String8
+
+ ProtocolMismatch:
+
+ RequestedVersion: Card8
+
+------------------------------------------------------------
+
+ SendWidgetTree:
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ name: String8
+ class: String8
+ window: Card32
+ toolkit: String8
+
+ Send Widget Tree returns the toolkit type, and a fuly specified list
+ of widgets for each widget in the tree. This is enough information
+ to completely reconstruct the entire widget heirarchy.
+
+ The window return value contains the Xid of the window currently
+ used by this widget. If the widget is unrealized then 0 is returned,
+ and if widget is a non-windowed object a value of 2 is returned.
+
+ SetValues:
+
+ name: String8
+ type: String8
+ value: String8
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ message: String8
+
+ SetValues will allow the same resource to be set on a number of
+ widgets. This function will return an error message if the SetValues
+ request caused an Xt error.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+ novalues: ListOfCard16
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. The request specifies the names of
+ the resources wanted and the widget id these resources are
+ from. The reply returns a list of indices from the requests
+ name list of resources for which a value can not be returned.
+ It also returns a list of returned values, in the order of the
+ requests names list, skipping those indices present in novalues.
+
+ GetResources:
+
+ Number of Entries: Card16
+ Entry
+ widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ Message: String 8 ]
+ [ Number of Resources: Card16
+ Resource:
+ Kind: {normal, constraint}
+ Name: String8
+ Class: String8
+ Type: String8 ]
+
+ GetResource retrieves the kind, name, class and type for every
+ widget passed to it. If an error occured with the resource fetch
+ Error will be set to True for the given widget and a message
+ is returned rather than the resource info.
+
+ GetGeometry:
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ message: String 8 ]
+ [ mapped: Boolean
+ X: Int16
+ Y: Int16
+ Width: Card16
+ Height: Card16
+ BorderWidth: Card16 ]
+
+ GetGeometry retreives the mapping state, x, y, width, height
+ and border width for each widget specified. If an error occured
+ with the geometry fetch "Error" will be set to True for the given
+ widget and a message is returned rather than the geometry info.
+ X an Y corrospond to the root coordinates of the upper left corner
+ of the widget (outside the window border).
+
+ FindChild:
+
+ Widget: ListOfWidgets
+ X: Int16
+ Y: Int16
+
+ --->
+
+ Widget: ListOfWidgets
+
+ Find Child returns a descendent of the widget specified that
+ is at the root coordinates specified.
+
+ NOTE:
+
+ The returned widget is undefined if the point is contained in
+ two or more mapped widgets, or in two overlapping Rect objs.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. Currently only InterViews 3.0.1 Styles
+ and their attributes are supported. In addition, the current
+ user interface only supports the return of 1 resource. The ability
+ to specify and return multiple resources is defined for future editres
+ interfaces where some or all of a widgets resource values are returned
+ and displayed at once.
+
+
+************************************************************/
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+#define XER_NBBY 8 /* number of bits in a byte */
+#define BYTE_MASK 255
+
+#define HEADER_SIZE 6
+
+#define EDITRES_IS_OBJECT 2
+#define EDITRES_IS_UNREALIZED 0
+
+/*
+ * Format for atoms
+ */
+#define EDITRES_FORMAT 8
+#define EDITRES_SEND_EVENT_FORMAT 32
+
+/*
+ * Atoms
+ */
+#define EDITRES_NAME "Editres"
+#define EDITRES_COMMAND_ATOM "EditresCommand"
+#define EDITRES_COMM_ATOM "EditresComm"
+#define EDITRES_CLIENT_VALUE "EditresClientVal"
+#define EDITRES_PROTOCOL_ATOM "EditresProtocol"
+
+typedef enum {
+ SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5
+} EditresCommand;
+
+typedef enum {
+ NormalResource = 0,
+ ConstraintResource = 1
+} ResourceType;
+
+/*
+ * The type of a resource identifier
+ */
+typedef unsigned char ResIdent;
+
+typedef enum {
+ PartialSuccess = 0,
+ Failure = 1,
+ ProtocolMismatch = 2
+} EditResError;
+
+typedef struct _WidgetInfo {
+ unsigned short num_widgets;
+ unsigned long *ids;
+ Widget real_widget;
+} WidgetInfo;
+
+typedef struct _ProtocolStream {
+ unsigned long size, alloc;
+ unsigned char *real_top, *top, *current;
+} ProtocolStream;
+
+/************************************************************
+ * Function definitions for reading and writing protocol requests
+ ************************************************************/
+_XFUNCPROTOBEGIN
+
+void _XEditResPutString8
+(
+ ProtocolStream *stream,
+ char *str
+ );
+
+void _XEditResPut8
+(
+ ProtocolStream *stream,
+ unsigned int value
+ );
+
+void _XEditResPut16
+(
+ ProtocolStream *stream,
+ unsigned int value
+ );
+
+void _XEditResPut32
+(
+ ProtocolStream *stream,
+ unsigned long value
+ );
+
+void _XEditResPutWidgetInfo
+(
+ ProtocolStream *stream,
+ WidgetInfo *info
+ );
+
+void _XEditResResetStream
+(
+ ProtocolStream *stream
+ );
+
+Bool _XEditResGet8
+(
+ ProtocolStream *stream,
+ unsigned char *value
+ );
+
+Bool _XEditResGet16
+(
+ ProtocolStream *stream,
+ unsigned short *value
+ );
+
+Bool _XEditResGetSigned16
+(
+ ProtocolStream *stream,
+ short *value
+ );
+
+Bool _XEditResGet32
+(
+ ProtocolStream *stream,
+ unsigned long *value
+ );
+
+Bool _XEditResGetString8
+(
+ ProtocolStream *stream,
+ char **str
+ );
+
+Bool _XEditResGetWidgetInfo
+(
+ ProtocolStream *stream,
+ WidgetInfo *info
+ );
+
+_XFUNCPROTOEND
diff --git a/libXmu/include/X11/Xmu/Error.h b/libXmu/include/X11/Xmu/Error.h index c69bf141e..f0f26f0d4 100644 --- a/libXmu/include/X11/Xmu/Error.h +++ b/libXmu/include/X11/Xmu/Error.h @@ -1,56 +1,56 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_ERROR_H_ -#define _XMU_ERROR_H_ - -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -int XmuPrintDefaultErrorMessage -( - Display *dpy, - XErrorEvent *event, - FILE *fp - ); - -int XmuSimpleErrorHandler -( - Display *dpy, - XErrorEvent *errorp - ); - -_XFUNCPROTOEND - -#endif /* _XMU_ERROR_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ERROR_H_
+#define _XMU_ERROR_H_
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuPrintDefaultErrorMessage
+(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp
+ );
+
+int XmuSimpleErrorHandler
+(
+ Display *dpy,
+ XErrorEvent *errorp
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ERROR_H_ */
diff --git a/libXmu/include/X11/Xmu/ExtAgent.h b/libXmu/include/X11/Xmu/ExtAgent.h index b30014012..1bdf269ff 100644 --- a/libXmu/include/X11/Xmu/ExtAgent.h +++ b/libXmu/include/X11/Xmu/ExtAgent.h @@ -1,41 +1,41 @@ -/* - -Copyright 1994,1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -extern void XmuRegisterExternalAgent -( - Widget w, - XtPointer data, - XEvent *event, - Boolean *cont - ); - -_XFUNCPROTOEND - +/*
+
+Copyright 1994,1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void XmuRegisterExternalAgent
+(
+ Widget w,
+ XtPointer data,
+ XEvent *event,
+ Boolean *cont
+ );
+
+_XFUNCPROTOEND
+
diff --git a/libXmu/include/X11/Xmu/Initer.h b/libXmu/include/X11/Xmu/Initer.h index 2ba86e833..a952ce8f0 100644 --- a/libXmu/include/X11/Xmu/Initer.h +++ b/libXmu/include/X11/Xmu/Initer.h @@ -1,55 +1,55 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_INITER_H_ -#define _XMU_INITER_H_ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -typedef void (*XmuInitializerProc)(XtAppContext app_context, XPointer data); - -_XFUNCPROTOBEGIN - -void XmuCallInitializers -( - XtAppContext app_context - ); - -void XmuAddInitializer -( - XmuInitializerProc func, - XPointer data - ); - -_XFUNCPROTOEND - -#endif /* _XMU_INITER_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_INITER_H_
+#define _XMU_INITER_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef void (*XmuInitializerProc)(XtAppContext app_context, XPointer data);
+
+_XFUNCPROTOBEGIN
+
+void XmuCallInitializers
+(
+ XtAppContext app_context
+ );
+
+void XmuAddInitializer
+(
+ XmuInitializerProc func,
+ XPointer data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_INITER_H_ */
diff --git a/libXmu/include/X11/Xmu/Lookup.h b/libXmu/include/X11/Xmu/Lookup.h index e99b8b1e5..302045ac6 100644 --- a/libXmu/include/X11/Xmu/Lookup.h +++ b/libXmu/include/X11/Xmu/Lookup.h @@ -1,124 +1,124 @@ -/************************************************************ - -Copyright 1999 by Thomas E. Dickey <dickey@clark.net> - - All Rights Reserved - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name(s) of the above copyright -holders shall not be used in advertising or otherwise to promote the -sale, use or other dealings in this Software without prior written -authorization. - -********************************************************/ - -#ifndef included_xmu_lookup_h -#define included_xmu_lookup_h 1 - -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -extern int XmuLookupString( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status, - unsigned long keysymSet); - -extern int XmuLookupLatin1( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupLatin2( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupLatin3( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupLatin4( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupKana( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupJISX0201( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupArabic( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupCyrillic( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupGreek( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupAPL( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -extern int XmuLookupHebrew( - XKeyEvent *event, - unsigned char *buffer, - int nbytes, - KeySym *keysym, - XComposeStatus *status); - -#endif /* included_xmu_lookup_h */ +/************************************************************
+
+Copyright 1999 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_xmu_lookup_h
+#define included_xmu_lookup_h 1
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+extern int XmuLookupString(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status,
+ unsigned long keysymSet);
+
+extern int XmuLookupLatin1(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin2(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin3(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupLatin4(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupKana(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupJISX0201(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupArabic(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupCyrillic(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupGreek(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupAPL(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+extern int XmuLookupHebrew(
+ XKeyEvent *event,
+ unsigned char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status);
+
+#endif /* included_xmu_lookup_h */
diff --git a/libXmu/include/X11/Xmu/Misc.h b/libXmu/include/X11/Xmu/Misc.h index 650771b19..9d70ae15b 100644 --- a/libXmu/include/X11/Xmu/Misc.h +++ b/libXmu/include/X11/Xmu/Misc.h @@ -1,63 +1,63 @@ -/* - -Copyright 1987, 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/*********************************************************** - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -******************************************************************/ - -/* Various useful constant and macro definitions */ - -#ifndef _Xmu_Misc_h -#define _Xmu_Misc_h - -#define MAXDIMENSION ((1 << 31)-1) - -#define Max(x, y) (((x) > (y)) ? (x) : (y)) -#define Min(x, y) (((x) < (y)) ? (x) : (y)) -#define AssignMax(x, y) {if ((y) > (x)) x = (y);} -#define AssignMin(x, y) {if ((y) < (x)) x = (y);} - -#endif /*_Xmu_Misc_h*/ +/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/***********************************************************
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+/* Various useful constant and macro definitions */
+
+#ifndef _Xmu_Misc_h
+#define _Xmu_Misc_h
+
+#define MAXDIMENSION ((1 << 31)-1)
+
+#define Max(x, y) (((x) > (y)) ? (x) : (y))
+#define Min(x, y) (((x) < (y)) ? (x) : (y))
+#define AssignMax(x, y) {if ((y) > (x)) x = (y);}
+#define AssignMin(x, y) {if ((y) < (x)) x = (y);}
+
+#endif /*_Xmu_Misc_h*/
diff --git a/libXmu/include/X11/Xmu/StdCmap.h b/libXmu/include/X11/Xmu/StdCmap.h index afad78f6d..885c0f484 100644 --- a/libXmu/include/X11/Xmu/StdCmap.h +++ b/libXmu/include/X11/Xmu/StdCmap.h @@ -1,116 +1,116 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_STDCMAP_H_ -#define _XMU_STDCMAP_H_ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -Status XmuAllStandardColormaps -( - Display *dpy - ); - -Status XmuCreateColormap -( - Display *dpy, - XStandardColormap *colormap - ); - -void XmuDeleteStandardColormap -( - Display *dpy, - int screen, - Atom property - ); - -Status XmuGetColormapAllocation -( - XVisualInfo *vinfo, - Atom property, - unsigned long *red_max_return, - unsigned long *green_max_return, - unsigned long *blue_max_return - ); - -Status XmuLookupStandardColormap -( - Display *dpy, - int screen, - VisualID visualid, - unsigned int depth, - Atom property, - Bool replace, - Bool retain - ); - -XStandardColormap *XmuStandardColormap -( - Display *dpy, - int screen, - VisualID visualid, - unsigned int depth, - Atom property, - Colormap cmap, - unsigned long red_max, - unsigned long green_max, - unsigned long blue_max - ); - -Status XmuVisualStandardColormaps -( - Display *dpy, - int screen, - VisualID visualid, - unsigned int depth, - Bool replace, - Bool retain - ); - -Bool XmuDistinguishableColors -( - XColor *colors, - int count - ); - -Bool XmuDistinguishablePixels -( - Display *dpy, - Colormap cmap, - unsigned long *pixels, - int count - ); - -_XFUNCPROTOEND - -#endif /* _XMU_STDCMAP_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STDCMAP_H_
+#define _XMU_STDCMAP_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Status XmuAllStandardColormaps
+(
+ Display *dpy
+ );
+
+Status XmuCreateColormap
+(
+ Display *dpy,
+ XStandardColormap *colormap
+ );
+
+void XmuDeleteStandardColormap
+(
+ Display *dpy,
+ int screen,
+ Atom property
+ );
+
+Status XmuGetColormapAllocation
+(
+ XVisualInfo *vinfo,
+ Atom property,
+ unsigned long *red_max_return,
+ unsigned long *green_max_return,
+ unsigned long *blue_max_return
+ );
+
+Status XmuLookupStandardColormap
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Atom property,
+ Bool replace,
+ Bool retain
+ );
+
+XStandardColormap *XmuStandardColormap
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Atom property,
+ Colormap cmap,
+ unsigned long red_max,
+ unsigned long green_max,
+ unsigned long blue_max
+ );
+
+Status XmuVisualStandardColormaps
+(
+ Display *dpy,
+ int screen,
+ VisualID visualid,
+ unsigned int depth,
+ Bool replace,
+ Bool retain
+ );
+
+Bool XmuDistinguishableColors
+(
+ XColor *colors,
+ int count
+ );
+
+Bool XmuDistinguishablePixels
+(
+ Display *dpy,
+ Colormap cmap,
+ unsigned long *pixels,
+ int count
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STDCMAP_H_ */
diff --git a/libXmu/include/X11/Xmu/StdSel.h b/libXmu/include/X11/Xmu/StdSel.h index c61214dd9..97d6d01fc 100644 --- a/libXmu/include/X11/Xmu/StdSel.h +++ b/libXmu/include/X11/Xmu/StdSel.h @@ -1,54 +1,54 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_SELECTION_H_ -#define _XMU_SELECTION_H_ - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -Boolean XmuConvertStandardSelection -( - Widget w, - Time timev, - Atom *selection, - Atom *target, - Atom *type_return, - XPointer *value_return, - unsigned long *length_return, - int *format_return - ); - -_XFUNCPROTOEND - -#endif /* _XMU_SELECTION_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_SELECTION_H_
+#define _XMU_SELECTION_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Boolean XmuConvertStandardSelection
+(
+ Widget w,
+ Time timev,
+ Atom *selection,
+ Atom *target,
+ Atom *type_return,
+ XPointer *value_return,
+ unsigned long *length_return,
+ int *format_return
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_SELECTION_H_ */
diff --git a/libXmu/include/X11/Xmu/SysUtil.h b/libXmu/include/X11/Xmu/SysUtil.h index da5b189f4..192352fc7 100644 --- a/libXmu/include/X11/Xmu/SysUtil.h +++ b/libXmu/include/X11/Xmu/SysUtil.h @@ -1,53 +1,53 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifndef _SYSUTIL_H_ -#define _SYSUTIL_H_ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -int XmuGetHostname -( - char *buf_return, - int maxlen -); - -#ifndef _XMU_H_ -int XmuSnprintf -( - char *str, - int size, - _Xconst char *fmt, - ... - ) -_X_ATTRIBUTE_PRINTF(3,4); -#endif - -_XFUNCPROTOEND - -#endif /* _SYSUTIL_H_ */ +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifndef _SYSUTIL_H_
+#define _SYSUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+int XmuGetHostname
+(
+ char *buf_return,
+ int maxlen
+);
+
+#ifndef _XMU_H_
+int XmuSnprintf
+(
+ char *str,
+ int size,
+ _Xconst char *fmt,
+ ...
+ )
+_X_ATTRIBUTE_PRINTF(3,4);
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _SYSUTIL_H_ */
diff --git a/libXmu/include/X11/Xmu/WhitePoint.h b/libXmu/include/X11/Xmu/WhitePoint.h index 9f41c4221..31440d1e1 100644 --- a/libXmu/include/X11/Xmu/WhitePoint.h +++ b/libXmu/include/X11/Xmu/WhitePoint.h @@ -1,63 +1,63 @@ -/* - -Copyright 1991, 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - - -/* - * - * DESCRIPTION - * This file contains a series of standard white point values. - */ -#define CIE_A_u 0.2560 -#define CIE_A_v 0.5243 -#define CIE_A_Y 1.0000 - -#define CIE_B_u 0.2137 -#define CIE_B_v 0.4852 -#define CIE_B_Y 1.0000 - -#define CIE_C_u 0.2009 -#define CIE_C_v 0.4609 -#define CIE_C_Y 1.0000 - -#define CIE_D55_u 0.2044 -#define CIE_D55_v 0.4808 -#define CIE_D55_Y 1.0000 - -#define CIE_D65_u 0.1978 -#define CIE_D65_v 0.4684 -#define CIE_D65_Y 1.0000 - -#define CIE_D75_u 0.1935 -#define CIE_D75_v 0.4586 -#define CIE_D75_Y 1.0000 - -#define ASTM_D50_u 0.2092 -#define ASTM_D50_v 0.4881 -#define ASTM_D50_Y 1.0000 - -#define WP_9300K_u 0.1884 -#define WP_9300K_v 0.4463 -#define WP_9300K_Y 1.0000 +/*
+
+Copyright 1991, 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+
+/*
+ *
+ * DESCRIPTION
+ * This file contains a series of standard white point values.
+ */
+#define CIE_A_u 0.2560
+#define CIE_A_v 0.5243
+#define CIE_A_Y 1.0000
+
+#define CIE_B_u 0.2137
+#define CIE_B_v 0.4852
+#define CIE_B_Y 1.0000
+
+#define CIE_C_u 0.2009
+#define CIE_C_v 0.4609
+#define CIE_C_Y 1.0000
+
+#define CIE_D55_u 0.2044
+#define CIE_D55_v 0.4808
+#define CIE_D55_Y 1.0000
+
+#define CIE_D65_u 0.1978
+#define CIE_D65_v 0.4684
+#define CIE_D65_Y 1.0000
+
+#define CIE_D75_u 0.1935
+#define CIE_D75_v 0.4586
+#define CIE_D75_Y 1.0000
+
+#define ASTM_D50_u 0.2092
+#define ASTM_D50_v 0.4881
+#define ASTM_D50_Y 1.0000
+
+#define WP_9300K_u 0.1884
+#define WP_9300K_v 0.4463
+#define WP_9300K_Y 1.0000
diff --git a/libXmu/include/X11/Xmu/WidgetNode.h b/libXmu/include/X11/Xmu/WidgetNode.h index f9d2cb57f..85a064ece 100644 --- a/libXmu/include/X11/Xmu/WidgetNode.h +++ b/libXmu/include/X11/Xmu/WidgetNode.h @@ -1,95 +1,95 @@ -/* - -Copyright 1990, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifndef _XmuWidgetNode_h -#define _XmuWidgetNode_h - -#include <X11/Intrinsic.h> -#include <X11/Xfuncproto.h> - -/* - * This is usually initialized by setting the first two fields and letting - * rest be implicitly nulled (by genlist.sh, for example) - */ -typedef struct _XmuWidgetNode { - char *label; /* mixed case name */ - WidgetClass *widget_class_ptr; /* addr of widget class */ - struct _XmuWidgetNode *superclass; /* superclass of widget_class */ - struct _XmuWidgetNode *children, *siblings; /* subclass links */ - char *lowered_label; /* lowercase version of label */ - char *lowered_classname; /* lowercase version of class_name */ - Bool have_resources; /* resources have been fetched */ - XtResourceList resources; /* extracted resource database */ - struct _XmuWidgetNode **resourcewn; /* where resources come from */ - Cardinal nresources; /* number of resources */ - XtResourceList constraints; /* extracted constraint resources */ - struct _XmuWidgetNode **constraintwn; /* where constraints come from */ - Cardinal nconstraints; /* number of constraint resources */ - XtPointer data; /* extra data */ -} XmuWidgetNode; - -#define XmuWnClass(wn) ((wn)->widget_class_ptr[0]) -#define XmuWnClassname(wn) (XmuWnClass(wn)->core_class.class_name) -#define XmuWnSuperclass(wn) ((XmuWnClass(wn))->core_class.superclass) - - /* external interfaces */ -_XFUNCPROTOBEGIN - -void XmuWnInitializeNodes -( - XmuWidgetNode *nodearray, - int nnodes - ); - -void XmuWnFetchResources -( - XmuWidgetNode *node, - Widget toplevel, - XmuWidgetNode *topnode - ); - -int XmuWnCountOwnedResources -( - XmuWidgetNode *node, - XmuWidgetNode *ownernode, - Bool constraints - ); - -XmuWidgetNode *XmuWnNameToNode -( - XmuWidgetNode *nodelist, - int nnodes, - _Xconst char *name - ); - -_XFUNCPROTOEND - -#endif /* _XmuWidgetNode_h */ - +/*
+
+Copyright 1990, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XmuWidgetNode_h
+#define _XmuWidgetNode_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * This is usually initialized by setting the first two fields and letting
+ * rest be implicitly nulled (by genlist.sh, for example)
+ */
+typedef struct _XmuWidgetNode {
+ char *label; /* mixed case name */
+ WidgetClass *widget_class_ptr; /* addr of widget class */
+ struct _XmuWidgetNode *superclass; /* superclass of widget_class */
+ struct _XmuWidgetNode *children, *siblings; /* subclass links */
+ char *lowered_label; /* lowercase version of label */
+ char *lowered_classname; /* lowercase version of class_name */
+ Bool have_resources; /* resources have been fetched */
+ XtResourceList resources; /* extracted resource database */
+ struct _XmuWidgetNode **resourcewn; /* where resources come from */
+ Cardinal nresources; /* number of resources */
+ XtResourceList constraints; /* extracted constraint resources */
+ struct _XmuWidgetNode **constraintwn; /* where constraints come from */
+ Cardinal nconstraints; /* number of constraint resources */
+ XtPointer data; /* extra data */
+} XmuWidgetNode;
+
+#define XmuWnClass(wn) ((wn)->widget_class_ptr[0])
+#define XmuWnClassname(wn) (XmuWnClass(wn)->core_class.class_name)
+#define XmuWnSuperclass(wn) ((XmuWnClass(wn))->core_class.superclass)
+
+ /* external interfaces */
+_XFUNCPROTOBEGIN
+
+void XmuWnInitializeNodes
+(
+ XmuWidgetNode *nodearray,
+ int nnodes
+ );
+
+void XmuWnFetchResources
+(
+ XmuWidgetNode *node,
+ Widget toplevel,
+ XmuWidgetNode *topnode
+ );
+
+int XmuWnCountOwnedResources
+(
+ XmuWidgetNode *node,
+ XmuWidgetNode *ownernode,
+ Bool constraints
+ );
+
+XmuWidgetNode *XmuWnNameToNode
+(
+ XmuWidgetNode *nodelist,
+ int nnodes,
+ _Xconst char *name
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _XmuWidgetNode_h */
+
diff --git a/libXmu/include/X11/Xmu/WinUtil.h b/libXmu/include/X11/Xmu/WinUtil.h index c3d11a86a..de1d0acaf 100644 --- a/libXmu/include/X11/Xmu/WinUtil.h +++ b/libXmu/include/X11/Xmu/WinUtil.h @@ -1,61 +1,61 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_WINDOWUTIL_H_ -#define _XMU_WINDOWUTIL_H_ - -#include <X11/Xutil.h> -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -Window XmuClientWindow -( - Display *dpy, - Window win - ); - -Bool XmuUpdateMapHints -( - Display *dpy, - Window win, - XSizeHints *hints - ); - -Screen *XmuScreenOfWindow -( - Display *dpy, - Window w -); - -_XFUNCPROTOEND - -#endif /* _XMU_WINDOWUTIL_H_ */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_WINDOWUTIL_H_
+#define _XMU_WINDOWUTIL_H_
+
+#include <X11/Xutil.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Window XmuClientWindow
+(
+ Display *dpy,
+ Window win
+ );
+
+Bool XmuUpdateMapHints
+(
+ Display *dpy,
+ Window win,
+ XSizeHints *hints
+ );
+
+Screen *XmuScreenOfWindow
+(
+ Display *dpy,
+ Window w
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_WINDOWUTIL_H_ */
diff --git a/libXmu/include/X11/Xmu/Xct.h b/libXmu/include/X11/Xmu/Xct.h index 514ad7fea..337b70bc8 100644 --- a/libXmu/include/X11/Xmu/Xct.h +++ b/libXmu/include/X11/Xmu/Xct.h @@ -1,165 +1,165 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifndef _Xct_h -#define _Xct_h - -#include <X11/Xfuncproto.h> - -#define XctVersion 1 - -typedef unsigned char *XctString; - -typedef enum { - XctUnspecified, - XctLeftToRight, - XctRightToLeft -} XctHDirection; - -typedef unsigned long XctFlags; - -/* These are bits in XctFlags. */ - -#define XctSingleSetSegments 0x0001 - /* This means that returned segments should contain characters from only - * one set (C0, C1, GL, GR). When this is requested, XctSegment is never - * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and - * XctGRSegment are returned. C0 and C1 segments are always returned as - * singleton characters. - */ - -#define XctProvideExtensions 0x0002 - /* This means that if the Compound Text string is from a higher version - * than this code is implemented to, then syntactically correct but unknown - * control sequences should be returned as XctExtension items. If this - * flag is not set, and the Compound Text string version indicates that - * extensions cannot be ignored, then each unknown control sequence will be - * reported as an XctError. - */ - -#define XctAcceptC0Extensions 0x0004 - /* This means that if the Compound Text string is from a higher version - * than this code is implemented to, then unknown C0 characters should be - * treated as if they were legal, and returned as C0 characters (regardless - * of how XctProvideExtensions is set). If this flag is not set, then all - * unknown C0 characters are treated according to XctProvideExtensions. - */ - -#define XctAcceptC1Extensions 0x0008 - /* This means that if the Compound Text string is from a higher version - * than this code is implemented to, then unknown C0 characters should be - * treated as if they were legal, and returned as C0 characters (regardless - * of how XctProvideExtensions is set). If this flag is not set, then all - * unknown C0 characters are treated according to XctProvideExtensions. - */ - -#define XctHideDirection 0x0010 - /* This means that horizontal direction changes should be reported as - * XctHorizontal items. If this flag is not set, then direction changes are - * not returned as items, but the current direction is still maintained and - * reported for other items. - */ - -#define XctFreeString 0x0020 - /* This means that XctFree should free the Compound Text string (that was - * passed to XctCreate. If this flag is not set, the string is not freed. - */ - -#define XctShiftMultiGRToGL 0x0040 - /* Translate GR segments on-the-fly into GL segments for the GR sets: - * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1. - */ - -/* This is the return type for XctNextItem. */ -typedef enum { - XctSegment, /* used when XctSingleSetSegments is not requested */ - XctC0Segment, /* used when XctSingleSetSegments is requested */ - XctGLSegment, /* used when XctSingleSetSegments is requested */ - XctC1Segment, /* used when XctSingleSetSegments is requested */ - XctGRSegment, /* used when XctSingleSetSegments is requested */ - XctExtendedSegment, /* an extended segment */ - XctExtension, /* used when XctProvideExtensions is requested */ - XctHorizontal, /* horizontal direction or depth change */ - XctEndOfText, /* end of text string */ - XctError /* syntactic or semantic error */ -} XctResult; - -typedef struct _XctRec { - XctString total_string; /* as given to XctCreate */ - int total_length; /* as given to XctCreate */ - XctFlags flags; /* as given to XctCreate */ - int version; /* indicates the version of the CT spec - * the string was produced from */ - int can_ignore_exts;/* non-zero if ignoring extensions is - * acceptable, else zero */ - XctString item; /* item returned from XctNextItem */ - unsigned item_length; /* length of item in bytes */ - int char_size; /* number of bytes per character in - * item, with zero meaning variable */ - char *encoding; /* Encoding name for item */ - XctHDirection horizontal; /* direction of item */ - unsigned horz_depth; /* current direction nesting depth */ - char *GL; /* "{I} F" string for current GL */ - char *GL_encoding; /* Encoding name for current GL */ - int GL_set_size; /* 94 or 96 */ - int GL_char_size; /* number of bytes per GL character */ - char *GR; /* "{I} F" string for current GR */ - char *GR_encoding; /* Encoding name for current GR */ - int GR_set_size; /* 94 or 96 */ - int GR_char_size; /* number of bytes per GR character */ - char *GLGR_encoding; /* Encoding name for current GL+GR, - * if known */ - struct _XctPriv *priv; /* private to parser, don't peek */ -} *XctData; - -/* these are the external routines */ -_XFUNCPROTOBEGIN - -XctData XctCreate -( - _Xconst unsigned char *string, - int length, - XctFlags flags -); - -XctResult XctNextItem -( - XctData data -); - -void XctFree -( - XctData data - ); - -void XctReset -( - XctData data - ); - -_XFUNCPROTOEND - -#endif /* _Xct_h */ +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifndef _Xct_h
+#define _Xct_h
+
+#include <X11/Xfuncproto.h>
+
+#define XctVersion 1
+
+typedef unsigned char *XctString;
+
+typedef enum {
+ XctUnspecified,
+ XctLeftToRight,
+ XctRightToLeft
+} XctHDirection;
+
+typedef unsigned long XctFlags;
+
+/* These are bits in XctFlags. */
+
+#define XctSingleSetSegments 0x0001
+ /* This means that returned segments should contain characters from only
+ * one set (C0, C1, GL, GR). When this is requested, XctSegment is never
+ * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and
+ * XctGRSegment are returned. C0 and C1 segments are always returned as
+ * singleton characters.
+ */
+
+#define XctProvideExtensions 0x0002
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then syntactically correct but unknown
+ * control sequences should be returned as XctExtension items. If this
+ * flag is not set, and the Compound Text string version indicates that
+ * extensions cannot be ignored, then each unknown control sequence will be
+ * reported as an XctError.
+ */
+
+#define XctAcceptC0Extensions 0x0004
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctAcceptC1Extensions 0x0008
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctHideDirection 0x0010
+ /* This means that horizontal direction changes should be reported as
+ * XctHorizontal items. If this flag is not set, then direction changes are
+ * not returned as items, but the current direction is still maintained and
+ * reported for other items.
+ */
+
+#define XctFreeString 0x0020
+ /* This means that XctFree should free the Compound Text string (that was
+ * passed to XctCreate. If this flag is not set, the string is not freed.
+ */
+
+#define XctShiftMultiGRToGL 0x0040
+ /* Translate GR segments on-the-fly into GL segments for the GR sets:
+ * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1.
+ */
+
+/* This is the return type for XctNextItem. */
+typedef enum {
+ XctSegment, /* used when XctSingleSetSegments is not requested */
+ XctC0Segment, /* used when XctSingleSetSegments is requested */
+ XctGLSegment, /* used when XctSingleSetSegments is requested */
+ XctC1Segment, /* used when XctSingleSetSegments is requested */
+ XctGRSegment, /* used when XctSingleSetSegments is requested */
+ XctExtendedSegment, /* an extended segment */
+ XctExtension, /* used when XctProvideExtensions is requested */
+ XctHorizontal, /* horizontal direction or depth change */
+ XctEndOfText, /* end of text string */
+ XctError /* syntactic or semantic error */
+} XctResult;
+
+typedef struct _XctRec {
+ XctString total_string; /* as given to XctCreate */
+ int total_length; /* as given to XctCreate */
+ XctFlags flags; /* as given to XctCreate */
+ int version; /* indicates the version of the CT spec
+ * the string was produced from */
+ int can_ignore_exts;/* non-zero if ignoring extensions is
+ * acceptable, else zero */
+ XctString item; /* item returned from XctNextItem */
+ unsigned item_length; /* length of item in bytes */
+ int char_size; /* number of bytes per character in
+ * item, with zero meaning variable */
+ char *encoding; /* Encoding name for item */
+ XctHDirection horizontal; /* direction of item */
+ unsigned horz_depth; /* current direction nesting depth */
+ char *GL; /* "{I} F" string for current GL */
+ char *GL_encoding; /* Encoding name for current GL */
+ int GL_set_size; /* 94 or 96 */
+ int GL_char_size; /* number of bytes per GL character */
+ char *GR; /* "{I} F" string for current GR */
+ char *GR_encoding; /* Encoding name for current GR */
+ int GR_set_size; /* 94 or 96 */
+ int GR_char_size; /* number of bytes per GR character */
+ char *GLGR_encoding; /* Encoding name for current GL+GR,
+ * if known */
+ struct _XctPriv *priv; /* private to parser, don't peek */
+} *XctData;
+
+/* these are the external routines */
+_XFUNCPROTOBEGIN
+
+XctData XctCreate
+(
+ _Xconst unsigned char *string,
+ int length,
+ XctFlags flags
+);
+
+XctResult XctNextItem
+(
+ XctData data
+);
+
+void XctFree
+(
+ XctData data
+ );
+
+void XctReset
+(
+ XctData data
+ );
+
+_XFUNCPROTOEND
+
+#endif /* _Xct_h */
diff --git a/libXmu/include/X11/Xmu/Xmu.h b/libXmu/include/X11/Xmu/Xmu.h index ad7948846..8ab9d7913 100644 --- a/libXmu/include/X11/Xmu/Xmu.h +++ b/libXmu/include/X11/Xmu/Xmu.h @@ -1,122 +1,122 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_H_ -#define _XMU_H_ - -#include <X11/Xfuncproto.h> -#include <X11/Intrinsic.h> -#include <X11/Xmu/Atoms.h> /* _XA_... */ -#include <X11/Xmu/CharSet.h> /* CopyISOLatin1Lowered */ -#include <X11/Xmu/Converters.h> /* CvtStringTo... */ -#include <X11/Xmu/Drawing.h> /* DrawRoundedRect, DrawLogo */ -#include <X11/Xmu/Error.h> /* PrintDefaultError */ -#include <X11/Xmu/StdSel.h> /* ConvertStandardSelection */ - -/* - * clip lists - */ -typedef struct _XmuSegment { - int x1, x2; - struct _XmuSegment *next; -} XmuSegment; - -typedef struct _XmuScanline { - int y; - XmuSegment *segment; - struct _XmuScanline *next; -} XmuScanline; - -typedef struct _XmuArea { - XmuScanline *scanline; -} XmuArea; - -#define XmuCreateArea() XmuNewArea(0, 0, 0, 0) -#define XmuAreaOr(dst, src) XmuAreaOrXor((dst), (src), True) -#define XmuAreaXor(dst, src) XmuAreaOrXor((dst), (src), False) - -#define XmuDestroyArea(a) \ - do { \ - XmuDestroyScanlineList((a)->scanline); \ - XtFree((char *)(a)); \ - } while (0) - -#define FreeArea(a) \ - do { \ - XmuDestroyScanlineList((a)->scanline); \ - a->scanline = (Scanline *)0; \ - } while (0) - -#define XmuValidSegment(s) ((s)->x1 < (s)->x2) -#define XmuSegmentEqu(s1, s2) ((s1)->x1 == (s2)->x1 && (s1)->x2 == (s2)->x2) -#define XmuDestroySegment(s) XtFree((char *)(s)) - -#define XmuDestroyScanline(s) \ - do { \ - XmuDestroySegmentList((s)->segment); \ - XtFree((char*)(s)); \ - } while (0) - -XmuArea *XmuNewArea(int, int, int, int); -XmuArea *XmuAreaDup(XmuArea*); -XmuArea *XmuAreaCopy(XmuArea*, XmuArea*); -XmuArea *XmuAreaNot(XmuArea*, int, int, int, int); -XmuArea *XmuAreaOrXor(XmuArea*, XmuArea*, Bool); -XmuArea *XmuAreaAnd(XmuArea*, XmuArea*); -Bool XmuValidArea(XmuArea*); -Bool XmuValidScanline(XmuScanline*); -Bool XmuScanlineEqu(XmuScanline*, XmuScanline*); -XmuSegment *XmuNewSegment(int, int); -void XmuDestroySegmentList(XmuSegment*); -XmuScanline *XmuScanlineCopy(XmuScanline*, XmuScanline*); -Bool XmuAppendSegment(XmuSegment*, XmuSegment*); -XmuScanline *XmuOptimizeScanline(XmuScanline*); -XmuScanline *XmuScanlineNot(XmuScanline *scanline, int, int); -XmuScanline *XmuScanlineOr(XmuScanline*, XmuScanline*); -XmuScanline *XmuScanlineAnd(XmuScanline*, XmuScanline*); -XmuScanline *XmuScanlineXor(XmuScanline*, XmuScanline*); -XmuScanline *XmuNewScanline(int, int, int); -void XmuDestroyScanlineList(XmuScanline*); -XmuArea *XmuOptimizeArea(XmuArea *area); - -#ifndef notdef -XmuScanline *XmuScanlineOrSegment(XmuScanline*, XmuSegment*); -XmuScanline *XmuScanlineAndSegment(XmuScanline*, XmuSegment*); -XmuScanline *XmuScanlineXorSegment(XmuScanline*, XmuSegment*); -#endif /* notdef */ - -#ifndef _SYSUTIL_H_ -int XmuSnprintf(char *str, int size, _Xconst char *fmt, ...) - _X_ATTRIBUTE_PRINTF(3,4); -#endif - -#endif /* _XMU_H_ */ - +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_H_
+#define _XMU_H_
+
+#include <X11/Xfuncproto.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Atoms.h> /* _XA_... */
+#include <X11/Xmu/CharSet.h> /* CopyISOLatin1Lowered */
+#include <X11/Xmu/Converters.h> /* CvtStringTo... */
+#include <X11/Xmu/Drawing.h> /* DrawRoundedRect, DrawLogo */
+#include <X11/Xmu/Error.h> /* PrintDefaultError */
+#include <X11/Xmu/StdSel.h> /* ConvertStandardSelection */
+
+/*
+ * clip lists
+ */
+typedef struct _XmuSegment {
+ int x1, x2;
+ struct _XmuSegment *next;
+} XmuSegment;
+
+typedef struct _XmuScanline {
+ int y;
+ XmuSegment *segment;
+ struct _XmuScanline *next;
+} XmuScanline;
+
+typedef struct _XmuArea {
+ XmuScanline *scanline;
+} XmuArea;
+
+#define XmuCreateArea() XmuNewArea(0, 0, 0, 0)
+#define XmuAreaOr(dst, src) XmuAreaOrXor((dst), (src), True)
+#define XmuAreaXor(dst, src) XmuAreaOrXor((dst), (src), False)
+
+#define XmuDestroyArea(a) \
+ do { \
+ XmuDestroyScanlineList((a)->scanline); \
+ XtFree((char *)(a)); \
+ } while (0)
+
+#define FreeArea(a) \
+ do { \
+ XmuDestroyScanlineList((a)->scanline); \
+ a->scanline = (Scanline *)0; \
+ } while (0)
+
+#define XmuValidSegment(s) ((s)->x1 < (s)->x2)
+#define XmuSegmentEqu(s1, s2) ((s1)->x1 == (s2)->x1 && (s1)->x2 == (s2)->x2)
+#define XmuDestroySegment(s) XtFree((char *)(s))
+
+#define XmuDestroyScanline(s) \
+ do { \
+ XmuDestroySegmentList((s)->segment); \
+ XtFree((char*)(s)); \
+ } while (0)
+
+XmuArea *XmuNewArea(int, int, int, int);
+XmuArea *XmuAreaDup(XmuArea*);
+XmuArea *XmuAreaCopy(XmuArea*, XmuArea*);
+XmuArea *XmuAreaNot(XmuArea*, int, int, int, int);
+XmuArea *XmuAreaOrXor(XmuArea*, XmuArea*, Bool);
+XmuArea *XmuAreaAnd(XmuArea*, XmuArea*);
+Bool XmuValidArea(XmuArea*);
+Bool XmuValidScanline(XmuScanline*);
+Bool XmuScanlineEqu(XmuScanline*, XmuScanline*);
+XmuSegment *XmuNewSegment(int, int);
+void XmuDestroySegmentList(XmuSegment*);
+XmuScanline *XmuScanlineCopy(XmuScanline*, XmuScanline*);
+Bool XmuAppendSegment(XmuSegment*, XmuSegment*);
+XmuScanline *XmuOptimizeScanline(XmuScanline*);
+XmuScanline *XmuScanlineNot(XmuScanline *scanline, int, int);
+XmuScanline *XmuScanlineOr(XmuScanline*, XmuScanline*);
+XmuScanline *XmuScanlineAnd(XmuScanline*, XmuScanline*);
+XmuScanline *XmuScanlineXor(XmuScanline*, XmuScanline*);
+XmuScanline *XmuNewScanline(int, int, int);
+void XmuDestroyScanlineList(XmuScanline*);
+XmuArea *XmuOptimizeArea(XmuArea *area);
+
+#ifndef notdef
+XmuScanline *XmuScanlineOrSegment(XmuScanline*, XmuSegment*);
+XmuScanline *XmuScanlineAndSegment(XmuScanline*, XmuSegment*);
+XmuScanline *XmuScanlineXorSegment(XmuScanline*, XmuSegment*);
+#endif /* notdef */
+
+#ifndef _SYSUTIL_H_
+int XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
+ _X_ATTRIBUTE_PRINTF(3,4);
+#endif
+
+#endif /* _XMU_H_ */
+
diff --git a/libXmu/src/AllCmap.c b/libXmu/src/AllCmap.c index 1daa8de7c..1f57b708a 100644 --- a/libXmu/src/AllCmap.c +++ b/libXmu/src/AllCmap.c @@ -1,155 +1,155 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -static XVisualInfo *getDeepestVisual(int, XVisualInfo*, int); - -/* - * To create all of the appropriate standard colormaps for every visual of - * every screen on a given display, use XmuAllStandardColormaps. - * - * Define and retain as permanent resources all standard colormaps which are - * meaningful for the visuals of each screen of the display. Return 0 on - * failure, non-zero on success. If the property of any standard colormap - * is already defined, redefine it. - * - * This interface is intended to be used by window managers or a client - * upon start-up of a session. - * - * The standard colormaps of a screen are defined by properties associated - * with the screen's root window. Each screen has exactly one root window. - * The property names of standard colormaps are predefined, and each property - * name may describe at most one colormap. - * - * The standard colormaps are - * RGB_BEST_MAP - * RGB_RED_MAP - * RGB_GREEN_MAP - * RGB_BLUE_MAP - * RGB_DEFAULT_MAP - * RGB_GRAY_MAP - * - * Therefore a screen may have at most 6 standard colormap properties defined. - * - * A standard colormap is associated with a particular visual of the screen. - * A screen may have multiple visuals defined, including visuals of the same - * class at different depths. Note that a visual id might be repeated for - * more than one depth, so the visual id and the depth of a visual identify - * the visual. The characteristics of the visual will determine which - * standard colormaps are meaningful under that visual, and will determine - * how the standard colormap is defined. Because a standard colormap is - * associated with a specific visual, there must be a method of determining - * which visuals take precedence in defining standard colormaps. - * - * The method used here is: for the visual of greatest depth, define all - * standard colormaps meaningful to that visual class, according to this - * order of (descending) precedence: - * 1. DirectColor - * 2. PseudoColor - * 3. TrueColor and GrayScale - * 4. StaticColor and StaticGray - * - * Allows partial success by screenful. For example, if a map on screen 1 - * fails, the maps on screen 0, created earlier, will remain. However, - * none on screen 1 will remain. If a map on 0 fails, none will remain. - * - * See the comments under XmuVisualStandardColormaps() for notes on which - * standard colormaps are meaningful under these classes of visuals. - */ - -Status -XmuAllStandardColormaps(Display *dpy) -{ - int nvisuals, scr; - Status status; - long vinfo_mask; - XVisualInfo template, *vinfo, *v1, *v2; - - status = 0; - /* for each screen, determine all visuals of this server */ - for (scr=0; scr < ScreenCount(dpy); scr++) - { - template.screen = scr; - vinfo_mask = VisualScreenMask; - vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals); - if (vinfo == NULL) /* unexpected: a screen with no visuals */ - continue; - - v1 = getDeepestVisual(DirectColor, vinfo, nvisuals); - v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals); - - if (v2 && - (!v1 || (v2->colormap_size >= - ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1)))) - status = XmuVisualStandardColormaps(dpy, scr, v2->visualid, - (unsigned) v2->depth, 1, 1); - else if (v1) - status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, 1); - - else { - if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL) - || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) != - NULL)) - status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, 1); - if (status && - (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL) - || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) != - NULL))) - status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, 1); - } - XFree ((char *) vinfo); - if (!status) break; - } - return status; -} - -static XVisualInfo * -getDeepestVisual(int visual_class, XVisualInfo *vinfo, int nvisuals) -{ - register int i; - register int maxdepth = 0; - XVisualInfo *v = NULL; - - for (i=0; i < nvisuals; i++, vinfo++) - if (vinfo->class == visual_class && vinfo->depth > maxdepth) - { - maxdepth = vinfo->depth; - v = vinfo; - } - return(v); -} - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+static XVisualInfo *getDeepestVisual(int, XVisualInfo*, int);
+
+/*
+ * To create all of the appropriate standard colormaps for every visual of
+ * every screen on a given display, use XmuAllStandardColormaps.
+ *
+ * Define and retain as permanent resources all standard colormaps which are
+ * meaningful for the visuals of each screen of the display. Return 0 on
+ * failure, non-zero on success. If the property of any standard colormap
+ * is already defined, redefine it.
+ *
+ * This interface is intended to be used by window managers or a client
+ * upon start-up of a session.
+ *
+ * The standard colormaps of a screen are defined by properties associated
+ * with the screen's root window. Each screen has exactly one root window.
+ * The property names of standard colormaps are predefined, and each property
+ * name may describe at most one colormap.
+ *
+ * The standard colormaps are
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_DEFAULT_MAP
+ * RGB_GRAY_MAP
+ *
+ * Therefore a screen may have at most 6 standard colormap properties defined.
+ *
+ * A standard colormap is associated with a particular visual of the screen.
+ * A screen may have multiple visuals defined, including visuals of the same
+ * class at different depths. Note that a visual id might be repeated for
+ * more than one depth, so the visual id and the depth of a visual identify
+ * the visual. The characteristics of the visual will determine which
+ * standard colormaps are meaningful under that visual, and will determine
+ * how the standard colormap is defined. Because a standard colormap is
+ * associated with a specific visual, there must be a method of determining
+ * which visuals take precedence in defining standard colormaps.
+ *
+ * The method used here is: for the visual of greatest depth, define all
+ * standard colormaps meaningful to that visual class, according to this
+ * order of (descending) precedence:
+ * 1. DirectColor
+ * 2. PseudoColor
+ * 3. TrueColor and GrayScale
+ * 4. StaticColor and StaticGray
+ *
+ * Allows partial success by screenful. For example, if a map on screen 1
+ * fails, the maps on screen 0, created earlier, will remain. However,
+ * none on screen 1 will remain. If a map on 0 fails, none will remain.
+ *
+ * See the comments under XmuVisualStandardColormaps() for notes on which
+ * standard colormaps are meaningful under these classes of visuals.
+ */
+
+Status
+XmuAllStandardColormaps(Display *dpy)
+{
+ int nvisuals, scr;
+ Status status;
+ long vinfo_mask;
+ XVisualInfo template, *vinfo, *v1, *v2;
+
+ status = 0;
+ /* for each screen, determine all visuals of this server */
+ for (scr=0; scr < ScreenCount(dpy); scr++)
+ {
+ template.screen = scr;
+ vinfo_mask = VisualScreenMask;
+ vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
+ if (vinfo == NULL) /* unexpected: a screen with no visuals */
+ continue;
+
+ v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
+ v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
+
+ if (v2 &&
+ (!v1 || (v2->colormap_size >=
+ ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
+ status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
+ (unsigned) v2->depth, 1, 1);
+ else if (v1)
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+
+ else {
+ if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
+ NULL))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ if (status &&
+ (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
+ NULL)))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ }
+ XFree ((char *) vinfo);
+ if (!status) break;
+ }
+ return status;
+}
+
+static XVisualInfo *
+getDeepestVisual(int visual_class, XVisualInfo *vinfo, int nvisuals)
+{
+ register int i;
+ register int maxdepth = 0;
+ XVisualInfo *v = NULL;
+
+ for (i=0; i < nvisuals; i++, vinfo++)
+ if (vinfo->class == visual_class && vinfo->depth > maxdepth)
+ {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ return(v);
+}
+
diff --git a/libXmu/src/Atoms.c b/libXmu/src/Atoms.c index 48e243194..aa56a83e6 100644 --- a/libXmu/src/Atoms.c +++ b/libXmu/src/Atoms.c @@ -1,151 +1,151 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * This file contains routines to cache atoms, avoiding multiple - * server round-trips. Not so useful now that Xlib caches them. - * - * Public entry points: - * - * XmuMakeAtom creates & initializes an opaque AtomRec - * XmuInternAtom fetches an Atom from cache or Display - * XmuInternStrings fetches multiple Atoms as strings - * XmuGetAtomName returns name of an Atom - * XmuNameOfAtom returns name from an AtomPtr - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include "Atoms.h" - -typedef struct _DisplayRec { - struct _DisplayRec* next; - Display *dpy; - Atom atom; -} DisplayRec; - -struct _AtomRec { - char *name; - DisplayRec* head; -}; - -#ifdef SUNSHLIB -#define STATIC -#else -#define STATIC static -#endif - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define DeclareAtom(atom,text) \ -STATIC struct _AtomRec __##atom = { text, NULL }; \ -AtomPtr _##atom = &__##atom; -#else -#define DeclareAtom(atom,text) \ -STATIC struct _AtomRec __/**/atom = { text, NULL }; \ -AtomPtr _/**/atom = &__/**/atom; -#endif - -DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" ) -DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" ) -DeclareAtom(XA_CLASS, "CLASS" ) -DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" ) -DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" ) -DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" ) -DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" ) -DeclareAtom(XA_DELETE, "DELETE" ) -DeclareAtom(XA_FILENAME, "FILENAME" ) -DeclareAtom(XA_HOSTNAME, "HOSTNAME" ) -DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" ) -DeclareAtom(XA_LENGTH, "LENGTH" ) -DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" ) -DeclareAtom(XA_NAME, "NAME" ) -DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" ) -DeclareAtom(XA_NULL, "NULL" ) -DeclareAtom(XA_OWNER_OS, "OWNER_OS" ) -DeclareAtom(XA_SPAN, "SPAN" ) -DeclareAtom(XA_TARGETS, "TARGETS" ) -DeclareAtom(XA_TEXT, "TEXT" ) -DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" ) -DeclareAtom(XA_USER, "USER" ) -DeclareAtom(XA_UTF8_STRING, "UTF8_STRING" ) - -/****************************************************************** - - Public procedures - - ******************************************************************/ - - -AtomPtr -XmuMakeAtom(_Xconst char *name) -{ - AtomPtr ptr = XtNew(struct _AtomRec); - ptr->name = (char *) name; - ptr->head = NULL; - return ptr; -} - -char * -XmuNameOfAtom(AtomPtr atom_ptr) -{ - return atom_ptr->name; -} - - -Atom -XmuInternAtom(Display *d, AtomPtr atom_ptr) -{ - DisplayRec* display_rec; - for (display_rec = atom_ptr->head; display_rec != NULL; - display_rec = display_rec->next) { - if (display_rec->dpy == d) - return display_rec->atom; - } - display_rec = XtNew(DisplayRec); - display_rec->next = atom_ptr->head; - atom_ptr->head = display_rec; - display_rec->dpy = d; - display_rec->atom = XInternAtom(d, atom_ptr->name, False); - return display_rec->atom; -} - - -char * -XmuGetAtomName(Display *d, Atom atom) -{ - if (atom == 0) return (NULL); - return XGetAtomName(d, atom); -} - -/* convert (names, count) to a list of atoms. Caller allocates list */ -void -XmuInternStrings(Display *d, register String *names, - register Cardinal count, register Atom *atoms) -{ - (void) XInternAtoms(d, (char**)names, (int)count, FALSE, atoms); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains routines to cache atoms, avoiding multiple
+ * server round-trips. Not so useful now that Xlib caches them.
+ *
+ * Public entry points:
+ *
+ * XmuMakeAtom creates & initializes an opaque AtomRec
+ * XmuInternAtom fetches an Atom from cache or Display
+ * XmuInternStrings fetches multiple Atoms as strings
+ * XmuGetAtomName returns name of an Atom
+ * XmuNameOfAtom returns name from an AtomPtr
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include "Atoms.h"
+
+typedef struct _DisplayRec {
+ struct _DisplayRec* next;
+ Display *dpy;
+ Atom atom;
+} DisplayRec;
+
+struct _AtomRec {
+ char *name;
+ DisplayRec* head;
+};
+
+#ifdef SUNSHLIB
+#define STATIC
+#else
+#define STATIC static
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __##atom = { text, NULL }; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __/**/atom = { text, NULL }; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" )
+DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" )
+DeclareAtom(XA_CLASS, "CLASS" )
+DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" )
+DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" )
+DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" )
+DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" )
+DeclareAtom(XA_DELETE, "DELETE" )
+DeclareAtom(XA_FILENAME, "FILENAME" )
+DeclareAtom(XA_HOSTNAME, "HOSTNAME" )
+DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" )
+DeclareAtom(XA_LENGTH, "LENGTH" )
+DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" )
+DeclareAtom(XA_NAME, "NAME" )
+DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" )
+DeclareAtom(XA_NULL, "NULL" )
+DeclareAtom(XA_OWNER_OS, "OWNER_OS" )
+DeclareAtom(XA_SPAN, "SPAN" )
+DeclareAtom(XA_TARGETS, "TARGETS" )
+DeclareAtom(XA_TEXT, "TEXT" )
+DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" )
+DeclareAtom(XA_USER, "USER" )
+DeclareAtom(XA_UTF8_STRING, "UTF8_STRING" )
+
+/******************************************************************
+
+ Public procedures
+
+ ******************************************************************/
+
+
+AtomPtr
+XmuMakeAtom(_Xconst char *name)
+{
+ AtomPtr ptr = XtNew(struct _AtomRec);
+ ptr->name = (char *) name;
+ ptr->head = NULL;
+ return ptr;
+}
+
+char *
+XmuNameOfAtom(AtomPtr atom_ptr)
+{
+ return atom_ptr->name;
+}
+
+
+Atom
+XmuInternAtom(Display *d, AtomPtr atom_ptr)
+{
+ DisplayRec* display_rec;
+ for (display_rec = atom_ptr->head; display_rec != NULL;
+ display_rec = display_rec->next) {
+ if (display_rec->dpy == d)
+ return display_rec->atom;
+ }
+ display_rec = XtNew(DisplayRec);
+ display_rec->next = atom_ptr->head;
+ atom_ptr->head = display_rec;
+ display_rec->dpy = d;
+ display_rec->atom = XInternAtom(d, atom_ptr->name, False);
+ return display_rec->atom;
+}
+
+
+char *
+XmuGetAtomName(Display *d, Atom atom)
+{
+ if (atom == 0) return (NULL);
+ return XGetAtomName(d, atom);
+}
+
+/* convert (names, count) to a list of atoms. Caller allocates list */
+void
+XmuInternStrings(Display *d, register String *names,
+ register Cardinal count, register Atom *atoms)
+{
+ (void) XInternAtoms(d, (char**)names, (int)count, FALSE, atoms);
+}
diff --git a/libXmu/src/ClientWin.c b/libXmu/src/ClientWin.c index 3af323e0a..17a49365b 100644 --- a/libXmu/src/ClientWin.c +++ b/libXmu/src/ClientWin.c @@ -1,97 +1,97 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xatom.h> - -#include <X11/Xmu/WinUtil.h> - -/* - * Prototypes - */ -static Window TryChildren(Display*, Window, Atom); - -/* Find a window with WM_STATE, else return win itself, as per ICCCM */ - -Window -XmuClientWindow(Display *dpy, Window win) -{ - Atom WM_STATE; - Atom type = None; - int format; - unsigned long nitems, after; - unsigned char *data = NULL; - Window inf; - - WM_STATE = XInternAtom(dpy, "WM_STATE", True); - if (!WM_STATE) - return win; - XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, - &type, &format, &nitems, &after, &data); - if (data) - XFree(data); - if (type) - return win; - inf = TryChildren(dpy, win, WM_STATE); - if (!inf) - inf = win; - return inf; -} - -static Window -TryChildren(Display *dpy, Window win, Atom WM_STATE) -{ - Window root, parent; - Window *children; - unsigned int nchildren; - unsigned int i; - Atom type = None; - int format; - unsigned long nitems, after; - unsigned char *data; - Window inf = 0; - - if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) - return 0; - for (i = 0; !inf && (i < nchildren); i++) { - data = NULL; - XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False, - AnyPropertyType, &type, &format, &nitems, - &after, &data); - if (data) - XFree(data); - if (type) - inf = children[i]; - } - for (i = 0; !inf && (i < nchildren); i++) - inf = TryChildren(dpy, children[i], WM_STATE); - if (children) - XFree(children); - return inf; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#include <X11/Xmu/WinUtil.h>
+
+/*
+ * Prototypes
+ */
+static Window TryChildren(Display*, Window, Atom);
+
+/* Find a window with WM_STATE, else return win itself, as per ICCCM */
+
+Window
+XmuClientWindow(Display *dpy, Window win)
+{
+ Atom WM_STATE;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data = NULL;
+ Window inf;
+
+ WM_STATE = XInternAtom(dpy, "WM_STATE", True);
+ if (!WM_STATE)
+ return win;
+ XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
+ &type, &format, &nitems, &after, &data);
+ if (data)
+ XFree(data);
+ if (type)
+ return win;
+ inf = TryChildren(dpy, win, WM_STATE);
+ if (!inf)
+ inf = win;
+ return inf;
+}
+
+static Window
+TryChildren(Display *dpy, Window win, Atom WM_STATE)
+{
+ Window root, parent;
+ Window *children;
+ unsigned int nchildren;
+ unsigned int i;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data;
+ Window inf = 0;
+
+ if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
+ return 0;
+ for (i = 0; !inf && (i < nchildren); i++) {
+ data = NULL;
+ XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
+ AnyPropertyType, &type, &format, &nitems,
+ &after, &data);
+ if (data)
+ XFree(data);
+ if (type)
+ inf = children[i];
+ }
+ for (i = 0; !inf && (i < nchildren); i++)
+ inf = TryChildren(dpy, children[i], WM_STATE);
+ if (children)
+ XFree(children);
+ return inf;
+}
diff --git a/libXmu/src/Clip.c b/libXmu/src/Clip.c index ff87a80c0..67f8a51c1 100644 --- a/libXmu/src/Clip.c +++ b/libXmu/src/Clip.c @@ -1,1616 +1,1616 @@ -/* - * Copyright (c) 1998 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdlib.h> - -#include <X11/IntrinsicP.h> -#include <X11/Xmu/Xmu.h> - -#define XmuMax(a, b) ((a) > (b) ? (a) : (b)) -#define XmuMin(a, b) ((a) < (b) ? (a) : (b)) - -/* - * Function: - * XmuNewArea - * - * Parameters: - * x1 - Coordinates of the rectangle - * y1 - "" - * x2 - "" - * y2 - "" - * - * Description: - * Creates a new rectangular clipping area - */ -XmuArea * -XmuNewArea(int x1, int y1, int x2, int y2) -{ - XmuArea *area; - - area = (XmuArea *)XtMalloc(sizeof(XmuArea)); - if (x2 > x1 && y2 > y1) - { - area->scanline = XmuNewScanline(y1, x1, x2); - area->scanline->next = XmuNewScanline(y2, 0, 0); - } - else - area->scanline = (XmuScanline *)NULL; - - return (area); -} - -/* - * Function: - * XmuAreaDup - * - * Parameters: - * area - Area to copy - * - * Description: - * Returns a copy of its argument - */ -XmuArea * -XmuAreaDup(XmuArea *area) -{ - XmuArea *dst; - - if (!area) - return ((XmuArea *)NULL); - - dst = XmuCreateArea(); - XmuAreaCopy(dst, area); - return (dst); -} - -/* - * Function: - * XmuAreaCopy - * - * Parameters: - * dst - destination area - * src - source area - * - * Description: - * Minimizes memory alocation, trying to use already alocated memory - * in dst, freeing what is not required anymore. - */ -XmuArea * -XmuAreaCopy(XmuArea *dst, XmuArea *src) -{ - XmuScanline *z, *p, *Z; - - if (!dst || !src || dst == src) - return (dst); - - z = p = dst->scanline; - Z = src->scanline; - - /*CONSTCOND*/ - while (1) - { - if (!Z) - { - if (z == dst->scanline) - { - XmuDestroyScanlineList(dst->scanline); - dst->scanline = (XmuScanline *)NULL; - } - else - { - XmuDestroyScanlineList(p->next); - p->next = (XmuScanline *)NULL; - } - return (dst); - } - if (z) - { - XmuScanlineCopy(z, Z); - z->y = Z->y; - } - else - { - z = XmuNewScanline(Z->y, 0, 0); - XmuScanlineCopy(z, Z); - if (p == dst->scanline && !dst->scanline) - p = dst->scanline = z; - else - p->next = z; - } - p = z; - z = z->next; - Z = Z->next; - } - - return (dst); -} - -/* - * Function: - * XmuAreaNot - * - * Parameters: - * area - area to operate - * x1 - retangle to clip the result against - * y1 - "" - * x2 - "" - * y2 - "" - * - * Description: - * (Input) - * (x1, y1) (x2, y1) - * +-------------+ - * +------------+ +----+ - * | +--------------+ - * +----------------+ - * (x1, y2) (x2, y2) - * - * (Output) - * (x1, y1) (x2, y1) - * +--------------+ +--------------------------+ - * | +------------+ +----+ | - * | | +--------------+ | - * +-+ +------------------------------------+ - * (x1, y2) (x2, y2) - */ -XmuArea * -XmuAreaNot(XmuArea *area, int x1, int y1, int x2, int y2) -{ - XmuScanline *z; - XmuArea *and; - - if (!area) - return (area); - - if (x1 > x2) - { - x1 ^= x2; x2 ^= x1; x1 ^= x2; - } - if (y1 > y2) - { - y1 ^= y2; y2 ^= y1; y1 ^= y2; - } - if (!area->scanline) - { - if ((area->scanline = XmuNewScanline(y1, x1, x2)) != NULL) - area->scanline->next = XmuNewScanline(y2, 0, 0); - return (area); - } - and = XmuNewArea(x1, y1, x2, y2); - XmuAreaAnd(area, and); - XmuDestroyArea(and); - z = area->scanline; - if (z->y != y1) - { - XmuScanline *q = XmuNewScanline(y1, x1, x2); - q->next = z; - area->scanline = q; - } - else - { - area->scanline = area->scanline->next; - XmuDestroyScanline(z); - XmuOptimizeArea(area); - if((z = area->scanline) == (XmuScanline *)NULL) - return (area); - } - - /* CONSTCOND */ - while (1) - { - XmuScanlineNot(z, x1, x2); - if (!z->next) - { - z->next = XmuNewScanline(y2, 0, 0); - break; - } - if (z->next->y == y2) - { - XmuDestroyScanlineList(z->next); - z->next = XmuNewScanline(y2, 0, 0); - break; - } - z = z->next; - } - - return (area); -} - -/* - * Function: - * XmuAreaOrXor - * - * Parameters: - * dst - destination area - * src - source area - * or - or operation if true, else xor operation - * - * Description: - * Executes Or (Union) or Xor (Reverse intesection) of the areas - */ -XmuArea * -XmuAreaOrXor(XmuArea *dst, XmuArea *src, Bool or) -{ - XmuScanline *z, *p, *Z, *P, *ins, *top; - - if (!dst || !src) - return (dst); - - if (dst == src) - { - if (or) - return (dst); - XmuDestroyScanlineList(dst->scanline); - dst->scanline = (XmuScanline *)NULL; - return (dst); - } - if (!XmuValidArea(src)) - return (dst); - if (!XmuValidArea(dst)) - { - XmuAreaCopy(dst, src); - return (dst); - } - - p = z = dst->scanline; - P = Z = src->scanline; - ins = XmuNewScanline(dst->scanline->y, 0, 0); - top = XmuNewScanline(dst->scanline->y, 0, 0); - XmuScanlineCopy(ins, dst->scanline); - XmuScanlineCopy(top, dst->scanline); - - /*CONSTCOND*/ - while (1) - { - if (!Z) - break; - else if (Z->y < z->y) - { - XmuScanline *q = XmuNewScanline(Z->y, 0, 0); - XmuScanlineCopy(q, Z); - - if (z == dst->scanline) - { - dst->scanline = p = q; - q->next = z; - } - else - { - p->next = q; - q->next = z; - if (Z->y >= p->y) - { - if (ins->y >= top->y - && (p->y != P->y || !XmuScanlineEqu(p, P) - || (ins->y <= P->y && !XmuScanlineEqu(ins, P)))) - { - if (or) - XmuScanlineOr(q, ins); - else - XmuScanlineXor(q, ins); - } - else if (Z->y >= top->y - && (top->y == p->y || top->y > ins->y - || !XmuValidScanline(Z) - || (p->y == P->y && XmuValidScanline(p) - && XmuValidScanline(P)) - || XmuScanlineEqu(ins, top))) - { - if (or) - XmuScanlineOr(q, top); - else - XmuScanlineXor(q, top); - } - if (ins->y != p->y && p->y != P->y) - { - XmuScanlineCopy(ins, p); - ins->y = p->y; - } - } - if (!XmuValidScanline(p) || Z->y <= p->y) - { - XmuScanlineCopy(top, p); - top->y = p->y; - } - p = q; - } - P = Z; - Z = Z->next; - continue; - } - else if (Z->y == z->y) - { - if (top->y != z->y) - { - XmuScanlineCopy(top, z); - top->y = z->y; - } - if (or) - XmuScanlineOr(z, Z); - else - XmuScanlineXor(z, Z); - P = Z; - Z = Z->next; - } - else if (P != Z) /* && Z->y > z->y */ - { - if (top->y == ins->y && top->y != z->y) - { - XmuScanlineCopy(top, z); - top->y = z->y; - } - if (ins->y != z->y) - { - XmuScanlineCopy(ins, z); - ins->y = z->y; - } - if (or) - XmuScanlineOr(z, P); - else - XmuScanlineXor(z, P); - } - else if (ins->y != z->y) - { - XmuScanlineCopy(ins, z); - ins->y = z->y; - } - p = z; - z = z->next; - if (!z) - { - while (Z) - { - p->next = XmuNewScanline(Z->y, 0, 0); - XmuScanlineCopy(p->next, Z); - p = p->next; - Z = Z->next; - } - break; - } - else if (ins->y > top->y && !XmuValidScanline(z) - && XmuValidScanline(ins)) - { - XmuScanlineCopy(top, ins); - top->y = ins->y; - } - } - XmuOptimizeArea(dst); - XmuDestroyScanline(ins); - XmuDestroyScanline(top); - - return (dst); -} - -/* - * Function: - * XmuAreaAnd(dst, src) - * - * Parameters: - * dst - destination area - * src - source area - * - * Description: - * Executes And (intersection) of the areas - */ -XmuArea * -XmuAreaAnd(XmuArea *dst, XmuArea *src) -{ - XmuScanline *z, *p, *Z, *P, *top; - - if (!dst || !src || dst == src) - return (dst); - if (!XmuValidArea(dst) || !XmuValidArea(src)) - { - XmuDestroyScanlineList(dst->scanline); - dst->scanline = (XmuScanline *)NULL; - return (dst); - } - z = p = dst->scanline; - Z = P = src->scanline; - top = XmuNewScanline(dst->scanline->y, 0, 0); - XmuScanlineCopy(top, dst->scanline); - - while (z) - { - while (Z->next && Z->next->y < z->y) - { - P = Z; - Z = Z->next; - if (Z->y >= p->y) - { - XmuScanline *q = XmuNewScanline(Z->y, 0, 0); - XmuScanlineCopy(q, Z); - - XmuScanlineAnd(q, top); - if (p->y != P->y) - { - XmuScanlineAnd(p, P); - p->y = XmuMax(p->y, P->y); - } - p->next = q; - q->next = z; - p = q; - } - } - if (!z->next) - { - z->y = XmuMax(z->y, Z->y); - break; - } - while (Z->y >= z->next->y) - { - if (z == dst->scanline) - { - p = dst->scanline = dst->scanline->next; - XmuDestroyScanline(z); - z = dst->scanline; - } - else - { - p->next = z->next; - XmuDestroyScanline(z); - z = p; - } - if (!z || !z->next) - { - XmuOptimizeArea(dst); - XmuDestroyScanline(top); - - return (dst); - } - } - if (Z->y > p->y) - z->y = XmuMax(z->y, Z->y); - if (top->y != z->y) - { - XmuScanlineCopy(top, z); - top->y = z->y; - } - XmuScanlineAnd(z, Z); - p = z; - z = z->next; - } - XmuOptimizeArea(dst); - XmuDestroyScanline(top); - - return (dst); -} - -/* - * Function: - * XmuValidArea(area) - * - * Parameters: - * area - area to verify - * - * Description: - * Verifies if the area is valid and/or useful - */ -Bool -XmuValidArea(XmuArea *area) -{ - XmuScanline *at; - - if (!area || !area->scanline) - return (False); - - at = area->scanline; - while (at) - { - if (XmuValidScanline(at)) - return (True); - at = at->next; - } - - return (False); -} - -/* - * Function: - * XmuValidScanline - * - * Parameters: - * scanline - scanline to verify - * - * Description: - * Verifies if a scanline is useful - */ -Bool -XmuValidScanline(XmuScanline *scanline) -{ - XmuSegment *z; - - if (!scanline) - return (False); - - z = scanline->segment; - while (z) - { - if (XmuValidSegment(z)) - return (True); - z = z->next; - } - - return (False); -} - -/* - * Function: - * XmuScanlineEqu - * - * Parameters: - * s1 - scanline 1 - * s2 - scanline 2 - * - * Description: - * Checks if s1 and s2 are equal - */ -Bool -XmuScanlineEqu(XmuScanline *s1, XmuScanline *s2) -{ - XmuSegment *z, *Z; - - if ((!s1 && !s2) || s1 == s2) - return (True); - if (!s1 || !s2) - return (False); - - z = s1->segment; - Z = s2->segment; - - /*CONSTCOND*/ - while (1) - { - if (!z && !Z) - return (True); - if (!z || !Z) - return (False); - if (!XmuSegmentEqu(z, Z)) - return (False); - z = z->next; - Z = Z->next; - } - /*NOTREACHED*/ -} - -/* - * Function: - * XmuNewSegment - * - * Parameters: - * x1 - coordinates of the segment - * x2 - "" - * - * Description: - * Creates a new segments with the coordinates x1 and x2 - * - * Returns: - * New Segment of NULL - */ -XmuSegment * -XmuNewSegment(int x1, int x2) -{ - XmuSegment *segment; - - if ((segment = (XmuSegment *)XtMalloc(sizeof(XmuSegment))) == NULL) - return (segment); - - segment->x1 = x1; - segment->x2 = x2; - segment->next = (XmuSegment *)NULL; - - return (segment); -} - -/* - * Function: - * XmuDestroySegmentList - * - * Parameters: - * segment - Segment to destroy - * - * Description: - * Frees the memory used by the list headed by segment - */ -void -XmuDestroySegmentList(XmuSegment *segment) -{ - XmuSegment *z; - - if (!segment) - return; - - while (segment) - { - z = segment; - segment = segment->next; - XmuDestroySegment(z); - } -} - -/* - * Function: - * XmuScanlineCopy - * - * Parameters: - * dst - destination scanline - * src - source scanline - * - * Description: - * Makes dst contain the same data as src - */ -XmuScanline * -XmuScanlineCopy(XmuScanline *dst, XmuScanline *src) -{ - XmuSegment *z, *p, *Z; - - if (!dst || !src || dst == src) - return (dst); - - z = p = dst->segment; - Z = src->segment; - - /*CONSTCOND*/ - while (1) - { - if (!Z) - { - if (z == dst->segment) - dst->segment = (XmuSegment *)NULL; - else - p->next = (XmuSegment *)NULL; - XmuDestroySegmentList(z); - return (dst); - } - if (z) - { - z->x1 = Z->x1; - z->x2 = Z->x2; - } - else - { - z = XmuNewSegment(Z->x1, Z->x2); - if (p == dst->segment && !dst->segment) - p = dst->segment = z; - else - p->next = z; - } - p = z; - z = z->next; - Z = Z->next; - } - /*NOTREACHED*/ -} - -/* - * Function: - * XmuAppendSegment - * - * Parameters: - * segment - destination segment - * append - segment to add - * - * Description: - * Adds a copy of the append list at the end of the segment list - */ -Bool -XmuAppendSegment(XmuSegment *segment, XmuSegment *append) -{ - if (!segment || !append) - return (False); - - if (segment->next) - /* Should not happen! */ - XmuDestroySegmentList(segment->next); - - while (append) - { - if (XmuValidSegment(append)) - { - if ((segment->next = XmuNewSegment(append->x1, append->x2)) == NULL) - return (False); - segment = segment->next; - } - append = append->next; - } - - return (True); -} - -/* - * Function: - * XmuOptimizeScanline - * - * Parameters: - * scanline - scanline to optimize - * - * Description: - * Some functions, when transforming Segments of Scanlines, left these - * with unnecessary data (that may cause error in these same functions). - * This function corrects these incorrect segments. - */ -XmuScanline * -XmuOptimizeScanline(XmuScanline *scanline) -{ - XmuSegment *z, *p; - - while (scanline->segment && !XmuValidSegment(scanline->segment)) - { - XmuSegment *s = scanline->segment; - - scanline->segment = scanline->segment->next; - XmuDestroySegment(s); - } - for (z = p = scanline->segment; z; p = z, z = z->next) - { - if (!XmuValidSegment(z)) - { - p->next = z->next; - XmuDestroySegment(z); - z = p; - } - } - return (scanline); -} - -/* - * Name: - * XmuScanlineNot(scanline, minx, maxx) - * - * Parameters: - * scanline - scanlines operate - * minx - minimum x coordinate - * maxx - maximum x coordinate - * - * Description: - * (minx) (maxx) - * + + - * (input) +---------+ +--------+ +--------+ - * (output) +-----+ +-----+ +--------+ +------------+ - */ -XmuScanline * -XmuScanlineNot(XmuScanline *scanline, int minx, int maxx) -{ - XmuSegment *z; - static XmuSegment x = { 0, 0, NULL }; - static XmuScanline and = { 0, &x, NULL }; - - if (!scanline) - return (scanline); - - XmuOptimizeScanline(scanline); - if (minx > maxx) - { - minx ^= maxx; maxx ^= minx; minx ^= maxx; - } - and.segment->x1 = minx; - and.segment->x2 = maxx; - XmuScanlineAnd(scanline, &and); - if (!scanline->segment) - { - scanline->segment = XmuNewSegment(minx, maxx); - return (scanline); - } - z = scanline->segment; - if (z->x1 != minx) - { - XmuSegment *q = XmuNewSegment(minx, z->x1); - - q->next = z; - scanline->segment = q; - } - - /*CONSTCOND*/ - while (1) - { - z->x1 = z->x2; - if (!z->next) - { - z->x2 = maxx; - break; - } - z->x2 = z->next->x1; - if (z->next->x2 == maxx) - { - XmuDestroySegment(z->next); - z->next = (XmuSegment *)NULL; - break; - } - z = z->next; - } - - return (scanline); -} - - -#ifndef notdef -/* - * Function: - * XmuScanlineOrSegment - * - * Parameters: - * dst - destionation scanline - * src - source segment - * - * Description: - * (input) +-----------+ +--------+ +---------+ - * (src) +-------------------+ - * (output) +-------------------------+ +---------+ - */ -XmuScanline * -XmuScanlineOrSegment(XmuScanline *dst, XmuSegment *src) -{ - XmuSegment *z, *p, ins; - - if (!src || !dst || !XmuValidSegment(src)) - return (dst); - - if (!dst->segment) - { - dst->segment = XmuNewSegment(src->x1, src->x2); - return (dst); - } - - z = p = dst->segment; - ins.x1 = src->x1; - ins.x2 = src->x2; - - /*CONSTCOND*/ - while (1) - { - if (!z) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - if (p == dst->segment && z == p) - dst->segment = q; - else - p->next = q; - break; - } - else if (ins.x2 < z->x1) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - if (p == dst->segment && z == p) - { - q->next = dst->segment; - dst->segment = q; - } - else - { - p->next = q; - q->next = z; - } - break; - } - else if (ins.x2 <= z->x2) - { - z->x1 = XmuMin(z->x1, ins.x1); - break; - } - else if (ins.x1 <= z->x2) - { - ins.x1 = XmuMin(z->x1, ins.x1); - if (!z->next) - { - z->x1 = ins.x1; - z->x2 = ins.x2; - break; - } - else - { - if (z == dst->segment) - { - p = dst->segment = dst->segment->next; - XmuDestroySegment(z); - z = dst->segment; - continue; - } - else - { - p->next = z->next; - XmuDestroySegment(z); - z = p; - } - } - } - p = z; - z = z->next; - } - - return (dst); -} - -/* - * Function: - * XmuScanlineAndSegment - * - * Parameters: - * dst - destination scanline - * src - source segment - * - * Description: - * (input) +------------+ +------+ +----------+ - * (src) +---------------------+ - * (output) +-------+ +------+ - */ -XmuScanline * -XmuScanlineAndSegment(XmuScanline *dst, XmuSegment *src) -{ - XmuSegment *z, *p; - - if (!dst || !src) - return (dst); - - if (!XmuValidSegment(src)) - { - XmuDestroySegmentList(dst->segment); - dst->segment = (XmuSegment *)NULL; - return (dst); - } - if (!dst->segment) - return (dst); - - z = p = dst->segment; - while (z) - { - if (src->x2 <= z->x1 || src->x1 >= z->x2) - { - if (z == dst->segment) - { - p = dst->segment = dst->segment->next; - XmuDestroySegment(z); - z = dst->segment; - continue; - } - else - { - p->next = z->next; - XmuDestroySegment(z); - z = p; - } - } - else - { - z->x1 = XmuMax(z->x1, src->x1); - z->x2 = XmuMin(z->x2, src->x2); - } - p = z; - z = z->next; - } - - return (dst); -} - -/* - * Function: - * XmuScanlineXorSegment - * - * Parameters: - * dst - destionation scanline - * src - source segment - * - * Descriptipn: - * (input) +------------+ +----------+ +-----------+ - * (src) +------------------------+ - * (output) +---+ +--+ +-+ +-----------+ - */ -XmuScanline * -XmuScanlineXorSegment(XmuScanline *dst, XmuSegment *src) -{ - XmuSegment *p, *z, ins; - int tmp1, tmp2; - - if (!dst || !src || !XmuValidSegment(src)) - return (dst); - if (!dst->segment) - { - dst->segment = XmuNewSegment(src->x1, src->x2); - return (dst); - } - - p = z = dst->segment; - ins.x1 = src->x1; - ins.x2 = src->x2; - - /*CONSTCOND*/ - while (1) - { - if (!XmuValidSegment((&ins))) - break; - if (!z || ins.x2 < z->x1) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - q->next = z; - if (z == dst->segment) - dst->segment = q; - else - p->next = q; - break; - } - else if (ins.x2 == z->x1) - { - z->x1 = ins.x1; - break; - } - else if (ins.x1 < z->x2) - { - if (ins.x1 < z->x1) - { - tmp1 = ins.x2; - tmp2 = z->x2; - ins.x2 = XmuMax(ins.x2, z->x2); - z->x2 = z->x1; - z->x1 = ins.x1; - ins.x1 = XmuMin(tmp1, tmp2); - } - else if (ins.x1 > z->x1) - { - tmp1 = ins.x1; - ins.x1 = XmuMin(ins.x2, z->x2); - ins.x2 = XmuMax(z->x2, ins.x2); - z->x2 = tmp1; - } - else /* ins.x1 == z->x1 */ - { - if (ins.x2 < z->x2) - { - z->x1 = ins.x2; - break; - } - else - { - ins.x1 = z->x2; - if (z == dst->segment) - p = dst->segment = dst->segment->next; - else - p->next = z->next; - XmuDestroySegment(z); - z = p; - continue; - } - } - } - else if (ins.x1 == z->x2) - { - ins.x1 = z->x1; - if (z == dst->segment) - p = dst->segment = dst->segment->next; - else - p->next = z->next; - XmuDestroySegment(z); - z = p; - continue; - } - p = z; - z = z->next; - } - - return (dst); -} -#endif /* notdef */ - -/* - * Function: - * ScanlineOr - * - * Parameters: - * dst - destionation scanline - * src - source scanline - * - * Description: - * (input) +--------------+ +-----+ +----------+ - * (src) +---------------------+ +-----------+ - * (output) +-------------------------+ +----------------+ - */ -XmuScanline * -XmuScanlineOr(XmuScanline *dst, XmuScanline *src) -{ - XmuSegment *z, *p, *Z, ins; - - if (!src || !src->segment || !dst || dst == src) - return (dst); - if (!dst->segment) - { - XmuScanlineCopy(dst, src); - return (dst); - } - - z = p = dst->segment; - Z = src->segment; - ins.x1 = Z->x1; - ins.x2 = Z->x2; - - /*CONSTCOND*/ - while (1) - { - while (!XmuValidSegment((&ins))) - { - if ((Z = Z->next) == (XmuSegment *)NULL) - return (dst); - ins.x1 = Z->x1; - ins.x2 = Z->x2; - } - if (!z) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - if (p == dst->segment && z == p) - dst->segment = p = q; - else - { - p->next = q; - p = q; - } - Z = Z->next; - XmuAppendSegment(p, Z); - break; - } - else if (ins.x2 < z->x1) - { - XmuSegment *r = XmuNewSegment(ins.x1, ins.x2); - - if (p == dst->segment && z == p) - { - r->next = dst->segment; - dst->segment = p = r; - } - else - { - p->next = r; - r->next = z; - p = r; - } - Z = Z->next; - if (!Z) - break; - else - { - ins.x1 = Z->x1; - ins.x2 = Z->x2; - continue; - } - } - else if (ins.x2 <= z->x2) - { - z->x1 = XmuMin(z->x1, ins.x1); - Z = Z->next; - if (!Z) - break; - else - { - ins.x1 = Z->x1; - ins.x2 = Z->x2; - continue; - } - } - else if (ins.x1 <= z->x2) - { - ins.x1 = XmuMin(z->x1, ins.x1); - if (!z->next) - { - z->x1 = ins.x1; - z->x2 = ins.x2; - p = z; - Z = Z->next; - XmuAppendSegment(p, Z); - break; - } - else - { - if (z == dst->segment) - { - p = dst->segment = dst->segment->next; - XmuDestroySegment(z); - z = p; - continue; - } - else - { - p->next = z->next; - XmuDestroySegment(z); - z = p; - } - } - } - p = z; - z = z->next; - } - - return (dst); -} - -/* - * Function: - * XmuScanlineAnd - * - * Parameters: - * dst - destination scanline - * src - source scanline - * - * Description: - * (input) +--------------+ +-----+ +----------+ - * (src) +---------------------+ +-----------+ - * (output) +----------+ +-----+ +-----+ - */ -XmuScanline * -XmuScanlineAnd(XmuScanline *dst, XmuScanline *src) -{ - XmuSegment *z, *p, *Z; - - if (!dst || !src || dst == src || !dst->segment) { - return (dst); - } - if (!src->segment) - { - XmuDestroySegmentList(dst->segment); - dst->segment = (XmuSegment *)NULL; - return (dst); - } - z = p = dst->segment; - Z = src->segment; - - while (z) - { - while (!XmuValidSegment(Z) || Z->x2 <= z->x1) - { - Z = Z->next; - if (!Z) - { - if (z == dst->segment) - dst->segment = (XmuSegment *)NULL; - else - p->next = (XmuSegment *)0; - XmuDestroySegmentList(z); - return (dst); - } - } - if (Z->x1 >= z->x2) - { - if (z == dst->segment) - { - p = dst->segment = dst->segment->next; - XmuDestroySegment(z); - z = dst->segment; - } - else - { - p->next = z->next; - XmuDestroySegment(z); - z = p->next; - } - if (!z) - return (dst); - else - continue; - } - z->x1 = XmuMax(z->x1, Z->x1); - if (z->x2 > Z->x2) - { - if (Z->next) - { - XmuSegment *q = XmuNewSegment(Z->x2, z->x2); - - q->next = z->next; - z->next = q; - } - z->x2 = Z->x2; - } - p = z; - z = z->next; - } - - return (dst); -} - -/* - * Function: - * ScanlineXor - * - * Parameters: - * dst - destination scanline - * src - source scanline - * - * Description: - * (input) +--------------+ +-----+ +----------+ - * (src) +---------------------+ +-----------+ - * (output) +---+ +--+ +-+ +----+ +-----+ - */ -XmuScanline * -XmuScanlineXor(XmuScanline *dst, XmuScanline *src) -{ - XmuSegment *z, *p, *Z, ins; - int tmp1, tmp2; - - if (!src || !dst || !src->segment) - return (dst); - if (src == dst) - { - XmuDestroySegmentList(dst->segment); - dst->segment = (XmuSegment *)NULL; - return (dst); - } - if (!dst->segment) - { - XmuScanlineCopy(dst, src); - return (dst); - } - - z = p = dst->segment; - Z = src->segment; - ins.x1 = Z->x1; - ins.x2 = Z->x2; - - /*CONSTCOND*/ - while (1) - { - while (!XmuValidSegment((&ins))) - { - if ((Z = Z->next) == (XmuSegment *)NULL) - return (dst); - ins.x1 = Z->x1; - ins.x2 = Z->x2; - } - if (!z) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - if (!dst->segment) - dst->segment = q; - else - p->next = q; - p = q; - Z = Z->next; - XmuAppendSegment(p, Z); - break; - } - else if (ins.x2 < z->x1) - { - XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); - - q->next = z; - if (z == dst->segment) - dst->segment = q; - else - p->next = q; - if ((Z = Z->next) == (XmuSegment *)NULL) - return (dst); - - p = q; - ins.x1 = Z->x1; - ins.x2 = Z->x2; - continue; - } - else if (ins.x2 == z->x1) - { - z->x1 = ins.x1; - if ((Z = Z->next) == (XmuSegment *)NULL) - break; - ins.x1 = Z->x1; - ins.x2 = Z->x2; - continue; - } - else if (ins.x1 < z->x2) - { - if (ins.x1 == z->x1) - { - if (ins.x2 < z->x2) - { - z->x1 = ins.x2; - if ((Z = Z->next) == (XmuSegment *)NULL) - break; - ins.x1 = Z->x1; - ins.x2 = Z->x2; - continue; - } - else - { - ins.x1 = z->x2; - if (z == dst->segment) - p = dst->segment = dst->segment->next; - else - p->next = z->next; - XmuDestroySegment(z); - z = p; - continue; - } - } - else - { - if (Z->x2 < z->x2) - { - XmuSegment *q = XmuNewSegment(XmuMin(ins.x1, z->x1), - XmuMax(z->x1, ins.x1)); - - q->next = z; - if (z == dst->segment) - dst->segment = q; - else - p->next = q; - ins.x1 = z->x2; - z->x1 = ins.x2; - p = q; - continue; - } - else - { - tmp1 = ins.x2; - tmp2 = z->x2; - ins.x2 = XmuMax(ins.x2, z->x2); - z->x2 = XmuMax(z->x1, ins.x1); - z->x1 = XmuMin(ins.x1, z->x1); - ins.x1 = XmuMin(tmp1, tmp2); - } - } - } - else if (ins.x1 == z->x2) - { - ins.x1 = z->x1; - if (z == dst->segment) - p = dst->segment = dst->segment->next; - else - p->next = z->next; - XmuDestroySegment(z); - z = p; - continue; - } - p = z; - z = z->next; - } - - return (dst); -} - -/* - * Function: - * XmuNewScanline - * - * Parameters: - * y - y coordinate - * x1 - left coordinate - * x2 - right coordinate - * - * Description: - * Creates a new Scanline - */ -XmuScanline * -XmuNewScanline(int y, int x1, int x2) -{ - XmuScanline *scanline; - - scanline = (XmuScanline *)XtMalloc(sizeof(XmuScanline)); - scanline->y = y; - if (x1 < x2) - scanline->segment = XmuNewSegment(x1, x2); - else - scanline->segment = (XmuSegment *)NULL; - - scanline->next = (XmuScanline *)NULL; - - return (scanline); -} - -/* - * Function: - * XmuDestroyScanlineList - * - * Parameters: - * scanline - scanline list to destroy - * - * Description: - * Destroy a scanline list - * - * Observation: - * Use as follow: - * XmuDestroyScanlineList(area->scanline); - * area->scanline = (XmuScanline *)NULL; - */ -void -XmuDestroyScanlineList(XmuScanline *scanline) -{ - XmuScanline *z; - - if (!scanline) - return; - - while (scanline) - { - z = scanline; - scanline = scanline->next; - XmuDestroyScanline(z); - } -} - -/* - * Function: - * XmuOptimizeArea - * - * Parameters: - * area - area to optimize - * - * Description: - * Optimizes an area. This function is called when finishing a - * operation between areas, since they can end with redundant data, - * and the algorithms for area combination waits a area with - * correct data (but can left unnecessary data in the area, to avoid - * to much paranoia tests). - */ -XmuArea *XmuOptimizeArea(XmuArea *area) -{ - XmuScanline *pr, *at; - - if (!area || !area->scanline) - return (area); - - if (!area->scanline->next) - { - XmuDestroyScanlineList(area->scanline); - area->scanline = (XmuScanline *)0; - return (area); - } - - pr = area->scanline; - at = area->scanline->next; - while (area->scanline && (!XmuValidScanline(area->scanline) - || (area->scanline->next && area->scanline->y - >= area->scanline->next->y))) - { - area->scanline = area->scanline->next; - XmuDestroyScanline(pr); - pr = area->scanline; - if (pr) - at = pr->next; - } - - for (; at; pr = at, at = at->next) - { - if (XmuScanlineEqu(at, pr) - || (!XmuValidScanline(at) && !XmuValidScanline(pr)) - || (at->next && at->y >= at->next->y)) - { - pr->next = at->next; - XmuDestroyScanline(at); - at = pr; - } - } - if (pr && XmuValidScanline(pr)) - { - XmuDestroySegmentList(pr->segment); - pr->segment = (XmuSegment *)NULL; - } - if (area->scanline && !area->scanline->next) - { - XmuDestroyScanlineList(area->scanline); - area->scanline = (XmuScanline *)NULL; - } - - return (area); -} +/*
+ * Copyright (c) 1998 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdlib.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/Xmu.h>
+
+#define XmuMax(a, b) ((a) > (b) ? (a) : (b))
+#define XmuMin(a, b) ((a) < (b) ? (a) : (b))
+
+/*
+ * Function:
+ * XmuNewArea
+ *
+ * Parameters:
+ * x1 - Coordinates of the rectangle
+ * y1 - ""
+ * x2 - ""
+ * y2 - ""
+ *
+ * Description:
+ * Creates a new rectangular clipping area
+ */
+XmuArea *
+XmuNewArea(int x1, int y1, int x2, int y2)
+{
+ XmuArea *area;
+
+ area = (XmuArea *)XtMalloc(sizeof(XmuArea));
+ if (x2 > x1 && y2 > y1)
+ {
+ area->scanline = XmuNewScanline(y1, x1, x2);
+ area->scanline->next = XmuNewScanline(y2, 0, 0);
+ }
+ else
+ area->scanline = (XmuScanline *)NULL;
+
+ return (area);
+}
+
+/*
+ * Function:
+ * XmuAreaDup
+ *
+ * Parameters:
+ * area - Area to copy
+ *
+ * Description:
+ * Returns a copy of its argument
+ */
+XmuArea *
+XmuAreaDup(XmuArea *area)
+{
+ XmuArea *dst;
+
+ if (!area)
+ return ((XmuArea *)NULL);
+
+ dst = XmuCreateArea();
+ XmuAreaCopy(dst, area);
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaCopy
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ *
+ * Description:
+ * Minimizes memory alocation, trying to use already alocated memory
+ * in dst, freeing what is not required anymore.
+ */
+XmuArea *
+XmuAreaCopy(XmuArea *dst, XmuArea *src)
+{
+ XmuScanline *z, *p, *Z;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+
+ z = p = dst->scanline;
+ Z = src->scanline;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ {
+ if (z == dst->scanline)
+ {
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ }
+ else
+ {
+ XmuDestroyScanlineList(p->next);
+ p->next = (XmuScanline *)NULL;
+ }
+ return (dst);
+ }
+ if (z)
+ {
+ XmuScanlineCopy(z, Z);
+ z->y = Z->y;
+ }
+ else
+ {
+ z = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(z, Z);
+ if (p == dst->scanline && !dst->scanline)
+ p = dst->scanline = z;
+ else
+ p->next = z;
+ }
+ p = z;
+ z = z->next;
+ Z = Z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaNot
+ *
+ * Parameters:
+ * area - area to operate
+ * x1 - retangle to clip the result against
+ * y1 - ""
+ * x2 - ""
+ * y2 - ""
+ *
+ * Description:
+ * (Input)
+ * (x1, y1) (x2, y1)
+ * +-------------+
+ * +------------+ +----+
+ * | +--------------+
+ * +----------------+
+ * (x1, y2) (x2, y2)
+ *
+ * (Output)
+ * (x1, y1) (x2, y1)
+ * +--------------+ +--------------------------+
+ * | +------------+ +----+ |
+ * | | +--------------+ |
+ * +-+ +------------------------------------+
+ * (x1, y2) (x2, y2)
+ */
+XmuArea *
+XmuAreaNot(XmuArea *area, int x1, int y1, int x2, int y2)
+{
+ XmuScanline *z;
+ XmuArea *and;
+
+ if (!area)
+ return (area);
+
+ if (x1 > x2)
+ {
+ x1 ^= x2; x2 ^= x1; x1 ^= x2;
+ }
+ if (y1 > y2)
+ {
+ y1 ^= y2; y2 ^= y1; y1 ^= y2;
+ }
+ if (!area->scanline)
+ {
+ if ((area->scanline = XmuNewScanline(y1, x1, x2)) != NULL)
+ area->scanline->next = XmuNewScanline(y2, 0, 0);
+ return (area);
+ }
+ and = XmuNewArea(x1, y1, x2, y2);
+ XmuAreaAnd(area, and);
+ XmuDestroyArea(and);
+ z = area->scanline;
+ if (z->y != y1)
+ {
+ XmuScanline *q = XmuNewScanline(y1, x1, x2);
+ q->next = z;
+ area->scanline = q;
+ }
+ else
+ {
+ area->scanline = area->scanline->next;
+ XmuDestroyScanline(z);
+ XmuOptimizeArea(area);
+ if((z = area->scanline) == (XmuScanline *)NULL)
+ return (area);
+ }
+
+ /* CONSTCOND */
+ while (1)
+ {
+ XmuScanlineNot(z, x1, x2);
+ if (!z->next)
+ {
+ z->next = XmuNewScanline(y2, 0, 0);
+ break;
+ }
+ if (z->next->y == y2)
+ {
+ XmuDestroyScanlineList(z->next);
+ z->next = XmuNewScanline(y2, 0, 0);
+ break;
+ }
+ z = z->next;
+ }
+
+ return (area);
+}
+
+/*
+ * Function:
+ * XmuAreaOrXor
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ * or - or operation if true, else xor operation
+ *
+ * Description:
+ * Executes Or (Union) or Xor (Reverse intesection) of the areas
+ */
+XmuArea *
+XmuAreaOrXor(XmuArea *dst, XmuArea *src, Bool or)
+{
+ XmuScanline *z, *p, *Z, *P, *ins, *top;
+
+ if (!dst || !src)
+ return (dst);
+
+ if (dst == src)
+ {
+ if (or)
+ return (dst);
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ return (dst);
+ }
+ if (!XmuValidArea(src))
+ return (dst);
+ if (!XmuValidArea(dst))
+ {
+ XmuAreaCopy(dst, src);
+ return (dst);
+ }
+
+ p = z = dst->scanline;
+ P = Z = src->scanline;
+ ins = XmuNewScanline(dst->scanline->y, 0, 0);
+ top = XmuNewScanline(dst->scanline->y, 0, 0);
+ XmuScanlineCopy(ins, dst->scanline);
+ XmuScanlineCopy(top, dst->scanline);
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ break;
+ else if (Z->y < z->y)
+ {
+ XmuScanline *q = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(q, Z);
+
+ if (z == dst->scanline)
+ {
+ dst->scanline = p = q;
+ q->next = z;
+ }
+ else
+ {
+ p->next = q;
+ q->next = z;
+ if (Z->y >= p->y)
+ {
+ if (ins->y >= top->y
+ && (p->y != P->y || !XmuScanlineEqu(p, P)
+ || (ins->y <= P->y && !XmuScanlineEqu(ins, P))))
+ {
+ if (or)
+ XmuScanlineOr(q, ins);
+ else
+ XmuScanlineXor(q, ins);
+ }
+ else if (Z->y >= top->y
+ && (top->y == p->y || top->y > ins->y
+ || !XmuValidScanline(Z)
+ || (p->y == P->y && XmuValidScanline(p)
+ && XmuValidScanline(P))
+ || XmuScanlineEqu(ins, top)))
+ {
+ if (or)
+ XmuScanlineOr(q, top);
+ else
+ XmuScanlineXor(q, top);
+ }
+ if (ins->y != p->y && p->y != P->y)
+ {
+ XmuScanlineCopy(ins, p);
+ ins->y = p->y;
+ }
+ }
+ if (!XmuValidScanline(p) || Z->y <= p->y)
+ {
+ XmuScanlineCopy(top, p);
+ top->y = p->y;
+ }
+ p = q;
+ }
+ P = Z;
+ Z = Z->next;
+ continue;
+ }
+ else if (Z->y == z->y)
+ {
+ if (top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ if (or)
+ XmuScanlineOr(z, Z);
+ else
+ XmuScanlineXor(z, Z);
+ P = Z;
+ Z = Z->next;
+ }
+ else if (P != Z) /* && Z->y > z->y */
+ {
+ if (top->y == ins->y && top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ if (ins->y != z->y)
+ {
+ XmuScanlineCopy(ins, z);
+ ins->y = z->y;
+ }
+ if (or)
+ XmuScanlineOr(z, P);
+ else
+ XmuScanlineXor(z, P);
+ }
+ else if (ins->y != z->y)
+ {
+ XmuScanlineCopy(ins, z);
+ ins->y = z->y;
+ }
+ p = z;
+ z = z->next;
+ if (!z)
+ {
+ while (Z)
+ {
+ p->next = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(p->next, Z);
+ p = p->next;
+ Z = Z->next;
+ }
+ break;
+ }
+ else if (ins->y > top->y && !XmuValidScanline(z)
+ && XmuValidScanline(ins))
+ {
+ XmuScanlineCopy(top, ins);
+ top->y = ins->y;
+ }
+ }
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(ins);
+ XmuDestroyScanline(top);
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuAreaAnd(dst, src)
+ *
+ * Parameters:
+ * dst - destination area
+ * src - source area
+ *
+ * Description:
+ * Executes And (intersection) of the areas
+ */
+XmuArea *
+XmuAreaAnd(XmuArea *dst, XmuArea *src)
+{
+ XmuScanline *z, *p, *Z, *P, *top;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+ if (!XmuValidArea(dst) || !XmuValidArea(src))
+ {
+ XmuDestroyScanlineList(dst->scanline);
+ dst->scanline = (XmuScanline *)NULL;
+ return (dst);
+ }
+ z = p = dst->scanline;
+ Z = P = src->scanline;
+ top = XmuNewScanline(dst->scanline->y, 0, 0);
+ XmuScanlineCopy(top, dst->scanline);
+
+ while (z)
+ {
+ while (Z->next && Z->next->y < z->y)
+ {
+ P = Z;
+ Z = Z->next;
+ if (Z->y >= p->y)
+ {
+ XmuScanline *q = XmuNewScanline(Z->y, 0, 0);
+ XmuScanlineCopy(q, Z);
+
+ XmuScanlineAnd(q, top);
+ if (p->y != P->y)
+ {
+ XmuScanlineAnd(p, P);
+ p->y = XmuMax(p->y, P->y);
+ }
+ p->next = q;
+ q->next = z;
+ p = q;
+ }
+ }
+ if (!z->next)
+ {
+ z->y = XmuMax(z->y, Z->y);
+ break;
+ }
+ while (Z->y >= z->next->y)
+ {
+ if (z == dst->scanline)
+ {
+ p = dst->scanline = dst->scanline->next;
+ XmuDestroyScanline(z);
+ z = dst->scanline;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroyScanline(z);
+ z = p;
+ }
+ if (!z || !z->next)
+ {
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(top);
+
+ return (dst);
+ }
+ }
+ if (Z->y > p->y)
+ z->y = XmuMax(z->y, Z->y);
+ if (top->y != z->y)
+ {
+ XmuScanlineCopy(top, z);
+ top->y = z->y;
+ }
+ XmuScanlineAnd(z, Z);
+ p = z;
+ z = z->next;
+ }
+ XmuOptimizeArea(dst);
+ XmuDestroyScanline(top);
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuValidArea(area)
+ *
+ * Parameters:
+ * area - area to verify
+ *
+ * Description:
+ * Verifies if the area is valid and/or useful
+ */
+Bool
+XmuValidArea(XmuArea *area)
+{
+ XmuScanline *at;
+
+ if (!area || !area->scanline)
+ return (False);
+
+ at = area->scanline;
+ while (at)
+ {
+ if (XmuValidScanline(at))
+ return (True);
+ at = at->next;
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XmuValidScanline
+ *
+ * Parameters:
+ * scanline - scanline to verify
+ *
+ * Description:
+ * Verifies if a scanline is useful
+ */
+Bool
+XmuValidScanline(XmuScanline *scanline)
+{
+ XmuSegment *z;
+
+ if (!scanline)
+ return (False);
+
+ z = scanline->segment;
+ while (z)
+ {
+ if (XmuValidSegment(z))
+ return (True);
+ z = z->next;
+ }
+
+ return (False);
+}
+
+/*
+ * Function:
+ * XmuScanlineEqu
+ *
+ * Parameters:
+ * s1 - scanline 1
+ * s2 - scanline 2
+ *
+ * Description:
+ * Checks if s1 and s2 are equal
+ */
+Bool
+XmuScanlineEqu(XmuScanline *s1, XmuScanline *s2)
+{
+ XmuSegment *z, *Z;
+
+ if ((!s1 && !s2) || s1 == s2)
+ return (True);
+ if (!s1 || !s2)
+ return (False);
+
+ z = s1->segment;
+ Z = s2->segment;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!z && !Z)
+ return (True);
+ if (!z || !Z)
+ return (False);
+ if (!XmuSegmentEqu(z, Z))
+ return (False);
+ z = z->next;
+ Z = Z->next;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * Function:
+ * XmuNewSegment
+ *
+ * Parameters:
+ * x1 - coordinates of the segment
+ * x2 - ""
+ *
+ * Description:
+ * Creates a new segments with the coordinates x1 and x2
+ *
+ * Returns:
+ * New Segment of NULL
+ */
+XmuSegment *
+XmuNewSegment(int x1, int x2)
+{
+ XmuSegment *segment;
+
+ if ((segment = (XmuSegment *)XtMalloc(sizeof(XmuSegment))) == NULL)
+ return (segment);
+
+ segment->x1 = x1;
+ segment->x2 = x2;
+ segment->next = (XmuSegment *)NULL;
+
+ return (segment);
+}
+
+/*
+ * Function:
+ * XmuDestroySegmentList
+ *
+ * Parameters:
+ * segment - Segment to destroy
+ *
+ * Description:
+ * Frees the memory used by the list headed by segment
+ */
+void
+XmuDestroySegmentList(XmuSegment *segment)
+{
+ XmuSegment *z;
+
+ if (!segment)
+ return;
+
+ while (segment)
+ {
+ z = segment;
+ segment = segment->next;
+ XmuDestroySegment(z);
+ }
+}
+
+/*
+ * Function:
+ * XmuScanlineCopy
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * Makes dst contain the same data as src
+ */
+XmuScanline *
+XmuScanlineCopy(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z;
+
+ if (!dst || !src || dst == src)
+ return (dst);
+
+ z = p = dst->segment;
+ Z = src->segment;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!Z)
+ {
+ if (z == dst->segment)
+ dst->segment = (XmuSegment *)NULL;
+ else
+ p->next = (XmuSegment *)NULL;
+ XmuDestroySegmentList(z);
+ return (dst);
+ }
+ if (z)
+ {
+ z->x1 = Z->x1;
+ z->x2 = Z->x2;
+ }
+ else
+ {
+ z = XmuNewSegment(Z->x1, Z->x2);
+ if (p == dst->segment && !dst->segment)
+ p = dst->segment = z;
+ else
+ p->next = z;
+ }
+ p = z;
+ z = z->next;
+ Z = Z->next;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * Function:
+ * XmuAppendSegment
+ *
+ * Parameters:
+ * segment - destination segment
+ * append - segment to add
+ *
+ * Description:
+ * Adds a copy of the append list at the end of the segment list
+ */
+Bool
+XmuAppendSegment(XmuSegment *segment, XmuSegment *append)
+{
+ if (!segment || !append)
+ return (False);
+
+ if (segment->next)
+ /* Should not happen! */
+ XmuDestroySegmentList(segment->next);
+
+ while (append)
+ {
+ if (XmuValidSegment(append))
+ {
+ if ((segment->next = XmuNewSegment(append->x1, append->x2)) == NULL)
+ return (False);
+ segment = segment->next;
+ }
+ append = append->next;
+ }
+
+ return (True);
+}
+
+/*
+ * Function:
+ * XmuOptimizeScanline
+ *
+ * Parameters:
+ * scanline - scanline to optimize
+ *
+ * Description:
+ * Some functions, when transforming Segments of Scanlines, left these
+ * with unnecessary data (that may cause error in these same functions).
+ * This function corrects these incorrect segments.
+ */
+XmuScanline *
+XmuOptimizeScanline(XmuScanline *scanline)
+{
+ XmuSegment *z, *p;
+
+ while (scanline->segment && !XmuValidSegment(scanline->segment))
+ {
+ XmuSegment *s = scanline->segment;
+
+ scanline->segment = scanline->segment->next;
+ XmuDestroySegment(s);
+ }
+ for (z = p = scanline->segment; z; p = z, z = z->next)
+ {
+ if (!XmuValidSegment(z))
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ return (scanline);
+}
+
+/*
+ * Name:
+ * XmuScanlineNot(scanline, minx, maxx)
+ *
+ * Parameters:
+ * scanline - scanlines operate
+ * minx - minimum x coordinate
+ * maxx - maximum x coordinate
+ *
+ * Description:
+ * (minx) (maxx)
+ * + +
+ * (input) +---------+ +--------+ +--------+
+ * (output) +-----+ +-----+ +--------+ +------------+
+ */
+XmuScanline *
+XmuScanlineNot(XmuScanline *scanline, int minx, int maxx)
+{
+ XmuSegment *z;
+ static XmuSegment x = { 0, 0, NULL };
+ static XmuScanline and = { 0, &x, NULL };
+
+ if (!scanline)
+ return (scanline);
+
+ XmuOptimizeScanline(scanline);
+ if (minx > maxx)
+ {
+ minx ^= maxx; maxx ^= minx; minx ^= maxx;
+ }
+ and.segment->x1 = minx;
+ and.segment->x2 = maxx;
+ XmuScanlineAnd(scanline, &and);
+ if (!scanline->segment)
+ {
+ scanline->segment = XmuNewSegment(minx, maxx);
+ return (scanline);
+ }
+ z = scanline->segment;
+ if (z->x1 != minx)
+ {
+ XmuSegment *q = XmuNewSegment(minx, z->x1);
+
+ q->next = z;
+ scanline->segment = q;
+ }
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ z->x1 = z->x2;
+ if (!z->next)
+ {
+ z->x2 = maxx;
+ break;
+ }
+ z->x2 = z->next->x1;
+ if (z->next->x2 == maxx)
+ {
+ XmuDestroySegment(z->next);
+ z->next = (XmuSegment *)NULL;
+ break;
+ }
+ z = z->next;
+ }
+
+ return (scanline);
+}
+
+
+#ifndef notdef
+/*
+ * Function:
+ * XmuScanlineOrSegment
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source segment
+ *
+ * Description:
+ * (input) +-----------+ +--------+ +---------+
+ * (src) +-------------------+
+ * (output) +-------------------------+ +---------+
+ */
+XmuScanline *
+XmuScanlineOrSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *z, *p, ins;
+
+ if (!src || !dst || !XmuValidSegment(src))
+ return (dst);
+
+ if (!dst->segment)
+ {
+ dst->segment = XmuNewSegment(src->x1, src->x2);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ ins.x1 = src->x1;
+ ins.x2 = src->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ dst->segment = q;
+ else
+ p->next = q;
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ {
+ q->next = dst->segment;
+ dst->segment = q;
+ }
+ else
+ {
+ p->next = q;
+ q->next = z;
+ }
+ break;
+ }
+ else if (ins.x2 <= z->x2)
+ {
+ z->x1 = XmuMin(z->x1, ins.x1);
+ break;
+ }
+ else if (ins.x1 <= z->x2)
+ {
+ ins.x1 = XmuMin(z->x1, ins.x1);
+ if (!z->next)
+ {
+ z->x1 = ins.x1;
+ z->x2 = ins.x2;
+ break;
+ }
+ else
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineAndSegment
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source segment
+ *
+ * Description:
+ * (input) +------------+ +------+ +----------+
+ * (src) +---------------------+
+ * (output) +-------+ +------+
+ */
+XmuScanline *
+XmuScanlineAndSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *z, *p;
+
+ if (!dst || !src)
+ return (dst);
+
+ if (!XmuValidSegment(src))
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ if (!dst->segment)
+ return (dst);
+
+ z = p = dst->segment;
+ while (z)
+ {
+ if (src->x2 <= z->x1 || src->x1 >= z->x2)
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ else
+ {
+ z->x1 = XmuMax(z->x1, src->x1);
+ z->x2 = XmuMin(z->x2, src->x2);
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineXorSegment
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source segment
+ *
+ * Descriptipn:
+ * (input) +------------+ +----------+ +-----------+
+ * (src) +------------------------+
+ * (output) +---+ +--+ +-+ +-----------+
+ */
+XmuScanline *
+XmuScanlineXorSegment(XmuScanline *dst, XmuSegment *src)
+{
+ XmuSegment *p, *z, ins;
+ int tmp1, tmp2;
+
+ if (!dst || !src || !XmuValidSegment(src))
+ return (dst);
+ if (!dst->segment)
+ {
+ dst->segment = XmuNewSegment(src->x1, src->x2);
+ return (dst);
+ }
+
+ p = z = dst->segment;
+ ins.x1 = src->x1;
+ ins.x2 = src->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ if (!XmuValidSegment((&ins)))
+ break;
+ if (!z || ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ break;
+ }
+ else if (ins.x2 == z->x1)
+ {
+ z->x1 = ins.x1;
+ break;
+ }
+ else if (ins.x1 < z->x2)
+ {
+ if (ins.x1 < z->x1)
+ {
+ tmp1 = ins.x2;
+ tmp2 = z->x2;
+ ins.x2 = XmuMax(ins.x2, z->x2);
+ z->x2 = z->x1;
+ z->x1 = ins.x1;
+ ins.x1 = XmuMin(tmp1, tmp2);
+ }
+ else if (ins.x1 > z->x1)
+ {
+ tmp1 = ins.x1;
+ ins.x1 = XmuMin(ins.x2, z->x2);
+ ins.x2 = XmuMax(z->x2, ins.x2);
+ z->x2 = tmp1;
+ }
+ else /* ins.x1 == z->x1 */
+ {
+ if (ins.x2 < z->x2)
+ {
+ z->x1 = ins.x2;
+ break;
+ }
+ else
+ {
+ ins.x1 = z->x2;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ }
+ }
+ else if (ins.x1 == z->x2)
+ {
+ ins.x1 = z->x1;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+#endif /* notdef */
+
+/*
+ * Function:
+ * ScanlineOr
+ *
+ * Parameters:
+ * dst - destionation scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +-------------------------+ +----------------+
+ */
+XmuScanline *
+XmuScanlineOr(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z, ins;
+
+ if (!src || !src->segment || !dst || dst == src)
+ return (dst);
+ if (!dst->segment)
+ {
+ XmuScanlineCopy(dst, src);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ Z = src->segment;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ while (!XmuValidSegment((&ins)))
+ {
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ }
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ dst->segment = p = q;
+ else
+ {
+ p->next = q;
+ p = q;
+ }
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *r = XmuNewSegment(ins.x1, ins.x2);
+
+ if (p == dst->segment && z == p)
+ {
+ r->next = dst->segment;
+ dst->segment = p = r;
+ }
+ else
+ {
+ p->next = r;
+ r->next = z;
+ p = r;
+ }
+ Z = Z->next;
+ if (!Z)
+ break;
+ else
+ {
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ }
+ else if (ins.x2 <= z->x2)
+ {
+ z->x1 = XmuMin(z->x1, ins.x1);
+ Z = Z->next;
+ if (!Z)
+ break;
+ else
+ {
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ }
+ else if (ins.x1 <= z->x2)
+ {
+ ins.x1 = XmuMin(z->x1, ins.x1);
+ if (!z->next)
+ {
+ z->x1 = ins.x1;
+ z->x2 = ins.x2;
+ p = z;
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ }
+ }
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuScanlineAnd
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +----------+ +-----+ +-----+
+ */
+XmuScanline *
+XmuScanlineAnd(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z;
+
+ if (!dst || !src || dst == src || !dst->segment) {
+ return (dst);
+ }
+ if (!src->segment)
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ z = p = dst->segment;
+ Z = src->segment;
+
+ while (z)
+ {
+ while (!XmuValidSegment(Z) || Z->x2 <= z->x1)
+ {
+ Z = Z->next;
+ if (!Z)
+ {
+ if (z == dst->segment)
+ dst->segment = (XmuSegment *)NULL;
+ else
+ p->next = (XmuSegment *)0;
+ XmuDestroySegmentList(z);
+ return (dst);
+ }
+ }
+ if (Z->x1 >= z->x2)
+ {
+ if (z == dst->segment)
+ {
+ p = dst->segment = dst->segment->next;
+ XmuDestroySegment(z);
+ z = dst->segment;
+ }
+ else
+ {
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p->next;
+ }
+ if (!z)
+ return (dst);
+ else
+ continue;
+ }
+ z->x1 = XmuMax(z->x1, Z->x1);
+ if (z->x2 > Z->x2)
+ {
+ if (Z->next)
+ {
+ XmuSegment *q = XmuNewSegment(Z->x2, z->x2);
+
+ q->next = z->next;
+ z->next = q;
+ }
+ z->x2 = Z->x2;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * ScanlineXor
+ *
+ * Parameters:
+ * dst - destination scanline
+ * src - source scanline
+ *
+ * Description:
+ * (input) +--------------+ +-----+ +----------+
+ * (src) +---------------------+ +-----------+
+ * (output) +---+ +--+ +-+ +----+ +-----+
+ */
+XmuScanline *
+XmuScanlineXor(XmuScanline *dst, XmuScanline *src)
+{
+ XmuSegment *z, *p, *Z, ins;
+ int tmp1, tmp2;
+
+ if (!src || !dst || !src->segment)
+ return (dst);
+ if (src == dst)
+ {
+ XmuDestroySegmentList(dst->segment);
+ dst->segment = (XmuSegment *)NULL;
+ return (dst);
+ }
+ if (!dst->segment)
+ {
+ XmuScanlineCopy(dst, src);
+ return (dst);
+ }
+
+ z = p = dst->segment;
+ Z = src->segment;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+
+ /*CONSTCOND*/
+ while (1)
+ {
+ while (!XmuValidSegment((&ins)))
+ {
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ }
+ if (!z)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ if (!dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ p = q;
+ Z = Z->next;
+ XmuAppendSegment(p, Z);
+ break;
+ }
+ else if (ins.x2 < z->x1)
+ {
+ XmuSegment *q = XmuNewSegment(ins.x1, ins.x2);
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ return (dst);
+
+ p = q;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else if (ins.x2 == z->x1)
+ {
+ z->x1 = ins.x1;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ break;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else if (ins.x1 < z->x2)
+ {
+ if (ins.x1 == z->x1)
+ {
+ if (ins.x2 < z->x2)
+ {
+ z->x1 = ins.x2;
+ if ((Z = Z->next) == (XmuSegment *)NULL)
+ break;
+ ins.x1 = Z->x1;
+ ins.x2 = Z->x2;
+ continue;
+ }
+ else
+ {
+ ins.x1 = z->x2;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ }
+ else
+ {
+ if (Z->x2 < z->x2)
+ {
+ XmuSegment *q = XmuNewSegment(XmuMin(ins.x1, z->x1),
+ XmuMax(z->x1, ins.x1));
+
+ q->next = z;
+ if (z == dst->segment)
+ dst->segment = q;
+ else
+ p->next = q;
+ ins.x1 = z->x2;
+ z->x1 = ins.x2;
+ p = q;
+ continue;
+ }
+ else
+ {
+ tmp1 = ins.x2;
+ tmp2 = z->x2;
+ ins.x2 = XmuMax(ins.x2, z->x2);
+ z->x2 = XmuMax(z->x1, ins.x1);
+ z->x1 = XmuMin(ins.x1, z->x1);
+ ins.x1 = XmuMin(tmp1, tmp2);
+ }
+ }
+ }
+ else if (ins.x1 == z->x2)
+ {
+ ins.x1 = z->x1;
+ if (z == dst->segment)
+ p = dst->segment = dst->segment->next;
+ else
+ p->next = z->next;
+ XmuDestroySegment(z);
+ z = p;
+ continue;
+ }
+ p = z;
+ z = z->next;
+ }
+
+ return (dst);
+}
+
+/*
+ * Function:
+ * XmuNewScanline
+ *
+ * Parameters:
+ * y - y coordinate
+ * x1 - left coordinate
+ * x2 - right coordinate
+ *
+ * Description:
+ * Creates a new Scanline
+ */
+XmuScanline *
+XmuNewScanline(int y, int x1, int x2)
+{
+ XmuScanline *scanline;
+
+ scanline = (XmuScanline *)XtMalloc(sizeof(XmuScanline));
+ scanline->y = y;
+ if (x1 < x2)
+ scanline->segment = XmuNewSegment(x1, x2);
+ else
+ scanline->segment = (XmuSegment *)NULL;
+
+ scanline->next = (XmuScanline *)NULL;
+
+ return (scanline);
+}
+
+/*
+ * Function:
+ * XmuDestroyScanlineList
+ *
+ * Parameters:
+ * scanline - scanline list to destroy
+ *
+ * Description:
+ * Destroy a scanline list
+ *
+ * Observation:
+ * Use as follow:
+ * XmuDestroyScanlineList(area->scanline);
+ * area->scanline = (XmuScanline *)NULL;
+ */
+void
+XmuDestroyScanlineList(XmuScanline *scanline)
+{
+ XmuScanline *z;
+
+ if (!scanline)
+ return;
+
+ while (scanline)
+ {
+ z = scanline;
+ scanline = scanline->next;
+ XmuDestroyScanline(z);
+ }
+}
+
+/*
+ * Function:
+ * XmuOptimizeArea
+ *
+ * Parameters:
+ * area - area to optimize
+ *
+ * Description:
+ * Optimizes an area. This function is called when finishing a
+ * operation between areas, since they can end with redundant data,
+ * and the algorithms for area combination waits a area with
+ * correct data (but can left unnecessary data in the area, to avoid
+ * to much paranoia tests).
+ */
+XmuArea *XmuOptimizeArea(XmuArea *area)
+{
+ XmuScanline *pr, *at;
+
+ if (!area || !area->scanline)
+ return (area);
+
+ if (!area->scanline->next)
+ {
+ XmuDestroyScanlineList(area->scanline);
+ area->scanline = (XmuScanline *)0;
+ return (area);
+ }
+
+ pr = area->scanline;
+ at = area->scanline->next;
+ while (area->scanline && (!XmuValidScanline(area->scanline)
+ || (area->scanline->next && area->scanline->y
+ >= area->scanline->next->y)))
+ {
+ area->scanline = area->scanline->next;
+ XmuDestroyScanline(pr);
+ pr = area->scanline;
+ if (pr)
+ at = pr->next;
+ }
+
+ for (; at; pr = at, at = at->next)
+ {
+ if (XmuScanlineEqu(at, pr)
+ || (!XmuValidScanline(at) && !XmuValidScanline(pr))
+ || (at->next && at->y >= at->next->y))
+ {
+ pr->next = at->next;
+ XmuDestroyScanline(at);
+ at = pr;
+ }
+ }
+ if (pr && XmuValidScanline(pr))
+ {
+ XmuDestroySegmentList(pr->segment);
+ pr->segment = (XmuSegment *)NULL;
+ }
+ if (area->scanline && !area->scanline->next)
+ {
+ XmuDestroyScanlineList(area->scanline);
+ area->scanline = (XmuScanline *)NULL;
+ }
+
+ return (area);
+}
diff --git a/libXmu/src/CloseHook.c b/libXmu/src/CloseHook.c index ca9d9def6..aeefad2bb 100644 --- a/libXmu/src/CloseHook.c +++ b/libXmu/src/CloseHook.c @@ -1,294 +1,294 @@ -/* -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * CloseDisplayHook package - provide callback on XCloseDisplay - * - * * - * Author: Jim Fulton, MIT X Consortium - * - * - * Public Entry Points - * - * CloseHook XmuAddCloseDisplayHook (dpy, func, arg) - * Display *dpy; - * XmuCloseHookProc func; - * XPointer arg; - * - * Bool XmuRemoveCloseDisplayHook (dpy, hook, func, arg) - * Display *dpy; - * CloseHook hook; - * XmuCloseHookProc func; - * XPointer arg; - * - * Bool XmuLookupCloseDisplayHook (dpy, hook, func, arg) - * Display *dpy; - * CloseHook hook; - * XmuCloseHookProc func; - * XPointer arg; - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> /* for NULL */ -#include <X11/Xos.h> -#include <X11/Xlib.h> -#include <X11/Xmu/CloseHook.h> -#include <stdlib.h> - -/* - * Private data - * - * This is a list of display entries, each of which contains a list of callback - * records. - */ - -typedef struct _CallbackRec { - struct _CallbackRec *next; /* next link in chain */ - XmuCloseHookProc func; /* function to call */ - XPointer arg; /* argument to pass with function */ -} CallbackRec; - - -typedef struct _DisplayEntry { - struct _DisplayEntry *next; /* next link in chain */ - Display *dpy; /* the display this represents */ - int extension; /* from XAddExtension */ - struct _CallbackRec *start, *end; /* linked list of callbacks */ - struct _CallbackRec *calling; /* currently being called back */ -} DisplayEntry; - -/* - * Prototypes - */ -static DisplayEntry *_FindDisplayEntry(Display*, DisplayEntry**); -static Bool _MakeExtension(Display*, int*); - -static DisplayEntry *elist = NULL; - - -/* - ***************************************************************************** - * Public Entry Points * - ***************************************************************************** - */ - -/* - * Add - add a callback for the given display. When the display is closed, - * the given function will be called as: - * - * (*func) (dpy, arg) - * - * This function is declared to return an int even though the value is ignored - * because some compilers have problems with functions returning void. - * - * This routine returns NULL if it was unable to add the callback, otherwise - * it returns an untyped pointer that can be used with Remove or Lookup, but - * not dereferenced. - */ -CloseHook -XmuAddCloseDisplayHook(Display *dpy, XmuCloseHookProc func, XPointer arg) -{ - DisplayEntry *de; - CallbackRec *cb; - - /* allocate ahead of time so that we can fail atomically */ - cb = (CallbackRec *) malloc (sizeof (CallbackRec)); - if (!cb) return ((XPointer) NULL); - - de = _FindDisplayEntry (dpy, NULL); - if (!de) { - if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL || - !_MakeExtension (dpy, &de->extension)) { - free ((char *) cb); - if (de) free ((char *) de); - return ((CloseHook) NULL); - } - de->dpy = dpy; - de->start = de->end = NULL; - de->calling = NULL; - de->next = elist; - elist = de; - } - - /* add to end of list of callback recordss */ - cb->func = func; - cb->arg = arg; - cb->next = NULL; - if (de->end) { - de->end->next = cb; - } else { - de->start = cb; - } - de->end = cb; - - return ((CloseHook) cb); -} - - -/* - * Remove - get rid of a callback. If handle is non-null, use that to compare - * entries. Otherwise, remove first instance of the function/argument pair. - */ -Bool -XmuRemoveCloseDisplayHook(Display *dpy, CloseHook handle, - XmuCloseHookProc func, XPointer arg) -{ - DisplayEntry *de = _FindDisplayEntry (dpy, NULL); - register CallbackRec *h, *prev; - - if (!de) return False; - - /* look for handle or function/argument pair */ - for (h = de->start, prev = NULL; h; h = h->next) { - if (handle) { - if (h == (CallbackRec *) handle) break; - } else { - if (h->func == func && h->arg == arg) break; - } - prev = h; - } - if (!h) return False; - - - /* remove from list, watch head and tail */ - if (de->start == h) { - de->start = h->next; - } else { - prev->next = h->next; - } - if (de->end == h) de->end = prev; - if (de->calling != h) free ((char *) h); - return True; -} - - -/* - * Lookup - see whether or not a handle has been installed. If handle is - * non-NULL, look for an entry that matches it; otherwise look for an entry - * with the same function/argument pair. - */ -Bool -XmuLookupCloseDisplayHook(Display *dpy, CloseHook handle, - XmuCloseHookProc func, XPointer arg) -{ - DisplayEntry *de = _FindDisplayEntry (dpy, NULL); - register CallbackRec *h; - - if (!de) return False; - - for (h = de->start; h; h = h->next) { - if (handle) { - if (h == (CallbackRec *) handle) break; - } else { - if (h->func == func && h->arg == arg) break; - } - } - return (h ? True : False); -} - - -/* - ***************************************************************************** - * internal routines * - ***************************************************************************** - */ - - -/* - * Find the specified display on the linked list of displays. Also return - * the preceeding link so that the display can be unlinked without having - * back pointers. - */ -static DisplayEntry * -_FindDisplayEntry(register Display *dpy, DisplayEntry **prevp) -{ - register DisplayEntry *d, *prev; - - for (d = elist, prev = NULL; d; d = d->next) { - if (d->dpy == dpy) { - if (prevp) *prevp = prev; - return d; - } - prev = d; - } - return NULL; -} - - - -/* - * _DoCallbacks - process all of the callbacks for this display and free - * the associated callback data (callback records and display entries). - */ -/* ARGSUSED */ -static int -_DoCallbacks(Display *dpy, XExtCodes *codes) -{ - register CallbackRec *h; - DisplayEntry *prev; - DisplayEntry *de = _FindDisplayEntry (dpy, &prev); - - if (!de) return 0; - - /* walk the list doing the callbacks and freeing callback record */ - for (h = de->start; h;) { - register CallbackRec *nexth = h->next; - de->calling = h; /* let remove know we'll free it */ - (*(h->func)) (dpy, h->arg); - de->calling = NULL; - free ((char *) h); - h = nexth; - } - - /* unlink this display from chain */ - if (elist == de) { - elist = de->next; - } else { - prev->next = de->next; - } - free ((char *) de); - return 1; -} - - -/* - * _MakeExtension - create an extension for this display; done once per display - */ -static Bool -_MakeExtension(Display *dpy, int *extensionp) -{ - XExtCodes *codes; - - codes = XAddExtension (dpy); - if (!codes) return False; - - (void) XESetCloseDisplay (dpy, codes->extension, _DoCallbacks); - - *extensionp = codes->extension; - return True; -} +/*
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * CloseDisplayHook package - provide callback on XCloseDisplay
+ *
+ * *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ *
+ * Public Entry Points
+ *
+ * CloseHook XmuAddCloseDisplayHook (dpy, func, arg)
+ * Display *dpy;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuRemoveCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuLookupCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h> /* for NULL */
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/CloseHook.h>
+#include <stdlib.h>
+
+/*
+ * Private data
+ *
+ * This is a list of display entries, each of which contains a list of callback
+ * records.
+ */
+
+typedef struct _CallbackRec {
+ struct _CallbackRec *next; /* next link in chain */
+ XmuCloseHookProc func; /* function to call */
+ XPointer arg; /* argument to pass with function */
+} CallbackRec;
+
+
+typedef struct _DisplayEntry {
+ struct _DisplayEntry *next; /* next link in chain */
+ Display *dpy; /* the display this represents */
+ int extension; /* from XAddExtension */
+ struct _CallbackRec *start, *end; /* linked list of callbacks */
+ struct _CallbackRec *calling; /* currently being called back */
+} DisplayEntry;
+
+/*
+ * Prototypes
+ */
+static DisplayEntry *_FindDisplayEntry(Display*, DisplayEntry**);
+static Bool _MakeExtension(Display*, int*);
+
+static DisplayEntry *elist = NULL;
+
+
+/*
+ *****************************************************************************
+ * Public Entry Points *
+ *****************************************************************************
+ */
+
+/*
+ * Add - add a callback for the given display. When the display is closed,
+ * the given function will be called as:
+ *
+ * (*func) (dpy, arg)
+ *
+ * This function is declared to return an int even though the value is ignored
+ * because some compilers have problems with functions returning void.
+ *
+ * This routine returns NULL if it was unable to add the callback, otherwise
+ * it returns an untyped pointer that can be used with Remove or Lookup, but
+ * not dereferenced.
+ */
+CloseHook
+XmuAddCloseDisplayHook(Display *dpy, XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de;
+ CallbackRec *cb;
+
+ /* allocate ahead of time so that we can fail atomically */
+ cb = (CallbackRec *) malloc (sizeof (CallbackRec));
+ if (!cb) return ((XPointer) NULL);
+
+ de = _FindDisplayEntry (dpy, NULL);
+ if (!de) {
+ if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
+ !_MakeExtension (dpy, &de->extension)) {
+ free ((char *) cb);
+ if (de) free ((char *) de);
+ return ((CloseHook) NULL);
+ }
+ de->dpy = dpy;
+ de->start = de->end = NULL;
+ de->calling = NULL;
+ de->next = elist;
+ elist = de;
+ }
+
+ /* add to end of list of callback recordss */
+ cb->func = func;
+ cb->arg = arg;
+ cb->next = NULL;
+ if (de->end) {
+ de->end->next = cb;
+ } else {
+ de->start = cb;
+ }
+ de->end = cb;
+
+ return ((CloseHook) cb);
+}
+
+
+/*
+ * Remove - get rid of a callback. If handle is non-null, use that to compare
+ * entries. Otherwise, remove first instance of the function/argument pair.
+ */
+Bool
+XmuRemoveCloseDisplayHook(Display *dpy, CloseHook handle,
+ XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h, *prev;
+
+ if (!de) return False;
+
+ /* look for handle or function/argument pair */
+ for (h = de->start, prev = NULL; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ prev = h;
+ }
+ if (!h) return False;
+
+
+ /* remove from list, watch head and tail */
+ if (de->start == h) {
+ de->start = h->next;
+ } else {
+ prev->next = h->next;
+ }
+ if (de->end == h) de->end = prev;
+ if (de->calling != h) free ((char *) h);
+ return True;
+}
+
+
+/*
+ * Lookup - see whether or not a handle has been installed. If handle is
+ * non-NULL, look for an entry that matches it; otherwise look for an entry
+ * with the same function/argument pair.
+ */
+Bool
+XmuLookupCloseDisplayHook(Display *dpy, CloseHook handle,
+ XmuCloseHookProc func, XPointer arg)
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h;
+
+ if (!de) return False;
+
+ for (h = de->start; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ }
+ return (h ? True : False);
+}
+
+
+/*
+ *****************************************************************************
+ * internal routines *
+ *****************************************************************************
+ */
+
+
+/*
+ * Find the specified display on the linked list of displays. Also return
+ * the preceeding link so that the display can be unlinked without having
+ * back pointers.
+ */
+static DisplayEntry *
+_FindDisplayEntry(register Display *dpy, DisplayEntry **prevp)
+{
+ register DisplayEntry *d, *prev;
+
+ for (d = elist, prev = NULL; d; d = d->next) {
+ if (d->dpy == dpy) {
+ if (prevp) *prevp = prev;
+ return d;
+ }
+ prev = d;
+ }
+ return NULL;
+}
+
+
+
+/*
+ * _DoCallbacks - process all of the callbacks for this display and free
+ * the associated callback data (callback records and display entries).
+ */
+/* ARGSUSED */
+static int
+_DoCallbacks(Display *dpy, XExtCodes *codes)
+{
+ register CallbackRec *h;
+ DisplayEntry *prev;
+ DisplayEntry *de = _FindDisplayEntry (dpy, &prev);
+
+ if (!de) return 0;
+
+ /* walk the list doing the callbacks and freeing callback record */
+ for (h = de->start; h;) {
+ register CallbackRec *nexth = h->next;
+ de->calling = h; /* let remove know we'll free it */
+ (*(h->func)) (dpy, h->arg);
+ de->calling = NULL;
+ free ((char *) h);
+ h = nexth;
+ }
+
+ /* unlink this display from chain */
+ if (elist == de) {
+ elist = de->next;
+ } else {
+ prev->next = de->next;
+ }
+ free ((char *) de);
+ return 1;
+}
+
+
+/*
+ * _MakeExtension - create an extension for this display; done once per display
+ */
+static Bool
+_MakeExtension(Display *dpy, int *extensionp)
+{
+ XExtCodes *codes;
+
+ codes = XAddExtension (dpy);
+ if (!codes) return False;
+
+ (void) XESetCloseDisplay (dpy, codes->extension, _DoCallbacks);
+
+ *extensionp = codes->extension;
+ return True;
+}
diff --git a/libXmu/src/CmapAlloc.c b/libXmu/src/CmapAlloc.c index 0bccb829c..44a1b5502 100644 --- a/libXmu/src/CmapAlloc.c +++ b/libXmu/src/CmapAlloc.c @@ -1,343 +1,343 @@ -/* - -Copyright 1989, 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> -#include <stdio.h> - -#define lowbit(x) ((x) & (~(x) + 1)) - -/* - * Prototypes - */ -static void best_allocation(XVisualInfo*, unsigned long*, unsigned long*, - unsigned long*); -static int default_allocation(XVisualInfo*, unsigned long*, - unsigned long*, unsigned long*); -static void gray_allocation(int, unsigned long*, unsigned long*, - unsigned long*); -static int icbrt(int); -static int icbrt_with_bits(int, int); -static int icbrt_with_guess(int, int); - -/* To determine the best allocation of reds, greens, and blues in a - * standard colormap, use XmuGetColormapAllocation. - * vinfo specifies visual information for a chosen visual - * property specifies one of the standard colormap property names - * red_max returns maximum red value - * green_max returns maximum green value - * blue_max returns maximum blue value - * - * XmuGetColormapAllocation returns 0 on failure, non-zero on success. - * It is assumed that the visual is appropriate for the colormap property. - */ - -Status -XmuGetColormapAllocation(XVisualInfo *vinfo, Atom property, - unsigned long *red_max, - unsigned long *green_max, - unsigned long *blue_max) -{ - Status status = 1; - - if (vinfo->colormap_size <= 2) - return 0; - - switch (property) - { - case XA_RGB_DEFAULT_MAP: - status = default_allocation(vinfo, red_max, green_max, blue_max); - break; - case XA_RGB_BEST_MAP: - best_allocation(vinfo, red_max, green_max, blue_max); - break; - case XA_RGB_GRAY_MAP: - gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max); - break; - case XA_RGB_RED_MAP: - *red_max = vinfo->colormap_size - 1; - *green_max = *blue_max = 0; - break; - case XA_RGB_GREEN_MAP: - *green_max = vinfo->colormap_size - 1; - *red_max = *blue_max = 0; - break; - case XA_RGB_BLUE_MAP: - *blue_max = vinfo->colormap_size - 1; - *red_max = *green_max = 0; - break; - default: - status = 0; - } - return status; -} - -/****************************************************************************/ -/* Determine the appropriate color allocations of a gray scale. - * - * Keith Packard, MIT X Consortium - */ - -static void -gray_allocation(int n, unsigned long *red_max, unsigned long *green_max, - unsigned long *blue_max) -{ - *red_max = (n * 30) / 100; - *green_max = (n * 59) / 100; - *blue_max = (n * 11) / 100; - *green_max += ((n - 1) - (*red_max + *green_max + *blue_max)); -} - -/****************************************************************************/ -/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP. - * If a map has less than a minimum number of definable entries, we do not - * produce an allocation for an RGB_DEFAULT_MAP. - * - * For 16 planes, the default colormap will have 27 each RGB; for 12 planes, - * 12 each. For 8 planes, let n = the number of colormap entries, which may - * be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1. - * Maximum green and maximum blue values are identical to maximum red. - * This leaves at least 125 cells which clients can allocate. - * - * Return 0 if an allocation has been determined, non-zero otherwise. - */ - -static int -default_allocation(XVisualInfo *vinfo, unsigned long *red, - unsigned long *green, unsigned long *blue) -{ - int ngrays; /* number of gray cells */ - - switch (vinfo->class) { - case PseudoColor: - - if (vinfo->colormap_size > 65000) - /* intended for displays with 16 planes */ - *red = *green = *blue = (unsigned long) 27; - else if (vinfo->colormap_size > 4000) - /* intended for displays with 12 planes */ - *red = *green = *blue = (unsigned long) 12; - else if (vinfo->colormap_size < 250) - return 0; - else - /* intended for displays with 8 planes */ - *red = *green = *blue = (unsigned long) - (icbrt(vinfo->colormap_size - 125) - 1); - break; - - case DirectColor: - - if (vinfo->colormap_size < 10) - return 0; - *red = *green = *blue = vinfo->colormap_size / 2 - 1; - break; - - case TrueColor: - - *red = vinfo->red_mask / lowbit(vinfo->red_mask); - *green = vinfo->green_mask / lowbit(vinfo->green_mask); - *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask); - break; - - case GrayScale: - - if (vinfo->colormap_size > 65000) - ngrays = 4096; - else if (vinfo->colormap_size > 4000) - ngrays = 512; - else if (vinfo->colormap_size < 250) - return 0; - else - ngrays = 12; - gray_allocation(ngrays, red, green, blue); - break; - - default: - return 0; - } - return 1; -} - -/****************************************************************************/ -/* Determine an appropriate color allocation for the RGB_BEST_MAP. - * - * For a DirectColor or TrueColor visual, the allocation is determined - * by the red_mask, green_mask, and blue_mask members of the visual info. - * - * Otherwise, if the colormap size is an integral power of 2, determine - * the allocation according to the number of bits given to each color, - * with green getting more than red, and red more than blue, if there - * are to be inequities in the distribution. If the colormap size is - * not an integral power of 2, let n = the number of colormap entries. - * Then maximum red value = floor(cube_root(n)) - 1; - * maximum blue value = floor(cube_root(n)) - 1; - * maximum green value = n / ((# red values) * (# blue values)) - 1; - * Which, on a GPX, allows for 252 entries in the best map, out of 254 - * defineable colormap entries. - */ - -static void -best_allocation(XVisualInfo *vinfo, unsigned long *red, unsigned long *green, - unsigned long *blue) -{ - - if (vinfo->class == DirectColor || vinfo->class == TrueColor) - { - *red = vinfo->red_mask; - while ((*red & 01) == 0) - *red >>= 1; - *green = vinfo->green_mask; - while ((*green & 01) == 0) - *green >>=1; - *blue = vinfo->blue_mask; - while ((*blue & 01) == 0) - *blue >>= 1; - } - else - { - register int bits, n; - - /* Determine n such that n is the least integral power of 2 which is - * greater than or equal to the number of entries in the colormap. - */ - n = 1; - bits = 0; - while (vinfo->colormap_size > n) - { - n = n << 1; - bits++; - } - - /* If the number of entries in the colormap is a power of 2, determine - * the allocation by "dealing" the bits, first to green, then red, then - * blue. If not, find the maximum integral red, green, and blue values - * which, when multiplied together, do not exceed the number of - - * colormap entries. - */ - if (n == vinfo->colormap_size) - { - register int r, g, b; - b = bits / 3; - g = b + ((bits % 3) ? 1 : 0); - r = b + (((bits % 3) == 2) ? 1 : 0); - *red = 1 << r; - *green = 1 << g; - *blue = 1 << b; - } - else - { - *red = icbrt_with_bits(vinfo->colormap_size, bits); - *blue = *red; - *green = (vinfo->colormap_size / ((*red) * (*blue))); - } - (*red)--; - (*green)--; - (*blue)--; - } - return; -} - -/* - * integer cube roots by Newton's method - * - * Stephen Gildea, MIT X Consortium, July 1991 - */ - -static int -icbrt(int a) -{ - register int bits = 0; - register unsigned n = a; - - while (n) - { - bits++; - n >>= 1; - } - return icbrt_with_bits(a, bits); -} - - -static int -icbrt_with_bits(int a, int bits) - /* bits - log 2 of a */ -{ - return icbrt_with_guess(a, a>>2*bits/3); -} - -#ifdef _X_ROOT_STATS -int icbrt_loopcount; -#endif - -/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */ - -/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */ - -/* - * Quick and dirty cube roots. Nothing fancy here, just Newton's method. - * Only works for positive integers (since that's all we need). - * We actually return floor(cbrt(a)) because that's what we need here, too. - */ - -static int -icbrt_with_guess(int a, int guess) -{ - register int delta; - -#ifdef _X_ROOT_STATS - icbrt_loopcount = 0; -#endif - if (a <= 0) - return 0; - if (guess < 1) - guess = 1; - - do { -#ifdef _X_ROOT_STATS - icbrt_loopcount++; -#endif - delta = (guess - a/(guess*guess))/3; -#ifdef DEBUG - printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, delta); -#endif - guess -= delta; - } while (delta != 0); - - if (guess*guess*guess > a) - guess--; - - return guess; -} +/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+#include <stdio.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/*
+ * Prototypes
+ */
+static void best_allocation(XVisualInfo*, unsigned long*, unsigned long*,
+ unsigned long*);
+static int default_allocation(XVisualInfo*, unsigned long*,
+ unsigned long*, unsigned long*);
+static void gray_allocation(int, unsigned long*, unsigned long*,
+ unsigned long*);
+static int icbrt(int);
+static int icbrt_with_bits(int, int);
+static int icbrt_with_guess(int, int);
+
+/* To determine the best allocation of reds, greens, and blues in a
+ * standard colormap, use XmuGetColormapAllocation.
+ * vinfo specifies visual information for a chosen visual
+ * property specifies one of the standard colormap property names
+ * red_max returns maximum red value
+ * green_max returns maximum green value
+ * blue_max returns maximum blue value
+ *
+ * XmuGetColormapAllocation returns 0 on failure, non-zero on success.
+ * It is assumed that the visual is appropriate for the colormap property.
+ */
+
+Status
+XmuGetColormapAllocation(XVisualInfo *vinfo, Atom property,
+ unsigned long *red_max,
+ unsigned long *green_max,
+ unsigned long *blue_max)
+{
+ Status status = 1;
+
+ if (vinfo->colormap_size <= 2)
+ return 0;
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ status = default_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_BEST_MAP:
+ best_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_GRAY_MAP:
+ gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_RED_MAP:
+ *red_max = vinfo->colormap_size - 1;
+ *green_max = *blue_max = 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ *green_max = vinfo->colormap_size - 1;
+ *red_max = *blue_max = 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ *blue_max = vinfo->colormap_size - 1;
+ *red_max = *green_max = 0;
+ break;
+ default:
+ status = 0;
+ }
+ return status;
+}
+
+/****************************************************************************/
+/* Determine the appropriate color allocations of a gray scale.
+ *
+ * Keith Packard, MIT X Consortium
+ */
+
+static void
+gray_allocation(int n, unsigned long *red_max, unsigned long *green_max,
+ unsigned long *blue_max)
+{
+ *red_max = (n * 30) / 100;
+ *green_max = (n * 59) / 100;
+ *blue_max = (n * 11) / 100;
+ *green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
+ * If a map has less than a minimum number of definable entries, we do not
+ * produce an allocation for an RGB_DEFAULT_MAP.
+ *
+ * For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
+ * 12 each. For 8 planes, let n = the number of colormap entries, which may
+ * be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1.
+ * Maximum green and maximum blue values are identical to maximum red.
+ * This leaves at least 125 cells which clients can allocate.
+ *
+ * Return 0 if an allocation has been determined, non-zero otherwise.
+ */
+
+static int
+default_allocation(XVisualInfo *vinfo, unsigned long *red,
+ unsigned long *green, unsigned long *blue)
+{
+ int ngrays; /* number of gray cells */
+
+ switch (vinfo->class) {
+ case PseudoColor:
+
+ if (vinfo->colormap_size > 65000)
+ /* intended for displays with 16 planes */
+ *red = *green = *blue = (unsigned long) 27;
+ else if (vinfo->colormap_size > 4000)
+ /* intended for displays with 12 planes */
+ *red = *green = *blue = (unsigned long) 12;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ /* intended for displays with 8 planes */
+ *red = *green = *blue = (unsigned long)
+ (icbrt(vinfo->colormap_size - 125) - 1);
+ break;
+
+ case DirectColor:
+
+ if (vinfo->colormap_size < 10)
+ return 0;
+ *red = *green = *blue = vinfo->colormap_size / 2 - 1;
+ break;
+
+ case TrueColor:
+
+ *red = vinfo->red_mask / lowbit(vinfo->red_mask);
+ *green = vinfo->green_mask / lowbit(vinfo->green_mask);
+ *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
+ break;
+
+ case GrayScale:
+
+ if (vinfo->colormap_size > 65000)
+ ngrays = 4096;
+ else if (vinfo->colormap_size > 4000)
+ ngrays = 512;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ ngrays = 12;
+ gray_allocation(ngrays, red, green, blue);
+ break;
+
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_BEST_MAP.
+ *
+ * For a DirectColor or TrueColor visual, the allocation is determined
+ * by the red_mask, green_mask, and blue_mask members of the visual info.
+ *
+ * Otherwise, if the colormap size is an integral power of 2, determine
+ * the allocation according to the number of bits given to each color,
+ * with green getting more than red, and red more than blue, if there
+ * are to be inequities in the distribution. If the colormap size is
+ * not an integral power of 2, let n = the number of colormap entries.
+ * Then maximum red value = floor(cube_root(n)) - 1;
+ * maximum blue value = floor(cube_root(n)) - 1;
+ * maximum green value = n / ((# red values) * (# blue values)) - 1;
+ * Which, on a GPX, allows for 252 entries in the best map, out of 254
+ * defineable colormap entries.
+ */
+
+static void
+best_allocation(XVisualInfo *vinfo, unsigned long *red, unsigned long *green,
+ unsigned long *blue)
+{
+
+ if (vinfo->class == DirectColor || vinfo->class == TrueColor)
+ {
+ *red = vinfo->red_mask;
+ while ((*red & 01) == 0)
+ *red >>= 1;
+ *green = vinfo->green_mask;
+ while ((*green & 01) == 0)
+ *green >>=1;
+ *blue = vinfo->blue_mask;
+ while ((*blue & 01) == 0)
+ *blue >>= 1;
+ }
+ else
+ {
+ register int bits, n;
+
+ /* Determine n such that n is the least integral power of 2 which is
+ * greater than or equal to the number of entries in the colormap.
+ */
+ n = 1;
+ bits = 0;
+ while (vinfo->colormap_size > n)
+ {
+ n = n << 1;
+ bits++;
+ }
+
+ /* If the number of entries in the colormap is a power of 2, determine
+ * the allocation by "dealing" the bits, first to green, then red, then
+ * blue. If not, find the maximum integral red, green, and blue values
+ * which, when multiplied together, do not exceed the number of
+
+ * colormap entries.
+ */
+ if (n == vinfo->colormap_size)
+ {
+ register int r, g, b;
+ b = bits / 3;
+ g = b + ((bits % 3) ? 1 : 0);
+ r = b + (((bits % 3) == 2) ? 1 : 0);
+ *red = 1 << r;
+ *green = 1 << g;
+ *blue = 1 << b;
+ }
+ else
+ {
+ *red = icbrt_with_bits(vinfo->colormap_size, bits);
+ *blue = *red;
+ *green = (vinfo->colormap_size / ((*red) * (*blue)));
+ }
+ (*red)--;
+ (*green)--;
+ (*blue)--;
+ }
+ return;
+}
+
+/*
+ * integer cube roots by Newton's method
+ *
+ * Stephen Gildea, MIT X Consortium, July 1991
+ */
+
+static int
+icbrt(int a)
+{
+ register int bits = 0;
+ register unsigned n = a;
+
+ while (n)
+ {
+ bits++;
+ n >>= 1;
+ }
+ return icbrt_with_bits(a, bits);
+}
+
+
+static int
+icbrt_with_bits(int a, int bits)
+ /* bits - log 2 of a */
+{
+ return icbrt_with_guess(a, a>>2*bits/3);
+}
+
+#ifdef _X_ROOT_STATS
+int icbrt_loopcount;
+#endif
+
+/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
+
+/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
+
+/*
+ * Quick and dirty cube roots. Nothing fancy here, just Newton's method.
+ * Only works for positive integers (since that's all we need).
+ * We actually return floor(cbrt(a)) because that's what we need here, too.
+ */
+
+static int
+icbrt_with_guess(int a, int guess)
+{
+ register int delta;
+
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount = 0;
+#endif
+ if (a <= 0)
+ return 0;
+ if (guess < 1)
+ guess = 1;
+
+ do {
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount++;
+#endif
+ delta = (guess - a/(guess*guess))/3;
+#ifdef _X_ROOT_STATS
+ printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, delta);
+#endif
+ guess -= delta;
+ } while (delta != 0);
+
+ if (guess*guess*guess > a)
+ guess--;
+
+ return guess;
+}
diff --git a/libXmu/src/CrCmap.c b/libXmu/src/CrCmap.c index 4343f5f0f..0c62ff009 100644 --- a/libXmu/src/CrCmap.c +++ b/libXmu/src/CrCmap.c @@ -1,534 +1,534 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -/* - * CreateCmap.c - given a standard colormap description, make the map. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -/* - * Prototypes - */ -/* allocate entire map Read Only */ -static int ROmap(Display*, Colormap, unsigned long[], int, int); - -/* allocate a cell, prefer Read Only */ -static Status ROorRWcell(Display*, Colormap, unsigned long[], int, - XColor*, unsigned long); - -/* allocate a cell Read Write */ -static Status RWcell(Display*, Colormap, XColor*, XColor*, unsigned long*); - -/* for quicksort */ -static int compare(_Xconst void*, _Xconst void*); - -/* find contiguous sequence of cells */ -static Status contiguous(unsigned long[], int, int, unsigned long, int*, int*); - -/* frees resources before quitting */ -static void free_cells(Display*, Colormap, unsigned long[], int, int); - -/* create a map in a RO visual type */ -static Status readonly_map(Display*, XVisualInfo*, XStandardColormap*); - -/* create a map in a RW visual type */ -static Status readwrite_map(Display*, XVisualInfo*, XStandardColormap*); - -#define lowbit(x) ((x) & (~(x) + 1)) -#define TRUEMATCH(mult,max,mask) \ - (colormap->max * colormap->mult <= vinfo->mask && \ - lowbit(vinfo->mask) == colormap->mult) - -/* - * To create any one colormap which is described by an XStandardColormap - * structure, use XmuCreateColormap(). - * - * Return 0 on failure, non-zero on success. - * Resources created by this function are not made permanent. - * No argument error checking is provided. Use at your own risk. - * - * All colormaps are created with read only allocations, with the exception - * of read only allocations of colors in the default map or otherwise - * which fail to return the expected pixel value, and these are individually - * defined as read/write allocations. This is done so that all the cells - * defined in the default map are contiguous, for use in image processing. - * This typically happens with White and Black in the default map. - * - * Colormaps of static visuals are considered to be successfully created if - * the map of the static visual matches the definition given in the - * standard colormap structure. - */ - -Status -XmuCreateColormap(Display *dpy, XStandardColormap *colormap) - /* dpy - specifies the connection under which the map is created - * colormap - specifies the map to be created, and returns, particularly - * if the map is created as a subset of the default colormap - * of the screen, the base_pixel of the map. - */ -{ - XVisualInfo vinfo_template; /* template visual information */ - XVisualInfo *vinfo; /* matching visual information */ - XVisualInfo *vpointer; /* for freeing the entire list */ - long vinfo_mask; /* specifies the visual mask value */ - int n; /* number of matching visuals */ - int status; - - vinfo_template.visualid = colormap->visualid; - vinfo_mask = VisualIDMask; - if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return 0; - - /* A visual id may be valid on multiple screens. Also, there may - * be multiple visuals with identical visual ids at different depths. - * If the colormap is the Default Colormap, use the Default Visual. - * Otherwise, arbitrarily, use the deepest visual. - */ - vpointer = vinfo; - if (n > 1) - { - register int i; - register int screen_number; - Bool def_cmap; - - def_cmap = False; - for (screen_number = ScreenCount(dpy); --screen_number >= 0; ) - if (colormap->colormap == DefaultColormap(dpy, screen_number)) { - def_cmap = True; - break; - } - - if (def_cmap) { - for (i=0; i < n; i++, vinfo++) { - if (vinfo->visual == DefaultVisual(dpy, screen_number)) - break; - } - } else { - int maxdepth = 0; - XVisualInfo *v = NULL; - - for (i=0; i < n; i++, vinfo++) - if (vinfo->depth > maxdepth) { - maxdepth = vinfo->depth; - v = vinfo; - } - vinfo = v; - } - } - - if (vinfo->class == PseudoColor || vinfo->class == DirectColor || - vinfo->class == GrayScale) - status = readwrite_map(dpy, vinfo, colormap); - else if (vinfo->class == TrueColor) - status = TRUEMATCH(red_mult, red_max, red_mask) && - TRUEMATCH(green_mult, green_max, green_mask) && - TRUEMATCH(blue_mult, blue_max, blue_mask); - else - status = readonly_map(dpy, vinfo, colormap); - - XFree((char *) vpointer); - return status; -} - -/****************************************************************************/ -static Status -readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap) -{ - register unsigned long i, n; /* index counters */ - unsigned long ncolors; /* number of colors to be defined */ - int npixels; /* number of pixels allocated R/W */ - int first_index; /* first index of pixels to use */ - int remainder; /* first index of remainder */ - XColor color; /* the definition of a color */ - unsigned long *pixels; /* array of colormap pixels */ - unsigned long delta; - - - /* Determine ncolors, the number of colors to be defined. - * Insure that 1 < ncolors <= the colormap size. - */ - if (vinfo->class == DirectColor) { - ncolors = colormap->red_max; - if (colormap->green_max > ncolors) - ncolors = colormap->green_max; - if (colormap->blue_max > ncolors) - ncolors = colormap->blue_max; - ncolors++; - delta = lowbit(vinfo->red_mask) + - lowbit(vinfo->green_mask) + - lowbit(vinfo->blue_mask); - } else { - ncolors = colormap->red_max * colormap->red_mult + - colormap->green_max * colormap->green_mult + - colormap->blue_max * colormap->blue_mult + 1; - delta = 1; - } - if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size) return 0; - - /* Allocate Read/Write as much of the colormap as we can possibly get. - * Then insure that the pixels we were allocated are given in - * monotonically increasing order, using a quicksort. Next, insure - * that our allocation includes a subset of contiguous pixels at least - * as long as the number of colors to be defined. Now we know that - * these conditions are met: - * 1) There are no free cells in the colormap. - * 2) We have a contiguous sequence of pixels, monotonically - * increasing, of length >= the number of colors requested. - * - * One cell at a time, we will free, compute the next color value, - * then allocate read only. This takes a long time. - * This is done to insure that cells are allocated read only in the - * contiguous order which we prefer. If the server has a choice of - * cells to grant to an allocation request, the server may give us any - * cell, so that is why we do these slow gymnastics. - */ - - if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size, - sizeof(unsigned long))) == NULL) - return 0; - - if ((npixels = ROmap(dpy, colormap->colormap, pixels, - vinfo->colormap_size, ncolors)) == 0) { - free((char *) pixels); - return 0; - } - - qsort((char *) pixels, npixels, sizeof(unsigned long), compare); - - if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder)) - { - /* can't find enough contiguous cells, give up */ - XFreeColors(dpy, colormap->colormap, pixels, npixels, - (unsigned long) 0); - free((char *) pixels); - return 0; - } - colormap->base_pixel = pixels[first_index]; - - /* construct a gray map */ - if (colormap->red_mult == 1 && colormap->green_mult == 1 && - colormap->blue_mult == 1) - for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta) - { - color.pixel = n; - color.blue = color.green = color.red = - (unsigned short) ((i * 65535) / (colormap->red_max + - colormap->green_max + - colormap->blue_max)); - - if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a red ramp map */ - else if (colormap->green_max == 0 && colormap->blue_max == 0) - for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta) - { - color.pixel = n; - color.red = (unsigned short) ((i * 65535) / colormap->red_max); - color.green = color.blue = 0; - - if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a green ramp map */ - else if (colormap->red_max == 0 && colormap->blue_max == 0) - for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta) - { - color.pixel = n; - color.green = (unsigned short) ((i * 65535) / colormap->green_max); - color.red = color.blue = 0; - - if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a blue ramp map */ - else if (colormap->red_max == 0 && colormap->green_max == 0) - for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta) - { - color.pixel = n; - color.blue = (unsigned short) ((i * 65535) / colormap->blue_max); - color.red = color.green = 0; - - if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a standard red green blue cube map */ - else - { -#define calc(max,mult) (((n / colormap->mult) % \ - (colormap->max + 1)) * 65535) / colormap->max - - for (n=0, i=0; i < ncolors; i++, n += delta) - { - color.pixel = n + colormap->base_pixel; - color.red = calc(red_max, red_mult); - color.green = calc(green_max, green_mult); - color.blue = calc(blue_max, blue_mult); - if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } -#undef calc - } - /* We have a read-only map defined. Now free unused cells, - * first those occuring before the contiguous sequence begins, - * then any following the contiguous sequence. - */ - - if (first_index) - XFreeColors(dpy, colormap->colormap, pixels, first_index, - (unsigned long) 0); - if (remainder) - XFreeColors(dpy, colormap->colormap, - &(pixels[first_index + ncolors]), remainder, - (unsigned long) 0); - - free((char *) pixels); - return 1; -} - - -/****************************************************************************/ -static int -ROmap(Display *dpy, Colormap cmap, unsigned long pixels[], int m, int n) - /* - * dpy - the X server connection - * cmap - specifies colormap ID - * pixels - returns pixel allocations - * m - specifies colormap size - * n - specifies number of colors - */ -{ - register int p; - - /* first try to allocate the entire colormap */ - if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, - (unsigned) 0, pixels, (unsigned) m)) - return m; - - /* Allocate all available cells in the colormap, using a binary - * algorithm to discover how many cells we can allocate in the colormap. - */ - m--; - while (n <= m) { - p = n + ((m - n + 1) / 2); - if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, - (unsigned) 0, pixels, (unsigned) p)) { - if (p == m) - return p; - else { - XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); - n = p; - } - } - else - m = p - 1; - } - return 0; -} - - -/****************************************************************************/ -static Status -contiguous(unsigned long pixels[], int npixels, int ncolors, - unsigned long delta, int *first, int *rem) - /* pixels - specifies allocated pixels - * npixels - specifies count of alloc'd pixels - * ncolors - specifies needed sequence length - * delta - between pixels - * first - returns first index of sequence - * rem - returns first index after sequence, or 0, if none follow - */ -{ - register int i = 1; /* walking index into the pixel array */ - register int count = 1; /* length of sequence discovered so far */ - - *first = 0; - if (npixels == ncolors) { - *rem = 0; - return 1; - } - *rem = npixels - 1; - while (count < ncolors && ncolors - count <= *rem) - { - if (pixels[i-1] + delta == pixels[i]) - count++; - else { - count = 1; - *first = i; - } - i++; - (*rem)--; - } - if (count != ncolors) - return 0; - return 1; -} - - -/****************************************************************************/ -static Status -ROorRWcell(Display *dpy, Colormap cmap, unsigned long pixels[], - int npixels, XColor *color, unsigned long p) -{ - unsigned long pixel; - XColor request; - - /* Free the read/write allocation of one cell in the colormap. - * Request a read only allocation of one cell in the colormap. - * If the read only allocation cannot be granted, give up, because - * there must be no free cells in the colormap. - * If the read only allocation is granted, but gives us a cell which - * is not the one that we just freed, it is probably the case that - * we are trying allocate White or Black or some other color which - * already has a read-only allocation in the map. So we try to - * allocate the previously freed cell with a read/write allocation, - * because we want contiguous cells for image processing algorithms. - */ - - pixel = color->pixel; - request.red = color->red; - request.green = color->green; - request.blue = color->blue; - - XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0); - if (! XAllocColor(dpy, cmap, color) - || (color->pixel != pixel && - (!RWcell(dpy, cmap, color, &request, &pixel)))) - { - free_cells(dpy, cmap, pixels, npixels, (int)p); - return 0; - } - return 1; -} - - -/****************************************************************************/ -static void -free_cells(Display *dpy, Colormap cmap, unsigned long pixels[], - int npixels, int p) - /* - * pixels - to be freed - * npixels - original number allocated - */ -{ - /* One of the npixels allocated has already been freed. - * p is the index of the freed pixel. - * First free the pixels preceeding p, and there are p of them; - * then free the pixels following p, there are npixels - p - 1 of them. - */ - XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); - XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0); - free((char *) pixels); -} - - -/****************************************************************************/ -static Status -RWcell(Display *dpy, Colormap cmap, XColor *color, XColor *request, - unsigned long *pixel) -{ - unsigned long n = *pixel; - - XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0); - if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL, - (unsigned) 0, pixel, (unsigned) 1)) - return 0; - if (*pixel != n) - { - XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0); - return 0; - } - color->pixel = *pixel; - color->flags = DoRed | DoGreen | DoBlue; - color->red = request->red; - color->green = request->green; - color->blue = request->blue; - XStoreColors(dpy, cmap, color, 1); - return 1; -} - - -/****************************************************************************/ -static int -compare(_Xconst void *e1, _Xconst void *e2) -{ - return ((int)(*(long *)e1 - *(long *)e2)); -} - - -/****************************************************************************/ -static Status -readonly_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap) -{ - int i, last_pixel; - XColor color; - - last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) * - (colormap->blue_max + 1) + colormap->base_pixel - 1; - - for(i=colormap->base_pixel; i <= last_pixel; i++) { - - color.pixel = (unsigned long) i; - color.red = (unsigned short) - (((i/colormap->red_mult) * 65535) / colormap->red_max); - - if (vinfo->class == StaticColor) { - color.green = (unsigned short) - ((((i/colormap->green_mult) % (colormap->green_max + 1)) * - 65535) / colormap->green_max); - color.blue = (unsigned short) - (((i%colormap->green_mult) * 65535) / colormap->blue_max); - } - else /* vinfo->class == GrayScale, old style allocation XXX */ - color.green = color.blue = color.red; - - XAllocColor(dpy, colormap->colormap, &color); - if (color.pixel != (unsigned long) i) - return 0; - } - return 1; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+/*
+ * CreateCmap.c - given a standard colormap description, make the map.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * Prototypes
+ */
+/* allocate entire map Read Only */
+static int ROmap(Display*, Colormap, unsigned long[], int, int);
+
+/* allocate a cell, prefer Read Only */
+static Status ROorRWcell(Display*, Colormap, unsigned long[], int,
+ XColor*, unsigned long);
+
+/* allocate a cell Read Write */
+static Status RWcell(Display*, Colormap, XColor*, XColor*, unsigned long*);
+
+/* for quicksort */
+static int compare(_Xconst void*, _Xconst void*);
+
+/* find contiguous sequence of cells */
+static Status contiguous(unsigned long[], int, int, unsigned long, int*, int*);
+
+/* frees resources before quitting */
+static void free_cells(Display*, Colormap, unsigned long[], int, int);
+
+/* create a map in a RO visual type */
+static Status readonly_map(Display*, XVisualInfo*, XStandardColormap*);
+
+/* create a map in a RW visual type */
+static Status readwrite_map(Display*, XVisualInfo*, XStandardColormap*);
+
+#define lowbit(x) ((x) & (~(x) + 1))
+#define TRUEMATCH(mult,max,mask) \
+ (colormap->max * colormap->mult <= vinfo->mask && \
+ lowbit(vinfo->mask) == colormap->mult)
+
+/*
+ * To create any one colormap which is described by an XStandardColormap
+ * structure, use XmuCreateColormap().
+ *
+ * Return 0 on failure, non-zero on success.
+ * Resources created by this function are not made permanent.
+ * No argument error checking is provided. Use at your own risk.
+ *
+ * All colormaps are created with read only allocations, with the exception
+ * of read only allocations of colors in the default map or otherwise
+ * which fail to return the expected pixel value, and these are individually
+ * defined as read/write allocations. This is done so that all the cells
+ * defined in the default map are contiguous, for use in image processing.
+ * This typically happens with White and Black in the default map.
+ *
+ * Colormaps of static visuals are considered to be successfully created if
+ * the map of the static visual matches the definition given in the
+ * standard colormap structure.
+ */
+
+Status
+XmuCreateColormap(Display *dpy, XStandardColormap *colormap)
+ /* dpy - specifies the connection under which the map is created
+ * colormap - specifies the map to be created, and returns, particularly
+ * if the map is created as a subset of the default colormap
+ * of the screen, the base_pixel of the map.
+ */
+{
+ XVisualInfo vinfo_template; /* template visual information */
+ XVisualInfo *vinfo; /* matching visual information */
+ XVisualInfo *vpointer; /* for freeing the entire list */
+ long vinfo_mask; /* specifies the visual mask value */
+ int n; /* number of matching visuals */
+ int status;
+
+ vinfo_template.visualid = colormap->visualid;
+ vinfo_mask = VisualIDMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ /* A visual id may be valid on multiple screens. Also, there may
+ * be multiple visuals with identical visual ids at different depths.
+ * If the colormap is the Default Colormap, use the Default Visual.
+ * Otherwise, arbitrarily, use the deepest visual.
+ */
+ vpointer = vinfo;
+ if (n > 1)
+ {
+ register int i;
+ register int screen_number;
+ Bool def_cmap;
+
+ def_cmap = False;
+ for (screen_number = ScreenCount(dpy); --screen_number >= 0; )
+ if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
+ def_cmap = True;
+ break;
+ }
+
+ if (def_cmap) {
+ for (i=0; i < n; i++, vinfo++) {
+ if (vinfo->visual == DefaultVisual(dpy, screen_number))
+ break;
+ }
+ } else {
+ int maxdepth = 0;
+ XVisualInfo *v = NULL;
+
+ for (i=0; i < n; i++, vinfo++)
+ if (vinfo->depth > maxdepth) {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ vinfo = v;
+ }
+ }
+
+ if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
+ vinfo->class == GrayScale)
+ status = readwrite_map(dpy, vinfo, colormap);
+ else if (vinfo->class == TrueColor)
+ status = TRUEMATCH(red_mult, red_max, red_mask) &&
+ TRUEMATCH(green_mult, green_max, green_mask) &&
+ TRUEMATCH(blue_mult, blue_max, blue_mask);
+ else
+ status = readonly_map(dpy, vinfo, colormap);
+
+ XFree((char *) vpointer);
+ return status;
+}
+
+/****************************************************************************/
+static Status
+readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
+{
+ register unsigned long i, n; /* index counters */
+ unsigned long ncolors; /* number of colors to be defined */
+ int npixels; /* number of pixels allocated R/W */
+ int first_index; /* first index of pixels to use */
+ int remainder; /* first index of remainder */
+ XColor color; /* the definition of a color */
+ unsigned long *pixels; /* array of colormap pixels */
+ unsigned long delta;
+
+
+ /* Determine ncolors, the number of colors to be defined.
+ * Insure that 1 < ncolors <= the colormap size.
+ */
+ if (vinfo->class == DirectColor) {
+ ncolors = colormap->red_max;
+ if (colormap->green_max > ncolors)
+ ncolors = colormap->green_max;
+ if (colormap->blue_max > ncolors)
+ ncolors = colormap->blue_max;
+ ncolors++;
+ delta = lowbit(vinfo->red_mask) +
+ lowbit(vinfo->green_mask) +
+ lowbit(vinfo->blue_mask);
+ } else {
+ ncolors = colormap->red_max * colormap->red_mult +
+ colormap->green_max * colormap->green_mult +
+ colormap->blue_max * colormap->blue_mult + 1;
+ delta = 1;
+ }
+ if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size) return 0;
+
+ /* Allocate Read/Write as much of the colormap as we can possibly get.
+ * Then insure that the pixels we were allocated are given in
+ * monotonically increasing order, using a quicksort. Next, insure
+ * that our allocation includes a subset of contiguous pixels at least
+ * as long as the number of colors to be defined. Now we know that
+ * these conditions are met:
+ * 1) There are no free cells in the colormap.
+ * 2) We have a contiguous sequence of pixels, monotonically
+ * increasing, of length >= the number of colors requested.
+ *
+ * One cell at a time, we will free, compute the next color value,
+ * then allocate read only. This takes a long time.
+ * This is done to insure that cells are allocated read only in the
+ * contiguous order which we prefer. If the server has a choice of
+ * cells to grant to an allocation request, the server may give us any
+ * cell, so that is why we do these slow gymnastics.
+ */
+
+ if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
+ sizeof(unsigned long))) == NULL)
+ return 0;
+
+ if ((npixels = ROmap(dpy, colormap->colormap, pixels,
+ vinfo->colormap_size, ncolors)) == 0) {
+ free((char *) pixels);
+ return 0;
+ }
+
+ qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
+
+ if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder))
+ {
+ /* can't find enough contiguous cells, give up */
+ XFreeColors(dpy, colormap->colormap, pixels, npixels,
+ (unsigned long) 0);
+ free((char *) pixels);
+ return 0;
+ }
+ colormap->base_pixel = pixels[first_index];
+
+ /* construct a gray map */
+ if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
+ colormap->blue_mult == 1)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = color.green = color.red =
+ (unsigned short) ((i * 65535) / (colormap->red_max +
+ colormap->green_max +
+ colormap->blue_max));
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a red ramp map */
+ else if (colormap->green_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.red = (unsigned short) ((i * 65535) / colormap->red_max);
+ color.green = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a green ramp map */
+ else if (colormap->red_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.green = (unsigned short) ((i * 65535) / colormap->green_max);
+ color.red = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a blue ramp map */
+ else if (colormap->red_max == 0 && colormap->green_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
+ color.red = color.green = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a standard red green blue cube map */
+ else
+ {
+#define calc(max,mult) (((n / colormap->mult) % \
+ (colormap->max + 1)) * 65535) / colormap->max
+
+ for (n=0, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n + colormap->base_pixel;
+ color.red = calc(red_max, red_mult);
+ color.green = calc(green_max, green_mult);
+ color.blue = calc(blue_max, blue_mult);
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+#undef calc
+ }
+ /* We have a read-only map defined. Now free unused cells,
+ * first those occuring before the contiguous sequence begins,
+ * then any following the contiguous sequence.
+ */
+
+ if (first_index)
+ XFreeColors(dpy, colormap->colormap, pixels, first_index,
+ (unsigned long) 0);
+ if (remainder)
+ XFreeColors(dpy, colormap->colormap,
+ &(pixels[first_index + ncolors]), remainder,
+ (unsigned long) 0);
+
+ free((char *) pixels);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int
+ROmap(Display *dpy, Colormap cmap, unsigned long pixels[], int m, int n)
+ /*
+ * dpy - the X server connection
+ * cmap - specifies colormap ID
+ * pixels - returns pixel allocations
+ * m - specifies colormap size
+ * n - specifies number of colors
+ */
+{
+ register int p;
+
+ /* first try to allocate the entire colormap */
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) m))
+ return m;
+
+ /* Allocate all available cells in the colormap, using a binary
+ * algorithm to discover how many cells we can allocate in the colormap.
+ */
+ m--;
+ while (n <= m) {
+ p = n + ((m - n + 1) / 2);
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) p)) {
+ if (p == m)
+ return p;
+ else {
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ n = p;
+ }
+ }
+ else
+ m = p - 1;
+ }
+ return 0;
+}
+
+
+/****************************************************************************/
+static Status
+contiguous(unsigned long pixels[], int npixels, int ncolors,
+ unsigned long delta, int *first, int *rem)
+ /* pixels - specifies allocated pixels
+ * npixels - specifies count of alloc'd pixels
+ * ncolors - specifies needed sequence length
+ * delta - between pixels
+ * first - returns first index of sequence
+ * rem - returns first index after sequence, or 0, if none follow
+ */
+{
+ register int i = 1; /* walking index into the pixel array */
+ register int count = 1; /* length of sequence discovered so far */
+
+ *first = 0;
+ if (npixels == ncolors) {
+ *rem = 0;
+ return 1;
+ }
+ *rem = npixels - 1;
+ while (count < ncolors && ncolors - count <= *rem)
+ {
+ if (pixels[i-1] + delta == pixels[i])
+ count++;
+ else {
+ count = 1;
+ *first = i;
+ }
+ i++;
+ (*rem)--;
+ }
+ if (count != ncolors)
+ return 0;
+ return 1;
+}
+
+
+/****************************************************************************/
+static Status
+ROorRWcell(Display *dpy, Colormap cmap, unsigned long pixels[],
+ int npixels, XColor *color, unsigned long p)
+{
+ unsigned long pixel;
+ XColor request;
+
+ /* Free the read/write allocation of one cell in the colormap.
+ * Request a read only allocation of one cell in the colormap.
+ * If the read only allocation cannot be granted, give up, because
+ * there must be no free cells in the colormap.
+ * If the read only allocation is granted, but gives us a cell which
+ * is not the one that we just freed, it is probably the case that
+ * we are trying allocate White or Black or some other color which
+ * already has a read-only allocation in the map. So we try to
+ * allocate the previously freed cell with a read/write allocation,
+ * because we want contiguous cells for image processing algorithms.
+ */
+
+ pixel = color->pixel;
+ request.red = color->red;
+ request.green = color->green;
+ request.blue = color->blue;
+
+ XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
+ if (! XAllocColor(dpy, cmap, color)
+ || (color->pixel != pixel &&
+ (!RWcell(dpy, cmap, color, &request, &pixel))))
+ {
+ free_cells(dpy, cmap, pixels, npixels, (int)p);
+ return 0;
+ }
+ return 1;
+}
+
+
+/****************************************************************************/
+static void
+free_cells(Display *dpy, Colormap cmap, unsigned long pixels[],
+ int npixels, int p)
+ /*
+ * pixels - to be freed
+ * npixels - original number allocated
+ */
+{
+ /* One of the npixels allocated has already been freed.
+ * p is the index of the freed pixel.
+ * First free the pixels preceeding p, and there are p of them;
+ * then free the pixels following p, there are npixels - p - 1 of them.
+ */
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
+ free((char *) pixels);
+}
+
+
+/****************************************************************************/
+static Status
+RWcell(Display *dpy, Colormap cmap, XColor *color, XColor *request,
+ unsigned long *pixel)
+{
+ unsigned long n = *pixel;
+
+ XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0);
+ if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
+ (unsigned) 0, pixel, (unsigned) 1))
+ return 0;
+ if (*pixel != n)
+ {
+ XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
+ return 0;
+ }
+ color->pixel = *pixel;
+ color->flags = DoRed | DoGreen | DoBlue;
+ color->red = request->red;
+ color->green = request->green;
+ color->blue = request->blue;
+ XStoreColors(dpy, cmap, color, 1);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int
+compare(_Xconst void *e1, _Xconst void *e2)
+{
+ return ((int)(*(long *)e1 - *(long *)e2));
+}
+
+
+/****************************************************************************/
+static Status
+readonly_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
+{
+ int i, last_pixel;
+ XColor color;
+
+ last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
+ (colormap->blue_max + 1) + colormap->base_pixel - 1;
+
+ for(i=colormap->base_pixel; i <= last_pixel; i++) {
+
+ color.pixel = (unsigned long) i;
+ color.red = (unsigned short)
+ (((i/colormap->red_mult) * 65535) / colormap->red_max);
+
+ if (vinfo->class == StaticColor) {
+ color.green = (unsigned short)
+ ((((i/colormap->green_mult) % (colormap->green_max + 1)) *
+ 65535) / colormap->green_max);
+ color.blue = (unsigned short)
+ (((i%colormap->green_mult) * 65535) / colormap->blue_max);
+ }
+ else /* vinfo->class == GrayScale, old style allocation XXX */
+ color.green = color.blue = color.red;
+
+ XAllocColor(dpy, colormap->colormap, &color);
+ if (color.pixel != (unsigned long) i)
+ return 0;
+ }
+ return 1;
+}
diff --git a/libXmu/src/CrPixFBit.c b/libXmu/src/CrPixFBit.c index 9489a19a0..55fe788b5 100644 --- a/libXmu/src/CrPixFBit.c +++ b/libXmu/src/CrPixFBit.c @@ -1,82 +1,82 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * This file contains miscellaneous utility routines and is not part of the - * Xlib standard. - */ - -/* - * Public entry points: - * - * XmuCreatePixmapFromBitmap make a pixmap from a bitmap - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xos.h> -#include <X11/Xlib.h> -#include <X11/Xmu/Drawing.h> - -Pixmap -XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, - unsigned int width, unsigned int height, - unsigned int depth, - unsigned long fore, unsigned long back) - /* - * dpy - connection to X server - * d - drawable indicating screen - * bitmap - single plane pixmap - * width, height - dimensions of bitmap and pixmap - * depth - depth of pixmap to create - * fore, back - colors to use - */ -{ - Pixmap pixmap; - - pixmap = XCreatePixmap (dpy, d, width, height, depth); - if (pixmap != None) { - GC gc; - XGCValues xgcv; - - xgcv.foreground = fore; - xgcv.background = back; - xgcv.graphics_exposures = False; - - gc = XCreateGC (dpy, d, - (GCForeground | GCBackground | GCGraphicsExposures), - &xgcv); - if (gc) { - XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); - XFreeGC (dpy, gc); - } else { - XFreePixmap (dpy, pixmap); - pixmap = None; - } - } - return pixmap; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ */
+
+/*
+ * Public entry points:
+ *
+ * XmuCreatePixmapFromBitmap make a pixmap from a bitmap
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+Pixmap
+XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap,
+ unsigned int width, unsigned int height,
+ unsigned int depth,
+ unsigned long fore, unsigned long back)
+ /*
+ * dpy - connection to X server
+ * d - drawable indicating screen
+ * bitmap - single plane pixmap
+ * width, height - dimensions of bitmap and pixmap
+ * depth - depth of pixmap to create
+ * fore, back - colors to use
+ */
+{
+ Pixmap pixmap;
+
+ pixmap = XCreatePixmap (dpy, d, width, height, depth);
+ if (pixmap != None) {
+ GC gc;
+ XGCValues xgcv;
+
+ xgcv.foreground = fore;
+ xgcv.background = back;
+ xgcv.graphics_exposures = False;
+
+ gc = XCreateGC (dpy, d,
+ (GCForeground | GCBackground | GCGraphicsExposures),
+ &xgcv);
+ if (gc) {
+ XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
+ XFreeGC (dpy, gc);
+ } else {
+ XFreePixmap (dpy, pixmap);
+ pixmap = None;
+ }
+ }
+ return pixmap;
+}
diff --git a/libXmu/src/CursorName.c b/libXmu/src/CursorName.c index 8867e8fa4..b2abea92b 100644 --- a/libXmu/src/CursorName.c +++ b/libXmu/src/CursorName.c @@ -1,138 +1,138 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xmu/CharSet.h> -#include <X11/Xmu/CurUtil.h> -#include <X11/cursorfont.h> -#include <string.h> - -int -XmuCursorNameToIndex(_Xconst char *name) -{ - static _Xconst struct _CursorName { - _Xconst char *name; - unsigned int shape; - } cursor_names[] = { - {"x_cursor", XC_X_cursor}, - {"arrow", XC_arrow}, - {"based_arrow_down", XC_based_arrow_down}, - {"based_arrow_up", XC_based_arrow_up}, - {"boat", XC_boat}, - {"bogosity", XC_bogosity}, - {"bottom_left_corner", XC_bottom_left_corner}, - {"bottom_right_corner", XC_bottom_right_corner}, - {"bottom_side", XC_bottom_side}, - {"bottom_tee", XC_bottom_tee}, - {"box_spiral", XC_box_spiral}, - {"center_ptr", XC_center_ptr}, - {"circle", XC_circle}, - {"clock", XC_clock}, - {"coffee_mug", XC_coffee_mug}, - {"cross", XC_cross}, - {"cross_reverse", XC_cross_reverse}, - {"crosshair", XC_crosshair}, - {"diamond_cross", XC_diamond_cross}, - {"dot", XC_dot}, - {"dotbox", XC_dotbox}, - {"double_arrow", XC_double_arrow}, - {"draft_large", XC_draft_large}, - {"draft_small", XC_draft_small}, - {"draped_box", XC_draped_box}, - {"exchange", XC_exchange}, - {"fleur", XC_fleur}, - {"gobbler", XC_gobbler}, - {"gumby", XC_gumby}, - {"hand1", XC_hand1}, - {"hand2", XC_hand2}, - {"heart", XC_heart}, - {"icon", XC_icon}, - {"iron_cross", XC_iron_cross}, - {"left_ptr", XC_left_ptr}, - {"left_side", XC_left_side}, - {"left_tee", XC_left_tee}, - {"leftbutton", XC_leftbutton}, - {"ll_angle", XC_ll_angle}, - {"lr_angle", XC_lr_angle}, - {"man", XC_man}, - {"middlebutton", XC_middlebutton}, - {"mouse", XC_mouse}, - {"pencil", XC_pencil}, - {"pirate", XC_pirate}, - {"plus", XC_plus}, - {"question_arrow", XC_question_arrow}, - {"right_ptr", XC_right_ptr}, - {"right_side", XC_right_side}, - {"right_tee", XC_right_tee}, - {"rightbutton", XC_rightbutton}, - {"rtl_logo", XC_rtl_logo}, - {"sailboat", XC_sailboat}, - {"sb_down_arrow", XC_sb_down_arrow}, - {"sb_h_double_arrow", XC_sb_h_double_arrow}, - {"sb_left_arrow", XC_sb_left_arrow}, - {"sb_right_arrow", XC_sb_right_arrow}, - {"sb_up_arrow", XC_sb_up_arrow}, - {"sb_v_double_arrow", XC_sb_v_double_arrow}, - {"shuttle", XC_shuttle}, - {"sizing", XC_sizing}, - {"spider", XC_spider}, - {"spraycan", XC_spraycan}, - {"star", XC_star}, - {"target", XC_target}, - {"tcross", XC_tcross}, - {"top_left_arrow", XC_top_left_arrow}, - {"top_left_corner", XC_top_left_corner}, - {"top_right_corner", XC_top_right_corner}, - {"top_side", XC_top_side}, - {"top_tee", XC_top_tee}, - {"trek", XC_trek}, - {"ul_angle", XC_ul_angle}, - {"umbrella", XC_umbrella}, - {"ur_angle", XC_ur_angle}, - {"watch", XC_watch}, - {"xterm", XC_xterm}, - }; -#define NUM_CURSOR_NAMES (sizeof (cursor_names) / sizeof (cursor_names[0])) - register _Xconst struct _CursorName *table; - register int i; - char tmp[40]; - - if (strlen (name) >= sizeof tmp) return -1; - XmuCopyISOLatin1Lowered (tmp, name); - - for (i=0, table=cursor_names; i < NUM_CURSOR_NAMES; i++, table++ ) { - if (strcmp(tmp, table->name) == 0) return table->shape; - } - - return -1; -} - - - - - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/CurUtil.h>
+#include <X11/cursorfont.h>
+#include <string.h>
+
+int
+XmuCursorNameToIndex(_Xconst char *name)
+{
+ static _Xconst struct _CursorName {
+ _Xconst char *name;
+ unsigned int shape;
+ } cursor_names[] = {
+ {"x_cursor", XC_X_cursor},
+ {"arrow", XC_arrow},
+ {"based_arrow_down", XC_based_arrow_down},
+ {"based_arrow_up", XC_based_arrow_up},
+ {"boat", XC_boat},
+ {"bogosity", XC_bogosity},
+ {"bottom_left_corner", XC_bottom_left_corner},
+ {"bottom_right_corner", XC_bottom_right_corner},
+ {"bottom_side", XC_bottom_side},
+ {"bottom_tee", XC_bottom_tee},
+ {"box_spiral", XC_box_spiral},
+ {"center_ptr", XC_center_ptr},
+ {"circle", XC_circle},
+ {"clock", XC_clock},
+ {"coffee_mug", XC_coffee_mug},
+ {"cross", XC_cross},
+ {"cross_reverse", XC_cross_reverse},
+ {"crosshair", XC_crosshair},
+ {"diamond_cross", XC_diamond_cross},
+ {"dot", XC_dot},
+ {"dotbox", XC_dotbox},
+ {"double_arrow", XC_double_arrow},
+ {"draft_large", XC_draft_large},
+ {"draft_small", XC_draft_small},
+ {"draped_box", XC_draped_box},
+ {"exchange", XC_exchange},
+ {"fleur", XC_fleur},
+ {"gobbler", XC_gobbler},
+ {"gumby", XC_gumby},
+ {"hand1", XC_hand1},
+ {"hand2", XC_hand2},
+ {"heart", XC_heart},
+ {"icon", XC_icon},
+ {"iron_cross", XC_iron_cross},
+ {"left_ptr", XC_left_ptr},
+ {"left_side", XC_left_side},
+ {"left_tee", XC_left_tee},
+ {"leftbutton", XC_leftbutton},
+ {"ll_angle", XC_ll_angle},
+ {"lr_angle", XC_lr_angle},
+ {"man", XC_man},
+ {"middlebutton", XC_middlebutton},
+ {"mouse", XC_mouse},
+ {"pencil", XC_pencil},
+ {"pirate", XC_pirate},
+ {"plus", XC_plus},
+ {"question_arrow", XC_question_arrow},
+ {"right_ptr", XC_right_ptr},
+ {"right_side", XC_right_side},
+ {"right_tee", XC_right_tee},
+ {"rightbutton", XC_rightbutton},
+ {"rtl_logo", XC_rtl_logo},
+ {"sailboat", XC_sailboat},
+ {"sb_down_arrow", XC_sb_down_arrow},
+ {"sb_h_double_arrow", XC_sb_h_double_arrow},
+ {"sb_left_arrow", XC_sb_left_arrow},
+ {"sb_right_arrow", XC_sb_right_arrow},
+ {"sb_up_arrow", XC_sb_up_arrow},
+ {"sb_v_double_arrow", XC_sb_v_double_arrow},
+ {"shuttle", XC_shuttle},
+ {"sizing", XC_sizing},
+ {"spider", XC_spider},
+ {"spraycan", XC_spraycan},
+ {"star", XC_star},
+ {"target", XC_target},
+ {"tcross", XC_tcross},
+ {"top_left_arrow", XC_top_left_arrow},
+ {"top_left_corner", XC_top_left_corner},
+ {"top_right_corner", XC_top_right_corner},
+ {"top_side", XC_top_side},
+ {"top_tee", XC_top_tee},
+ {"trek", XC_trek},
+ {"ul_angle", XC_ul_angle},
+ {"umbrella", XC_umbrella},
+ {"ur_angle", XC_ur_angle},
+ {"watch", XC_watch},
+ {"xterm", XC_xterm},
+ };
+#define NUM_CURSOR_NAMES (sizeof (cursor_names) / sizeof (cursor_names[0]))
+ register _Xconst struct _CursorName *table;
+ register int i;
+ char tmp[40];
+
+ if (strlen (name) >= sizeof tmp) return -1;
+ XmuCopyISOLatin1Lowered (tmp, name);
+
+ for (i=0, table=cursor_names; i < NUM_CURSOR_NAMES; i++, table++ ) {
+ if (strcmp(tmp, table->name) == 0) return table->shape;
+ }
+
+ return -1;
+}
+
+
+
+
+
diff --git a/libXmu/src/CvtCache.c b/libXmu/src/CvtCache.c index 39a5d0caf..dd6b0559f 100644 --- a/libXmu/src/CvtCache.c +++ b/libXmu/src/CvtCache.c @@ -1,133 +1,133 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xos.h> -#include <X11/Xmu/CvtCache.h> -#include <stdlib.h> - -/* - * Prototypes - */ -static int _CloseDisplay(XmuDisplayQueue*, XmuDisplayQueueEntry*); -static int _FreeCCDQ(XmuDisplayQueue*); -static void _InitializeCvtCache(XmuCvtCache*); - -/* - * Initialization - */ -static XmuDisplayQueue *dq = NULL; - - -/* - * internal utility callbacks - */ - -static int -_FreeCCDQ(XmuDisplayQueue *q) -{ - XmuDQDestroy (dq, False); - dq = NULL; - return (0); -} - - -static int -_CloseDisplay(XmuDisplayQueue *q, XmuDisplayQueueEntry *e) -{ - XmuCvtCache *c; - - if (e && (c = (XmuCvtCache *)(e->data))) { - _XmuStringToBitmapFreeCache (c); - /* insert calls to free any cached memory */ - - } - return 0; -} - -static void -_InitializeCvtCache(register XmuCvtCache *c) -{ - _XmuStringToBitmapInitCache (c); - /* insert calls to init any cached memory */ -} - - -/* - * XmuCCLookupDisplay - return the cache entry for the indicated display; - * initialize the cache if necessary - */ -XmuCvtCache * -_XmuCCLookupDisplay(Display *dpy) -{ - XmuDisplayQueueEntry *e; - - /* - * If no displays have been added before this, create the display queue. - */ - if (!dq) { - dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL); - if (!dq) return NULL; - } - - /* - * See if the display is already there - */ - e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */ - if (!e) { /* else create it */ - XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache)); - if (!c) return NULL; - - /* - * Add the display to the queue - */ - e = XmuDQAddDisplay (dq, dpy, (XPointer) c); - if (!e) { - free ((char *) c); - return NULL; - } - - /* - * initialize fields in cache - */ - _InitializeCvtCache (c); - } - - /* - * got it - */ - return (XmuCvtCache *)(e->data); -} - - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CvtCache.h>
+#include <stdlib.h>
+
+/*
+ * Prototypes
+ */
+static int _CloseDisplay(XmuDisplayQueue*, XmuDisplayQueueEntry*);
+static int _FreeCCDQ(XmuDisplayQueue*);
+static void _InitializeCvtCache(XmuCvtCache*);
+
+/*
+ * Initialization
+ */
+static XmuDisplayQueue *dq = NULL;
+
+
+/*
+ * internal utility callbacks
+ */
+
+static int
+_FreeCCDQ(XmuDisplayQueue *q)
+{
+ XmuDQDestroy (dq, False);
+ dq = NULL;
+ return (0);
+}
+
+
+static int
+_CloseDisplay(XmuDisplayQueue *q, XmuDisplayQueueEntry *e)
+{
+ XmuCvtCache *c;
+
+ if (e && (c = (XmuCvtCache *)(e->data))) {
+ _XmuStringToBitmapFreeCache (c);
+ /* insert calls to free any cached memory */
+
+ }
+ return 0;
+}
+
+static void
+_InitializeCvtCache(register XmuCvtCache *c)
+{
+ _XmuStringToBitmapInitCache (c);
+ /* insert calls to init any cached memory */
+}
+
+
+/*
+ * XmuCCLookupDisplay - return the cache entry for the indicated display;
+ * initialize the cache if necessary
+ */
+XmuCvtCache *
+_XmuCCLookupDisplay(Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ /*
+ * If no displays have been added before this, create the display queue.
+ */
+ if (!dq) {
+ dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL);
+ if (!dq) return NULL;
+ }
+
+ /*
+ * See if the display is already there
+ */
+ e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */
+ if (!e) { /* else create it */
+ XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
+ if (!c) return NULL;
+
+ /*
+ * Add the display to the queue
+ */
+ e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
+ if (!e) {
+ free ((char *) c);
+ return NULL;
+ }
+
+ /*
+ * initialize fields in cache
+ */
+ _InitializeCvtCache (c);
+ }
+
+ /*
+ * got it
+ */
+ return (XmuCvtCache *)(e->data);
+}
+
+
diff --git a/libXmu/src/CvtStdSel.c b/libXmu/src/CvtStdSel.c index 81d1a8474..a931aa90c 100644 --- a/libXmu/src/CvtStdSel.c +++ b/libXmu/src/CvtStdSel.c @@ -1,347 +1,347 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * This file contains routines to handle common selection targets. - * - * Public entry points: - * - * XmuConvertStandardSelection() return a known selection - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef SYSVNET -#include <interlan/il_types.h> -#define __TYPES__ /* prevent #include <sys/types.h> in Xlib.h */ -#include <interlan/netdb.h> -#include <interlan/socket.h> -#endif /* SYSVNET */ - -#include <X11/IntrinsicP.h> -#include <X11/Xatom.h> -#include <X11/ShellP.h> -#ifdef XTHREADS -#include <X11/Xthreads.h> -#endif -#include <stdio.h> - -#ifndef SYSVNET -#ifdef WIN32 -#include <X11/Xwinsock.h> -#define XOS_USE_MTSAFE_NETDBAPI -#else -#ifndef Lynx -#include <sys/socket.h> -#else -#include <sys/types.h> -#include <socket.h> -#endif -#define XOS_USE_XT_LOCKING -#endif -#define X_INCLUDE_NETDB_H -#include <X11/Xos_r.h> -#endif - -#include <X11/Xos.h> -#include <stdlib.h> -#include "Atoms.h" -#include "StdSel.h" -#include "SysUtil.h" -#include <X11/Xfuncs.h> - -#ifndef OS_NAME -#ifndef X_OS_FILE -#ifdef SYSV /* keep separate until makedepend fixed */ -#define USE_UNAME -#endif -#ifdef SVR4 -#define USE_UNAME -#endif -#ifdef ultrix -#define USE_UNAME -#endif -#ifdef CSRG_BASED -#define USE_UNAME -#endif -#endif /*X_OS_FILE*/ -#ifdef USE_UNAME -#include <sys/utsname.h> -#endif -#endif - -/* - * Prototypes - */ -static char *get_os_name(void); -static Bool isApplicationShell(Widget); - -/* - * Implementation - */ -static char * -get_os_name(void) -{ -#ifdef OS_NAME - return XtNewString(OS_NAME); -#else -#if defined(X_OS_FILE) || defined(MOTD_FILE) - FILE *f = NULL; -#endif - -#ifdef USE_UNAME - struct utsname utss; - - if (uname (&utss) >= 0) { - char *os_name; - int len = strlen(utss.sysname) + 1; -#ifndef hpux /* because of hostname length crock */ - len += 2 + strlen(utss.release); -#endif - os_name = XtMalloc (len); - strcpy (os_name, utss.sysname); -#ifndef hpux - strcat (os_name, " "); - strcat (os_name, utss.release); -#endif - return os_name; - } -#endif - -#ifdef X_OS_FILE - f = fopen(X_OS_FILE, "r"); - if (!f) -#endif -#ifdef MOTD_FILE - f = fopen(MOTD_FILE, "r"); -#endif -#if defined(X_OS_FILE) || defined(MOTD_FILE) - if (f) { - char motd[512]; - motd[0] = '\0'; - (void) fgets(motd, 511, f); - fclose(f); - motd[511] = '\0'; - if (motd[0] != '\0') { - int len = strlen(motd); - if (motd[len - 1] == '\n') - motd[len - 1] = '\0'; - return XtNewString(motd); - } - } -#endif - -#ifdef sun - return XtNewString("SunOS"); -#else -# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix)) - return XtNewString("BSD"); -# else - return NULL; -# endif -#endif - -#endif /*OS_NAME*/ -} - -/* This is a trick/kludge. To make shared libraries happier (linking - * against Xmu but not linking against Xt, and apparently even work - * as we desire on SVR4, we need to avoid an explicit data reference - * to applicationShellWidgetClass. XtIsTopLevelShell is known - * (implementation dependent assumption!) to use a bit flag. So we - * go that far. Then, we test whether it is an applicationShellWidget - * class by looking for an explicit class name. Seems pretty safe. - */ -static Bool -isApplicationShell(Widget w) -{ - register WidgetClass c; - - if (!XtIsTopLevelShell(w)) - return False; - for (c = XtClass(w); c; c = c->core_class.superclass) { - if (!strcmp(c->core_class.class_name, "ApplicationShell")) - return True; - } - return False; -} - -Boolean -XmuConvertStandardSelection(Widget w, Time time, Atom *selection, Atom *target, - Atom *type, XPointer *value, - unsigned long *length, int *format) -{ - Display *d = XtDisplay(w); - if (*target == XA_TIMESTAMP(d)) { - *value = XtMalloc(4); - if (sizeof(long) == 4) - *(long*)*value = time; - else { - long temp = time; - (void) memmove((char*)*value, ((char*)&temp)+sizeof(long)-4, 4); - } - *type = XA_INTEGER; - *length = 1; - *format = 32; - return True; - } - if (*target == XA_HOSTNAME(d)) { - char hostname[1024]; - hostname[0] = '\0'; - *length = XmuGetHostname (hostname, sizeof hostname); - *value = XtNewString(hostname); - *type = XA_STRING; - *format = 8; - return True; - } -#if defined(TCPCONN) - if (*target == XA_IP_ADDRESS(d)) { - char hostname[1024]; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - struct hostent *hostp; - - hostname[0] = '\0'; - (void) XmuGetHostname (hostname, sizeof hostname); - - if ((hostp = _XGethostbyname (hostname,hparams)) == NULL) - return False; - - if (hostp->h_addrtype != AF_INET) return False; - *length = hostp->h_length; - *value = XtMalloc(*length); - (void) memmove (*value, hostp->h_addr, *length); - *type = XA_NET_ADDRESS(d); - *format = 8; - return True; - } -#endif -#ifdef DNETCONN - if (*target == XA_DECNET_ADDRESS(d)) { - return False; /* XXX niy */ - } -#endif - if (*target == XA_USER(d)) { - char *name = (char*)getenv("USER"); - if (name == NULL) return False; - *value = XtNewString(name); - *type = XA_STRING; - *length = strlen(name); - *format = 8; - return True; - } - if (*target == XA_CLASS(d)) { - Widget parent = XtParent(w); - char *class; - int len; - while (parent != NULL && !isApplicationShell(w)) { - w = parent; - parent = XtParent(w); - } - if (isApplicationShell(w)) - class = ((ApplicationShellWidget) w)->application.class; - else - class = XtClass(w)->core_class.class_name; - *length = (len=strlen(w->core.name)) + strlen(class) + 2; - *value = XtMalloc(*length); - strcpy( (char*)*value, w->core.name ); - strcpy( (char*)*value+len+1, class ); - *type = XA_STRING; - *format = 8; - return True; - } - if (*target == XA_NAME(d)) { - Widget parent = XtParent(w); - - while (parent != NULL && !XtIsWMShell(w)) { - w = parent; - parent = XtParent(w); - } - if (!XtIsWMShell(w)) return False; - *value = XtNewString( ((WMShellWidget) w)->wm.title ); - *length = strlen(*value); - *type = XA_STRING; - *format = 8; - return True; - } - if (*target == XA_CLIENT_WINDOW(d)) { - Widget parent = XtParent(w); - while (parent != NULL) { - w = parent; - parent = XtParent(w); - } - *value = XtMalloc(sizeof(Window)); - *(Window*)*value = w->core.window; - *type = XA_WINDOW; - *length = 1; - *format = 32; - return True; - } - if (*target == XA_OWNER_OS(d)) { - *value = get_os_name(); - if (*value == NULL) return False; - *type = XA_STRING; - *length = strlen(*value); - *format = 8; - return True; - } - if (*target == XA_TARGETS(d)) { -#if defined(unix) && defined(DNETCONN) -# define NUM_TARGETS 9 -#else -# if defined(unix) || defined(DNETCONN) -# define NUM_TARGETS 8 -# else -# define NUM_TARGETS 7 -# endif -#endif - Atom* std_targets = (Atom*)XtMalloc(NUM_TARGETS*sizeof(Atom)); - int i = 0; - std_targets[i++] = XA_TIMESTAMP(d); - std_targets[i++] = XA_HOSTNAME(d); - std_targets[i++] = XA_IP_ADDRESS(d); - std_targets[i++] = XA_USER(d); - std_targets[i++] = XA_CLASS(d); - std_targets[i++] = XA_NAME(d); - std_targets[i++] = XA_CLIENT_WINDOW(d); -#ifdef unix - std_targets[i++] = XA_OWNER_OS(d); -#endif -#ifdef DNETCONN - std_targets[i++] = XA_DECNET_ADDRESS(d); -#endif - *value = (XPointer)std_targets; - *type = XA_ATOM; - *length = NUM_TARGETS; - *format = 32; - return True; - } - /* else */ - return False; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains routines to handle common selection targets.
+ *
+ * Public entry points:
+ *
+ * XmuConvertStandardSelection() return a known selection
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef SYSVNET
+#include <interlan/il_types.h>
+#define __TYPES__ /* prevent #include <sys/types.h> in Xlib.h */
+#include <interlan/netdb.h>
+#include <interlan/socket.h>
+#endif /* SYSVNET */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xatom.h>
+#include <X11/ShellP.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#include <stdio.h>
+
+#ifndef SYSVNET
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#define XOS_USE_MTSAFE_NETDBAPI
+#else
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <sys/types.h>
+#include <socket.h>
+#endif
+#define XOS_USE_XT_LOCKING
+#endif
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+#endif
+
+#include <X11/Xos.h>
+#include <stdlib.h>
+#include "Atoms.h"
+#include "StdSel.h"
+#include "SysUtil.h"
+#include <X11/Xfuncs.h>
+
+#ifndef OS_NAME
+#ifndef X_OS_FILE
+#ifdef SYSV /* keep separate until makedepend fixed */
+#define USE_UNAME
+#endif
+#ifdef SVR4
+#define USE_UNAME
+#endif
+#ifdef ultrix
+#define USE_UNAME
+#endif
+#ifdef CSRG_BASED
+#define USE_UNAME
+#endif
+#endif /*X_OS_FILE*/
+#ifdef USE_UNAME
+#include <sys/utsname.h>
+#endif
+#endif
+
+/*
+ * Prototypes
+ */
+static char *get_os_name(void);
+static Bool isApplicationShell(Widget);
+
+/*
+ * Implementation
+ */
+static char *
+get_os_name(void)
+{
+#ifdef OS_NAME
+ return XtNewString(OS_NAME);
+#else
+#if defined(X_OS_FILE) || defined(MOTD_FILE)
+ FILE *f = NULL;
+#endif
+
+#ifdef USE_UNAME
+ struct utsname utss;
+
+ if (uname (&utss) >= 0) {
+ char *os_name;
+ int len = strlen(utss.sysname) + 1;
+#ifndef hpux /* because of hostname length crock */
+ len += 2 + strlen(utss.release);
+#endif
+ os_name = XtMalloc (len);
+ strcpy (os_name, utss.sysname);
+#ifndef hpux
+ strcat (os_name, " ");
+ strcat (os_name, utss.release);
+#endif
+ return os_name;
+ }
+#endif
+
+#ifdef X_OS_FILE
+ f = fopen(X_OS_FILE, "r");
+ if (!f)
+#endif
+#ifdef MOTD_FILE
+ f = fopen(MOTD_FILE, "r");
+#endif
+#if defined(X_OS_FILE) || defined(MOTD_FILE)
+ if (f) {
+ char motd[512];
+ motd[0] = '\0';
+ (void) fgets(motd, 511, f);
+ fclose(f);
+ motd[511] = '\0';
+ if (motd[0] != '\0') {
+ int len = strlen(motd);
+ if (motd[len - 1] == '\n')
+ motd[len - 1] = '\0';
+ return XtNewString(motd);
+ }
+ }
+#endif
+
+#ifdef sun
+ return XtNewString("SunOS");
+#else
+# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix))
+ return XtNewString("BSD");
+# else
+ return NULL;
+# endif
+#endif
+
+#endif /*OS_NAME*/
+}
+
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool
+isApplicationShell(Widget w)
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return False;
+ for (c = XtClass(w); c; c = c->core_class.superclass) {
+ if (!strcmp(c->core_class.class_name, "ApplicationShell"))
+ return True;
+ }
+ return False;
+}
+
+Boolean
+XmuConvertStandardSelection(Widget w, Time time, Atom *selection, Atom *target,
+ Atom *type, XPointer *value,
+ unsigned long *length, int *format)
+{
+ Display *d = XtDisplay(w);
+ if (*target == XA_TIMESTAMP(d)) {
+ *value = XtMalloc(4);
+ if (sizeof(long) == 4)
+ *(long*)*value = time;
+ else {
+ long temp = time;
+ (void) memmove((char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ }
+ *type = XA_INTEGER;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_HOSTNAME(d)) {
+ char hostname[1024];
+ hostname[0] = '\0';
+ *length = XmuGetHostname (hostname, sizeof hostname);
+ *value = XtNewString(hostname);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+#if defined(TCPCONN)
+ if (*target == XA_IP_ADDRESS(d)) {
+ char hostname[1024];
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ hostname[0] = '\0';
+ (void) XmuGetHostname (hostname, sizeof hostname);
+
+ if ((hostp = _XGethostbyname (hostname,hparams)) == NULL)
+ return False;
+
+ if (hostp->h_addrtype != AF_INET) return False;
+ *length = hostp->h_length;
+ *value = XtMalloc(*length);
+ (void) memmove (*value, hostp->h_addr, *length);
+ *type = XA_NET_ADDRESS(d);
+ *format = 8;
+ return True;
+ }
+#endif
+#ifdef DNETCONN
+ if (*target == XA_DECNET_ADDRESS(d)) {
+ return False; /* XXX niy */
+ }
+#endif
+ if (*target == XA_USER(d)) {
+ char *name = (char*)getenv("USER");
+ if (name == NULL) return False;
+ *value = XtNewString(name);
+ *type = XA_STRING;
+ *length = strlen(name);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLASS(d)) {
+ Widget parent = XtParent(w);
+ char *class;
+ int len;
+ while (parent != NULL && !isApplicationShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (isApplicationShell(w))
+ class = ((ApplicationShellWidget) w)->application.class;
+ else
+ class = XtClass(w)->core_class.class_name;
+ *length = (len=strlen(w->core.name)) + strlen(class) + 2;
+ *value = XtMalloc(*length);
+ strcpy( (char*)*value, w->core.name );
+ strcpy( (char*)*value+len+1, class );
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_NAME(d)) {
+ Widget parent = XtParent(w);
+
+ while (parent != NULL && !XtIsWMShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (!XtIsWMShell(w)) return False;
+ *value = XtNewString( ((WMShellWidget) w)->wm.title );
+ *length = strlen(*value);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLIENT_WINDOW(d)) {
+ Widget parent = XtParent(w);
+ while (parent != NULL) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ *value = XtMalloc(sizeof(Window));
+ *(Window*)*value = w->core.window;
+ *type = XA_WINDOW;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_OWNER_OS(d)) {
+ *value = get_os_name();
+ if (*value == NULL) return False;
+ *type = XA_STRING;
+ *length = strlen(*value);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_TARGETS(d)) {
+#if defined(unix) && defined(DNETCONN)
+# define NUM_TARGETS 9
+#else
+# if defined(unix) || defined(DNETCONN)
+# define NUM_TARGETS 8
+# else
+# define NUM_TARGETS 7
+# endif
+#endif
+ Atom* std_targets = (Atom*)XtMalloc(NUM_TARGETS*sizeof(Atom));
+ int i = 0;
+ std_targets[i++] = XA_TIMESTAMP(d);
+ std_targets[i++] = XA_HOSTNAME(d);
+ std_targets[i++] = XA_IP_ADDRESS(d);
+ std_targets[i++] = XA_USER(d);
+ std_targets[i++] = XA_CLASS(d);
+ std_targets[i++] = XA_NAME(d);
+ std_targets[i++] = XA_CLIENT_WINDOW(d);
+#ifdef unix
+ std_targets[i++] = XA_OWNER_OS(d);
+#endif
+#ifdef DNETCONN
+ std_targets[i++] = XA_DECNET_ADDRESS(d);
+#endif
+ *value = (XPointer)std_targets;
+ *type = XA_ATOM;
+ *length = NUM_TARGETS;
+ *format = 32;
+ return True;
+ }
+ /* else */
+ return False;
+}
diff --git a/libXmu/src/DefErrMsg.c b/libXmu/src/DefErrMsg.c index 37fe0aa31..836fd67bc 100644 --- a/libXmu/src/DefErrMsg.c +++ b/libXmu/src/DefErrMsg.c @@ -1,169 +1,169 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlibint.h> -#include <X11/Xproto.h> -#include <X11/Xmu/Error.h> -#include <X11/Xmu/SysUtil.h> - -/* - * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual - * message. Returns 1 if the caller should consider exitting else 0. - */ -int -XmuPrintDefaultErrorMessage(Display *dpy, XErrorEvent *event, FILE *fp) -{ - char buffer[BUFSIZ]; - char mesg[BUFSIZ]; - char number[32]; - char *mtype = "XlibMessage"; - register _XExtension *ext = (_XExtension *)NULL; - _XExtension *bext = (_XExtension *)NULL; - XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); - XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); - (void) fprintf(fp, "%s: %s\n ", mesg, buffer); - XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->request_code); - if (event->request_code < 128) { - XmuSnprintf(number, sizeof(number), "%d", event->request_code); - XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); - } else { - /* XXX this is non-portable */ - for (ext = dpy->ext_procs; - ext && (ext->codes.major_opcode != event->request_code); - ext = ext->next) - ; - if (ext) - XmuSnprintf(buffer, sizeof(buffer), "%s", ext->name); - else - buffer[0] = '\0'; - } - (void) fprintf(fp, " (%s)", buffer); - fputs("\n ", fp); - if (event->request_code >= 128) { - XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->minor_code); - if (ext) { - XmuSnprintf(mesg, sizeof(mesg), - "%s.%d", ext->name, event->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); - (void) fprintf(fp, " (%s)", buffer); - } - fputs("\n ", fp); - } - if (event->error_code >= 128) { - /* kludge, try to find the extension that caused it */ - buffer[0] = '\0'; - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_string) - (*ext->error_string)(dpy, event->error_code, &ext->codes, - buffer, BUFSIZ); - if (buffer[0]) { - bext = ext; - break; - } - if (ext->codes.first_error && - ext->codes.first_error < event->error_code && - (!bext || ext->codes.first_error > bext->codes.first_error)) - bext = ext; - } - if (bext) - XmuSnprintf(buffer, sizeof(buffer), "%s.%d", bext->name, - event->error_code - bext->codes.first_error); - else - strcpy(buffer, "Value"); - XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ); - if (mesg[0]) { - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - /* let extensions try to print the values */ - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_values) - (*ext->error_values)(dpy, event, fp); - } - } else if ((event->error_code == BadWindow) || - (event->error_code == BadPixmap) || - (event->error_code == BadCursor) || - (event->error_code == BadFont) || - (event->error_code == BadDrawable) || - (event->error_code == BadColor) || - (event->error_code == BadGC) || - (event->error_code == BadIDChoice) || - (event->error_code == BadValue) || - (event->error_code == BadAtom)) { - if (event->error_code == BadValue) - XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", - mesg, BUFSIZ); - else if (event->error_code == BadAtom) - XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", - mesg, BUFSIZ); - else - XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n ", fp); - } - XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->serial); - fputs("\n ", fp); - XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, NextRequest(dpy)-1); - fputs("\n", fp); - if (event->error_code == BadImplementation) return 0; - return 1; -} - - -/* - * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes, - * and XGetGeometry; print a message for everything else. In all case, do - * not exit. - */ -int -XmuSimpleErrorHandler(Display *dpy, XErrorEvent *errorp) -{ - switch (errorp->request_code) { - case X_QueryTree: - case X_GetWindowAttributes: - if (errorp->error_code == BadWindow) return 0; - break; - case X_GetGeometry: - if (errorp->error_code == BadDrawable) return 0; - break; - } - /* got a "real" X error */ - return XmuPrintDefaultErrorMessage (dpy, errorp, stderr); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/Xproto.h>
+#include <X11/Xmu/Error.h>
+#include <X11/Xmu/SysUtil.h>
+
+/*
+ * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
+ * message. Returns 1 if the caller should consider exitting else 0.
+ */
+int
+XmuPrintDefaultErrorMessage(Display *dpy, XErrorEvent *event, FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ XmuSnprintf(number, sizeof(number), "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ /* XXX this is non-portable */
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ XmuSnprintf(buffer, sizeof(buffer), "%s", ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)", buffer);
+ fputs("\n ", fp);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ XmuSnprintf(mesg, sizeof(mesg),
+ "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n ", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ XmuSnprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n ", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->serial);
+ fputs("\n ", fp);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, NextRequest(dpy)-1);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+
+/*
+ * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
+ * and XGetGeometry; print a message for everything else. In all case, do
+ * not exit.
+ */
+int
+XmuSimpleErrorHandler(Display *dpy, XErrorEvent *errorp)
+{
+ switch (errorp->request_code) {
+ case X_QueryTree:
+ case X_GetWindowAttributes:
+ if (errorp->error_code == BadWindow) return 0;
+ break;
+ case X_GetGeometry:
+ if (errorp->error_code == BadDrawable) return 0;
+ break;
+ }
+ /* got a "real" X error */
+ return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
+}
diff --git a/libXmu/src/DelCmap.c b/libXmu/src/DelCmap.c index f29ae00f0..11bec0617 100644 --- a/libXmu/src/DelCmap.c +++ b/libXmu/src/DelCmap.c @@ -1,70 +1,70 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -/* To remove any standard colormap property, use XmuDeleteStandardColormap(). - * XmuDeleteStandardColormap() will remove the specified property from the - * specified screen, releasing any resources used by the colormap(s) of the - * property if possible. - */ - -void -XmuDeleteStandardColormap(Display *dpy, int screen, Atom property) - /* dpy; - specifies the X server to connect to - * screen - specifies the screen of the display - * property - specifies the standard colormap property - */ -{ - XStandardColormap *stdcmaps, *s; - int count = 0; - - if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count, - property)) - { - for (s=stdcmaps; count > 0; count--, s++) { - if ((s->killid == ReleaseByFreeingColormap) && - (s->colormap != None) && - (s->colormap != DefaultColormap(dpy, screen))) - XFreeColormap(dpy, s->colormap); - else if (s->killid != None) - XKillClient(dpy, s->killid); - } - XDeleteProperty(dpy, RootWindow(dpy, screen), property); - XFree((char *) stdcmaps); - XSync(dpy, False); - } -} - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/* To remove any standard colormap property, use XmuDeleteStandardColormap().
+ * XmuDeleteStandardColormap() will remove the specified property from the
+ * specified screen, releasing any resources used by the colormap(s) of the
+ * property if possible.
+ */
+
+void
+XmuDeleteStandardColormap(Display *dpy, int screen, Atom property)
+ /* dpy; - specifies the X server to connect to
+ * screen - specifies the screen of the display
+ * property - specifies the standard colormap property
+ */
+{
+ XStandardColormap *stdcmaps, *s;
+ int count = 0;
+
+ if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
+ property))
+ {
+ for (s=stdcmaps; count > 0; count--, s++) {
+ if ((s->killid == ReleaseByFreeingColormap) &&
+ (s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+ }
+ XDeleteProperty(dpy, RootWindow(dpy, screen), property);
+ XFree((char *) stdcmaps);
+ XSync(dpy, False);
+ }
+}
+
diff --git a/libXmu/src/DisplayQue.c b/libXmu/src/DisplayQue.c index de76a69c4..fadefcc84 100644 --- a/libXmu/src/DisplayQue.c +++ b/libXmu/src/DisplayQue.c @@ -1,191 +1,191 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <stdlib.h> -#include <X11/Xmu/DisplayQue.h> - -/* - * Prototypes - */ -static int _DQCloseDisplay(Display*, XPointer); - -#define CallCloseCallback(q,e) (void) (*((q)->closefunc)) ((q), (e)) -#define CallFreeCallback(q) (void) (*((q)->freefunc)) ((q)) - -/* - * XmuDQCreate - create a display queue - */ -XmuDisplayQueue * -XmuDQCreate(XmuCloseDisplayQueueProc closefunc, - XmuFreeDisplayQueueProc freefunc, - XPointer data) -{ - XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue)); - if (q) { - q->nentries = 0; - q->head = q->tail = NULL; - q->closefunc = closefunc; - q->freefunc = freefunc; - q->data = data; - } - return q; -} - - -/* - * XmuDQDestroy - free all storage associated with this display queue, - * optionally invoking the close callbacks. - */ - -Bool -XmuDQDestroy(XmuDisplayQueue *q, Bool docallbacks) -{ - XmuDisplayQueueEntry *e = q->head; - - while (e) { - XmuDisplayQueueEntry *nexte = e->next; - if (docallbacks && q->closefunc) CallCloseCallback (q, e); - free ((char *) e); - e = nexte; - } - free ((char *) q); - return True; -} - - -/* - * XmuDQLookupDisplay - finds the indicated display on the given queue - */ -XmuDisplayQueueEntry * -XmuDQLookupDisplay(XmuDisplayQueue *q, Display *dpy) -{ - XmuDisplayQueueEntry *e; - - for (e = q->head; e; e = e->next) { - if (e->display == dpy) return e; - } - return NULL; -} - - -/* - * XmuDQAddDisplay - add the specified display to the queue; set data as a - * convenience. Does not ensure that dpy hasn't already been added. - */ -XmuDisplayQueueEntry * -XmuDQAddDisplay(XmuDisplayQueue *q, Display *dpy, XPointer data) -{ - XmuDisplayQueueEntry *e; - - if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) { - return NULL; - } - if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay, - (XPointer) q))) { - free ((char *) e); - return NULL; - } - - e->display = dpy; - e->next = NULL; - e->data = data; - - if (q->tail) { - q->tail->next = e; - e->prev = q->tail; - } else { - q->head = e; - e->prev = NULL; - } - q->tail = e; - q->nentries++; - return e; -} - - -/* - * XmuDQRemoveDisplay - remove the specified display from the queue - */ -Bool -XmuDQRemoveDisplay(XmuDisplayQueue *q, Display *dpy) -{ - XmuDisplayQueueEntry *e; - - for (e = q->head; e; e = e->next) { - if (e->display == dpy) { - if (q->head == e) - q->head = e->next; /* if at head, then bump head */ - else - e->prev->next = e->next; /* else splice out */ - if (q->tail == e) - q->tail = e->prev; /* if at tail, then bump tail */ - else - e->next->prev = e->prev; /* else splice out */ - (void) XmuRemoveCloseDisplayHook (dpy, e->closehook, - _DQCloseDisplay, (XPointer) q); - free ((char *) e); - q->nentries--; - return True; - } - } - return False; -} - - -/***************************************************************************** - * private functions * - *****************************************************************************/ - -/* - * _DQCloseDisplay - upcalled from CloseHook to notify this queue; remove the - * display when finished - */ -static int -_DQCloseDisplay(Display *dpy, XPointer arg) -{ - XmuDisplayQueue *q = (XmuDisplayQueue *) arg; - XmuDisplayQueueEntry *e; - - for (e = q->head; e; e = e->next) { - if (e->display == dpy) { - if (q->closefunc) CallCloseCallback (q, e); - (void) XmuDQRemoveDisplay (q, dpy); - if (q->nentries == 0 && q->freefunc) CallFreeCallback (q); - return 1; - } - } - - return 0; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <X11/Xmu/DisplayQue.h>
+
+/*
+ * Prototypes
+ */
+static int _DQCloseDisplay(Display*, XPointer);
+
+#define CallCloseCallback(q,e) (void) (*((q)->closefunc)) ((q), (e))
+#define CallFreeCallback(q) (void) (*((q)->freefunc)) ((q))
+
+/*
+ * XmuDQCreate - create a display queue
+ */
+XmuDisplayQueue *
+XmuDQCreate(XmuCloseDisplayQueueProc closefunc,
+ XmuFreeDisplayQueueProc freefunc,
+ XPointer data)
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
+ if (q) {
+ q->nentries = 0;
+ q->head = q->tail = NULL;
+ q->closefunc = closefunc;
+ q->freefunc = freefunc;
+ q->data = data;
+ }
+ return q;
+}
+
+
+/*
+ * XmuDQDestroy - free all storage associated with this display queue,
+ * optionally invoking the close callbacks.
+ */
+
+Bool
+XmuDQDestroy(XmuDisplayQueue *q, Bool docallbacks)
+{
+ XmuDisplayQueueEntry *e = q->head;
+
+ while (e) {
+ XmuDisplayQueueEntry *nexte = e->next;
+ if (docallbacks && q->closefunc) CallCloseCallback (q, e);
+ free ((char *) e);
+ e = nexte;
+ }
+ free ((char *) q);
+ return True;
+}
+
+
+/*
+ * XmuDQLookupDisplay - finds the indicated display on the given queue
+ */
+XmuDisplayQueueEntry *
+XmuDQLookupDisplay(XmuDisplayQueue *q, Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) return e;
+ }
+ return NULL;
+}
+
+
+/*
+ * XmuDQAddDisplay - add the specified display to the queue; set data as a
+ * convenience. Does not ensure that dpy hasn't already been added.
+ */
+XmuDisplayQueueEntry *
+XmuDQAddDisplay(XmuDisplayQueue *q, Display *dpy, XPointer data)
+{
+ XmuDisplayQueueEntry *e;
+
+ if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
+ return NULL;
+ }
+ if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
+ (XPointer) q))) {
+ free ((char *) e);
+ return NULL;
+ }
+
+ e->display = dpy;
+ e->next = NULL;
+ e->data = data;
+
+ if (q->tail) {
+ q->tail->next = e;
+ e->prev = q->tail;
+ } else {
+ q->head = e;
+ e->prev = NULL;
+ }
+ q->tail = e;
+ q->nentries++;
+ return e;
+}
+
+
+/*
+ * XmuDQRemoveDisplay - remove the specified display from the queue
+ */
+Bool
+XmuDQRemoveDisplay(XmuDisplayQueue *q, Display *dpy)
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->head == e)
+ q->head = e->next; /* if at head, then bump head */
+ else
+ e->prev->next = e->next; /* else splice out */
+ if (q->tail == e)
+ q->tail = e->prev; /* if at tail, then bump tail */
+ else
+ e->next->prev = e->prev; /* else splice out */
+ (void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
+ _DQCloseDisplay, (XPointer) q);
+ free ((char *) e);
+ q->nentries--;
+ return True;
+ }
+ }
+ return False;
+}
+
+
+/*****************************************************************************
+ * private functions *
+ *****************************************************************************/
+
+/*
+ * _DQCloseDisplay - upcalled from CloseHook to notify this queue; remove the
+ * display when finished
+ */
+static int
+_DQCloseDisplay(Display *dpy, XPointer arg)
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) arg;
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->closefunc) CallCloseCallback (q, e);
+ (void) XmuDQRemoveDisplay (q, dpy);
+ if (q->nentries == 0 && q->freefunc) CallFreeCallback (q);
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/libXmu/src/Distinct.c b/libXmu/src/Distinct.c index 9d31494ec..254eb7f04 100644 --- a/libXmu/src/Distinct.c +++ b/libXmu/src/Distinct.c @@ -1,89 +1,89 @@ -/* - -Copyright 1990, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <stdlib.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -/* - * Distinguishable colors routine. Determines if two colors are - * distinguishable or not. Somewhat arbitrary meaning. - */ - -#define MIN_DISTINGUISH 10000.0 - -Bool -XmuDistinguishableColors(XColor *colors, int count) -{ - double deltaRed, deltaGreen, deltaBlue; - double dist; - int i, j; - - for (i = 0; i < count - 1; i++) - for (j = i + 1; j < count; j++) - { - deltaRed = (double)colors[i].red - (double)colors[j].red; - deltaGreen = (double)colors[i].green - (double)colors[j].green; - deltaBlue = (double)colors[i].blue - (double)colors[j].blue; - dist = deltaRed * deltaRed + - deltaGreen * deltaGreen + - deltaBlue * deltaBlue; - if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH) - return False; - } - return True; -} - -Bool -XmuDistinguishablePixels(Display *dpy, Colormap cmap, - unsigned long *pixels, int count) -{ - XColor *defs; - int i, j; - Bool ret; - - for (i = 0; i < count - 1; i++) - for (j = i + 1; j < count; j++) - if (pixels[i] == pixels[j]) - return False; - defs = (XColor *) malloc (count * sizeof (XColor)); - if (!defs) - return False; - for (i = 0; i < count; i++) - defs[i].pixel = pixels[i]; - XQueryColors (dpy, cmap, defs, count); - ret = XmuDistinguishableColors (defs, count); - free ((char *) defs); - return ret; -} +/*
+
+Copyright 1990, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * Distinguishable colors routine. Determines if two colors are
+ * distinguishable or not. Somewhat arbitrary meaning.
+ */
+
+#define MIN_DISTINGUISH 10000.0
+
+Bool
+XmuDistinguishableColors(XColor *colors, int count)
+{
+ double deltaRed, deltaGreen, deltaBlue;
+ double dist;
+ int i, j;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ {
+ deltaRed = (double)colors[i].red - (double)colors[j].red;
+ deltaGreen = (double)colors[i].green - (double)colors[j].green;
+ deltaBlue = (double)colors[i].blue - (double)colors[j].blue;
+ dist = deltaRed * deltaRed +
+ deltaGreen * deltaGreen +
+ deltaBlue * deltaBlue;
+ if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
+ return False;
+ }
+ return True;
+}
+
+Bool
+XmuDistinguishablePixels(Display *dpy, Colormap cmap,
+ unsigned long *pixels, int count)
+{
+ XColor *defs;
+ int i, j;
+ Bool ret;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ if (pixels[i] == pixels[j])
+ return False;
+ defs = (XColor *) malloc (count * sizeof (XColor));
+ if (!defs)
+ return False;
+ for (i = 0; i < count; i++)
+ defs[i].pixel = pixels[i];
+ XQueryColors (dpy, cmap, defs, count);
+ ret = XmuDistinguishableColors (defs, count);
+ free ((char *) defs);
+ return ret;
+}
diff --git a/libXmu/src/DrRndRect.c b/libXmu/src/DrRndRect.c index 1373de07d..4a3508a76 100644 --- a/libXmu/src/DrRndRect.c +++ b/libXmu/src/DrRndRect.c @@ -1,179 +1,179 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * XmuDrawRoundedRectangle, XmuFillRoundedRectangle - * - * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of - * the overall rectangle, and ew and eh are the sizes of a bounding box - * that the corners are drawn inside of. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xmu/Drawing.h> - -void -XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc, - int x, int y, int w, int h, int ew, int eh) -{ - XArc arcs[8]; - int ew2, eh2; - - if ((ew2 = (ew << 1)) > w) - ew2 = ew = 0; - if ((eh2 = (eh << 1)) > h) - eh2 = eh = 0; - - arcs[0].x = x; - arcs[0].y = y; - arcs[0].width = ew2; - arcs[0].height = eh2; - arcs[0].angle1 = 180 * 64; - arcs[0].angle2 = -90 * 64; - - arcs[1].x = x + ew; - arcs[1].y = y; - arcs[1].width = w - ew2; - arcs[1].height = 0; - arcs[1].angle1 = 180 * 64; - arcs[1].angle2 = -180 * 64; - - arcs[2].x = x + w - ew2; - arcs[2].y = y; - arcs[2].width = ew2; - arcs[2].height = eh2; - arcs[2].angle1 = 90 * 64; - arcs[2].angle2 = -90 * 64; - - arcs[3].x = x + w; - arcs[3].y = y + eh; - arcs[3].width = 0; - arcs[3].height = h - eh2; - arcs[3].angle1 = 90 * 64; - arcs[3].angle2 = -180 * 64; - - arcs[4].x = x + w - ew2; - arcs[4].y = y + h - eh2; - arcs[4].width = ew2; - arcs[4].height = eh2; - arcs[4].angle1 = 0; - arcs[4].angle2 = -90 * 64; - - arcs[5].x = x + ew; - arcs[5].y = y + h; - arcs[5].width = w - ew2; - arcs[5].height = 0; - arcs[5].angle1 = 0; - arcs[5].angle2 = -180 * 64; - - arcs[6].x = x; - arcs[6].y = y + h - eh2; - arcs[6].width = ew2; - arcs[6].height = eh2; - arcs[6].angle1 = 270 * 64; - arcs[6].angle2 = -90 * 64; - - arcs[7].x = x; - arcs[7].y = y + eh; - arcs[7].width = 0; - arcs[7].height = h - eh2; - arcs[7].angle1 = 270 * 64; - arcs[7].angle2 = -180 * 64; - - XDrawArcs(dpy, draw, gc, arcs, 8); -} - -void -XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc, - int x, int y, int w, int h, int ew, int eh) -{ - XArc arcs[4]; - XRectangle rects[3]; - XGCValues vals; - int ew2, eh2; - - XGetGCValues(dpy, gc, GCArcMode, &vals); - if (vals.arc_mode != ArcPieSlice) - XSetArcMode(dpy, gc, ArcPieSlice); - - if ((ew2 = (ew << 1)) > w) - ew2 = ew = 0; - if ((eh2 = (eh << 1)) > h) - eh2 = eh = 0; - - arcs[0].x = x; - arcs[0].y = y; - arcs[0].width = ew2; - arcs[0].height = eh2; - arcs[0].angle1 = 180 * 64; - arcs[0].angle2 = -90 * 64; - - arcs[1].x = x + w - ew2 - 1; - arcs[1].y = y; - arcs[1].width = ew2; - arcs[1].height = eh2; - arcs[1].angle1 = 90 * 64; - arcs[1].angle2 = -90 * 64; - - arcs[2].x = x + w - ew2 - 1; - arcs[2].y = y + h - eh2 - 1; - arcs[2].width = ew2; - arcs[2].height = eh2; - arcs[2].angle1 = 0; - arcs[2].angle2 = -90 * 64; - - arcs[3].x = x; - arcs[3].y = y + h - eh2 - 1; - arcs[3].width = ew2; - arcs[3].height = eh2; - arcs[3].angle1 = 270 * 64; - arcs[3].angle2 = -90 * 64; - - XFillArcs(dpy, draw, gc, arcs, 4); - - rects[0].x = x + ew; - rects[0].y = y; - rects[0].width = w - ew2; - rects[0].height = h; - - rects[1].x = x; - rects[1].y = y + eh; - rects[1].width = ew; - rects[1].height = h - eh2; - - rects[2].x = x + w - ew; - rects[2].y = y + eh; - rects[2].width = ew; - rects[2].height = h - eh2; - - XFillRectangles(dpy, draw, gc, rects, 3); - - if (vals.arc_mode != ArcPieSlice) - XSetArcMode(dpy, gc, vals.arc_mode); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * XmuDrawRoundedRectangle, XmuFillRoundedRectangle
+ *
+ * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of
+ * the overall rectangle, and ew and eh are the sizes of a bounding box
+ * that the corners are drawn inside of.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+void
+XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc,
+ int x, int y, int w, int h, int ew, int eh)
+{
+ XArc arcs[8];
+ int ew2, eh2;
+
+ if ((ew2 = (ew << 1)) > w)
+ ew2 = ew = 0;
+ if ((eh2 = (eh << 1)) > h)
+ eh2 = eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew2;
+ arcs[0].height = eh2;
+ arcs[0].angle1 = 180 * 64;
+ arcs[0].angle2 = -90 * 64;
+
+ arcs[1].x = x + ew;
+ arcs[1].y = y;
+ arcs[1].width = w - ew2;
+ arcs[1].height = 0;
+ arcs[1].angle1 = 180 * 64;
+ arcs[1].angle2 = -180 * 64;
+
+ arcs[2].x = x + w - ew2;
+ arcs[2].y = y;
+ arcs[2].width = ew2;
+ arcs[2].height = eh2;
+ arcs[2].angle1 = 90 * 64;
+ arcs[2].angle2 = -90 * 64;
+
+ arcs[3].x = x + w;
+ arcs[3].y = y + eh;
+ arcs[3].width = 0;
+ arcs[3].height = h - eh2;
+ arcs[3].angle1 = 90 * 64;
+ arcs[3].angle2 = -180 * 64;
+
+ arcs[4].x = x + w - ew2;
+ arcs[4].y = y + h - eh2;
+ arcs[4].width = ew2;
+ arcs[4].height = eh2;
+ arcs[4].angle1 = 0;
+ arcs[4].angle2 = -90 * 64;
+
+ arcs[5].x = x + ew;
+ arcs[5].y = y + h;
+ arcs[5].width = w - ew2;
+ arcs[5].height = 0;
+ arcs[5].angle1 = 0;
+ arcs[5].angle2 = -180 * 64;
+
+ arcs[6].x = x;
+ arcs[6].y = y + h - eh2;
+ arcs[6].width = ew2;
+ arcs[6].height = eh2;
+ arcs[6].angle1 = 270 * 64;
+ arcs[6].angle2 = -90 * 64;
+
+ arcs[7].x = x;
+ arcs[7].y = y + eh;
+ arcs[7].width = 0;
+ arcs[7].height = h - eh2;
+ arcs[7].angle1 = 270 * 64;
+ arcs[7].angle2 = -180 * 64;
+
+ XDrawArcs(dpy, draw, gc, arcs, 8);
+}
+
+void
+XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc,
+ int x, int y, int w, int h, int ew, int eh)
+{
+ XArc arcs[4];
+ XRectangle rects[3];
+ XGCValues vals;
+ int ew2, eh2;
+
+ XGetGCValues(dpy, gc, GCArcMode, &vals);
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, ArcPieSlice);
+
+ if ((ew2 = (ew << 1)) > w)
+ ew2 = ew = 0;
+ if ((eh2 = (eh << 1)) > h)
+ eh2 = eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew2;
+ arcs[0].height = eh2;
+ arcs[0].angle1 = 180 * 64;
+ arcs[0].angle2 = -90 * 64;
+
+ arcs[1].x = x + w - ew2 - 1;
+ arcs[1].y = y;
+ arcs[1].width = ew2;
+ arcs[1].height = eh2;
+ arcs[1].angle1 = 90 * 64;
+ arcs[1].angle2 = -90 * 64;
+
+ arcs[2].x = x + w - ew2 - 1;
+ arcs[2].y = y + h - eh2 - 1;
+ arcs[2].width = ew2;
+ arcs[2].height = eh2;
+ arcs[2].angle1 = 0;
+ arcs[2].angle2 = -90 * 64;
+
+ arcs[3].x = x;
+ arcs[3].y = y + h - eh2 - 1;
+ arcs[3].width = ew2;
+ arcs[3].height = eh2;
+ arcs[3].angle1 = 270 * 64;
+ arcs[3].angle2 = -90 * 64;
+
+ XFillArcs(dpy, draw, gc, arcs, 4);
+
+ rects[0].x = x + ew;
+ rects[0].y = y;
+ rects[0].width = w - ew2;
+ rects[0].height = h;
+
+ rects[1].x = x;
+ rects[1].y = y + eh;
+ rects[1].width = ew;
+ rects[1].height = h - eh2;
+
+ rects[2].x = x + w - ew;
+ rects[2].y = y + eh;
+ rects[2].width = ew;
+ rects[2].height = h - eh2;
+
+ XFillRectangles(dpy, draw, gc, rects, 3);
+
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, vals.arc_mode);
+}
diff --git a/libXmu/src/DrawLogo.c b/libXmu/src/DrawLogo.c index 4af89b530..a6729e081 100644 --- a/libXmu/src/DrawLogo.c +++ b/libXmu/src/DrawLogo.c @@ -1,152 +1,152 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <X11/Xmu/Drawing.h> - -/* - * Draw the "official" X Window System Logo, designed by Danny Chong - * - * Written by Ollie Jones, Apollo Computer - * - * Does some fancy stuff to make the logo look acceptable even - * if it is tiny. Also makes the various linear elements of - * the logo line up as well as possible considering rasterization. - */ -void -XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack, - int x, int y, unsigned int width, unsigned int height) -{ - unsigned int size; - int thin, gap, d31; - XPoint poly[4]; - - XFillRectangle(dpy, drawable, gcBack, x, y, width, height); - - /* for now, do a centered even-sized square, at least for now */ - size = width; - if (height < width) - size = height; - size &= ~1; - x += (width - size) >> 1; - y += (height - size) >> 1; - -/* - * Draw what will be the thin strokes. - * - * ----- - * / / - * / / - * / / - * / / - * /____/ - * d - * - * Point d is 9/44 (~1/5) of the way across. - */ - - thin = (size / 11); - if (thin < 1) thin = 1; - gap = (thin+3) / 4; - d31 = thin + thin + gap; - poly[0].x = x + size; poly[0].y = y; - poly[1].x = x + size-d31; poly[1].y = y; - poly[2].x = x + 0; poly[2].y = y + size; - poly[3].x = x + d31; poly[3].y = y + size; - XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin); - -/* - * Erase area not needed for lower thin stroke. - * - * ------ - * / / - * / __ / - * / / / - * / / / - * /__/__/ - */ - - poly[0].x = x + d31/2; poly[0].y = y + size; - poly[1].x = x + size / 2; poly[1].y = y + size/2; - poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2; - poly[3].x = x + d31; poly[3].y = y + size; - XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); - -/* - * Erase area not needed for upper thin stroke. - * - * ------ - * / / / - * /--/ / - * / / - * / / - * /_____/ - */ - - poly[0].x = x + size - d31/2; poly[0].y = y; - poly[1].x = x + size / 2; poly[1].y = y + size/2; - poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2; - poly[3].x = x + size - d31; poly[3].y = y; - XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); - -/* - * Draw thick stroke. - * Point b is 1/4 of the way across. - * - * b - * ----- - * \ \ - * \ \ - * \ \ - * \ \ - * \____\ - */ - - poly[0].x = x; poly[0].y = y; - poly[1].x = x + size/4; poly[1].y = y; - poly[2].x = x + size; poly[2].y = y + size; - poly[3].x = x + size - size/4; poly[3].y = y + size; - XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin); - -/* - * Erase to create gap. - * - * / - * / - * / - * / - * / - */ - - poly[0].x = x + size- thin; poly[0].y = y; - poly[1].x = x + size-( thin+gap); poly[1].y = y; - poly[2].x = x + thin; poly[2].y = y + size; - poly[3].x = x + thin + gap; poly[3].y = y + size; - XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xmu/Drawing.h>
+
+/*
+ * Draw the "official" X Window System Logo, designed by Danny Chong
+ *
+ * Written by Ollie Jones, Apollo Computer
+ *
+ * Does some fancy stuff to make the logo look acceptable even
+ * if it is tiny. Also makes the various linear elements of
+ * the logo line up as well as possible considering rasterization.
+ */
+void
+XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack,
+ int x, int y, unsigned int width, unsigned int height)
+{
+ unsigned int size;
+ int thin, gap, d31;
+ XPoint poly[4];
+
+ XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
+
+ /* for now, do a centered even-sized square, at least for now */
+ size = width;
+ if (height < width)
+ size = height;
+ size &= ~1;
+ x += (width - size) >> 1;
+ y += (height - size) >> 1;
+
+/*
+ * Draw what will be the thin strokes.
+ *
+ * -----
+ * / /
+ * / /
+ * / /
+ * / /
+ * /____/
+ * d
+ *
+ * Point d is 9/44 (~1/5) of the way across.
+ */
+
+ thin = (size / 11);
+ if (thin < 1) thin = 1;
+ gap = (thin+3) / 4;
+ d31 = thin + thin + gap;
+ poly[0].x = x + size; poly[0].y = y;
+ poly[1].x = x + size-d31; poly[1].y = y;
+ poly[2].x = x + 0; poly[2].y = y + size;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for lower thin stroke.
+ *
+ * ------
+ * / /
+ * / __ /
+ * / / /
+ * / / /
+ * /__/__/
+ */
+
+ poly[0].x = x + d31/2; poly[0].y = y + size;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for upper thin stroke.
+ *
+ * ------
+ * / / /
+ * /--/ /
+ * / /
+ * / /
+ * /_____/
+ */
+
+ poly[0].x = x + size - d31/2; poly[0].y = y;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + size - d31; poly[3].y = y;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Draw thick stroke.
+ * Point b is 1/4 of the way across.
+ *
+ * b
+ * -----
+ * \ \
+ * \ \
+ * \ \
+ * \ \
+ * \____\
+ */
+
+ poly[0].x = x; poly[0].y = y;
+ poly[1].x = x + size/4; poly[1].y = y;
+ poly[2].x = x + size; poly[2].y = y + size;
+ poly[3].x = x + size - size/4; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase to create gap.
+ *
+ * /
+ * /
+ * /
+ * /
+ * /
+ */
+
+ poly[0].x = x + size- thin; poly[0].y = y;
+ poly[1].x = x + size-( thin+gap); poly[1].y = y;
+ poly[2].x = x + thin; poly[2].y = y + size;
+ poly[3].x = x + thin + gap; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+}
diff --git a/libXmu/src/EditresCom.c b/libXmu/src/EditresCom.c index b4554e142..aeef24099 100644 --- a/libXmu/src/EditresCom.c +++ b/libXmu/src/EditresCom.c @@ -1,2213 +1,2213 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Chris D. Peterson, Dave Sternlicht, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/IntrinsicP.h> /* To get into the composite and core widget - structures. */ -#include <X11/ObjectP.h> /* For XtIs<Classname> macros. */ -#include <X11/StringDefs.h> /* for XtRString. */ -#include <X11/ShellP.h> /* for Application Shell Widget class. */ - -#include <X11/Xatom.h> -#include <X11/Xos.h> /* for strcpy declaration */ -#include <X11/Xfuncs.h> -#include <X11/Xmu/EditresP.h> -#include <X11/Xmd.h> -#include <X11/Xmu/CharSet.h> -#include <X11/Xmu/SysUtil.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#define _XEditResPutBool _XEditResPut8 -#define _XEditResPutResourceType _XEditResPut8 - -/* - * Types - */ -typedef enum { - BlockNone, - BlockSetValues, - BlockAll -} EditresBlock; - -typedef struct _SetValuesEvent { - EditresCommand type; /* first field must be type */ - WidgetInfo *widgets; - unsigned short num_entries; /* number of set values requests */ - char *name; - char *res_type; - XtPointer value; - unsigned short value_len; -} SetValuesEvent; - -typedef struct _SVErrorInfo { - SetValuesEvent *event; - ProtocolStream *stream; - unsigned short *count; - WidgetInfo *entry; -} SVErrorInfo; - -typedef struct _GetValuesEvent { - EditresCommand type; /* first field must be type */ - WidgetInfo *widgets; - unsigned short num_entries; /* number of get values requests */ - char *name; -} GetValuesEvent; - -typedef struct _FindChildEvent { - EditresCommand type; /* first field must be type */ - WidgetInfo *widgets; - short x, y; -} FindChildEvent; - -typedef struct _GenericGetEvent { - EditresCommand type; /* first field must be type */ - WidgetInfo *widgets; - unsigned short num_entries; /* number of set values requests */ -} GenericGetEvent, GetResEvent, GetGeomEvent; - -/* - * Common to all events - */ -typedef struct _AnyEvent { - EditresCommand type; /* first field must be type */ - WidgetInfo *widgets; -} AnyEvent; - -/* - * The event union - */ -typedef union _EditresEvent { - AnyEvent any_event; - SetValuesEvent set_values_event; - GetResEvent get_resources_event; - GetGeomEvent get_geometry_event; - FindChildEvent find_child_event; -} EditresEvent; - -typedef struct _Globals { - EditresBlock block; - SVErrorInfo error_info; - ProtocolStream stream; - ProtocolStream *command_stream; /* command stream */ -#if defined(LONG64) || defined(WORD64) - unsigned long base_address; -#endif -} Globals; - -#define CURRENT_PROTOCOL_VERSION 5L - -#define streq(a,b) (strcmp((a), (b)) == 0) - -/* - * Prototypes - */ -static Widget _FindChild(Widget, int, int); -static void _XEditresGetStringValues(Widget, Arg*, int); -static XtPointer BuildReturnPacket(ResIdent, EditResError, ProtocolStream*); -static void CommandDone(Widget, Atom*, Atom*); -static Boolean ConvertReturnCommand(Widget, Atom*, Atom*, Atom*, XtPointer*, - unsigned long*, int*); -static Boolean CvtStringToBlock(Display*, XrmValue*, Cardinal*, - XrmValue*, XrmValue*, XtPointer*); -static EditresEvent *BuildEvent(Widget, Atom, XtPointer, ResIdent, - unsigned long); -static char *DoFindChild(Widget, EditresEvent*, ProtocolStream*); -static char *DoGetGeometry(Widget, EditresEvent*, ProtocolStream*); -static char *DoGetResources(Widget, EditresEvent*, ProtocolStream*); -static char *DoSetValues(Widget, EditresEvent*, ProtocolStream*); -static void DumpChildren(Widget, ProtocolStream*, unsigned short*); -static char *DumpValues(Widget, EditresEvent*, ProtocolStream*); -static char *DumpWidgets(Widget, EditresEvent*, ProtocolStream*); -static void ExecuteCommand(Widget, Atom, ResIdent, EditresEvent*); -static void ExecuteGetGeometry(Widget, ProtocolStream*); -static void ExecuteGetResources(Widget w, ProtocolStream *stream); -static void ExecuteSetValues(Widget, SetValuesEvent*, WidgetInfo*, - ProtocolStream*, unsigned short*); -static void FreeEvent(EditresEvent*); -static void GetCommand(Widget w, XtPointer, Atom*, Atom*, XtPointer, - unsigned long*, int*); -static void HandleToolkitErrors(String, String, String, String, - String*, Cardinal*); -static void InsertWidget(ProtocolStream*, Widget); -static Bool IsChild(Widget, Widget, Widget); -static Bool isApplicationShell(Widget); -static void LoadResources(Widget); -static Bool PositionInChild(Widget, int, int); -static int qcmp_widget_list(register _Xconst void*, register _Xconst void*); -static void SendCommand(Widget, Atom, ResIdent, EditResError, - ProtocolStream*); -static void SendFailure(Widget, Atom, ResIdent, char*); -static char *VerifyWidget(Widget, WidgetInfo*); - -/* - * External - */ -void _XEditResCheckMessages(Widget, XtPointer, XEvent*, Boolean*); - -/* - * Initialization - */ -static Atom res_editor_command, res_editor_protocol, client_value; -static Globals globals; - -/************************************************************ - * Resource Editor Communication Code - ************************************************************/ -/* - * Function: - * _XEditResCheckMessages - * - * Parameters: - * data - unused - * event - The X Event that triggered this handler - * cont - unused - * - * Description: - * This callback routine is set on all shell widgets, and checks to - * see if a client message event has come from the resource editor. - */ -/*ARGSUSED*/ -void -_XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont) -{ - Time time; - ResIdent ident; - static Boolean first_time = False; - static Atom res_editor, res_comm; - Display *dpy; - - if (event->type == ClientMessage) - { - XClientMessageEvent * c_event = (XClientMessageEvent *)event; - dpy = XtDisplay(w); - - if (!first_time) - { - Atom atoms[4]; - static char *names[] = { - EDITRES_NAME, EDITRES_COMMAND_ATOM, - EDITRES_PROTOCOL_ATOM, EDITRES_CLIENT_VALUE - }; - - first_time = True; - XInternAtoms(dpy, names, 4, False, atoms); - res_editor = atoms[0]; - res_editor_command = atoms[1]; - res_editor_protocol = atoms[2]; - /* Used in later procedures */ - client_value = atoms[3]; - LoadResources(w); - } - - if ((c_event->message_type != res_editor) - || (c_event->format != EDITRES_SEND_EVENT_FORMAT)) - return; - - time = c_event->data.l[0]; - res_comm = c_event->data.l[1]; - ident = (ResIdent) c_event->data.l[2]; - if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION) - { - _XEditResResetStream(&globals.stream); - _XEditResPut8(&globals.stream, - (unsigned int) CURRENT_PROTOCOL_VERSION); - SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream); - return; - } - - XtGetSelectionValue(w, res_comm, res_editor_command, - GetCommand, (XtPointer)(long)ident, time); - } -} - -/* - * Function: - * BuildEvent - * - * Parameters: - * w - widget to own selection, in case of error - * sel - selection to send error message beck in - * data - the data for the request - * ident - the id number we are looking for - * length - length of request - * - * Description: - * Takes the info out the protocol stream an constructs - * the proper event structure. - * - * Returns: - * the event, or NULL - */ -#if defined(ERROR_MESSAGE) -#undef ERROR_MESSAGE -#endif -#define ERROR_MESSAGE "Client: Improperly formatted protocol request" -static EditresEvent * -BuildEvent(Widget w, Atom sel, XtPointer data, ResIdent ident, - unsigned long length) -{ - EditresEvent *event; - ProtocolStream alloc_stream, *stream; - unsigned char temp; - register unsigned int i; - - stream = &alloc_stream; - stream->current = stream->top = (unsigned char *)data; - stream->size = HEADER_SIZE; /* size of header */ - - /* - * Retrieve the Header - */ - if (length < HEADER_SIZE) - { - SendFailure(w, sel, ident, ERROR_MESSAGE); - return (NULL); - } - - (void)_XEditResGet8(stream, &temp); - if (temp != ident) /* Id's don't match, ignore request */ - return (NULL); - - event = (EditresEvent *)XtCalloc(sizeof(EditresEvent), 1); - - (void)_XEditResGet8(stream, &temp); - event->any_event.type = (EditresCommand)temp; - (void)_XEditResGet32(stream, &stream->size); - stream->top = stream->current; /* reset stream to top of value */ - - /* - * Now retrieve the data segment - */ - switch(event->any_event.type) - { - case SendWidgetTree: - break; /* no additional info */ - case SetValues: - { - SetValuesEvent *sv_event = (SetValuesEvent *)event; - - if (!(_XEditResGetString8(stream, &sv_event->name) - && _XEditResGetString8(stream, &sv_event->res_type))) - goto done; - - /* - * Since we need the value length, we have to pull the - * value out by hand - */ - if (!_XEditResGet16(stream, &sv_event->value_len)) - goto done; - - sv_event->value = XtMalloc(sizeof(char) * (sv_event->value_len + 1)); - - for (i = 0; i < sv_event->value_len; i++) - if (!_XEditResGet8(stream, (unsigned char *)sv_event->value + i)) - goto done; - - ((char*)sv_event->value)[i] = '\0'; - - if (!_XEditResGet16(stream, &sv_event->num_entries)) - goto done; - - sv_event->widgets = (WidgetInfo *) - XtCalloc(sizeof(WidgetInfo), sv_event->num_entries); - - for (i = 0; i < sv_event->num_entries; i++) - if (!_XEditResGetWidgetInfo(stream, sv_event->widgets + i)) - goto done; - } - break; - case FindChild: - { - FindChildEvent *find_event = (FindChildEvent *)event; - - find_event->widgets = (WidgetInfo *)XtCalloc(sizeof(WidgetInfo), 1); - - if (!(_XEditResGetWidgetInfo(stream, find_event->widgets) - && _XEditResGetSigned16(stream, &find_event->x) - && _XEditResGetSigned16(stream, &find_event->y))) - goto done; - } - break; - case GetGeometry: - case GetResources: - { - GenericGetEvent *get_event = (GenericGetEvent *)event; - - if (!_XEditResGet16(stream, &get_event->num_entries)) - goto done; - - get_event->widgets = (WidgetInfo *) - XtCalloc(sizeof(WidgetInfo), get_event->num_entries); - - for (i = 0; i < get_event->num_entries; i++) - if (!_XEditResGetWidgetInfo(stream, get_event->widgets + i)) - goto done; - } - break; - case GetValues: - { - GetValuesEvent *gv_event = (GetValuesEvent *)event; - - _XEditResGetString8(stream, &gv_event->name); - _XEditResGet16(stream, &gv_event->num_entries); - gv_event->widgets = (WidgetInfo *) - XtCalloc(sizeof(WidgetInfo), gv_event->num_entries); - _XEditResGetWidgetInfo(stream, gv_event->widgets); - } - break; - default: - { - char buf[BUFSIZ]; - - XmuSnprintf(buf, sizeof(buf), - "Unknown Protocol request %d.", event->any_event.type); - SendFailure(w, sel, ident, buf); - FreeEvent(event); - return (NULL); - } - } - - return (event); - - done: - SendFailure(w, sel, ident, ERROR_MESSAGE); - FreeEvent(event); - return (NULL); -} - -/* - * Function: - * FreeEvent - * - * Parameters: - * event - event to free - * - * Description: - * Frees the event structure and any other pieces in it that need freeing. - */ -static void -FreeEvent(EditresEvent *event) -{ - if (event->any_event.widgets != NULL) - { - XtFree((char *)event->any_event.widgets->ids); - XtFree((char *)event->any_event.widgets); - } - - if (event->any_event.type == SetValues) - { - XtFree(event->set_values_event.name); - XtFree(event->set_values_event.res_type); - } - - XtFree((char *)event); -} - -/* - * Function: - * GetCommand - * - * Parameters: - * (See Xt XtConvertSelectionProc) - * data - contains the ident number for the command - * - * Description: - * Gets the Command out of the selection asserted by the resource manager. - */ -/*ARGSUSED*/ -static void -GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type, - XtPointer value, unsigned long *length, int *format) -{ - ResIdent ident = (ResIdent)(long)data; - EditresEvent *event; - - if (*type != res_editor_protocol || *format != EDITRES_FORMAT) - return; - - if ((event = BuildEvent(w, *selection, value, ident, *length)) != NULL) - { - ExecuteCommand(w, *selection, ident, event); - FreeEvent(event); - } -} - -/* - * Function: - * ExecuteCommand - * - * Parameters: - * w - widget - * command - the command to execute - * value - the associated with the command - * - * Description: - * Executes a command string received from the resource editor. - */ -/*ARGSUSED*/ -static void -ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event) -{ - char *(*func)(Widget, EditresEvent*, ProtocolStream*); - char *str; - - if (globals.block == BlockAll) - { - SendFailure(w, sel, ident, - "This client has blocked all Editres commands."); - return; - } - else if (globals.block == BlockSetValues - && event->any_event.type == SetValues) - { - SendFailure(w, sel, ident, - "This client has blocked all SetValues requests."); - return; - } - - switch(event->any_event.type) - { - case SendWidgetTree: -#if defined(LONG64) || defined(WORD64) - globals.base_address = (unsigned long)w & 0xFFFFFFFF00000000; -#endif - func = DumpWidgets; - break; - case SetValues: - func = DoSetValues; - break; - case FindChild: - func = DoFindChild; - break; - case GetGeometry: - func = DoGetGeometry; - break; - case GetResources: - func = DoGetResources; - break; - case GetValues: - func = DumpValues; - break; - default: - { - char buf[BUFSIZ]; - - XmuSnprintf(buf, sizeof(buf), - "Unknown Protocol request %d.",event->any_event.type); - SendFailure(w, sel, ident, buf); - return; - } - } - - _XEditResResetStream(&globals.stream); - if ((str = (*func)(w, event, &globals.stream)) == NULL) - SendCommand(w, sel, ident, PartialSuccess, &globals.stream); - else - SendFailure(w, sel, ident, str); -} - -/* - * Function: - * ConvertReturnCommand - * - * Parameters: - * w - the widget that owns the selection - * selection - selection to convert - * target - target type for this selection - * type_ret - type of the selection - * value_ret - selection value - * length_ret - lenght of this selection - * format_ret - the format the selection is in - * - * Description: - * Converts a selection - * - * Returns: - * True if conversion was sucessful - */ -/*ARGSUSED*/ -static Boolean -ConvertReturnCommand(Widget w, Atom *selection, Atom *target, Atom *type_ret, - XtPointer *value_ret, unsigned long *length_ret, - int *format_ret) -{ - /* - * I assume the intrinsics give me the correct selection back - */ - if ((*target != client_value)) - return (False); - - *type_ret = res_editor_protocol; - *value_ret = (XtPointer)globals.command_stream->real_top; - *length_ret = globals.command_stream->size + HEADER_SIZE; - *format_ret = EDITRES_FORMAT; - - return (True); -} - -/* - * Function: - * CommandDone - * - * Parameters: - * widget - unused - * selection - unused - * target - unused - * - * Description: - * done with the selection - */ -/*ARGSUSED*/ -static void -CommandDone(Widget widget, Atom *selection, Atom *target) -{ - /* Keep the toolkit from automaticaly freeing the selection value */ -} - -/* - * Function: - * SendFailure - * - * Paramters: - * w - widget to own the selection - * sel - selection to assert - * ident - identifier - * str - error message - * - * Description: - * Sends a failure message - */ -static void -SendFailure(Widget w, Atom sel, ResIdent ident, char *str) -{ - _XEditResResetStream(&globals.stream); - _XEditResPutString8(&globals.stream, str); - SendCommand(w, sel, ident, Failure, &globals.stream); -} - -/* - * Function: - * BuildReturnPacket - * - * Parameters: - * ident - identifier - * command - command code - * stream - protocol stream - * Description: - * Builds a return packet, given the data to send - * - * Returns: - * packet to send - */ -static XtPointer -BuildReturnPacket(ResIdent ident, EditResError error, ProtocolStream *stream) -{ - long old_alloc, old_size; - unsigned char *old_current; - - /* - * We have cleverly keep enough space at the top of the header - * for the return protocol stream, so all we have to do is - * fill in the space - */ - /* - * Fool the insert routines into putting the header in the right - * place while being damn sure not to realloc (that would be very bad.) - */ - old_current = stream->current; - old_alloc = stream->alloc; - old_size = stream->size; - - stream->current = stream->real_top; - stream->alloc = stream->size + (2 * HEADER_SIZE); - - _XEditResPut8(stream, ident); - _XEditResPut8(stream, (unsigned char)error); - _XEditResPut32(stream, old_size); - - stream->alloc = old_alloc; - stream->current = old_current; - stream->size = old_size; - - return ((XtPointer)stream->real_top); -} - -/* - * Function: - * SendCommand - * Parameters: - * w - widget to own the selection - * sel - selection to assert - * ident - identifier - * command - command code - * stream - protocol stream - * - * Description: - * Builds a return command line - */ -static void -SendCommand(Widget w, Atom sel, ResIdent ident, EditResError error, - ProtocolStream *stream) -{ - BuildReturnPacket(ident, error, stream); - globals.command_stream = stream; - - /* - * I REALLY want to own the selection. Since this was not triggered - * by a user action, and I am the only one using this atom it is safe to - * use CurrentTime - */ - XtOwnSelection(w, sel, CurrentTime, ConvertReturnCommand, NULL, CommandDone); -} - -/************************************************************ - * Generic Utility Functions - ************************************************************/ -static int -qcmp_widget_list(register _Xconst void *left, register _Xconst void *right) -{ - return (char *)*(Widget **)left - (char *)*(Widget **)right; -} - -/* - * Function: - * FindChildren - * - * Parameters: - * parent - parent widget - * children - list of children - * normal - return normal children - * popup - return popup children - * extra - return extra children - * - * Description: - * Retuns all children (popup, normal and otherwise) of this widget - * - * Returns: - * number of children - */ -static int -FindChildren(Widget parent, Widget **children, Bool normal, Bool popup, - Bool extra) -{ - CompositeWidget cw = (CompositeWidget)parent; - Cardinal i, num_children, current = 0; - Widget *extra_widgets = NULL; - Cardinal num_extra = 0; - - num_children = 0; - - if (XtIsWidget(parent) && popup) - num_children += parent->core.num_popups; - - if (XtIsComposite(parent) && normal) - num_children += cw->composite.num_children; - - if (XtIsWidget(parent) && extra) - { - XtResourceList norm_list, cons_list; - Cardinal num_norm, num_cons; - Arg args[1]; - Widget widget; - - XtGetResourceList(XtClass(parent), &norm_list, &num_norm); - - if (XtParent(parent) != NULL) - XtGetConstraintResourceList(XtClass(XtParent(parent)), - &cons_list, &num_cons); - else - num_cons = 0; - - extra_widgets = (Widget *)XtMalloc(sizeof(Widget)); - for (i = 0; i < num_norm; i++) - if (strcmp(norm_list[i].resource_type, XtRWidget) == 0) - { - widget = NULL; - XtSetArg(args[0], norm_list[i].resource_name, &widget); - XtGetValues(parent, args, 1); - if (widget && XtParent(widget) == parent) - { - ++num_extra; - extra_widgets = (Widget *) XtRealloc( - (char *)extra_widgets, num_extra * sizeof(Widget)); - extra_widgets[num_extra - 1] = widget; - } - } - for (i = 0; i < num_cons; i++) - if (strcmp(cons_list[i].resource_type, XtRWidget) == 0) - { - widget = NULL; - XtSetArg(args[0], cons_list[i].resource_name, &widget); - XtGetValues(parent, args, 1); - if (widget && XtParent(widget) == parent) - { - ++num_extra; - extra_widgets = (Widget *) XtRealloc( - (char *)extra_widgets, num_extra * sizeof(Widget)); - extra_widgets[num_extra - 1] = widget; - } - } - if (num_norm) - XtFree((char *)norm_list); - if (num_cons) - XtFree((char *)cons_list); - } - - if ((num_children + num_extra) == 0) - { - *children = NULL; - return (0); - } - - *children = (Widget *)XtMalloc(sizeof(Widget) * (num_children + num_extra)); - - if (XtIsComposite(parent) && normal) - for (i = 0; i < cw->composite.num_children; i++, current++) - (*children)[current] = cw->composite.children[i]; - - if (XtIsWidget(parent) && popup) - for (i = 0; i < parent->core.num_popups; i++, current++) - (*children)[current] = parent->core.popup_list[i]; - - if (num_extra) - /* Check for dups */ - { - Cardinal j, old_num_extra = num_extra; - - qsort(extra_widgets, num_extra, sizeof(Widget), qcmp_widget_list); - for (i = 0; i < num_extra - 1; i++) - while (i < num_extra - 1 && - extra_widgets[i] == extra_widgets[i + 1]) - { - memmove(&extra_widgets[i], &extra_widgets[i + 1], - (num_extra - i) * sizeof(Widget)); - --num_extra; - } - - for (i = 0; i < num_children; i++) - for (j = 0; j < num_extra; j++) - if ((*children)[i] == extra_widgets[j]) - { - if ((j + 1) < num_extra) - memmove(&extra_widgets[j], &extra_widgets[j + 1], - (num_extra - j) * sizeof(Widget)); - --num_extra; - } - - if (old_num_extra != num_extra) - *children = (Widget *)XtRealloc((char *)*children, sizeof(Widget) - * (num_children + num_extra)); - - if (num_extra) - memcpy(&(*children)[num_children], extra_widgets, - sizeof(Widget) * num_extra); - } - if (extra_widgets) - XtFree((char *)extra_widgets); - if (num_children + num_extra == 0) - { - XtFree((char *)*children); - *children = NULL; - } - - return (num_children + num_extra); -} - -/* - * Function: - * IsChild - * - * parameters: - * top - top of the tree - * parent - parent widget - * child - child widget - * - * Description: - * Check to see of child is a child of parent - */ -static Bool -IsChild(Widget top, Widget parent, Widget child) -{ - int i, num_children; - Widget *children; - - if (parent == NULL) - return (top == child); - - num_children = FindChildren(parent, &children, True, True, True); - - for (i = 0; i < num_children; i++) - if (children[i] == child) - { - XtFree((char *)children); - return (True); - } - - XtFree((char *)children); - return (False); -} - -/* - * Function: - * VerifyWidget - * - * Parameters: - * w - any widget in the tree - * info - info about the widget to verify - * - * Description: - * Makes sure all the widgets still exist - */ -static char * -VerifyWidget(Widget w, WidgetInfo *info) -{ - Widget top; - register int count; - register Widget parent; - register unsigned long *child; - - for (top = w; XtParent(top) != NULL; top = XtParent(top)) - ; - - parent = NULL; - child = info->ids; - count = 0; - - while (True) - { - if (!IsChild(top, parent, (Widget) *child)) - return ("This widget no longer exists in the client."); - - if (++count == info->num_widgets) - break; - - parent = (Widget)*child++; - } - - info->real_widget = (Widget)*child; - - return (NULL); -} - -/************************************************************ - * Code to Perform SetValues operations - ************************************************************/ -/* - * Function: - * DoSetValues - * - * Parameters: - * w - a widget in the tree - * event - event that caused this action - * stream - protocol stream to add - * - * Description: - * Performs the setvalues requested - * - * Returns: - * NULL - */ -static char * -DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream) -{ - char *str; - register unsigned i; - unsigned short count = 0; - SetValuesEvent *sv_event = (SetValuesEvent *)event; - - _XEditResPut16(stream, count); /* insert 0, will be overwritten later */ - - for (i = 0; i < sv_event->num_entries; i++) - { - if ((str = VerifyWidget(w, &sv_event->widgets[i])) != NULL) - { - _XEditResPutWidgetInfo(stream, &sv_event->widgets[i]); - _XEditResPutString8(stream, str); - count++; - } - else - ExecuteSetValues(sv_event->widgets[i].real_widget, - sv_event, sv_event->widgets + i, stream, &count); - } - - /* - * Overwrite the first 2 bytes with the real count. - */ - *(stream->top) = count >> XER_NBBY; - *(stream->top + 1) = count; - - return (NULL); -} - -/* - * Function: - * HandleToolkitErrors - * - * Parameters: - * name - name of the error - * type - type of the error - * class - class of the error - * msg - the default message - * params - the extra parameters for this message - * num_params - "" - * - * Description: Handles X Toolkit Errors. - */ -/* ARGSUSED */ -static void -HandleToolkitErrors(String name, String type, String class, String msg, - String *params, Cardinal *num_params) -{ - SVErrorInfo *info = &globals.error_info; - char buf[BUFSIZ]; - - if (streq(name, "unknownType")) - XmuSnprintf(buf, sizeof(buf), - "The `%s' resource is not used by this widget.", - info->event->name); - else if (streq(name, "noColormap")) - XmuSnprintf(buf, sizeof(buf), msg, params[0]); - else if (streq(name, "conversionFailed") || streq(name, "conversionError")) - { - if (streq((String)info->event->value, XtRString)) - XmuSnprintf(buf, sizeof(buf), - "Could not convert the string '%s' for the `%s' " - "resource.", (String)info->event->value, - info->event->name); - else - XmuSnprintf(buf, sizeof(buf), - "Could not convert the `%s' resource.", - info->event->name); - } - else - XmuSnprintf(buf, sizeof(buf), - "Name: %s, Type: %s, Class: %s, Msg: %s", - name, type, class, msg); - - /* - * Insert this info into the protocol stream, and update the count - */ - (*(info->count))++; - _XEditResPutWidgetInfo(info->stream, info->entry); - _XEditResPutString8(info->stream, buf); -} - -/* - * Function: - * ExecuteSetValues - * - * Parameters: - * w - widget to perform the set_values on - * sv_event - set values event - * sv_info - set_value info - *. - * Description: - * Performs a setvalues for a given command - */ -static void -ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry, - ProtocolStream *stream, unsigned short *count) -{ - XtErrorMsgHandler old; - SVErrorInfo *info = &globals.error_info; - - info->event = sv_event; /* No data can be passed to */ - info->stream = stream; /* an error handler, so we */ - info->count = count; /* have to use a global */ - info->entry = entry; - - old = XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), - HandleToolkitErrors); - - XtVaSetValues(w, XtVaTypedArg, - sv_event->name, sv_event->res_type, - sv_event->value, sv_event->value_len, - NULL); - - (void)XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), old); -} - -/************************************************************ - * Code for Creating and dumping widget tree. - ************************************************************/ -/* Function: - * DumpWidgets - * - * Parameters: - * w - a widget in the tree - * event - event that caused this action - * stream - protocol stream to add - * - * Description: - * Given a widget it builds a protocol packet containing the entire - * widget heirarchy. - * - * Returns: - * NULL - */ -#define TOOLKIT_TYPE ("Xt") -/*ARGSUSED*/ -static char * -DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream) -{ - unsigned short count = 0; - - /* Find Tree's root */ - for (; XtParent(w) != NULL; w = XtParent(w)) - ; - - /* - * hold space for count, overwritten later - */ - _XEditResPut16(stream, (unsigned int)0); - - DumpChildren(w, stream, &count); - - /* - * write out toolkit type - */ - _XEditResPutString8(stream, TOOLKIT_TYPE); - - /* - * Overwrite the first 2 bytes with the real count - */ - *(stream->top) = count >> XER_NBBY; - *(stream->top + 1) = count; - - return (NULL); -} - -/* - * Function: - * DumpChildren - * - * Parameters: - * w - widget to dump - * stream - stream to dump to - * count - number of dumps we have performed - * - * Description: - * Adds a child's name to the list. - */ -/* This is a trick/kludge. To make shared libraries happier (linking - * against Xmu but not linking against Xt, and apparently even work - * as we desire on SVR4, we need to avoid an explicit data reference - * to applicationShellWidgetClass. XtIsTopLevelShell is known - * (implementation dependent assumption!) to use a bit flag. So we - * go that far. Then, we test whether it is an applicationShellWidget - * class by looking for an explicit class name. Seems pretty safe. - */ -static Bool -isApplicationShell(Widget w) -{ - register WidgetClass c; - - if (!XtIsTopLevelShell(w)) - return (False); - for (c = XtClass(w); c; c = c->core_class.superclass) - if (strcmp(c->core_class.class_name, "ApplicationShell") == 0) - return (True); - - return (False); -} - -static void -DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count) -{ - int i, num_children; - Widget *children; - unsigned long window; - char *c_class; - - (*count)++; - - InsertWidget(stream, w); /* Insert the widget into the stream */ - - _XEditResPutString8(stream, XtName(w)); /* Insert name */ - - if (isApplicationShell(w)) - c_class = ((ApplicationShellWidget)w)->application.class; - else - c_class = XtClass(w)->core_class.class_name; - - _XEditResPutString8(stream, c_class); /* Insert class */ - - if (XtIsWidget(w)) - if (XtIsRealized(w)) - window = XtWindow(w); - else - window = EDITRES_IS_UNREALIZED; - else - window = EDITRES_IS_OBJECT; - - _XEditResPut32(stream, window); /* Insert window id */ - - /* - * Find children and recurse - */ - num_children = FindChildren(w, &children, True, True, True); - for (i = 0; i < num_children; i++) - DumpChildren(children[i], stream, count); - - XtFree((char *)children); -} - -/************************************************************ - * Code for getting the geometry of widgets - ************************************************************/ -/* - * Function: - * DoGetGeometry - * - * Parameters: - * w - widget in the tree - * event - event that caused this action - * stream - protocol stream to add - * - * Description: - * Retrieves the Geometry of each specified widget. - * - * Returns: - * NULL - */ -static char * -DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream) -{ - unsigned i; - char *str; - GetGeomEvent *geom_event = (GetGeomEvent *)event; - - _XEditResPut16(stream, geom_event->num_entries); - - for (i = 0; i < geom_event->num_entries; i++) - { - /* - * Send out the widget id - */ - _XEditResPutWidgetInfo(stream, &geom_event->widgets[i]); - - if ((str = VerifyWidget(w, &geom_event->widgets[i])) != NULL) - { - _XEditResPutBool(stream, True); /* an error occured */ - _XEditResPutString8(stream, str); /* set message */ - } - else - ExecuteGetGeometry(geom_event->widgets[i].real_widget, stream); - } - - return (NULL); -} - -/* - * Function: - * ExecuteGetGeometry - * - * Parameters: - * w - widget to get geometry - * stream - stream to append to - * - * Description: - * Gets the geometry for each widget specified. - * - * Returns: - * True if no error occured. - */ -static void -ExecuteGetGeometry(Widget w, ProtocolStream *stream) -{ - int i; - Boolean mapped_when_man; - Dimension width, height, border_width; - Arg args[8]; - Cardinal num_args = 0; - Position x, y; - - if (!XtIsRectObj(w) || (XtIsWidget(w) && !XtIsRealized(w))) - { - _XEditResPutBool(stream, False); /* no error */ - _XEditResPutBool(stream, False); /* not visable */ - for (i = 0; i < 5; i++) /* fill in extra space with 0's */ - _XEditResPut16(stream, 0); - return; - } - - XtSetArg(args[num_args], XtNwidth, &width); num_args++; - XtSetArg(args[num_args], XtNheight, &height); num_args++; - XtSetArg(args[num_args], XtNborderWidth, &border_width); num_args++; - XtSetArg(args[num_args], XtNmappedWhenManaged, &mapped_when_man); - num_args++; - XtGetValues(w, args, num_args); - - if (!(XtIsManaged(w) && mapped_when_man) && XtIsWidget(w)) - { - XWindowAttributes attrs; - - /* - * The toolkit does not maintain mapping state, we have - * to go to the server - */ - if (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attrs) != 0) - { - if (attrs.map_state != IsViewable) - { - _XEditResPutBool(stream, False); /* no error */ - _XEditResPutBool(stream, False); /* not visable */ - for (i = 0; i < 5; i++) /* fill in extra space with 0's */ - _XEditResPut16(stream, 0); - return; - } - } - else - { - _XEditResPut8(stream, True); /* Error occured. */ - _XEditResPutString8(stream, "XGetWindowAttributes failed."); - return; - } - } - - XtTranslateCoords(w, -((int) border_width), -((int) border_width), &x, &y); - - _XEditResPutBool(stream, False); /* no error */ - _XEditResPutBool(stream, True); /* Visable */ - _XEditResPut16(stream, x); - _XEditResPut16(stream, y); - _XEditResPut16(stream, width); - _XEditResPut16(stream, height); - _XEditResPut16(stream, border_width); -} - -/************************************************************ - * Code for executing FindChild - ************************************************************/ -/* - * Function: - * PositionInChild - * - * Parameters: - * child - child widget to check - * x - location of point to check in the parent's coord space - * y - "" - * - * Description: - * Returns true if this location is in the child. - */ -static Bool -PositionInChild(Widget child, int x, int y) -{ - Arg args[6]; - Cardinal num; - Dimension width, height, border_width; - Position child_x, child_y; - Boolean mapped_when_managed; - - if (!XtIsRectObj(child)) /* we must at least be a rect obj */ - return (False); - - num = 0; - XtSetArg(args[num], XtNmappedWhenManaged, &mapped_when_managed); num++; - XtSetArg(args[num], XtNwidth, &width); num++; - XtSetArg(args[num], XtNheight, &height); num++; - XtSetArg(args[num], XtNx, &child_x); num++; - XtSetArg(args[num], XtNy, &child_y); num++; - XtSetArg(args[num], XtNborderWidth, &border_width); num++; - XtGetValues(child, args, num); - - /* - * The only way we will know of the widget is mapped is to see if - * mapped when managed is True and this is a managed child. Otherwise - * we will have to ask the server if this window is mapped - */ - if (XtIsWidget(child) && !(mapped_when_managed && XtIsManaged(child))) - { - XWindowAttributes attrs; - - if (XGetWindowAttributes(XtDisplay(child), XtWindow(child), &attrs) - && attrs.map_state != IsViewable) - return (False); - } - - return ((x >= child_x) - && (x <= (child_x + (Position)width + 2 * (Position)border_width)) - && (y >= child_y) - && (y <= (child_y + (Position)height + 2 * (Position)border_width))); -} - -/* - * Function: - * _FindChild - * - * Parameters: - * parent - widget that is known to contain the point specified - * x - point in coordinates relative to the widget specified - * y - "" - * - * Description: - * Finds the child that actually contains the point shown. - */ -static Widget -_FindChild(Widget parent, int x, int y) -{ - Widget *children; - int i = FindChildren(parent, &children, True, False, True); - - while (i > 0) - { - i--; - - if (PositionInChild(children[i], x, y)) - { - Widget child = children[i]; - - XtFree((char *)children); - return (_FindChild(child, x - child->core.x, y - child->core.y)); - } - } - - XtFree((char *)children); - - return (parent); -} - -/* - * Function: - * DoFindChild - * - * Parameters: - * w - widget in the tree - * event - event that caused this action - * stream - protocol stream to add - * Description: - * Finds the child that contains the location specified. - * - * Returns: - * An allocated error message if something went horribly wrong and - * no set values were performed, else NULL. - */ -static char * -DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream) -{ - char *str; - Widget parent, child; - Position parent_x, parent_y; - FindChildEvent *find_event = (FindChildEvent *)event; - - if ((str = VerifyWidget(w, find_event->widgets)) != NULL) - return (str); - - parent = find_event->widgets->real_widget; - - XtTranslateCoords(parent, (Position) 0, (Position) 0, - &parent_x, &parent_y); - - child = _FindChild(parent, find_event->x - (int) parent_x, - find_event->y - (int) parent_y); - - InsertWidget(stream, child); - - return (NULL); -} - -/************************************************************ - * Procedures for performing GetResources - ************************************************************/ -/* - * Function: - * DoGetResources - * - * Parameters: - * w - widget in the tree - * event - event that caused this action - * stream - protocol stream to add - * - * Description: - * Gets the Resources associated with the widgets passed. - * - * Returns: - * NULL - */ -static char * -DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream) -{ - unsigned int i; - char *str; - GetResEvent *res_event = (GetResEvent *)event; - - _XEditResPut16(stream, res_event->num_entries); /* number of replys */ - - for (i = 0; i < res_event->num_entries; i++) - { - /* - * Send out the widget id - */ - _XEditResPutWidgetInfo(stream, &res_event->widgets[i]); - if ((str = VerifyWidget(w, &res_event->widgets[i])) != NULL) - { - _XEditResPutBool(stream, True); /* an error occured */ - _XEditResPutString8(stream, str); /* set message */ - } - else - { - _XEditResPutBool(stream, False); /* no error occured */ - ExecuteGetResources(res_event->widgets[i].real_widget, stream); - } - } - - return (NULL); -} - -/* Function: - * ExecuteGetResources - * - * Parameters: - * w - widget to get resources on - * stream - protocol stream - * - * Description: - * Gets the resources for any individual widget - */ -static void -ExecuteGetResources(Widget w, ProtocolStream *stream) -{ - XtResourceList norm_list, cons_list; - Cardinal num_norm, num_cons; - register Cardinal i; - - /* - * Get Normal Resources - */ - XtGetResourceList(XtClass(w), &norm_list, &num_norm); - - if (XtParent(w) != NULL) - XtGetConstraintResourceList(XtClass(XtParent(w)), &cons_list,&num_cons); - else - num_cons = 0; - - _XEditResPut16(stream, num_norm + num_cons); /* how many resources */ - - /* - * Insert all the normal resources - */ - for (i = 0; i < num_norm; i++) - { - _XEditResPutResourceType(stream, NormalResource); - _XEditResPutString8(stream, norm_list[i].resource_name); - _XEditResPutString8(stream, norm_list[i].resource_class); - _XEditResPutString8(stream, norm_list[i].resource_type); - } - XtFree((char *)norm_list); - - /* - * Insert all the constraint resources - */ - if (num_cons > 0) - { - for (i = 0; i < num_cons; i++) - { - _XEditResPutResourceType(stream, ConstraintResource); - _XEditResPutString8(stream, cons_list[i].resource_name); - _XEditResPutString8(stream, cons_list[i].resource_class); - _XEditResPutString8(stream, cons_list[i].resource_type); - } - XtFree((char *)cons_list); - } -} - -/* - * Function: - * DumpValues - * - * Parameters: - * event - event that caused this action - * stream - protocol stream to add - * - * Description: - * Returns resource values to the resource editor. - * - * Returns: - * NULL - */ -/*ARGSUSED*/ -static char * -DumpValues(Widget w, EditresEvent* event, ProtocolStream* stream) -{ - char *str; - Arg warg[1]; - String res_value = NULL; - GetValuesEvent *gv_event = (GetValuesEvent *)event; - - /* put the count in the stream */ - _XEditResPut16(stream, (unsigned int)1); - - /* - * Get the resource of the widget asked for by the - * resource editor and insert it into the stream - */ - XtSetArg(warg[0], gv_event->name, &res_value); - - if ((str = VerifyWidget(w, &gv_event->widgets[0])) != NULL) - _XEditResPutString8(stream, str); - else - { - _XEditresGetStringValues(gv_event->widgets[0].real_widget, warg, 1); - if (!res_value) - res_value = "NoValue"; - _XEditResPutString8(stream, res_value); - } - - return (NULL); -} - -/************************************************************ - * Code for inserting values into the protocol stream - ************************************************************/ -/* - * Function: - * InsertWidget - * - * Parameters: - * stream - protocol stream - * w - widget to insert - * - * Description: - * Inserts the full parent hierarchy of this widget into the protocol - * stream as a widget list. - */ -static void -InsertWidget(ProtocolStream *stream, Widget w) -{ - Widget temp; - unsigned long *widget_list; - register int i, num_widgets; - - for (temp = w, i = 0; temp != NULL; temp = XtParent(temp), i++) - ; - - num_widgets = i; - widget_list = (unsigned long *)XtMalloc(sizeof(unsigned long) * num_widgets); - - /* - * Put the widgets into the list - * make sure that they are inserted in the list from parent -> child - */ - for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--) - widget_list[i] = (unsigned long)temp; - - _XEditResPut16(stream, num_widgets); /* insert number of widgets */ - for (i = 0; i < num_widgets; i++) /* insert Widgets themselves */ - _XEditResPut32(stream, widget_list[i]); - - XtFree((char *)widget_list); -} - -/************************************************************ - * All of the following routines are public - ************************************************************/ -/* - * Function: - * _XEditResPutString8 - * - * Parameters: - * stream - stream to insert string into - * str - string to insert - * - * Description: - * Inserts a string into the protocol stream. - */ -void -_XEditResPutString8(ProtocolStream *stream, char *str) -{ - int i, len = strlen(str); - - _XEditResPut16(stream, len); - for (i = 0; i < len; i++, str++) - _XEditResPut8(stream, *str); -} - -/* - * Function: - * _XEditResPut8 - * - * Parameters: - * stream - stream to insert string into - * value - value to insert - * - * Description: - * Inserts an 8 bit integer into the protocol stream. - */ -void -_XEditResPut8(ProtocolStream *stream, unsigned int value) -{ - unsigned char temp; - - if (stream->size >= stream->alloc) - { - stream->alloc += 100; - stream->real_top = (unsigned char *) - XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE); - stream->top = stream->real_top + HEADER_SIZE; - stream->current = stream->top + stream->size; - } - - temp = (unsigned char) (value & BYTE_MASK); - *((stream->current)++) = temp; - (stream->size)++; -} - -/* - * Function: - * _XEditResPut16 - * - * Arguments: - * stream - stream to insert string into - * value - value to insert - * - * Description: - * Inserts a 16 bit integer into the protocol stream. - */ -void -_XEditResPut16(ProtocolStream *stream, unsigned int value) -{ - _XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK); - _XEditResPut8(stream, value & BYTE_MASK); -} - -/* - * Function: - * _XEditResPut32 - * - * Arguments: - * stream - stream to insert string into - * value - value to insert - * - * Description: - * Inserts a 32 bit integer into the protocol stream. - */ -void -_XEditResPut32(ProtocolStream *stream, unsigned long value) -{ - int i; - - for (i = 3; i >= 0; i--) - _XEditResPut8(stream, (value >> (XER_NBBY * i)) & BYTE_MASK); -} - -/* - * Function: - * _XEditResPutWidgetInfo - * - * Parameters: - * stream - stream to insert widget info into - * info - info to insert - * - * Description: - * Inserts the widget info into the protocol stream. - */ -void -_XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info) -{ - unsigned int i; - - _XEditResPut16(stream, info->num_widgets); - for (i = 0; i < info->num_widgets; i++) - _XEditResPut32(stream, info->ids[i]); -} - -/************************************************************ - * Code for retrieving values from the protocol stream - ************************************************************/ -/* - * Function: - * _XEditResResetStream - * - * Parameters: - * stream - stream to reset - * - * Description: - * Resets the protocol stream. - */ -void -_XEditResResetStream(ProtocolStream *stream) -{ - stream->current = stream->top; - stream->size = 0; - if (stream->real_top == NULL) - { - stream->real_top = (unsigned char *) - XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE); - stream->top = stream->real_top + HEADER_SIZE; - stream->current = stream->top + stream->size; - } -} - -/* - * NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE - * - * The only modified field if the "current" field - * - * The only fields that must be set correctly are the "current", "top" - * and "size" fields. - */ -/* - * Function: - * _XEditResGetg8 - * - * Parameters: - * stream - protocol stream - * value - a pointer to value to return - * - * Description: - * Retrieves an unsigned 8 bit value from the protocol stream. - * - * Returns: - * True if sucessful - */ -Bool -_XEditResGet8(ProtocolStream *stream, unsigned char *value) -{ - if (stream->size < (unsigned long)(stream->current - stream->top)) - return (False); - - *value = *((stream->current)++); - return (True); -} - -/* - * Function: - * _XEditResGet16 - * - * Parameters: - * stream - protocol stream - * value - pointer to return value - * - * Description: - * Retrieves an unsigned 16 bit value from the protocol stream. - * - * Returns: - * True if sucessful - */ -Bool -_XEditResGet16(ProtocolStream *stream, unsigned short *value) -{ - unsigned char temp1, temp2; - - if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2))) - return (False); - - *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2; - return (True); -} - -/* - * Function: - * _XEditResGetSigned16 - * - * Parameters: - * stream - protocol stream - * value - pointer to return value - * - * Description: - * Retrieves an signed 16 bit value from the protocol stream. - * - * Returns: - * True if sucessful - */ -Bool -_XEditResGetSigned16(ProtocolStream *stream, short *value) -{ - unsigned char temp1, temp2; - - if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2))) - return (False); - - if (temp1 & (1 << (XER_NBBY - 1))) /* If the sign bit is active */ - { - *value = -1; /* store all 1's */ - *value &= (temp1 << XER_NBBY); /* Now and in the MSB */ - *value &= temp2; /* and LSB */ - } - else - *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2; - - return (True); -} - -/* - * Function: - * _XEditResGet32 - * - * Parameters: - * stream - protocol stream - * value - pointer to return value - * - * Description: - * Retrieves an unsigned 32 bit value from the protocol stream. - * - * Returns: - * True if sucessful - */ -Bool -_XEditResGet32(ProtocolStream *stream, unsigned long *value) -{ - unsigned short temp1, temp2; - - if (!(_XEditResGet16(stream, &temp1) && _XEditResGet16(stream, &temp2))) - return (False); - - *value = ((unsigned short)temp1 << (XER_NBBY * 2)) + (unsigned short)temp2; - return (True); -} - -/* Function: - * _XEditResGetString8 - * - * Parameters: - * stream - protocol stream - * str - string to retrieve - * - * Description: - * Retrieves an 8 bit string value from the protocol stream. - * - * Returns: - * True if retrieval was successful - */ -Bool -_XEditResGetString8(ProtocolStream *stream, char **str) -{ - unsigned short len; - register unsigned i; - - if (!_XEditResGet16(stream, &len)) - return (False); - - *str = XtMalloc(sizeof(char) * (len + 1)); - - for (i = 0; i < len; i++) - { - if (!_XEditResGet8(stream, (unsigned char *)*str + i)) - { - XtFree(*str); - *str = NULL; - return (False); - } - } - (*str)[i] = '\0'; - - return (True); -} - -/* - * Function: - * _XEditResGetWidgetInfo - * - * Parameters: - * stream - protocol stream - * info - widget info struct to store into - * - * Description: - * Retrieves the list of widgets that follow and stores them in the - * widget info structure provided. - * - * Returns: - * True if retrieval was successful - */ -Bool -_XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info) -{ - unsigned int i; - - if (!_XEditResGet16(stream, &info->num_widgets)) - return (False); - - info->ids = (unsigned long *)XtMalloc(sizeof(long) * info->num_widgets); - - for (i = 0; i < info->num_widgets; i++) - { - if (!_XEditResGet32(stream, info->ids + i)) - { - XtFree((char *)info->ids); - info->ids = NULL; - return (False); - } -#if defined(LONG64) || defined(WORD64) - info->ids[i] |= globals.base_address; -#endif - } - return (True); -} - -/************************************************************ - * Code for Loading the EditresBlock resource - ************************************************************/ -/* - * Function: - * CvStringToBlock - * - * Parameters: - * dpy - display - * args - unused - * num_args - unused - * from_val - value to convert - * to_val - where to store - * converter_data - unused - * - * Description: - * Converts a string to an editres block value. - * - * Returns: - * True if conversion was sucessful - */ -/*ARGSUSED*/ -static Boolean -CvtStringToBlock(Display *dpy, XrmValue *args, Cardinal *num_args, - XrmValue *from_val, XrmValue *to_val, - XtPointer *converter_data) -{ - char ptr[16]; - static EditresBlock block; - - XmuNCopyISOLatin1Lowered(ptr, from_val->addr, sizeof(ptr)); - - if (streq(ptr, "none")) - block = BlockNone; - else if (streq(ptr, "setvalues")) - block = BlockSetValues; - else if (streq(ptr, "all")) - block = BlockAll; - else - { - Cardinal num_params = 1; - String params[1]; - - params[0] = from_val->addr; - XtAppWarningMsg(XtDisplayToApplicationContext(dpy), - "CvtStringToBlock", "unknownValue", "EditresError", - "Could not convert string \"%s\" to EditresBlock.", - params, &num_params); - return FALSE; - } - - if (to_val->addr != NULL) - { - if (to_val->size < sizeof(EditresBlock)) - { - to_val->size = sizeof(EditresBlock); - return FALSE; - } - *(EditresBlock *)(to_val->addr) = block; - } - else - to_val->addr = (XtPointer)block; - - to_val->size = sizeof(EditresBlock); - return TRUE; -} - -#define XtREditresBlock "EditresBlock" -/* - * Function: - * LoadResources - * - * Parameters: - * w - any widget in the tree - * - * Description: - * Loads a global resource the determines of this application should - * allow Editres requests. - */ -static void -LoadResources(Widget w) -{ - static XtResource resources[] = { - {"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock), - XtOffsetOf(Globals, block), XtRImmediate, (XtPointer)BlockNone} - }; - - for (; XtParent(w) != NULL; w = XtParent(w)) - ; - - XtAppSetTypeConverter(XtWidgetToApplicationContext(w), - XtRString, XtREditresBlock, CvtStringToBlock, - NULL, 0, XtCacheAll, NULL); - - XtGetApplicationResources(w, (XtPointer)&globals, resources, - XtNumber(resources), NULL, 0); -} - -/* - * Function: - * _XEditresGetStringValues - * - * Parameters: - * w - widget - * warg - where to store result - * numargs - unused - */ -/*ARGSUSED*/ -static void -_XEditresGetStringValues(Widget w, Arg *warg, int numargs) -{ - static char buffer[32]; - XtResourceList res_list; - Cardinal num_res; - XtResource *res = NULL; - long value; - Cardinal i; - char *string = ""; - Arg args[1]; - XrmValue to, from; - - /* - * Look for the resource - */ - XtGetResourceList(XtClass(w), &res_list, &num_res); - for (i = 0; i < num_res; i++) - if (strcmp(res_list[i].resource_name, warg->name) == 0) - { - res = &res_list[i]; - break; - } - - if (res == NULL && XtParent(w) != NULL) - { - XtFree((char *)res_list); - XtGetConstraintResourceList(XtClass(XtParent(w)), &res_list, &num_res); - for (i = 0; i < num_res; i++) - if (strcmp(res_list[i].resource_name, warg->name) == 0) - { - res = &res_list[i]; - break; - } - } - - if (res == NULL) - { - /* Couldn't find resource */ - - XtFree((char *)res_list); - *(XtPointer *)warg->value = NULL; - return; - } - - /* try to get the value in the proper size */ - switch (res->resource_size) - { -#ifdef LONG64 - long v8; -#endif - int v4; - short v2; - char v1; - - case 1: - XtSetArg(args[0], res->resource_name, &v1); - XtGetValues(w, args, 1); - value = (int)v1; - break; - case 2: - XtSetArg(args[0], res->resource_name, &v2); - XtGetValues(w, args, 1); - value = (int)v2; - break; - case 4: - XtSetArg(args[0], res->resource_name, &v4); - XtGetValues(w, args, 1); - value = (int)v4; - break; -#ifdef LONG64 - case 8: - XtSetArg(args[0], res->resource_name, &v8); - XtGetValues(w, args, 1); - value = (long)v8; - break; -#endif - default: - fprintf(stderr, "_XEditresGetStringValues: bad size %d\n", - res->resource_size); - string = "bad size"; - *(char **)(warg->value) = string; - XtFree((char *)res_list); - return; - } - - /* - * If the resource is already String, no conversion needed - */ - if (strcmp(XtRString, res->resource_type) == 0) - { - if (value == 0) - string = "(null)"; - else - string = (char *)value; - } - else - { - from.size = res->resource_size; - from.addr = (XPointer)&value; - to.addr = NULL; - to.size = 0; - - if (XtConvertAndStore(w,res->resource_type, &from, XtRString, &to)) - string = to.addr; - else - { - string = buffer; - /* - * Conversion failed, fall back to representing it as integer - */ - switch (res->resource_size) - { - case sizeof(char): - XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xff)); - break; - case sizeof(short): - XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xffff)); - break; - case sizeof(int): - XmuSnprintf(buffer, sizeof(buffer), "0x%08x", (int)value); - break; -#ifdef LONG64 - case sizeof(long): - XmuSnprintf(buffer, sizeof(buffer), "0x%016lx", value); - break; -#endif - } - } - } - - if (string == NULL) - string = ""; - - *(char **)(warg->value) = string; - XtFree((char *)res_list); -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Chris D. Peterson, Dave Sternlicht, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h> /* To get into the composite and core widget
+ structures. */
+#include <X11/ObjectP.h> /* For XtIs<Classname> macros. */
+#include <X11/StringDefs.h> /* for XtRString. */
+#include <X11/ShellP.h> /* for Application Shell Widget class. */
+
+#include <X11/Xatom.h>
+#include <X11/Xos.h> /* for strcpy declaration */
+#include <X11/Xfuncs.h>
+#include <X11/Xmu/EditresP.h>
+#include <X11/Xmd.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define _XEditResPutBool _XEditResPut8
+#define _XEditResPutResourceType _XEditResPut8
+
+/*
+ * Types
+ */
+typedef enum {
+ BlockNone,
+ BlockSetValues,
+ BlockAll
+} EditresBlock;
+
+typedef struct _SetValuesEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of set values requests */
+ char *name;
+ char *res_type;
+ XtPointer value;
+ unsigned short value_len;
+} SetValuesEvent;
+
+typedef struct _SVErrorInfo {
+ SetValuesEvent *event;
+ ProtocolStream *stream;
+ unsigned short *count;
+ WidgetInfo *entry;
+} SVErrorInfo;
+
+typedef struct _GetValuesEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of get values requests */
+ char *name;
+} GetValuesEvent;
+
+typedef struct _FindChildEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ short x, y;
+} FindChildEvent;
+
+typedef struct _GenericGetEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+ unsigned short num_entries; /* number of set values requests */
+} GenericGetEvent, GetResEvent, GetGeomEvent;
+
+/*
+ * Common to all events
+ */
+typedef struct _AnyEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo *widgets;
+} AnyEvent;
+
+/*
+ * The event union
+ */
+typedef union _EditresEvent {
+ AnyEvent any_event;
+ SetValuesEvent set_values_event;
+ GetResEvent get_resources_event;
+ GetGeomEvent get_geometry_event;
+ FindChildEvent find_child_event;
+} EditresEvent;
+
+typedef struct _Globals {
+ EditresBlock block;
+ SVErrorInfo error_info;
+ ProtocolStream stream;
+ ProtocolStream *command_stream; /* command stream */
+#if defined(LONG64) || defined(WORD64)
+ unsigned long base_address;
+#endif
+} Globals;
+
+#define CURRENT_PROTOCOL_VERSION 5L
+
+#define streq(a,b) (strcmp((a), (b)) == 0)
+
+/*
+ * Prototypes
+ */
+static Widget _FindChild(Widget, int, int);
+static void _XEditresGetStringValues(Widget, Arg*, int);
+static XtPointer BuildReturnPacket(ResIdent, EditResError, ProtocolStream*);
+static void CommandDone(Widget, Atom*, Atom*);
+static Boolean ConvertReturnCommand(Widget, Atom*, Atom*, Atom*, XtPointer*,
+ unsigned long*, int*);
+static Boolean CvtStringToBlock(Display*, XrmValue*, Cardinal*,
+ XrmValue*, XrmValue*, XtPointer*);
+static EditresEvent *BuildEvent(Widget, Atom, XtPointer, ResIdent,
+ unsigned long);
+static char *DoFindChild(Widget, EditresEvent*, ProtocolStream*);
+static char *DoGetGeometry(Widget, EditresEvent*, ProtocolStream*);
+static char *DoGetResources(Widget, EditresEvent*, ProtocolStream*);
+static char *DoSetValues(Widget, EditresEvent*, ProtocolStream*);
+static void DumpChildren(Widget, ProtocolStream*, unsigned short*);
+static char *DumpValues(Widget, EditresEvent*, ProtocolStream*);
+static char *DumpWidgets(Widget, EditresEvent*, ProtocolStream*);
+static void ExecuteCommand(Widget, Atom, ResIdent, EditresEvent*);
+static void ExecuteGetGeometry(Widget, ProtocolStream*);
+static void ExecuteGetResources(Widget w, ProtocolStream *stream);
+static void ExecuteSetValues(Widget, SetValuesEvent*, WidgetInfo*,
+ ProtocolStream*, unsigned short*);
+static void FreeEvent(EditresEvent*);
+static void GetCommand(Widget w, XtPointer, Atom*, Atom*, XtPointer,
+ unsigned long*, int*);
+static void HandleToolkitErrors(String, String, String, String,
+ String*, Cardinal*);
+static void InsertWidget(ProtocolStream*, Widget);
+static Bool IsChild(Widget, Widget, Widget);
+static Bool isApplicationShell(Widget);
+static void LoadResources(Widget);
+static Bool PositionInChild(Widget, int, int);
+static int qcmp_widget_list(register _Xconst void*, register _Xconst void*);
+static void SendCommand(Widget, Atom, ResIdent, EditResError,
+ ProtocolStream*);
+static void SendFailure(Widget, Atom, ResIdent, char*);
+static char *VerifyWidget(Widget, WidgetInfo*);
+
+/*
+ * External
+ */
+void _XEditResCheckMessages(Widget, XtPointer, XEvent*, Boolean*);
+
+/*
+ * Initialization
+ */
+static Atom res_editor_command, res_editor_protocol, client_value;
+static Globals globals;
+
+/************************************************************
+ * Resource Editor Communication Code
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResCheckMessages
+ *
+ * Parameters:
+ * data - unused
+ * event - The X Event that triggered this handler
+ * cont - unused
+ *
+ * Description:
+ * This callback routine is set on all shell widgets, and checks to
+ * see if a client message event has come from the resource editor.
+ */
+/*ARGSUSED*/
+void
+_XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont)
+{
+ Time time;
+ ResIdent ident;
+ static Boolean first_time = False;
+ static Atom res_editor, res_comm;
+ Display *dpy;
+
+ if (event->type == ClientMessage)
+ {
+ XClientMessageEvent * c_event = (XClientMessageEvent *)event;
+ dpy = XtDisplay(w);
+
+ if (!first_time)
+ {
+ Atom atoms[4];
+ static char *names[] = {
+ EDITRES_NAME, EDITRES_COMMAND_ATOM,
+ EDITRES_PROTOCOL_ATOM, EDITRES_CLIENT_VALUE
+ };
+
+ first_time = True;
+ XInternAtoms(dpy, names, 4, False, atoms);
+ res_editor = atoms[0];
+ res_editor_command = atoms[1];
+ res_editor_protocol = atoms[2];
+ /* Used in later procedures */
+ client_value = atoms[3];
+ LoadResources(w);
+ }
+
+ if ((c_event->message_type != res_editor)
+ || (c_event->format != EDITRES_SEND_EVENT_FORMAT))
+ return;
+
+ time = c_event->data.l[0];
+ res_comm = c_event->data.l[1];
+ ident = (ResIdent) c_event->data.l[2];
+ if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION)
+ {
+ _XEditResResetStream(&globals.stream);
+ _XEditResPut8(&globals.stream,
+ (unsigned int) CURRENT_PROTOCOL_VERSION);
+ SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream);
+ return;
+ }
+
+ XtGetSelectionValue(w, res_comm, res_editor_command,
+ GetCommand, (XtPointer)(long)ident, time);
+ }
+}
+
+/*
+ * Function:
+ * BuildEvent
+ *
+ * Parameters:
+ * w - widget to own selection, in case of error
+ * sel - selection to send error message beck in
+ * data - the data for the request
+ * ident - the id number we are looking for
+ * length - length of request
+ *
+ * Description:
+ * Takes the info out the protocol stream an constructs
+ * the proper event structure.
+ *
+ * Returns:
+ * the event, or NULL
+ */
+#if defined(ERROR_MESSAGE)
+#undef ERROR_MESSAGE
+#endif
+#define ERROR_MESSAGE "Client: Improperly formatted protocol request"
+static EditresEvent *
+BuildEvent(Widget w, Atom sel, XtPointer data, ResIdent ident,
+ unsigned long length)
+{
+ EditresEvent *event;
+ ProtocolStream alloc_stream, *stream;
+ unsigned char temp;
+ register unsigned int i;
+
+ stream = &alloc_stream;
+ stream->current = stream->top = (unsigned char *)data;
+ stream->size = HEADER_SIZE; /* size of header */
+
+ /*
+ * Retrieve the Header
+ */
+ if (length < HEADER_SIZE)
+ {
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
+ return (NULL);
+ }
+
+ (void)_XEditResGet8(stream, &temp);
+ if (temp != ident) /* Id's don't match, ignore request */
+ return (NULL);
+
+ event = (EditresEvent *)XtCalloc(sizeof(EditresEvent), 1);
+
+ (void)_XEditResGet8(stream, &temp);
+ event->any_event.type = (EditresCommand)temp;
+ (void)_XEditResGet32(stream, &stream->size);
+ stream->top = stream->current; /* reset stream to top of value */
+
+ /*
+ * Now retrieve the data segment
+ */
+ switch(event->any_event.type)
+ {
+ case SendWidgetTree:
+ break; /* no additional info */
+ case SetValues:
+ {
+ SetValuesEvent *sv_event = (SetValuesEvent *)event;
+
+ if (!(_XEditResGetString8(stream, &sv_event->name)
+ && _XEditResGetString8(stream, &sv_event->res_type)))
+ goto done;
+
+ /*
+ * Since we need the value length, we have to pull the
+ * value out by hand
+ */
+ if (!_XEditResGet16(stream, &sv_event->value_len))
+ goto done;
+
+ sv_event->value = XtMalloc(sizeof(char) * (sv_event->value_len + 1));
+
+ for (i = 0; i < sv_event->value_len; i++)
+ if (!_XEditResGet8(stream, (unsigned char *)sv_event->value + i))
+ goto done;
+
+ ((char*)sv_event->value)[i] = '\0';
+
+ if (!_XEditResGet16(stream, &sv_event->num_entries))
+ goto done;
+
+ sv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), sv_event->num_entries);
+
+ for (i = 0; i < sv_event->num_entries; i++)
+ if (!_XEditResGetWidgetInfo(stream, sv_event->widgets + i))
+ goto done;
+ }
+ break;
+ case FindChild:
+ {
+ FindChildEvent *find_event = (FindChildEvent *)event;
+
+ find_event->widgets = (WidgetInfo *)XtCalloc(sizeof(WidgetInfo), 1);
+
+ if (!(_XEditResGetWidgetInfo(stream, find_event->widgets)
+ && _XEditResGetSigned16(stream, &find_event->x)
+ && _XEditResGetSigned16(stream, &find_event->y)))
+ goto done;
+ }
+ break;
+ case GetGeometry:
+ case GetResources:
+ {
+ GenericGetEvent *get_event = (GenericGetEvent *)event;
+
+ if (!_XEditResGet16(stream, &get_event->num_entries))
+ goto done;
+
+ get_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), get_event->num_entries);
+
+ for (i = 0; i < get_event->num_entries; i++)
+ if (!_XEditResGetWidgetInfo(stream, get_event->widgets + i))
+ goto done;
+ }
+ break;
+ case GetValues:
+ {
+ GetValuesEvent *gv_event = (GetValuesEvent *)event;
+
+ _XEditResGetString8(stream, &gv_event->name);
+ _XEditResGet16(stream, &gv_event->num_entries);
+ gv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), gv_event->num_entries);
+ _XEditResGetWidgetInfo(stream, gv_event->widgets);
+ }
+ break;
+ default:
+ {
+ char buf[BUFSIZ];
+
+ XmuSnprintf(buf, sizeof(buf),
+ "Unknown Protocol request %d.", event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ FreeEvent(event);
+ return (NULL);
+ }
+ }
+
+ return (event);
+
+ done:
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
+ FreeEvent(event);
+ return (NULL);
+}
+
+/*
+ * Function:
+ * FreeEvent
+ *
+ * Parameters:
+ * event - event to free
+ *
+ * Description:
+ * Frees the event structure and any other pieces in it that need freeing.
+ */
+static void
+FreeEvent(EditresEvent *event)
+{
+ if (event->any_event.widgets != NULL)
+ {
+ XtFree((char *)event->any_event.widgets->ids);
+ XtFree((char *)event->any_event.widgets);
+ }
+
+ if (event->any_event.type == SetValues)
+ {
+ XtFree(event->set_values_event.name);
+ XtFree(event->set_values_event.res_type);
+ }
+
+ XtFree((char *)event);
+}
+
+/*
+ * Function:
+ * GetCommand
+ *
+ * Parameters:
+ * (See Xt XtConvertSelectionProc)
+ * data - contains the ident number for the command
+ *
+ * Description:
+ * Gets the Command out of the selection asserted by the resource manager.
+ */
+/*ARGSUSED*/
+static void
+GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ ResIdent ident = (ResIdent)(long)data;
+ EditresEvent *event;
+
+ if (*type != res_editor_protocol || *format != EDITRES_FORMAT)
+ return;
+
+ if ((event = BuildEvent(w, *selection, value, ident, *length)) != NULL)
+ {
+ ExecuteCommand(w, *selection, ident, event);
+ FreeEvent(event);
+ }
+}
+
+/*
+ * Function:
+ * ExecuteCommand
+ *
+ * Parameters:
+ * w - widget
+ * command - the command to execute
+ * value - the associated with the command
+ *
+ * Description:
+ * Executes a command string received from the resource editor.
+ */
+/*ARGSUSED*/
+static void
+ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event)
+{
+ char *(*func)(Widget, EditresEvent*, ProtocolStream*);
+ char *str;
+
+ if (globals.block == BlockAll)
+ {
+ SendFailure(w, sel, ident,
+ "This client has blocked all Editres commands.");
+ return;
+ }
+ else if (globals.block == BlockSetValues
+ && event->any_event.type == SetValues)
+ {
+ SendFailure(w, sel, ident,
+ "This client has blocked all SetValues requests.");
+ return;
+ }
+
+ switch(event->any_event.type)
+ {
+ case SendWidgetTree:
+#if defined(LONG64) || defined(WORD64)
+ globals.base_address = (unsigned long)w & 0xFFFFFFFF00000000;
+#endif
+ func = DumpWidgets;
+ break;
+ case SetValues:
+ func = DoSetValues;
+ break;
+ case FindChild:
+ func = DoFindChild;
+ break;
+ case GetGeometry:
+ func = DoGetGeometry;
+ break;
+ case GetResources:
+ func = DoGetResources;
+ break;
+ case GetValues:
+ func = DumpValues;
+ break;
+ default:
+ {
+ char buf[BUFSIZ];
+
+ XmuSnprintf(buf, sizeof(buf),
+ "Unknown Protocol request %d.",event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ return;
+ }
+ }
+
+ _XEditResResetStream(&globals.stream);
+ if ((str = (*func)(w, event, &globals.stream)) == NULL)
+ SendCommand(w, sel, ident, PartialSuccess, &globals.stream);
+ else
+ SendFailure(w, sel, ident, str);
+}
+
+/*
+ * Function:
+ * ConvertReturnCommand
+ *
+ * Parameters:
+ * w - the widget that owns the selection
+ * selection - selection to convert
+ * target - target type for this selection
+ * type_ret - type of the selection
+ * value_ret - selection value
+ * length_ret - lenght of this selection
+ * format_ret - the format the selection is in
+ *
+ * Description:
+ * Converts a selection
+ *
+ * Returns:
+ * True if conversion was sucessful
+ */
+/*ARGSUSED*/
+static Boolean
+ConvertReturnCommand(Widget w, Atom *selection, Atom *target, Atom *type_ret,
+ XtPointer *value_ret, unsigned long *length_ret,
+ int *format_ret)
+{
+ /*
+ * I assume the intrinsics give me the correct selection back
+ */
+ if ((*target != client_value))
+ return (False);
+
+ *type_ret = res_editor_protocol;
+ *value_ret = (XtPointer)globals.command_stream->real_top;
+ *length_ret = globals.command_stream->size + HEADER_SIZE;
+ *format_ret = EDITRES_FORMAT;
+
+ return (True);
+}
+
+/*
+ * Function:
+ * CommandDone
+ *
+ * Parameters:
+ * widget - unused
+ * selection - unused
+ * target - unused
+ *
+ * Description:
+ * done with the selection
+ */
+/*ARGSUSED*/
+static void
+CommandDone(Widget widget, Atom *selection, Atom *target)
+{
+ /* Keep the toolkit from automaticaly freeing the selection value */
+}
+
+/*
+ * Function:
+ * SendFailure
+ *
+ * Paramters:
+ * w - widget to own the selection
+ * sel - selection to assert
+ * ident - identifier
+ * str - error message
+ *
+ * Description:
+ * Sends a failure message
+ */
+static void
+SendFailure(Widget w, Atom sel, ResIdent ident, char *str)
+{
+ _XEditResResetStream(&globals.stream);
+ _XEditResPutString8(&globals.stream, str);
+ SendCommand(w, sel, ident, Failure, &globals.stream);
+}
+
+/*
+ * Function:
+ * BuildReturnPacket
+ *
+ * Parameters:
+ * ident - identifier
+ * command - command code
+ * stream - protocol stream
+ * Description:
+ * Builds a return packet, given the data to send
+ *
+ * Returns:
+ * packet to send
+ */
+static XtPointer
+BuildReturnPacket(ResIdent ident, EditResError error, ProtocolStream *stream)
+{
+ long old_alloc, old_size;
+ unsigned char *old_current;
+
+ /*
+ * We have cleverly keep enough space at the top of the header
+ * for the return protocol stream, so all we have to do is
+ * fill in the space
+ */
+ /*
+ * Fool the insert routines into putting the header in the right
+ * place while being damn sure not to realloc (that would be very bad.)
+ */
+ old_current = stream->current;
+ old_alloc = stream->alloc;
+ old_size = stream->size;
+
+ stream->current = stream->real_top;
+ stream->alloc = stream->size + (2 * HEADER_SIZE);
+
+ _XEditResPut8(stream, ident);
+ _XEditResPut8(stream, (unsigned char)error);
+ _XEditResPut32(stream, old_size);
+
+ stream->alloc = old_alloc;
+ stream->current = old_current;
+ stream->size = old_size;
+
+ return ((XtPointer)stream->real_top);
+}
+
+/*
+ * Function:
+ * SendCommand
+ * Parameters:
+ * w - widget to own the selection
+ * sel - selection to assert
+ * ident - identifier
+ * command - command code
+ * stream - protocol stream
+ *
+ * Description:
+ * Builds a return command line
+ */
+static void
+SendCommand(Widget w, Atom sel, ResIdent ident, EditResError error,
+ ProtocolStream *stream)
+{
+ BuildReturnPacket(ident, error, stream);
+ globals.command_stream = stream;
+
+ /*
+ * I REALLY want to own the selection. Since this was not triggered
+ * by a user action, and I am the only one using this atom it is safe to
+ * use CurrentTime
+ */
+ XtOwnSelection(w, sel, CurrentTime, ConvertReturnCommand, NULL, CommandDone);
+}
+
+/************************************************************
+ * Generic Utility Functions
+ ************************************************************/
+static int
+qcmp_widget_list(register _Xconst void *left, register _Xconst void *right)
+{
+ return (char *)*(Widget **)left - (char *)*(Widget **)right;
+}
+
+/*
+ * Function:
+ * FindChildren
+ *
+ * Parameters:
+ * parent - parent widget
+ * children - list of children
+ * normal - return normal children
+ * popup - return popup children
+ * extra - return extra children
+ *
+ * Description:
+ * Retuns all children (popup, normal and otherwise) of this widget
+ *
+ * Returns:
+ * number of children
+ */
+static int
+FindChildren(Widget parent, Widget **children, Bool normal, Bool popup,
+ Bool extra)
+{
+ CompositeWidget cw = (CompositeWidget)parent;
+ Cardinal i, num_children, current = 0;
+ Widget *extra_widgets = NULL;
+ Cardinal num_extra = 0;
+
+ num_children = 0;
+
+ if (XtIsWidget(parent) && popup)
+ num_children += parent->core.num_popups;
+
+ if (XtIsComposite(parent) && normal)
+ num_children += cw->composite.num_children;
+
+ if (XtIsWidget(parent) && extra)
+ {
+ XtResourceList norm_list, cons_list;
+ Cardinal num_norm, num_cons;
+ Arg args[1];
+ Widget widget;
+
+ XtGetResourceList(XtClass(parent), &norm_list, &num_norm);
+
+ if (XtParent(parent) != NULL)
+ XtGetConstraintResourceList(XtClass(XtParent(parent)),
+ &cons_list, &num_cons);
+ else
+ num_cons = 0;
+
+ extra_widgets = (Widget *)XtMalloc(sizeof(Widget));
+ for (i = 0; i < num_norm; i++)
+ if (strcmp(norm_list[i].resource_type, XtRWidget) == 0)
+ {
+ widget = NULL;
+ XtSetArg(args[0], norm_list[i].resource_name, &widget);
+ XtGetValues(parent, args, 1);
+ if (widget && XtParent(widget) == parent)
+ {
+ ++num_extra;
+ extra_widgets = (Widget *) XtRealloc(
+ (char *)extra_widgets, num_extra * sizeof(Widget));
+ extra_widgets[num_extra - 1] = widget;
+ }
+ }
+ for (i = 0; i < num_cons; i++)
+ if (strcmp(cons_list[i].resource_type, XtRWidget) == 0)
+ {
+ widget = NULL;
+ XtSetArg(args[0], cons_list[i].resource_name, &widget);
+ XtGetValues(parent, args, 1);
+ if (widget && XtParent(widget) == parent)
+ {
+ ++num_extra;
+ extra_widgets = (Widget *) XtRealloc(
+ (char *)extra_widgets, num_extra * sizeof(Widget));
+ extra_widgets[num_extra - 1] = widget;
+ }
+ }
+ if (num_norm)
+ XtFree((char *)norm_list);
+ if (num_cons)
+ XtFree((char *)cons_list);
+ }
+
+ if ((num_children + num_extra) == 0)
+ {
+ *children = NULL;
+ return (0);
+ }
+
+ *children = (Widget *)XtMalloc(sizeof(Widget) * (num_children + num_extra));
+
+ if (XtIsComposite(parent) && normal)
+ for (i = 0; i < cw->composite.num_children; i++, current++)
+ (*children)[current] = cw->composite.children[i];
+
+ if (XtIsWidget(parent) && popup)
+ for (i = 0; i < parent->core.num_popups; i++, current++)
+ (*children)[current] = parent->core.popup_list[i];
+
+ if (num_extra)
+ /* Check for dups */
+ {
+ Cardinal j, old_num_extra = num_extra;
+
+ qsort(extra_widgets, num_extra, sizeof(Widget), qcmp_widget_list);
+ for (i = 0; i < num_extra - 1; i++)
+ while (i < num_extra - 1 &&
+ extra_widgets[i] == extra_widgets[i + 1])
+ {
+ memmove(&extra_widgets[i], &extra_widgets[i + 1],
+ (num_extra - i) * sizeof(Widget));
+ --num_extra;
+ }
+
+ for (i = 0; i < num_children; i++)
+ for (j = 0; j < num_extra; j++)
+ if ((*children)[i] == extra_widgets[j])
+ {
+ if ((j + 1) < num_extra)
+ memmove(&extra_widgets[j], &extra_widgets[j + 1],
+ (num_extra - j) * sizeof(Widget));
+ --num_extra;
+ }
+
+ if (old_num_extra != num_extra)
+ *children = (Widget *)XtRealloc((char *)*children, sizeof(Widget)
+ * (num_children + num_extra));
+
+ if (num_extra)
+ memcpy(&(*children)[num_children], extra_widgets,
+ sizeof(Widget) * num_extra);
+ }
+ if (extra_widgets)
+ XtFree((char *)extra_widgets);
+ if (num_children + num_extra == 0)
+ {
+ XtFree((char *)*children);
+ *children = NULL;
+ }
+
+ return (num_children + num_extra);
+}
+
+/*
+ * Function:
+ * IsChild
+ *
+ * parameters:
+ * top - top of the tree
+ * parent - parent widget
+ * child - child widget
+ *
+ * Description:
+ * Check to see of child is a child of parent
+ */
+static Bool
+IsChild(Widget top, Widget parent, Widget child)
+{
+ int i, num_children;
+ Widget *children;
+
+ if (parent == NULL)
+ return (top == child);
+
+ num_children = FindChildren(parent, &children, True, True, True);
+
+ for (i = 0; i < num_children; i++)
+ if (children[i] == child)
+ {
+ XtFree((char *)children);
+ return (True);
+ }
+
+ XtFree((char *)children);
+ return (False);
+}
+
+/*
+ * Function:
+ * VerifyWidget
+ *
+ * Parameters:
+ * w - any widget in the tree
+ * info - info about the widget to verify
+ *
+ * Description:
+ * Makes sure all the widgets still exist
+ */
+static char *
+VerifyWidget(Widget w, WidgetInfo *info)
+{
+ Widget top;
+ register int count;
+ register Widget parent;
+ register unsigned long *child;
+
+ for (top = w; XtParent(top) != NULL; top = XtParent(top))
+ ;
+
+ parent = NULL;
+ child = info->ids;
+ count = 0;
+
+ while (True)
+ {
+ if (!IsChild(top, parent, (Widget) *child))
+ return ("This widget no longer exists in the client.");
+
+ if (++count == info->num_widgets)
+ break;
+
+ parent = (Widget)*child++;
+ }
+
+ info->real_widget = (Widget)*child;
+
+ return (NULL);
+}
+
+/************************************************************
+ * Code to Perform SetValues operations
+ ************************************************************/
+/*
+ * Function:
+ * DoSetValues
+ *
+ * Parameters:
+ * w - a widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Performs the setvalues requested
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ char *str;
+ register unsigned i;
+ unsigned short count = 0;
+ SetValuesEvent *sv_event = (SetValuesEvent *)event;
+
+ _XEditResPut16(stream, count); /* insert 0, will be overwritten later */
+
+ for (i = 0; i < sv_event->num_entries; i++)
+ {
+ if ((str = VerifyWidget(w, &sv_event->widgets[i])) != NULL)
+ {
+ _XEditResPutWidgetInfo(stream, &sv_event->widgets[i]);
+ _XEditResPutString8(stream, str);
+ count++;
+ }
+ else
+ ExecuteSetValues(sv_event->widgets[i].real_widget,
+ sv_event, sv_event->widgets + i, stream, &count);
+ }
+
+ /*
+ * Overwrite the first 2 bytes with the real count.
+ */
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * HandleToolkitErrors
+ *
+ * Parameters:
+ * name - name of the error
+ * type - type of the error
+ * class - class of the error
+ * msg - the default message
+ * params - the extra parameters for this message
+ * num_params - ""
+ *
+ * Description: Handles X Toolkit Errors.
+ */
+/* ARGSUSED */
+static void
+HandleToolkitErrors(String name, String type, String class, String msg,
+ String *params, Cardinal *num_params)
+{
+ SVErrorInfo *info = &globals.error_info;
+ char buf[BUFSIZ];
+
+ if (streq(name, "unknownType"))
+ XmuSnprintf(buf, sizeof(buf),
+ "The `%s' resource is not used by this widget.",
+ info->event->name);
+ else if (streq(name, "noColormap"))
+ XmuSnprintf(buf, sizeof(buf), msg, params[0]);
+ else if (streq(name, "conversionFailed") || streq(name, "conversionError"))
+ {
+ if (streq((String)info->event->value, XtRString))
+ XmuSnprintf(buf, sizeof(buf),
+ "Could not convert the string '%s' for the `%s' "
+ "resource.", (String)info->event->value,
+ info->event->name);
+ else
+ XmuSnprintf(buf, sizeof(buf),
+ "Could not convert the `%s' resource.",
+ info->event->name);
+ }
+ else
+ XmuSnprintf(buf, sizeof(buf),
+ "Name: %s, Type: %s, Class: %s, Msg: %s",
+ name, type, class, msg);
+
+ /*
+ * Insert this info into the protocol stream, and update the count
+ */
+ (*(info->count))++;
+ _XEditResPutWidgetInfo(info->stream, info->entry);
+ _XEditResPutString8(info->stream, buf);
+}
+
+/*
+ * Function:
+ * ExecuteSetValues
+ *
+ * Parameters:
+ * w - widget to perform the set_values on
+ * sv_event - set values event
+ * sv_info - set_value info
+ *.
+ * Description:
+ * Performs a setvalues for a given command
+ */
+static void
+ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry,
+ ProtocolStream *stream, unsigned short *count)
+{
+ XtErrorMsgHandler old;
+ SVErrorInfo *info = &globals.error_info;
+
+ info->event = sv_event; /* No data can be passed to */
+ info->stream = stream; /* an error handler, so we */
+ info->count = count; /* have to use a global */
+ info->entry = entry;
+
+ old = XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w),
+ HandleToolkitErrors);
+
+ XtVaSetValues(w, XtVaTypedArg,
+ sv_event->name, sv_event->res_type,
+ sv_event->value, sv_event->value_len,
+ NULL);
+
+ (void)XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), old);
+}
+
+/************************************************************
+ * Code for Creating and dumping widget tree.
+ ************************************************************/
+/* Function:
+ * DumpWidgets
+ *
+ * Parameters:
+ * w - a widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Given a widget it builds a protocol packet containing the entire
+ * widget heirarchy.
+ *
+ * Returns:
+ * NULL
+ */
+#define TOOLKIT_TYPE ("Xt")
+/*ARGSUSED*/
+static char *
+DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned short count = 0;
+
+ /* Find Tree's root */
+ for (; XtParent(w) != NULL; w = XtParent(w))
+ ;
+
+ /*
+ * hold space for count, overwritten later
+ */
+ _XEditResPut16(stream, (unsigned int)0);
+
+ DumpChildren(w, stream, &count);
+
+ /*
+ * write out toolkit type
+ */
+ _XEditResPutString8(stream, TOOLKIT_TYPE);
+
+ /*
+ * Overwrite the first 2 bytes with the real count
+ */
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * DumpChildren
+ *
+ * Parameters:
+ * w - widget to dump
+ * stream - stream to dump to
+ * count - number of dumps we have performed
+ *
+ * Description:
+ * Adds a child's name to the list.
+ */
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool
+isApplicationShell(Widget w)
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return (False);
+ for (c = XtClass(w); c; c = c->core_class.superclass)
+ if (strcmp(c->core_class.class_name, "ApplicationShell") == 0)
+ return (True);
+
+ return (False);
+}
+
+static void
+DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count)
+{
+ int i, num_children;
+ Widget *children;
+ unsigned long window;
+ char *c_class;
+
+ (*count)++;
+
+ InsertWidget(stream, w); /* Insert the widget into the stream */
+
+ _XEditResPutString8(stream, XtName(w)); /* Insert name */
+
+ if (isApplicationShell(w))
+ c_class = ((ApplicationShellWidget)w)->application.class;
+ else
+ c_class = XtClass(w)->core_class.class_name;
+
+ _XEditResPutString8(stream, c_class); /* Insert class */
+
+ if (XtIsWidget(w))
+ if (XtIsRealized(w))
+ window = XtWindow(w);
+ else
+ window = EDITRES_IS_UNREALIZED;
+ else
+ window = EDITRES_IS_OBJECT;
+
+ _XEditResPut32(stream, window); /* Insert window id */
+
+ /*
+ * Find children and recurse
+ */
+ num_children = FindChildren(w, &children, True, True, True);
+ for (i = 0; i < num_children; i++)
+ DumpChildren(children[i], stream, count);
+
+ XtFree((char *)children);
+}
+
+/************************************************************
+ * Code for getting the geometry of widgets
+ ************************************************************/
+/*
+ * Function:
+ * DoGetGeometry
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Retrieves the Geometry of each specified widget.
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned i;
+ char *str;
+ GetGeomEvent *geom_event = (GetGeomEvent *)event;
+
+ _XEditResPut16(stream, geom_event->num_entries);
+
+ for (i = 0; i < geom_event->num_entries; i++)
+ {
+ /*
+ * Send out the widget id
+ */
+ _XEditResPutWidgetInfo(stream, &geom_event->widgets[i]);
+
+ if ((str = VerifyWidget(w, &geom_event->widgets[i])) != NULL)
+ {
+ _XEditResPutBool(stream, True); /* an error occured */
+ _XEditResPutString8(stream, str); /* set message */
+ }
+ else
+ ExecuteGetGeometry(geom_event->widgets[i].real_widget, stream);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Function:
+ * ExecuteGetGeometry
+ *
+ * Parameters:
+ * w - widget to get geometry
+ * stream - stream to append to
+ *
+ * Description:
+ * Gets the geometry for each widget specified.
+ *
+ * Returns:
+ * True if no error occured.
+ */
+static void
+ExecuteGetGeometry(Widget w, ProtocolStream *stream)
+{
+ int i;
+ Boolean mapped_when_man;
+ Dimension width, height, border_width;
+ Arg args[8];
+ Cardinal num_args = 0;
+ Position x, y;
+
+ if (!XtIsRectObj(w) || (XtIsWidget(w) && !XtIsRealized(w)))
+ {
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, False); /* not visable */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+
+ XtSetArg(args[num_args], XtNwidth, &width); num_args++;
+ XtSetArg(args[num_args], XtNheight, &height); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, &border_width); num_args++;
+ XtSetArg(args[num_args], XtNmappedWhenManaged, &mapped_when_man);
+ num_args++;
+ XtGetValues(w, args, num_args);
+
+ if (!(XtIsManaged(w) && mapped_when_man) && XtIsWidget(w))
+ {
+ XWindowAttributes attrs;
+
+ /*
+ * The toolkit does not maintain mapping state, we have
+ * to go to the server
+ */
+ if (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attrs) != 0)
+ {
+ if (attrs.map_state != IsViewable)
+ {
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, False); /* not visable */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+ }
+ else
+ {
+ _XEditResPut8(stream, True); /* Error occured. */
+ _XEditResPutString8(stream, "XGetWindowAttributes failed.");
+ return;
+ }
+ }
+
+ XtTranslateCoords(w, -((int) border_width), -((int) border_width), &x, &y);
+
+ _XEditResPutBool(stream, False); /* no error */
+ _XEditResPutBool(stream, True); /* Visable */
+ _XEditResPut16(stream, x);
+ _XEditResPut16(stream, y);
+ _XEditResPut16(stream, width);
+ _XEditResPut16(stream, height);
+ _XEditResPut16(stream, border_width);
+}
+
+/************************************************************
+ * Code for executing FindChild
+ ************************************************************/
+/*
+ * Function:
+ * PositionInChild
+ *
+ * Parameters:
+ * child - child widget to check
+ * x - location of point to check in the parent's coord space
+ * y - ""
+ *
+ * Description:
+ * Returns true if this location is in the child.
+ */
+static Bool
+PositionInChild(Widget child, int x, int y)
+{
+ Arg args[6];
+ Cardinal num;
+ Dimension width, height, border_width;
+ Position child_x, child_y;
+ Boolean mapped_when_managed;
+
+ if (!XtIsRectObj(child)) /* we must at least be a rect obj */
+ return (False);
+
+ num = 0;
+ XtSetArg(args[num], XtNmappedWhenManaged, &mapped_when_managed); num++;
+ XtSetArg(args[num], XtNwidth, &width); num++;
+ XtSetArg(args[num], XtNheight, &height); num++;
+ XtSetArg(args[num], XtNx, &child_x); num++;
+ XtSetArg(args[num], XtNy, &child_y); num++;
+ XtSetArg(args[num], XtNborderWidth, &border_width); num++;
+ XtGetValues(child, args, num);
+
+ /*
+ * The only way we will know of the widget is mapped is to see if
+ * mapped when managed is True and this is a managed child. Otherwise
+ * we will have to ask the server if this window is mapped
+ */
+ if (XtIsWidget(child) && !(mapped_when_managed && XtIsManaged(child)))
+ {
+ XWindowAttributes attrs;
+
+ if (XGetWindowAttributes(XtDisplay(child), XtWindow(child), &attrs)
+ && attrs.map_state != IsViewable)
+ return (False);
+ }
+
+ return ((x >= child_x)
+ && (x <= (child_x + (Position)width + 2 * (Position)border_width))
+ && (y >= child_y)
+ && (y <= (child_y + (Position)height + 2 * (Position)border_width)));
+}
+
+/*
+ * Function:
+ * _FindChild
+ *
+ * Parameters:
+ * parent - widget that is known to contain the point specified
+ * x - point in coordinates relative to the widget specified
+ * y - ""
+ *
+ * Description:
+ * Finds the child that actually contains the point shown.
+ */
+static Widget
+_FindChild(Widget parent, int x, int y)
+{
+ Widget *children;
+ int i = FindChildren(parent, &children, True, False, True);
+
+ while (i > 0)
+ {
+ i--;
+
+ if (PositionInChild(children[i], x, y))
+ {
+ Widget child = children[i];
+
+ XtFree((char *)children);
+ return (_FindChild(child, x - child->core.x, y - child->core.y));
+ }
+ }
+
+ XtFree((char *)children);
+
+ return (parent);
+}
+
+/*
+ * Function:
+ * DoFindChild
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ * Description:
+ * Finds the child that contains the location specified.
+ *
+ * Returns:
+ * An allocated error message if something went horribly wrong and
+ * no set values were performed, else NULL.
+ */
+static char *
+DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ char *str;
+ Widget parent, child;
+ Position parent_x, parent_y;
+ FindChildEvent *find_event = (FindChildEvent *)event;
+
+ if ((str = VerifyWidget(w, find_event->widgets)) != NULL)
+ return (str);
+
+ parent = find_event->widgets->real_widget;
+
+ XtTranslateCoords(parent, (Position) 0, (Position) 0,
+ &parent_x, &parent_y);
+
+ child = _FindChild(parent, find_event->x - (int) parent_x,
+ find_event->y - (int) parent_y);
+
+ InsertWidget(stream, child);
+
+ return (NULL);
+}
+
+/************************************************************
+ * Procedures for performing GetResources
+ ************************************************************/
+/*
+ * Function:
+ * DoGetResources
+ *
+ * Parameters:
+ * w - widget in the tree
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Gets the Resources associated with the widgets passed.
+ *
+ * Returns:
+ * NULL
+ */
+static char *
+DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream)
+{
+ unsigned int i;
+ char *str;
+ GetResEvent *res_event = (GetResEvent *)event;
+
+ _XEditResPut16(stream, res_event->num_entries); /* number of replys */
+
+ for (i = 0; i < res_event->num_entries; i++)
+ {
+ /*
+ * Send out the widget id
+ */
+ _XEditResPutWidgetInfo(stream, &res_event->widgets[i]);
+ if ((str = VerifyWidget(w, &res_event->widgets[i])) != NULL)
+ {
+ _XEditResPutBool(stream, True); /* an error occured */
+ _XEditResPutString8(stream, str); /* set message */
+ }
+ else
+ {
+ _XEditResPutBool(stream, False); /* no error occured */
+ ExecuteGetResources(res_event->widgets[i].real_widget, stream);
+ }
+ }
+
+ return (NULL);
+}
+
+/* Function:
+ * ExecuteGetResources
+ *
+ * Parameters:
+ * w - widget to get resources on
+ * stream - protocol stream
+ *
+ * Description:
+ * Gets the resources for any individual widget
+ */
+static void
+ExecuteGetResources(Widget w, ProtocolStream *stream)
+{
+ XtResourceList norm_list, cons_list;
+ Cardinal num_norm, num_cons;
+ register Cardinal i;
+
+ /*
+ * Get Normal Resources
+ */
+ XtGetResourceList(XtClass(w), &norm_list, &num_norm);
+
+ if (XtParent(w) != NULL)
+ XtGetConstraintResourceList(XtClass(XtParent(w)), &cons_list,&num_cons);
+ else
+ num_cons = 0;
+
+ _XEditResPut16(stream, num_norm + num_cons); /* how many resources */
+
+ /*
+ * Insert all the normal resources
+ */
+ for (i = 0; i < num_norm; i++)
+ {
+ _XEditResPutResourceType(stream, NormalResource);
+ _XEditResPutString8(stream, norm_list[i].resource_name);
+ _XEditResPutString8(stream, norm_list[i].resource_class);
+ _XEditResPutString8(stream, norm_list[i].resource_type);
+ }
+ XtFree((char *)norm_list);
+
+ /*
+ * Insert all the constraint resources
+ */
+ if (num_cons > 0)
+ {
+ for (i = 0; i < num_cons; i++)
+ {
+ _XEditResPutResourceType(stream, ConstraintResource);
+ _XEditResPutString8(stream, cons_list[i].resource_name);
+ _XEditResPutString8(stream, cons_list[i].resource_class);
+ _XEditResPutString8(stream, cons_list[i].resource_type);
+ }
+ XtFree((char *)cons_list);
+ }
+}
+
+/*
+ * Function:
+ * DumpValues
+ *
+ * Parameters:
+ * event - event that caused this action
+ * stream - protocol stream to add
+ *
+ * Description:
+ * Returns resource values to the resource editor.
+ *
+ * Returns:
+ * NULL
+ */
+/*ARGSUSED*/
+static char *
+DumpValues(Widget w, EditresEvent* event, ProtocolStream* stream)
+{
+ char *str;
+ Arg warg[1];
+ String res_value = NULL;
+ GetValuesEvent *gv_event = (GetValuesEvent *)event;
+
+ /* put the count in the stream */
+ _XEditResPut16(stream, (unsigned int)1);
+
+ /*
+ * Get the resource of the widget asked for by the
+ * resource editor and insert it into the stream
+ */
+ XtSetArg(warg[0], gv_event->name, &res_value);
+
+ if ((str = VerifyWidget(w, &gv_event->widgets[0])) != NULL)
+ _XEditResPutString8(stream, str);
+ else
+ {
+ _XEditresGetStringValues(gv_event->widgets[0].real_widget, warg, 1);
+ if (!res_value)
+ res_value = "NoValue";
+ _XEditResPutString8(stream, res_value);
+ }
+
+ return (NULL);
+}
+
+/************************************************************
+ * Code for inserting values into the protocol stream
+ ************************************************************/
+/*
+ * Function:
+ * InsertWidget
+ *
+ * Parameters:
+ * stream - protocol stream
+ * w - widget to insert
+ *
+ * Description:
+ * Inserts the full parent hierarchy of this widget into the protocol
+ * stream as a widget list.
+ */
+static void
+InsertWidget(ProtocolStream *stream, Widget w)
+{
+ Widget temp;
+ unsigned long *widget_list;
+ register int i, num_widgets;
+
+ for (temp = w, i = 0; temp != NULL; temp = XtParent(temp), i++)
+ ;
+
+ num_widgets = i;
+ widget_list = (unsigned long *)XtMalloc(sizeof(unsigned long) * num_widgets);
+
+ /*
+ * Put the widgets into the list
+ * make sure that they are inserted in the list from parent -> child
+ */
+ for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--)
+ widget_list[i] = (unsigned long)temp;
+
+ _XEditResPut16(stream, num_widgets); /* insert number of widgets */
+ for (i = 0; i < num_widgets; i++) /* insert Widgets themselves */
+ _XEditResPut32(stream, widget_list[i]);
+
+ XtFree((char *)widget_list);
+}
+
+/************************************************************
+ * All of the following routines are public
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResPutString8
+ *
+ * Parameters:
+ * stream - stream to insert string into
+ * str - string to insert
+ *
+ * Description:
+ * Inserts a string into the protocol stream.
+ */
+void
+_XEditResPutString8(ProtocolStream *stream, char *str)
+{
+ int i, len = strlen(str);
+
+ _XEditResPut16(stream, len);
+ for (i = 0; i < len; i++, str++)
+ _XEditResPut8(stream, *str);
+}
+
+/*
+ * Function:
+ * _XEditResPut8
+ *
+ * Parameters:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts an 8 bit integer into the protocol stream.
+ */
+void
+_XEditResPut8(ProtocolStream *stream, unsigned int value)
+{
+ unsigned char temp;
+
+ if (stream->size >= stream->alloc)
+ {
+ stream->alloc += 100;
+ stream->real_top = (unsigned char *)
+ XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+
+ temp = (unsigned char) (value & BYTE_MASK);
+ *((stream->current)++) = temp;
+ (stream->size)++;
+}
+
+/*
+ * Function:
+ * _XEditResPut16
+ *
+ * Arguments:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts a 16 bit integer into the protocol stream.
+ */
+void
+_XEditResPut16(ProtocolStream *stream, unsigned int value)
+{
+ _XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK);
+ _XEditResPut8(stream, value & BYTE_MASK);
+}
+
+/*
+ * Function:
+ * _XEditResPut32
+ *
+ * Arguments:
+ * stream - stream to insert string into
+ * value - value to insert
+ *
+ * Description:
+ * Inserts a 32 bit integer into the protocol stream.
+ */
+void
+_XEditResPut32(ProtocolStream *stream, unsigned long value)
+{
+ int i;
+
+ for (i = 3; i >= 0; i--)
+ _XEditResPut8(stream, (value >> (XER_NBBY * i)) & BYTE_MASK);
+}
+
+/*
+ * Function:
+ * _XEditResPutWidgetInfo
+ *
+ * Parameters:
+ * stream - stream to insert widget info into
+ * info - info to insert
+ *
+ * Description:
+ * Inserts the widget info into the protocol stream.
+ */
+void
+_XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
+{
+ unsigned int i;
+
+ _XEditResPut16(stream, info->num_widgets);
+ for (i = 0; i < info->num_widgets; i++)
+ _XEditResPut32(stream, info->ids[i]);
+}
+
+/************************************************************
+ * Code for retrieving values from the protocol stream
+ ************************************************************/
+/*
+ * Function:
+ * _XEditResResetStream
+ *
+ * Parameters:
+ * stream - stream to reset
+ *
+ * Description:
+ * Resets the protocol stream.
+ */
+void
+_XEditResResetStream(ProtocolStream *stream)
+{
+ stream->current = stream->top;
+ stream->size = 0;
+ if (stream->real_top == NULL)
+ {
+ stream->real_top = (unsigned char *)
+ XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+}
+
+/*
+ * NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+ *
+ * The only modified field if the "current" field
+ *
+ * The only fields that must be set correctly are the "current", "top"
+ * and "size" fields.
+ */
+/*
+ * Function:
+ * _XEditResGetg8
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - a pointer to value to return
+ *
+ * Description:
+ * Retrieves an unsigned 8 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet8(ProtocolStream *stream, unsigned char *value)
+{
+ if (stream->size < (unsigned long)(stream->current - stream->top))
+ return (False);
+
+ *value = *((stream->current)++);
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGet16
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an unsigned 16 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet16(ProtocolStream *stream, unsigned short *value)
+{
+ unsigned char temp1, temp2;
+
+ if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
+ return (False);
+
+ *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGetSigned16
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an signed 16 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGetSigned16(ProtocolStream *stream, short *value)
+{
+ unsigned char temp1, temp2;
+
+ if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
+ return (False);
+
+ if (temp1 & (1 << (XER_NBBY - 1))) /* If the sign bit is active */
+ {
+ *value = -1; /* store all 1's */
+ *value &= (temp1 << XER_NBBY); /* Now and in the MSB */
+ *value &= temp2; /* and LSB */
+ }
+ else
+ *value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
+
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGet32
+ *
+ * Parameters:
+ * stream - protocol stream
+ * value - pointer to return value
+ *
+ * Description:
+ * Retrieves an unsigned 32 bit value from the protocol stream.
+ *
+ * Returns:
+ * True if sucessful
+ */
+Bool
+_XEditResGet32(ProtocolStream *stream, unsigned long *value)
+{
+ unsigned short temp1, temp2;
+
+ if (!(_XEditResGet16(stream, &temp1) && _XEditResGet16(stream, &temp2)))
+ return (False);
+
+ *value = ((unsigned short)temp1 << (XER_NBBY * 2)) + (unsigned short)temp2;
+ return (True);
+}
+
+/* Function:
+ * _XEditResGetString8
+ *
+ * Parameters:
+ * stream - protocol stream
+ * str - string to retrieve
+ *
+ * Description:
+ * Retrieves an 8 bit string value from the protocol stream.
+ *
+ * Returns:
+ * True if retrieval was successful
+ */
+Bool
+_XEditResGetString8(ProtocolStream *stream, char **str)
+{
+ unsigned short len;
+ register unsigned i;
+
+ if (!_XEditResGet16(stream, &len))
+ return (False);
+
+ *str = XtMalloc(sizeof(char) * (len + 1));
+
+ for (i = 0; i < len; i++)
+ {
+ if (!_XEditResGet8(stream, (unsigned char *)*str + i))
+ {
+ XtFree(*str);
+ *str = NULL;
+ return (False);
+ }
+ }
+ (*str)[i] = '\0';
+
+ return (True);
+}
+
+/*
+ * Function:
+ * _XEditResGetWidgetInfo
+ *
+ * Parameters:
+ * stream - protocol stream
+ * info - widget info struct to store into
+ *
+ * Description:
+ * Retrieves the list of widgets that follow and stores them in the
+ * widget info structure provided.
+ *
+ * Returns:
+ * True if retrieval was successful
+ */
+Bool
+_XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
+{
+ unsigned int i;
+
+ if (!_XEditResGet16(stream, &info->num_widgets))
+ return (False);
+
+ info->ids = (unsigned long *)XtMalloc(sizeof(long) * info->num_widgets);
+
+ for (i = 0; i < info->num_widgets; i++)
+ {
+ if (!_XEditResGet32(stream, info->ids + i))
+ {
+ XtFree((char *)info->ids);
+ info->ids = NULL;
+ return (False);
+ }
+#if defined(LONG64) || defined(WORD64)
+ info->ids[i] |= globals.base_address;
+#endif
+ }
+ return (True);
+}
+
+/************************************************************
+ * Code for Loading the EditresBlock resource
+ ************************************************************/
+/*
+ * Function:
+ * CvStringToBlock
+ *
+ * Parameters:
+ * dpy - display
+ * args - unused
+ * num_args - unused
+ * from_val - value to convert
+ * to_val - where to store
+ * converter_data - unused
+ *
+ * Description:
+ * Converts a string to an editres block value.
+ *
+ * Returns:
+ * True if conversion was sucessful
+ */
+/*ARGSUSED*/
+static Boolean
+CvtStringToBlock(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *from_val, XrmValue *to_val,
+ XtPointer *converter_data)
+{
+ char ptr[16];
+ static EditresBlock block;
+
+ XmuNCopyISOLatin1Lowered(ptr, from_val->addr, sizeof(ptr));
+
+ if (streq(ptr, "none"))
+ block = BlockNone;
+ else if (streq(ptr, "setvalues"))
+ block = BlockSetValues;
+ else if (streq(ptr, "all"))
+ block = BlockAll;
+ else
+ {
+ Cardinal num_params = 1;
+ String params[1];
+
+ params[0] = from_val->addr;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "CvtStringToBlock", "unknownValue", "EditresError",
+ "Could not convert string \"%s\" to EditresBlock.",
+ params, &num_params);
+ return FALSE;
+ }
+
+ if (to_val->addr != NULL)
+ {
+ if (to_val->size < sizeof(EditresBlock))
+ {
+ to_val->size = sizeof(EditresBlock);
+ return FALSE;
+ }
+ *(EditresBlock *)(to_val->addr) = block;
+ }
+ else
+ to_val->addr = (XtPointer)block;
+
+ to_val->size = sizeof(EditresBlock);
+ return TRUE;
+}
+
+#define XtREditresBlock "EditresBlock"
+/*
+ * Function:
+ * LoadResources
+ *
+ * Parameters:
+ * w - any widget in the tree
+ *
+ * Description:
+ * Loads a global resource the determines of this application should
+ * allow Editres requests.
+ */
+static void
+LoadResources(Widget w)
+{
+ static XtResource resources[] = {
+ {"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock),
+ XtOffsetOf(Globals, block), XtRImmediate, (XtPointer)BlockNone}
+ };
+
+ for (; XtParent(w) != NULL; w = XtParent(w))
+ ;
+
+ XtAppSetTypeConverter(XtWidgetToApplicationContext(w),
+ XtRString, XtREditresBlock, CvtStringToBlock,
+ NULL, 0, XtCacheAll, NULL);
+
+ XtGetApplicationResources(w, (XtPointer)&globals, resources,
+ XtNumber(resources), NULL, 0);
+}
+
+/*
+ * Function:
+ * _XEditresGetStringValues
+ *
+ * Parameters:
+ * w - widget
+ * warg - where to store result
+ * numargs - unused
+ */
+/*ARGSUSED*/
+static void
+_XEditresGetStringValues(Widget w, Arg *warg, int numargs)
+{
+ static char buffer[32];
+ XtResourceList res_list;
+ Cardinal num_res;
+ XtResource *res = NULL;
+ long value;
+ Cardinal i;
+ char *string = "";
+ Arg args[1];
+ XrmValue to, from;
+
+ /*
+ * Look for the resource
+ */
+ XtGetResourceList(XtClass(w), &res_list, &num_res);
+ for (i = 0; i < num_res; i++)
+ if (strcmp(res_list[i].resource_name, warg->name) == 0)
+ {
+ res = &res_list[i];
+ break;
+ }
+
+ if (res == NULL && XtParent(w) != NULL)
+ {
+ XtFree((char *)res_list);
+ XtGetConstraintResourceList(XtClass(XtParent(w)), &res_list, &num_res);
+ for (i = 0; i < num_res; i++)
+ if (strcmp(res_list[i].resource_name, warg->name) == 0)
+ {
+ res = &res_list[i];
+ break;
+ }
+ }
+
+ if (res == NULL)
+ {
+ /* Couldn't find resource */
+
+ XtFree((char *)res_list);
+ *(XtPointer *)warg->value = NULL;
+ return;
+ }
+
+ /* try to get the value in the proper size */
+ switch (res->resource_size)
+ {
+#ifdef LONG64
+ long v8;
+#endif
+ int v4;
+ short v2;
+ char v1;
+
+ case 1:
+ XtSetArg(args[0], res->resource_name, &v1);
+ XtGetValues(w, args, 1);
+ value = (int)v1;
+ break;
+ case 2:
+ XtSetArg(args[0], res->resource_name, &v2);
+ XtGetValues(w, args, 1);
+ value = (int)v2;
+ break;
+ case 4:
+ XtSetArg(args[0], res->resource_name, &v4);
+ XtGetValues(w, args, 1);
+ value = (int)v4;
+ break;
+#ifdef LONG64
+ case 8:
+ XtSetArg(args[0], res->resource_name, &v8);
+ XtGetValues(w, args, 1);
+ value = (long)v8;
+ break;
+#endif
+ default:
+ fprintf(stderr, "_XEditresGetStringValues: bad size %d\n",
+ res->resource_size);
+ string = "bad size";
+ *(char **)(warg->value) = string;
+ XtFree((char *)res_list);
+ return;
+ }
+
+ /*
+ * If the resource is already String, no conversion needed
+ */
+ if (strcmp(XtRString, res->resource_type) == 0)
+ {
+ if (value == 0)
+ string = "(null)";
+ else
+ string = (char *)value;
+ }
+ else
+ {
+ from.size = res->resource_size;
+ from.addr = (XPointer)&value;
+ to.addr = NULL;
+ to.size = 0;
+
+ if (XtConvertAndStore(w,res->resource_type, &from, XtRString, &to))
+ string = to.addr;
+ else
+ {
+ string = buffer;
+ /*
+ * Conversion failed, fall back to representing it as integer
+ */
+ switch (res->resource_size)
+ {
+ case sizeof(char):
+ XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xff));
+ break;
+ case sizeof(short):
+ XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xffff));
+ break;
+ case sizeof(int):
+ XmuSnprintf(buffer, sizeof(buffer), "0x%08x", (int)value);
+ break;
+#ifdef LONG64
+ case sizeof(long):
+ XmuSnprintf(buffer, sizeof(buffer), "0x%016lx", value);
+ break;
+#endif
+ }
+ }
+ }
+
+ if (string == NULL)
+ string = "";
+
+ *(char **)(warg->value) = string;
+ XtFree((char *)res_list);
+}
diff --git a/libXmu/src/ExtAgent.c b/libXmu/src/ExtAgent.c index 6b0dfdbd8..c7d284b3b 100644 --- a/libXmu/src/ExtAgent.c +++ b/libXmu/src/ExtAgent.c @@ -1,43 +1,43 @@ -/* - -Copyright 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/Xmu/ExtAgent.h> - -/* ARGSUSED */ -void -XmuRegisterExternalAgent(Widget w, XtPointer data, - XEvent *event, Boolean *cont) -{ -/* -* This is a stub. Writers of protocol libraries -* that want to add protocol to Xaw, such as RAP, will reimplement this -* procedure in their own libraries. -*/ -} +/*
+
+Copyright 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/ExtAgent.h>
+
+/* ARGSUSED */
+void
+XmuRegisterExternalAgent(Widget w, XtPointer data,
+ XEvent *event, Boolean *cont)
+{
+/*
+* This is a stub. Writers of protocol libraries
+* that want to add protocol to Xaw, such as RAP, will reimplement this
+* procedure in their own libraries.
+*/
+}
diff --git a/libXmu/src/FToCback.c b/libXmu/src/FToCback.c index 4ca8d459a..e001cc972 100644 --- a/libXmu/src/FToCback.c +++ b/libXmu/src/FToCback.c @@ -1,45 +1,45 @@ -/* - -Copyright 1988,1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/Xmu/Converters.h> - -/* ARGSUSED */ -void -XmuCvtFunctionToCallback(XrmValue *args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static XtCallbackRec callback[2]; /* K&R: initialized to NULL */ - static XtCallbackList callback_list = callback; - - callback[0].callback = *(XtCallbackProc *)fromVal->addr; - - toVal->size = sizeof(XtCallbackList); - toVal->addr = (XPointer)&callback_list; -} +/*
+
+Copyright 1988,1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+
+/* ARGSUSED */
+void
+XmuCvtFunctionToCallback(XrmValue *args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtCallbackRec callback[2]; /* K&R: initialized to NULL */
+ static XtCallbackList callback_list = callback;
+
+ callback[0].callback = *(XtCallbackProc *)fromVal->addr;
+
+ toVal->size = sizeof(XtCallbackList);
+ toVal->addr = (XPointer)&callback_list;
+}
diff --git a/libXmu/src/GetHost.c b/libXmu/src/GetHost.c index 2f0bccded..59e7aa9bb 100644 --- a/libXmu/src/GetHost.c +++ b/libXmu/src/GetHost.c @@ -1,84 +1,84 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - * - * _XGetHostname - similar to gethostname but allows special processing. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xosdefs.h> -#include <string.h> -#include <unistd.h> - -#ifdef WIN32 -#include <X11/Xlibint.h> -#include <X11/Xwinsock.h> -#endif - -#ifdef USG -#define NEED_UTSNAME -#endif - -#ifdef NEED_UTSNAME -#include <sys/utsname.h> -#endif - -#include <X11/Xmu/SysUtil.h> - -int -XmuGetHostname(char *buf, int maxlen) -{ - int len; -#ifdef WIN32 - static WSADATA wsadata; - - if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata)) - return -1; -#endif - -#ifdef NEED_UTSNAME - /* - * same host name crock as in server and xinit. - */ - struct utsname name; - - uname (&name); - len = strlen (name.nodename); - if (len >= maxlen) len = maxlen - 1; - strncpy (buf, name.nodename, len); - buf[len] = '\0'; -#else - buf[0] = '\0'; - (void) gethostname (buf, maxlen); - buf [maxlen - 1] = '\0'; - len = strlen(buf); -#endif /* hpux */ - return len; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xosdefs.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef WIN32
+#include <X11/Xlibint.h>
+#include <X11/Xwinsock.h>
+#endif
+
+#ifdef USG
+#define NEED_UTSNAME
+#endif
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+#include <X11/Xmu/SysUtil.h>
+
+int
+XmuGetHostname(char *buf, int maxlen)
+{
+ int len;
+#ifdef WIN32
+ static WSADATA wsadata;
+
+ if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
+ return -1;
+#endif
+
+#ifdef NEED_UTSNAME
+ /*
+ * same host name crock as in server and xinit.
+ */
+ struct utsname name;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* hpux */
+ return len;
+}
diff --git a/libXmu/src/GrayPixmap.c b/libXmu/src/GrayPixmap.c index ccea46116..66320e1a6 100644 --- a/libXmu/src/GrayPixmap.c +++ b/libXmu/src/GrayPixmap.c @@ -1,136 +1,136 @@ -/* - -Copyright 1987, 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/*********************************************************** - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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 <config.h> -#endif -#include <stdio.h> -#include <X11/Intrinsic.h> -#include <X11/Xmu/Drawing.h> - -typedef struct _PixmapCache { - Screen *screen; - Pixmap pixmap; - Pixel foreground, background; - unsigned int depth; - int ref_count; - struct _PixmapCache *next; - } CacheEntry; - -static CacheEntry *pixmapCache = NULL; - - - -Pixmap -XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back, - unsigned int depth) -/* - * Creates a stippled pixmap of specified depth - * caches these so that multiple requests share the pixmap - */ -{ - register Display *display = DisplayOfScreen(screen); - CacheEntry *cachePtr; - Pixmap stippled_pixmap; - static unsigned char pixmap_bits[] = { - 0x02, 0x01, - }; - -/* - * Creates a stippled pixmap of depth DefaultDepth(screen) - * caches these so that multiple requests share the pixmap - */ - -#define pixmap_width 2 -#define pixmap_height 2 - - /* see if we already have a pixmap suitable for this screen */ - for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) { - if (cachePtr->screen == screen && cachePtr->foreground == fore && - cachePtr->background == back && cachePtr->depth == depth) - return( cachePtr->ref_count++, cachePtr->pixmap ); - } - - stippled_pixmap = XCreatePixmapFromBitmapData (display, - RootWindowOfScreen(screen), (char *)pixmap_bits, - pixmap_width, pixmap_height, fore, back, depth); - - /* and insert it at the head of the cache */ - cachePtr = XtNew(CacheEntry); - cachePtr->screen = screen; - cachePtr->foreground = fore; - cachePtr->background = back; - cachePtr->depth = depth; - cachePtr->pixmap = stippled_pixmap; - cachePtr->ref_count = 1; - cachePtr->next = pixmapCache; - pixmapCache = cachePtr; - - return( stippled_pixmap ); -} - -void -XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap) -{ - register Display *display = DisplayOfScreen(screen); - CacheEntry *cachePtr, **prevP; - for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) { - if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) { - if (--cachePtr->ref_count == 0) { - XFreePixmap( display, pixmap ); - *prevP = cachePtr->next; - XtFree( (char*)cachePtr ); - break; - } - } - prevP = &cachePtr->next; - cachePtr = *prevP; - } -} +/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/***********************************************************
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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 <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Drawing.h>
+
+typedef struct _PixmapCache {
+ Screen *screen;
+ Pixmap pixmap;
+ Pixel foreground, background;
+ unsigned int depth;
+ int ref_count;
+ struct _PixmapCache *next;
+ } CacheEntry;
+
+static CacheEntry *pixmapCache = NULL;
+
+
+
+Pixmap
+XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back,
+ unsigned int depth)
+/*
+ * Creates a stippled pixmap of specified depth
+ * caches these so that multiple requests share the pixmap
+ */
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr;
+ Pixmap stippled_pixmap;
+ static unsigned char pixmap_bits[] = {
+ 0x02, 0x01,
+ };
+
+/*
+ * Creates a stippled pixmap of depth DefaultDepth(screen)
+ * caches these so that multiple requests share the pixmap
+ */
+
+#define pixmap_width 2
+#define pixmap_height 2
+
+ /* see if we already have a pixmap suitable for this screen */
+ for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) {
+ if (cachePtr->screen == screen && cachePtr->foreground == fore &&
+ cachePtr->background == back && cachePtr->depth == depth)
+ return( cachePtr->ref_count++, cachePtr->pixmap );
+ }
+
+ stippled_pixmap = XCreatePixmapFromBitmapData (display,
+ RootWindowOfScreen(screen), (char *)pixmap_bits,
+ pixmap_width, pixmap_height, fore, back, depth);
+
+ /* and insert it at the head of the cache */
+ cachePtr = XtNew(CacheEntry);
+ cachePtr->screen = screen;
+ cachePtr->foreground = fore;
+ cachePtr->background = back;
+ cachePtr->depth = depth;
+ cachePtr->pixmap = stippled_pixmap;
+ cachePtr->ref_count = 1;
+ cachePtr->next = pixmapCache;
+ pixmapCache = cachePtr;
+
+ return( stippled_pixmap );
+}
+
+void
+XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap)
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr, **prevP;
+ for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) {
+ if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) {
+ if (--cachePtr->ref_count == 0) {
+ XFreePixmap( display, pixmap );
+ *prevP = cachePtr->next;
+ XtFree( (char*)cachePtr );
+ break;
+ }
+ }
+ prevP = &cachePtr->next;
+ cachePtr = *prevP;
+ }
+}
diff --git a/libXmu/src/Initer.c b/libXmu/src/Initer.c index bd7678480..13533855b 100644 --- a/libXmu/src/Initer.c +++ b/libXmu/src/Initer.c @@ -1,114 +1,114 @@ -/* - -Copyright 1988, 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* Created By: Chris D. Peterson - * MIT X Consortium - * Date: May 8, 1989 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/Xmu/Initer.h> - -struct InitializerList { - XmuInitializerProc function; /* function to call */ - XPointer data; /* Data to pass the function. */ - XtAppContext * app_con_list; /* a null terminated list of app_contexts. */ -}; - -/* - * Prototypes - */ -static Bool AddToAppconList(XtAppContext**, XtAppContext); - -static struct InitializerList * init_list = NULL; -static Cardinal init_list_length = 0; - -void -XmuAddInitializer(XmuInitializerProc func, XPointer data) -{ - init_list_length++; - init_list = (struct InitializerList *) XtRealloc( (char *) init_list, - (sizeof(struct InitializerList) * - init_list_length) ); - - init_list[init_list_length - 1].function = func; - init_list[init_list_length - 1].data = data; - init_list[init_list_length - 1].app_con_list = NULL; -} - -void -XmuCallInitializers(XtAppContext app_con) -{ - unsigned i; - - for (i = 0 ; i < init_list_length ; i++) { - if (AddToAppconList(&(init_list[i].app_con_list), app_con)) - (init_list[i].function) (app_con, init_list[i].data); - } -} - -/* - * Function: - * AddToAppconList - * - * Parameters: - * app_list - NULL terminated list of application contexts - * app_con - application context to test - * - * Description: - * Adds an action to the application context list and - * returns True, if this app_con is already on the list then - * it is NOT added and False is returned. - * - * Returns: - * True if not found, False if found - */ -static Bool -AddToAppconList(XtAppContext **app_list, XtAppContext app_con) -{ - int i; - XtAppContext *local_list; - - i = 0; - local_list = *app_list; - if (*app_list != NULL) { - for ( ; *local_list != NULL ; i++, local_list++) { - if (*local_list == app_con) - return (False); - } - } - - *app_list = (XtAppContext *) XtRealloc((char *)(*app_list), - sizeof(XtAppContext *) * (i + 2) ); - (*app_list)[i++] = app_con; - (*app_list)[i] = NULL; - - return (True); -} - +/*
+
+Copyright 1988, 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* Created By: Chris D. Peterson
+ * MIT X Consortium
+ * Date: May 8, 1989
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Initer.h>
+
+struct InitializerList {
+ XmuInitializerProc function; /* function to call */
+ XPointer data; /* Data to pass the function. */
+ XtAppContext * app_con_list; /* a null terminated list of app_contexts. */
+};
+
+/*
+ * Prototypes
+ */
+static Bool AddToAppconList(XtAppContext**, XtAppContext);
+
+static struct InitializerList * init_list = NULL;
+static Cardinal init_list_length = 0;
+
+void
+XmuAddInitializer(XmuInitializerProc func, XPointer data)
+{
+ init_list_length++;
+ init_list = (struct InitializerList *) XtRealloc( (char *) init_list,
+ (sizeof(struct InitializerList) *
+ init_list_length) );
+
+ init_list[init_list_length - 1].function = func;
+ init_list[init_list_length - 1].data = data;
+ init_list[init_list_length - 1].app_con_list = NULL;
+}
+
+void
+XmuCallInitializers(XtAppContext app_con)
+{
+ unsigned i;
+
+ for (i = 0 ; i < init_list_length ; i++) {
+ if (AddToAppconList(&(init_list[i].app_con_list), app_con))
+ (init_list[i].function) (app_con, init_list[i].data);
+ }
+}
+
+/*
+ * Function:
+ * AddToAppconList
+ *
+ * Parameters:
+ * app_list - NULL terminated list of application contexts
+ * app_con - application context to test
+ *
+ * Description:
+ * Adds an action to the application context list and
+ * returns True, if this app_con is already on the list then
+ * it is NOT added and False is returned.
+ *
+ * Returns:
+ * True if not found, False if found
+ */
+static Bool
+AddToAppconList(XtAppContext **app_list, XtAppContext app_con)
+{
+ int i;
+ XtAppContext *local_list;
+
+ i = 0;
+ local_list = *app_list;
+ if (*app_list != NULL) {
+ for ( ; *local_list != NULL ; i++, local_list++) {
+ if (*local_list == app_con)
+ return (False);
+ }
+ }
+
+ *app_list = (XtAppContext *) XtRealloc((char *)(*app_list),
+ sizeof(XtAppContext *) * (i + 2) );
+ (*app_list)[i++] = app_con;
+ (*app_list)[i] = NULL;
+
+ return (True);
+}
+
diff --git a/libXmu/src/LocBitmap.c b/libXmu/src/LocBitmap.c index 0cfbdaa23..75c80bc1b 100644 --- a/libXmu/src/LocBitmap.c +++ b/libXmu/src/LocBitmap.c @@ -1,269 +1,269 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlib.h> -#include <stdlib.h> -#include <string.h> -#include <X11/Xresource.h> -#include <X11/Xutil.h> -#include <X11/Xmu/CvtCache.h> -#include <X11/Xmu/Drawing.h> -#include <X11/Xmu/SysUtil.h> - -#ifndef X_NOT_POSIX -#ifdef _POSIX_SOURCE -#include <limits.h> -#else -#define _POSIX_SOURCE -#include <limits.h> -#undef _POSIX_SOURCE -#endif -#endif /* X_NOT_POSIX */ -#ifndef PATH_MAX -#ifdef WIN32 -#define PATH_MAX 512 -#else -#include <sys/param.h> -#endif -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif /* PATH_MAX */ - -/* - * Prototypes - */ -static char **split_path_string(char*); - -/* - * XmuLocateBitmapFile - read a bitmap file using the normal defaults - */ - -Pixmap -XmuLocateBitmapFile(Screen *screen, _Xconst char *name, char *srcname, - int srcnamelen, int *widthp, int *heightp, - int *xhotp, int *yhotp) -{ - return XmuLocatePixmapFile (screen, name, - (unsigned long) 1, (unsigned long) 0, - (unsigned int) 1, srcname, srcnamelen, - widthp, heightp, xhotp, yhotp); -} - - -/* - * version that reads pixmap data as well as bitmap data - */ -Pixmap -XmuLocatePixmapFile(Screen *screen, _Xconst char *name, - unsigned long fore, unsigned long back, - unsigned int depth, - char *srcname, int srcnamelen, - int *widthp, int *heightp, int *xhotp, int *yhotp) -{ - -#ifndef BITMAPDIR -#define BITMAPDIR "/usr/include/X11/bitmaps" -#endif - - Display *dpy = DisplayOfScreen (screen); - Window root = RootWindowOfScreen (screen); - Bool try_plain_name = True; - XmuCvtCache *cache = _XmuCCLookupDisplay (dpy); - char **file_paths = (char **) NULL; - char filename[PATH_MAX]; -#if 0 - char* bitmapdir = BITMAPDIR; -#endif - unsigned int width, height; - int xhot, yhot; - int i; - - /* - * look in cache for bitmap path - */ - if (cache) { - if (!cache->string_to_bitmap.bitmapFilePath) { - XrmName xrm_name[2]; - XrmClass xrm_class[2]; - XrmRepresentation rep_type; - XrmValue value; - - xrm_name[0] = XrmPermStringToQuark ("bitmapFilePath"); - xrm_name[1] = NULLQUARK; - xrm_class[0] = XrmPermStringToQuark ("BitmapFilePath"); - xrm_class[1] = NULLQUARK; - if (!XrmGetDatabase(dpy)) { - /* what a hack; need to initialize it */ - (void) XGetDefault (dpy, "", ""); - } - if (XrmQGetResource (XrmGetDatabase(dpy), xrm_name, xrm_class, - &rep_type, &value) && - rep_type == XrmPermStringToQuark("String")) { - cache->string_to_bitmap.bitmapFilePath = - split_path_string (value.addr); - } - } - file_paths = cache->string_to_bitmap.bitmapFilePath; - } - - /* - * Search order: - * 1. name if it begins with / or ./ - * 2. "each prefix in file_paths"/name - * 3. BITMAPDIR/name - * 4. name if didn't begin with / or . - */ - - for (i = 1; i <= 4; i++) { - char *fn = filename; - Pixmap pixmap; - unsigned char *data; - - switch (i) { - case 1: -#ifndef __UNIXOS2__ - if (!(name[0] == '/' || ((name[0] == '.') && name[1] == '/'))) -#else - if (!(name[0] == '/' || (name[0] == '.' && name[1] == '/') || - (isalpha(name[0]) && name[1] == ':'))) -#endif - continue; - fn = (char *) name; - try_plain_name = False; - break; - case 2: - if (file_paths && *file_paths) { - XmuSnprintf(filename, sizeof(filename), - "%s/%s", *file_paths, name); - file_paths++; - i--; - break; - } - continue; - case 3: - XmuSnprintf(filename, sizeof(filename), "%s/%s", BITMAPDIR, name); - break; - case 4: - if (!try_plain_name) continue; - fn = (char *) name; - break; - } - - data = NULL; - pixmap = None; -#ifdef __UNIXOS2__ - fn = (char*)__XOS2RedirRoot(fn); -#endif - if (XmuReadBitmapDataFromFile (fn, &width, &height, &data, - &xhot, &yhot) == BitmapSuccess) { - pixmap = XCreatePixmapFromBitmapData (dpy, root, (char *) data, - width, height, - fore, back, depth); - XFree ((char *)data); - } - - if (pixmap) { - if (widthp) *widthp = (int)width; - if (heightp) *heightp = (int)height; - if (xhotp) *xhotp = xhot; - if (yhotp) *yhotp = yhot; - if (srcname && srcnamelen > 0) { - strncpy (srcname, fn, srcnamelen - 1); - srcname[srcnamelen - 1] = '\0'; - } - return pixmap; - } - } - - return None; -} - - -/* - * split_path_string - split a colon-separated list into its constituent - * parts; to release, free list[0] and list. - */ -static char ** -split_path_string(register char *src) -{ - int nelems = 1; - register char *dst; - char **elemlist, **elem; - - /* count the number of elements */ - for (dst = src; *dst; dst++) if (*dst == ':') nelems++; - - /* get memory for everything */ - dst = (char *) malloc (dst - src + 1); - if (!dst) return NULL; - elemlist = (char **) calloc ((nelems + 1), sizeof (char *)); - if (!elemlist) { - free (dst); - return NULL; - } - - /* copy to new list and walk up nulling colons and setting list pointers */ - strcpy (dst, src); - for (elem = elemlist, src = dst; *src; src++) { - if (*src == ':') { - *elem++ = dst; - *src = '\0'; - dst = src + 1; - } - } - *elem = dst; - - return elemlist; -} - - -void -_XmuStringToBitmapInitCache(register XmuCvtCache *c) -{ - c->string_to_bitmap.bitmapFilePath = NULL; -} - -void -_XmuStringToBitmapFreeCache(register XmuCvtCache *c) -{ - if (c->string_to_bitmap.bitmapFilePath) { - if (c->string_to_bitmap.bitmapFilePath[0]) - free (c->string_to_bitmap.bitmapFilePath[0]); - free ((char *) (c->string_to_bitmap.bitmapFilePath)); - } -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/CvtCache.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/SysUtil.h>
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#ifndef PATH_MAX
+#ifdef WIN32
+#define PATH_MAX 512
+#else
+#include <sys/param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif /* PATH_MAX */
+
+/*
+ * Prototypes
+ */
+static char **split_path_string(char*);
+
+/*
+ * XmuLocateBitmapFile - read a bitmap file using the normal defaults
+ */
+
+Pixmap
+XmuLocateBitmapFile(Screen *screen, _Xconst char *name, char *srcname,
+ int srcnamelen, int *widthp, int *heightp,
+ int *xhotp, int *yhotp)
+{
+ return XmuLocatePixmapFile (screen, name,
+ (unsigned long) 1, (unsigned long) 0,
+ (unsigned int) 1, srcname, srcnamelen,
+ widthp, heightp, xhotp, yhotp);
+}
+
+
+/*
+ * version that reads pixmap data as well as bitmap data
+ */
+Pixmap
+XmuLocatePixmapFile(Screen *screen, _Xconst char *name,
+ unsigned long fore, unsigned long back,
+ unsigned int depth,
+ char *srcname, int srcnamelen,
+ int *widthp, int *heightp, int *xhotp, int *yhotp)
+{
+
+#ifndef BITMAPDIR
+#define BITMAPDIR "/usr/include/X11/bitmaps"
+#endif
+
+ Display *dpy = DisplayOfScreen (screen);
+ Window root = RootWindowOfScreen (screen);
+ Bool try_plain_name = True;
+ XmuCvtCache *cache = _XmuCCLookupDisplay (dpy);
+ char **file_paths = (char **) NULL;
+ char filename[PATH_MAX];
+#if 0
+ char* bitmapdir = BITMAPDIR;
+#endif
+ unsigned int width, height;
+ int xhot, yhot;
+ int i;
+
+ /*
+ * look in cache for bitmap path
+ */
+ if (cache) {
+ if (!cache->string_to_bitmap.bitmapFilePath) {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("bitmapFilePath");
+ xrm_name[1] = NULLQUARK;
+ xrm_class[0] = XrmPermStringToQuark ("BitmapFilePath");
+ xrm_class[1] = NULLQUARK;
+ if (!XrmGetDatabase(dpy)) {
+ /* what a hack; need to initialize it */
+ (void) XGetDefault (dpy, "", "");
+ }
+ if (XrmQGetResource (XrmGetDatabase(dpy), xrm_name, xrm_class,
+ &rep_type, &value) &&
+ rep_type == XrmPermStringToQuark("String")) {
+ cache->string_to_bitmap.bitmapFilePath =
+ split_path_string (value.addr);
+ }
+ }
+ file_paths = cache->string_to_bitmap.bitmapFilePath;
+ }
+
+ /*
+ * Search order:
+ * 1. name if it begins with / or ./
+ * 2. "each prefix in file_paths"/name
+ * 3. BITMAPDIR/name
+ * 4. name if didn't begin with / or .
+ */
+
+ for (i = 1; i <= 4; i++) {
+ char *fn = filename;
+ Pixmap pixmap;
+ unsigned char *data;
+
+ switch (i) {
+ case 1:
+#ifndef __UNIXOS2__
+ if (!(name[0] == '/' || ((name[0] == '.') && name[1] == '/')))
+#else
+ if (!(name[0] == '/' || (name[0] == '.' && name[1] == '/') ||
+ (isalpha(name[0]) && name[1] == ':')))
+#endif
+ continue;
+ fn = (char *) name;
+ try_plain_name = False;
+ break;
+ case 2:
+ if (file_paths && *file_paths) {
+ XmuSnprintf(filename, sizeof(filename),
+ "%s/%s", *file_paths, name);
+ file_paths++;
+ i--;
+ break;
+ }
+ continue;
+ case 3:
+ XmuSnprintf(filename, sizeof(filename), "%s/%s", BITMAPDIR, name);
+ break;
+ case 4:
+ if (!try_plain_name) continue;
+ fn = (char *) name;
+ break;
+ }
+
+ data = NULL;
+ pixmap = None;
+#ifdef __UNIXOS2__
+ fn = (char*)__XOS2RedirRoot(fn);
+#endif
+ if (XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy, root, (char *) data,
+ width, height,
+ fore, back, depth);
+ XFree ((char *)data);
+ }
+
+ if (pixmap) {
+ if (widthp) *widthp = (int)width;
+ if (heightp) *heightp = (int)height;
+ if (xhotp) *xhotp = xhot;
+ if (yhotp) *yhotp = yhot;
+ if (srcname && srcnamelen > 0) {
+ strncpy (srcname, fn, srcnamelen - 1);
+ srcname[srcnamelen - 1] = '\0';
+ }
+ return pixmap;
+ }
+ }
+
+ return None;
+}
+
+
+/*
+ * split_path_string - split a colon-separated list into its constituent
+ * parts; to release, free list[0] and list.
+ */
+static char **
+split_path_string(register char *src)
+{
+ int nelems = 1;
+ register char *dst;
+ char **elemlist, **elem;
+
+ /* count the number of elements */
+ for (dst = src; *dst; dst++) if (*dst == ':') nelems++;
+
+ /* get memory for everything */
+ dst = (char *) malloc (dst - src + 1);
+ if (!dst) return NULL;
+ elemlist = (char **) calloc ((nelems + 1), sizeof (char *));
+ if (!elemlist) {
+ free (dst);
+ return NULL;
+ }
+
+ /* copy to new list and walk up nulling colons and setting list pointers */
+ strcpy (dst, src);
+ for (elem = elemlist, src = dst; *src; src++) {
+ if (*src == ':') {
+ *elem++ = dst;
+ *src = '\0';
+ dst = src + 1;
+ }
+ }
+ *elem = dst;
+
+ return elemlist;
+}
+
+
+void
+_XmuStringToBitmapInitCache(register XmuCvtCache *c)
+{
+ c->string_to_bitmap.bitmapFilePath = NULL;
+}
+
+void
+_XmuStringToBitmapFreeCache(register XmuCvtCache *c)
+{
+ if (c->string_to_bitmap.bitmapFilePath) {
+ if (c->string_to_bitmap.bitmapFilePath[0])
+ free (c->string_to_bitmap.bitmapFilePath[0]);
+ free ((char *) (c->string_to_bitmap.bitmapFilePath));
+ }
+}
diff --git a/libXmu/src/Lookup.c b/libXmu/src/Lookup.c index 75b546df4..f64d5d3db 100644 --- a/libXmu/src/Lookup.c +++ b/libXmu/src/Lookup.c @@ -1,276 +1,276 @@ -/* - -Copyright 1988, 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xmu/Lookup.h> - -#define XK_LATIN1 -#define XK_PUBLISHING -#include <X11/keysymdef.h> - -/* bit (1<<i) means character is in codeset i */ -static unsigned short _Xconst latin1[128] = - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x10ee, 0x0000, 0x1000, 0x1084, 0x102e, 0x1000, 0x1080, 0x108e, /* 10 */ - 0x108e, 0x1080, 0x0000, 0x1080, 0x1080, 0x10ee, 0x1000, 0x1008, - 0x108e, 0x1080, 0x1084, 0x1084, 0x108e, 0x1004, 0x1000, 0x1084, /* 11 */ - 0x100e, 0x1000, 0x0000, 0x1080, 0x1000, 0x1084, 0x1000, 0x0000, - 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 12 */ - 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004, - 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 13 */ - 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x000e, - 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 14 */ - 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004, - 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 15 */ - 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x0000}; - -/* bit (1<<i) means character is in codeset i */ -static unsigned short _Xconst latin2[128] = - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 10 */ - 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004, - 0x0000, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, /* 11 */ - 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */ - 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 13 */ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 14 */ - 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 15 */ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000c}; - -/* maps Cyrillic keysyms to 8859-5 */ -static unsigned char _Xconst cyrillic[128] = - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 10 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff, - 0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 11 */ - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, - 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 12 */ - 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, - 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 13 */ - 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, - 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 14 */ - 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, - 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 15 */ - 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca}; - -/* maps Greek keysyms to 8859-7 */ -static unsigned char _Xconst greek[128] = - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 10 */ - 0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf, - 0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 11 */ - 0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */ - 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */ - 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -#define sLatin1 (unsigned long)0 -#define sLatin2 (unsigned long)1 -#define sLatin3 (unsigned long)2 -#define sLatin4 (unsigned long)3 -#define sKana (unsigned long)4 -#define sX0201 (unsigned long)0x01000004 -#define sArabic (unsigned long)5 -#define sCyrillic (unsigned long)6 -#define sGreek (unsigned long)7 -#define sAPL (unsigned long)11 -#define sHebrew (unsigned long)12 - -int -XmuLookupString(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status, - unsigned long keysymSet) -{ - int count; - KeySym symbol; - unsigned long kset; - - kset = keysymSet & 0xffffff; - count = XLookupString(event, (char *)buffer, nbytes, &symbol, status); - if (keysym) *keysym = symbol; - if ((nbytes == 0) || (symbol == NoSymbol)) { - /* nothing */ - } else if ((count == 0) && ((symbol >> 8) == kset)) { - count = 1; - switch (keysymSet) { - case sKana: - buffer[0] = (symbol & 0xff); - if (buffer[0] == 0x7e) - count = 0; - break; - case sCyrillic: - buffer[0] = cyrillic[symbol & 0x7f]; - break; - case sGreek: - buffer[0] = greek[symbol & 0x7f]; - if (!buffer[0]) - count = 0; - break; - default: - buffer[0] = (symbol & 0xff); - break; - } - } else if ((keysymSet != 0) && (count == 1) && - (((unsigned char *)buffer)[0] == symbol) && - (symbol & 0x80) && - !(latin1[symbol & 0x7f] & (1 << kset))) { - if ((keysymSet == sHebrew) && (symbol == XK_multiply)) - buffer[0] = 0xaa; - else if ((keysymSet == sHebrew) && (symbol == XK_division)) - buffer[0] = 0xba; - else if ((keysymSet == sCyrillic) && (symbol == XK_section)) - buffer[0] = 0xfd; - else if ((keysymSet == sX0201) && (symbol == XK_yen)) - buffer[0] = 0x5c; - else - count = 0; - } else if (count != 0) { - if ((keysymSet == sX0201) && - ((symbol == XK_backslash) || (symbol == XK_asciitilde))) - count = 0; - } else if (((symbol >> 8) == sLatin2) && - (symbol & 0x80) && (latin2[symbol & 0x7f] & (1 << kset))) { - buffer[0] = (symbol & 0xff); - count = 1; - } else if ((keysymSet == sGreek) && - ((symbol == XK_leftsinglequotemark) || - (symbol == XK_rightsinglequotemark))) { - buffer[0] = symbol - (XK_leftsinglequotemark - 0xa1); - count = 1; - } - return count; -} - -/* produces ISO 8859-1 encoding plus ASCII control */ -int -XmuLookupLatin1(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XLookupString(event, (char *)buffer, nbytes, keysym, status); -} - -/* produces ISO 8859-2 encoding plus ASCII control */ -int -XmuLookupLatin2(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin2); -} - -/* produces ISO 8859-3 encoding plus ASCII control */ -int -XmuLookupLatin3(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin3); -} - -/* produces ISO 8859-4 encoding plus ASCII control */ -int -XmuLookupLatin4(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin4); -} - -/* produces ISO 8859-1 GL plus Katakana plus ASCII control */ -int -XmuLookupKana(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sKana); -} - -/* produces JIS X0201-1976 (8-bit) */ -int -XmuLookupJISX0201(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sX0201); -} - -/* produces ISO 8859-6 encoding plus ASCII control */ -int -XmuLookupArabic(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sArabic); -} - -/* produces ISO/IEC 8859-5 encoding plus ASCII control */ -int -XmuLookupCyrillic(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sCyrillic); -} - -/* produces ISO 8859-7 encoding plus ASCII control */ -int -XmuLookupGreek(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sGreek); -} - -/* XXX this character set needs work */ - -int -XmuLookupAPL(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sAPL); -} - -/* produces ISO 8859-8 encoding plus ASCII control */ -int -XmuLookupHebrew(register XKeyEvent *event, unsigned char *buffer, int nbytes, - KeySym *keysym, XComposeStatus *status) -{ - return XmuLookupString(event, buffer, nbytes, keysym, status, sHebrew); -} +/*
+
+Copyright 1988, 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xmu/Lookup.h>
+
+#define XK_LATIN1
+#define XK_PUBLISHING
+#include <X11/keysymdef.h>
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short _Xconst latin1[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x10ee, 0x0000, 0x1000, 0x1084, 0x102e, 0x1000, 0x1080, 0x108e, /* 10 */
+ 0x108e, 0x1080, 0x0000, 0x1080, 0x1080, 0x10ee, 0x1000, 0x1008,
+ 0x108e, 0x1080, 0x1084, 0x1084, 0x108e, 0x1004, 0x1000, 0x1084, /* 11 */
+ 0x100e, 0x1000, 0x0000, 0x1080, 0x1000, 0x1084, 0x1000, 0x0000,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 12 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 13 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x000e,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 14 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 15 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x0000};
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short _Xconst latin2[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 10 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, /* 11 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 13 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 14 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 15 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000c};
+
+/* maps Cyrillic keysyms to 8859-5 */
+static unsigned char _Xconst cyrillic[128] =
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 10 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff,
+ 0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 11 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf,
+ 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 12 */
+ 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
+ 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 13 */
+ 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
+ 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 14 */
+ 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
+ 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 15 */
+ 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca};
+
+/* maps Greek keysyms to 8859-7 */
+static unsigned char _Xconst greek[128] =
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 10 */
+ 0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf,
+ 0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 11 */
+ 0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
+ 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
+ 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+#define sLatin1 (unsigned long)0
+#define sLatin2 (unsigned long)1
+#define sLatin3 (unsigned long)2
+#define sLatin4 (unsigned long)3
+#define sKana (unsigned long)4
+#define sX0201 (unsigned long)0x01000004
+#define sArabic (unsigned long)5
+#define sCyrillic (unsigned long)6
+#define sGreek (unsigned long)7
+#define sAPL (unsigned long)11
+#define sHebrew (unsigned long)12
+
+int
+XmuLookupString(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status,
+ unsigned long keysymSet)
+{
+ int count;
+ KeySym symbol;
+ unsigned long kset;
+
+ kset = keysymSet & 0xffffff;
+ count = XLookupString(event, (char *)buffer, nbytes, &symbol, status);
+ if (keysym) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) {
+ /* nothing */
+ } else if ((count == 0) && ((symbol >> 8) == kset)) {
+ count = 1;
+ switch (keysymSet) {
+ case sKana:
+ buffer[0] = (symbol & 0xff);
+ if (buffer[0] == 0x7e)
+ count = 0;
+ break;
+ case sCyrillic:
+ buffer[0] = cyrillic[symbol & 0x7f];
+ break;
+ case sGreek:
+ buffer[0] = greek[symbol & 0x7f];
+ if (!buffer[0])
+ count = 0;
+ break;
+ default:
+ buffer[0] = (symbol & 0xff);
+ break;
+ }
+ } else if ((keysymSet != 0) && (count == 1) &&
+ (((unsigned char *)buffer)[0] == symbol) &&
+ (symbol & 0x80) &&
+ !(latin1[symbol & 0x7f] & (1 << kset))) {
+ if ((keysymSet == sHebrew) && (symbol == XK_multiply))
+ buffer[0] = 0xaa;
+ else if ((keysymSet == sHebrew) && (symbol == XK_division))
+ buffer[0] = 0xba;
+ else if ((keysymSet == sCyrillic) && (symbol == XK_section))
+ buffer[0] = 0xfd;
+ else if ((keysymSet == sX0201) && (symbol == XK_yen))
+ buffer[0] = 0x5c;
+ else
+ count = 0;
+ } else if (count != 0) {
+ if ((keysymSet == sX0201) &&
+ ((symbol == XK_backslash) || (symbol == XK_asciitilde)))
+ count = 0;
+ } else if (((symbol >> 8) == sLatin2) &&
+ (symbol & 0x80) && (latin2[symbol & 0x7f] & (1 << kset))) {
+ buffer[0] = (symbol & 0xff);
+ count = 1;
+ } else if ((keysymSet == sGreek) &&
+ ((symbol == XK_leftsinglequotemark) ||
+ (symbol == XK_rightsinglequotemark))) {
+ buffer[0] = symbol - (XK_leftsinglequotemark - 0xa1);
+ count = 1;
+ }
+ return count;
+}
+
+/* produces ISO 8859-1 encoding plus ASCII control */
+int
+XmuLookupLatin1(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XLookupString(event, (char *)buffer, nbytes, keysym, status);
+}
+
+/* produces ISO 8859-2 encoding plus ASCII control */
+int
+XmuLookupLatin2(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin2);
+}
+
+/* produces ISO 8859-3 encoding plus ASCII control */
+int
+XmuLookupLatin3(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin3);
+}
+
+/* produces ISO 8859-4 encoding plus ASCII control */
+int
+XmuLookupLatin4(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin4);
+}
+
+/* produces ISO 8859-1 GL plus Katakana plus ASCII control */
+int
+XmuLookupKana(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sKana);
+}
+
+/* produces JIS X0201-1976 (8-bit) */
+int
+XmuLookupJISX0201(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sX0201);
+}
+
+/* produces ISO 8859-6 encoding plus ASCII control */
+int
+XmuLookupArabic(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sArabic);
+}
+
+/* produces ISO/IEC 8859-5 encoding plus ASCII control */
+int
+XmuLookupCyrillic(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sCyrillic);
+}
+
+/* produces ISO 8859-7 encoding plus ASCII control */
+int
+XmuLookupGreek(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sGreek);
+}
+
+/* XXX this character set needs work */
+
+int
+XmuLookupAPL(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sAPL);
+}
+
+/* produces ISO 8859-8 encoding plus ASCII control */
+int
+XmuLookupHebrew(register XKeyEvent *event, unsigned char *buffer, int nbytes,
+ KeySym *keysym, XComposeStatus *status)
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sHebrew);
+}
diff --git a/libXmu/src/LookupCmap.c b/libXmu/src/LookupCmap.c index 5756b83ec..0dc8aaaab 100644 --- a/libXmu/src/LookupCmap.c +++ b/libXmu/src/LookupCmap.c @@ -1,322 +1,322 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> -#include <stdlib.h> - -/* - * Prototypes - */ -static Status lookup(Display*, int, VisualID, Atom, XStandardColormap*, Bool); - -/* - * To create a standard colormap if one does not currently exist, or - * replace the currently existing standard colormap, use - * XmuLookupStandardColormap(). - * - * Given a screen, a visual, and a property, XmuLookupStandardColormap() - * will determine the best allocation for the property under the specified - * visual, and determine the whether to create a new colormap or to use - * the default colormap of the screen. It will call XmuStandardColormap() - * to create the standard colormap. - * - * If replace is true, any previous definition of the property will be - * replaced. If retain is true, the property and the colormap will be - * made permanent for the duration of the server session. However, - * pre-existing property definitions which are not replaced cannot be made - * permanent by a call to XmuLookupStandardColormap(); a request to retain - * resources pertains to newly created resources. - * - * Returns 0 on failure, non-zero on success. A request to create a - * standard colormap upon a visual which cannot support such a map is - * considered a failure. An example of this would be requesting any - * standard colormap property on a monochrome visual, or, requesting an - * RGB_BEST_MAP on a display whose colormap size is 16. - */ - -Status -XmuLookupStandardColormap(Display *dpy, int screen, VisualID visualid, - unsigned int depth, Atom property, - Bool replace, Bool retain) - /* - * dpy - specifies X server connection - * screen - specifies screen of display - * visualid - specifies the visual type - * depth - specifies the visual type - * property - a standard colormap property - * replace - specifies whether to replace - * retain - specifies whether to retain - */ -{ - Display *odpy; /* original display connection */ - XStandardColormap *colormap; - XVisualInfo vinfo_template, *vinfo; /* visual */ - long vinfo_mask; - unsigned long r_max, g_max, b_max; /* allocation */ - int count; - Colormap cmap; /* colormap ID */ - Status status = 0; - - - /* Match the requested visual */ - - vinfo_template.visualid = visualid; - vinfo_template.screen = screen; - vinfo_template.depth = depth; - vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask; - if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) == - NULL) - return 0; - - /* Monochrome visuals have no standard maps */ - - if (vinfo->colormap_size <= 2) { - XFree((char *) vinfo); - return 0; - } - - /* If the requested property already exists on this screen, and, - * if the replace flag has not been set to true, return success. - * lookup() will remove a pre-existing map if replace is true. - */ - - if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL, - replace) && !replace) { - XFree((char *) vinfo); - return 1; - } - - /* Determine the best allocation for this property under the requested - * visualid and depth, and determine whether or not to use the default - * colormap of the screen. - */ - - if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) { - XFree((char *) vinfo); - return 0; - } - - cmap = (property == XA_RGB_DEFAULT_MAP && - visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen))) - ? DefaultColormap(dpy, screen) : None; - - /* If retaining resources, open a new connection to the same server */ - - if (retain) { - odpy = dpy; - if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) { - XFree((char *) vinfo); - return 0; - } - } - - /* Create the standard colormap */ - - colormap = XmuStandardColormap(dpy, screen, visualid, depth, property, - cmap, r_max, g_max, b_max); - - /* Set the standard colormap property */ - - if (colormap) { - XGrabServer(dpy); - - if (lookup(dpy, screen, visualid, property, colormap, replace) && - !replace) { - /* Someone has defined the property since we last looked. - * Since we will not replace it, release our own resources. - * If this is the default map, our allocations will be freed - * when this connection closes. - */ - if (colormap->killid == ReleaseByFreeingColormap) - XFreeColormap(dpy, colormap->colormap); - } - else if (retain) { - XSetCloseDownMode(dpy, RetainPermanent); - } - XUngrabServer(dpy); - XFree((char *) colormap); - status = 1; - } - - if (retain) - XCloseDisplay(dpy); - XFree((char *) vinfo); - return status; -} - -/***************************************************************************/ - -/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP, - * the visualid is used to determine whether the indicated standard colormap - * exists. If the map exists and replace is true, delete the resources used - * by the map and remove the property. Return true if the map exists, - * or did exist and was deleted; return false if the map was not found. - * - * Note that this is not the way that a Status return is normally used. - * - * If new is not NULL, new points to an XStandardColormap structure which - * describes a standard colormap of the specified property. It will be made - * a standard colormap of the screen if none already exists, or if replace - * is true. - */ - -static Status -lookup(Display *dpy, int screen, VisualID visualid, Atom property, - XStandardColormap *cnew, Bool replace) - /* - * dpy - specifies display connection - * screen - specifies screen number - * visualid - specifies visualid for std map - * property - specifies colormap property name - * cnew - specifies a standard colormap - * replace - specifies whether to replace - */ -{ - register int i; - int count; - XStandardColormap *stdcmaps, *s; - Window win = RootWindow(dpy, screen); - - /* The property does not already exist */ - - if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) { - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - return 0; - } - - /* The property exists and is not describing the RGB_DEFAULT_MAP */ - - if (property != XA_RGB_DEFAULT_MAP) { - if (replace) { - XmuDeleteStandardColormap(dpy, screen, property); - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - } - XFree((char *)stdcmaps); - return 1; - } - - /* The property exists and is RGB_DEFAULT_MAP */ - - for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++) - ; - - /* No RGB_DEFAULT_MAP property matches the given visualid */ - - if (i == count) { - if (cnew) { - XStandardColormap *m, *maps; - - s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof - (XStandardColormap))); - - for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) { - m->colormap = maps->colormap; - m->red_max = maps->red_max; - m->red_mult = maps->red_mult; - m->green_max = maps->green_max; - m->green_mult = maps->green_mult; - m->blue_max = maps->blue_max; - m->blue_mult = maps->blue_mult; - m->base_pixel = maps->base_pixel; - m->visualid = maps->visualid; - m->killid = maps->killid; - } - m->colormap = cnew->colormap; - m->red_max = cnew->red_max; - m->red_mult = cnew->red_mult; - m->green_max = cnew->green_max; - m->green_mult = cnew->green_mult; - m->blue_max = cnew->blue_max; - m->blue_mult = cnew->blue_mult; - m->base_pixel = cnew->base_pixel; - m->visualid = cnew->visualid; - m->killid = cnew->killid; - - XSetRGBColormaps(dpy, win, s, ++count, property); - free((char *) s); - } - XFree((char *) stdcmaps); - return 0; - } - - /* Found an RGB_DEFAULT_MAP property with a matching visualid */ - - if (replace) { - /* Free old resources first - we may need them, particularly in - * the default colormap of the screen. However, because of this, - * it is possible that we will destroy the old resource and fail - * to create a new one if XmuStandardColormap() fails. - */ - - if (count == 1) { - XmuDeleteStandardColormap(dpy, screen, property); - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - } - else { - XStandardColormap *map; - - /* s still points to the matching standard colormap */ - - if (s->killid == ReleaseByFreeingColormap) { - if ((s->colormap != None) && - (s->colormap != DefaultColormap(dpy, screen))) - XFreeColormap(dpy, s->colormap); - } - else if (s->killid != None) - XKillClient(dpy, s->killid); - - map = (cnew) ? cnew : stdcmaps + --count; - - s->colormap = map->colormap; - s->red_max = map->red_max; - s->red_mult = map->red_mult; - s->green_max = map->green_max; - s->green_mult = map->green_mult; - s->blue_max = map->blue_max; - s->blue_mult = map->blue_mult; - s->visualid = map->visualid; - s->killid = map->killid; - - XSetRGBColormaps(dpy, win, stdcmaps, count, property); - } - } - XFree((char *) stdcmaps); - return 1; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+#include <stdlib.h>
+
+/*
+ * Prototypes
+ */
+static Status lookup(Display*, int, VisualID, Atom, XStandardColormap*, Bool);
+
+/*
+ * To create a standard colormap if one does not currently exist, or
+ * replace the currently existing standard colormap, use
+ * XmuLookupStandardColormap().
+ *
+ * Given a screen, a visual, and a property, XmuLookupStandardColormap()
+ * will determine the best allocation for the property under the specified
+ * visual, and determine the whether to create a new colormap or to use
+ * the default colormap of the screen. It will call XmuStandardColormap()
+ * to create the standard colormap.
+ *
+ * If replace is true, any previous definition of the property will be
+ * replaced. If retain is true, the property and the colormap will be
+ * made permanent for the duration of the server session. However,
+ * pre-existing property definitions which are not replaced cannot be made
+ * permanent by a call to XmuLookupStandardColormap(); a request to retain
+ * resources pertains to newly created resources.
+ *
+ * Returns 0 on failure, non-zero on success. A request to create a
+ * standard colormap upon a visual which cannot support such a map is
+ * considered a failure. An example of this would be requesting any
+ * standard colormap property on a monochrome visual, or, requesting an
+ * RGB_BEST_MAP on a display whose colormap size is 16.
+ */
+
+Status
+XmuLookupStandardColormap(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Atom property,
+ Bool replace, Bool retain)
+ /*
+ * dpy - specifies X server connection
+ * screen - specifies screen of display
+ * visualid - specifies the visual type
+ * depth - specifies the visual type
+ * property - a standard colormap property
+ * replace - specifies whether to replace
+ * retain - specifies whether to retain
+ */
+{
+ Display *odpy; /* original display connection */
+ XStandardColormap *colormap;
+ XVisualInfo vinfo_template, *vinfo; /* visual */
+ long vinfo_mask;
+ unsigned long r_max, g_max, b_max; /* allocation */
+ int count;
+ Colormap cmap; /* colormap ID */
+ Status status = 0;
+
+
+ /* Match the requested visual */
+
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
+ NULL)
+ return 0;
+
+ /* Monochrome visuals have no standard maps */
+
+ if (vinfo->colormap_size <= 2) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ /* If the requested property already exists on this screen, and,
+ * if the replace flag has not been set to true, return success.
+ * lookup() will remove a pre-existing map if replace is true.
+ */
+
+ if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
+ replace) && !replace) {
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ /* Determine the best allocation for this property under the requested
+ * visualid and depth, and determine whether or not to use the default
+ * colormap of the screen.
+ */
+
+ if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ cmap = (property == XA_RGB_DEFAULT_MAP &&
+ visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
+ ? DefaultColormap(dpy, screen) : None;
+
+ /* If retaining resources, open a new connection to the same server */
+
+ if (retain) {
+ odpy = dpy;
+ if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+ }
+
+ /* Create the standard colormap */
+
+ colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
+ cmap, r_max, g_max, b_max);
+
+ /* Set the standard colormap property */
+
+ if (colormap) {
+ XGrabServer(dpy);
+
+ if (lookup(dpy, screen, visualid, property, colormap, replace) &&
+ !replace) {
+ /* Someone has defined the property since we last looked.
+ * Since we will not replace it, release our own resources.
+ * If this is the default map, our allocations will be freed
+ * when this connection closes.
+ */
+ if (colormap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, colormap->colormap);
+ }
+ else if (retain) {
+ XSetCloseDownMode(dpy, RetainPermanent);
+ }
+ XUngrabServer(dpy);
+ XFree((char *) colormap);
+ status = 1;
+ }
+
+ if (retain)
+ XCloseDisplay(dpy);
+ XFree((char *) vinfo);
+ return status;
+}
+
+/***************************************************************************/
+
+/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP,
+ * the visualid is used to determine whether the indicated standard colormap
+ * exists. If the map exists and replace is true, delete the resources used
+ * by the map and remove the property. Return true if the map exists,
+ * or did exist and was deleted; return false if the map was not found.
+ *
+ * Note that this is not the way that a Status return is normally used.
+ *
+ * If new is not NULL, new points to an XStandardColormap structure which
+ * describes a standard colormap of the specified property. It will be made
+ * a standard colormap of the screen if none already exists, or if replace
+ * is true.
+ */
+
+static Status
+lookup(Display *dpy, int screen, VisualID visualid, Atom property,
+ XStandardColormap *cnew, Bool replace)
+ /*
+ * dpy - specifies display connection
+ * screen - specifies screen number
+ * visualid - specifies visualid for std map
+ * property - specifies colormap property name
+ * cnew - specifies a standard colormap
+ * replace - specifies whether to replace
+ */
+{
+ register int i;
+ int count;
+ XStandardColormap *stdcmaps, *s;
+ Window win = RootWindow(dpy, screen);
+
+ /* The property does not already exist */
+
+ if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ return 0;
+ }
+
+ /* The property exists and is not describing the RGB_DEFAULT_MAP */
+
+ if (property != XA_RGB_DEFAULT_MAP) {
+ if (replace) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ }
+ XFree((char *)stdcmaps);
+ return 1;
+ }
+
+ /* The property exists and is RGB_DEFAULT_MAP */
+
+ for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++)
+ ;
+
+ /* No RGB_DEFAULT_MAP property matches the given visualid */
+
+ if (i == count) {
+ if (cnew) {
+ XStandardColormap *m, *maps;
+
+ s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
+ (XStandardColormap)));
+
+ for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
+ m->colormap = maps->colormap;
+ m->red_max = maps->red_max;
+ m->red_mult = maps->red_mult;
+ m->green_max = maps->green_max;
+ m->green_mult = maps->green_mult;
+ m->blue_max = maps->blue_max;
+ m->blue_mult = maps->blue_mult;
+ m->base_pixel = maps->base_pixel;
+ m->visualid = maps->visualid;
+ m->killid = maps->killid;
+ }
+ m->colormap = cnew->colormap;
+ m->red_max = cnew->red_max;
+ m->red_mult = cnew->red_mult;
+ m->green_max = cnew->green_max;
+ m->green_mult = cnew->green_mult;
+ m->blue_max = cnew->blue_max;
+ m->blue_mult = cnew->blue_mult;
+ m->base_pixel = cnew->base_pixel;
+ m->visualid = cnew->visualid;
+ m->killid = cnew->killid;
+
+ XSetRGBColormaps(dpy, win, s, ++count, property);
+ free((char *) s);
+ }
+ XFree((char *) stdcmaps);
+ return 0;
+ }
+
+ /* Found an RGB_DEFAULT_MAP property with a matching visualid */
+
+ if (replace) {
+ /* Free old resources first - we may need them, particularly in
+ * the default colormap of the screen. However, because of this,
+ * it is possible that we will destroy the old resource and fail
+ * to create a new one if XmuStandardColormap() fails.
+ */
+
+ if (count == 1) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (cnew)
+ XSetRGBColormaps(dpy, win, cnew, 1, property);
+ }
+ else {
+ XStandardColormap *map;
+
+ /* s still points to the matching standard colormap */
+
+ if (s->killid == ReleaseByFreeingColormap) {
+ if ((s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ }
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+
+ map = (cnew) ? cnew : stdcmaps + --count;
+
+ s->colormap = map->colormap;
+ s->red_max = map->red_max;
+ s->red_mult = map->red_mult;
+ s->green_max = map->green_max;
+ s->green_mult = map->green_mult;
+ s->blue_max = map->blue_max;
+ s->blue_mult = map->blue_mult;
+ s->visualid = map->visualid;
+ s->killid = map->killid;
+
+ XSetRGBColormaps(dpy, win, stdcmaps, count, property);
+ }
+ }
+ XFree((char *) stdcmaps);
+ return 1;
+}
diff --git a/libXmu/src/Lower.c b/libXmu/src/Lower.c index 7522cc161..4f4fa403c 100644 --- a/libXmu/src/Lower.c +++ b/libXmu/src/Lower.c @@ -1,153 +1,153 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#define XK_LATIN1 -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/keysymdef.h> -#include <X11/Xmu/CharSet.h> -#include <X11/Xmu/SysUtil.h> - -#include <stdio.h> -#include <stdarg.h> - -/* - * ISO Latin-1 case conversion routine - */ -#define XmuTolower(c) \ -((c) >= XK_a && (c) <= XK_z ? \ - (c) : (c) >= XK_A && (c) <= XK_Z ? \ - (c) + (XK_a - XK_A) : (c) >= XK_Agrave && (c) <= XK_Odiaeresis ? \ - (c) + (XK_agrave - XK_Agrave) : (c) >= XK_Ooblique && (c) <= XK_Thorn ? \ - (c) + (XK_oslash - XK_Ooblique) : \ - (c)) - -#define XmuToupper(c) \ -((c) >= XK_A && (c) <= XK_Z ? \ - (c) : (c) >= XK_a && (c) <= XK_z ? \ - (c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \ - (c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \ - (c) - (XK_oslash - XK_Ooblique) : \ - (c)) - -/* - * Implementation - */ -void -XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src) -{ - register unsigned char *dest, *source; - - for (dest = (unsigned char *)dst, source = (unsigned char *)src; - *source; - source++, dest++) - *dest = XmuTolower(*source); - *dest = '\0'; -} - -void -XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src) -{ - register unsigned char *dest, *source; - - for (dest = (unsigned char *)dst, source = (unsigned char *)src; - *source; - source++, dest++) - *dest = XmuToupper(*source); - *dest = '\0'; -} - -int -XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second) -{ - register unsigned char *ap, *bp; - - for (ap = (unsigned char *)first, bp = (unsigned char *)second; - *ap && *bp && XmuTolower(*ap) == XmuTolower(*bp); - ap++, bp++) - ; - - return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp)); -} - -void -XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size) -{ - register unsigned char *dest, *source; - - if (size > 0) - { - for (dest = (unsigned char *)dst, source = (unsigned char *)src; - *source && size > 1; - source++, dest++, size--) - *dest = XmuTolower(*source); - *dest = '\0'; - } -} - -void -XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size) -{ - register unsigned char *dest, *source; - - if (size > 0) - { - for (dest = (unsigned char *)dst, source = (unsigned char *)src; - *source && size > 1; - source++, dest++, size--) - *dest = XmuToupper(*source); - *dest = '\0'; - } -} - -int -XmuSnprintf(char *str, int size, _Xconst char *fmt, ...) -{ - va_list ap; - int retval; - - if (size <= 0) - return (size); - - va_start(ap, fmt); - -#if 0 - retval = vsprintf(str, fmt, ap); - if (retval >= size) - { - fprintf(stderr, "WARNING: buffer overflow detected!\n"); - fflush(stderr); - abort(); - } -#else - retval = vsnprintf(str, size, fmt, ap); -#endif - - va_end(ap); - - return (retval); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define XK_LATIN1
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/keysymdef.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+
+/*
+ * ISO Latin-1 case conversion routine
+ */
+#define XmuTolower(c) \
+((c) >= XK_a && (c) <= XK_z ? \
+ (c) : (c) >= XK_A && (c) <= XK_Z ? \
+ (c) + (XK_a - XK_A) : (c) >= XK_Agrave && (c) <= XK_Odiaeresis ? \
+ (c) + (XK_agrave - XK_Agrave) : (c) >= XK_Ooblique && (c) <= XK_Thorn ? \
+ (c) + (XK_oslash - XK_Ooblique) : \
+ (c))
+
+#define XmuToupper(c) \
+((c) >= XK_A && (c) <= XK_Z ? \
+ (c) : (c) >= XK_a && (c) <= XK_z ? \
+ (c) - (XK_a - XK_A) : (c) >= XK_agrave && (c) <= XK_odiaeresis ? \
+ (c) - (XK_agrave - XK_Agrave) : (c) >= XK_oslash && (c) <= XK_thorn ? \
+ (c) - (XK_oslash - XK_Ooblique) : \
+ (c))
+
+/*
+ * Implementation
+ */
+void
+XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source;
+ source++, dest++)
+ *dest = XmuTolower(*source);
+ *dest = '\0';
+}
+
+void
+XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source;
+ source++, dest++)
+ *dest = XmuToupper(*source);
+ *dest = '\0';
+}
+
+int
+XmuCompareISOLatin1(_Xconst char *first, _Xconst char *second)
+{
+ register unsigned char *ap, *bp;
+
+ for (ap = (unsigned char *)first, bp = (unsigned char *)second;
+ *ap && *bp && XmuTolower(*ap) == XmuTolower(*bp);
+ ap++, bp++)
+ ;
+
+ return ((int)XmuTolower(*ap) - (int)XmuTolower(*bp));
+}
+
+void
+XmuNCopyISOLatin1Lowered(char *dst, _Xconst char *src, register int size)
+{
+ register unsigned char *dest, *source;
+
+ if (size > 0)
+ {
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source && size > 1;
+ source++, dest++, size--)
+ *dest = XmuTolower(*source);
+ *dest = '\0';
+ }
+}
+
+void
+XmuNCopyISOLatin1Uppered(char *dst, _Xconst char *src, register int size)
+{
+ register unsigned char *dest, *source;
+
+ if (size > 0)
+ {
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source && size > 1;
+ source++, dest++, size--)
+ *dest = XmuToupper(*source);
+ *dest = '\0';
+ }
+}
+
+int
+XmuSnprintf(char *str, int size, _Xconst char *fmt, ...)
+{
+ va_list ap;
+ int retval;
+
+ if (size <= 0)
+ return (size);
+
+ va_start(ap, fmt);
+
+#if 0
+ retval = vsprintf(str, fmt, ap);
+ if (retval >= size)
+ {
+ fprintf(stderr, "WARNING: buffer overflow detected!\n");
+ fflush(stderr);
+ abort();
+ }
+#else
+ retval = vsnprintf(str, size, fmt, ap);
+#endif
+
+ va_end(ap);
+
+ return (retval);
+}
diff --git a/libXmu/src/RdBitF.c b/libXmu/src/RdBitF.c index 9402159b3..1bc6ab042 100644 --- a/libXmu/src/RdBitF.c +++ b/libXmu/src/RdBitF.c @@ -1,401 +1,401 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * This file contains miscellaneous utility routines and is not part of the - * Xlib standard. - * - * Public entry points: - * - * XmuReadBitmapData read data from FILE descriptor - * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files - * and return data - * - * Note that this file and ../X/XRdBitF.c look very similar.... Keep them - * that way (but don't use common source code so that people can have one - * without the other). - */ - - -/* - * Based on an optimized version provided by Jim Becker, Auguest 5, 1988. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xos.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xlibint.h> -#include <stdio.h> -#include <ctype.h> -#include <X11/Xmu/Drawing.h> -#ifdef WIN32 -#include <X11/Xwindows.h> -#endif - -#define MAX_SIZE 255 - -/* - * Prototypes - */ -static void initHexTable(void); -static int NextInt(FILE*); - -/* shared data for the image read/parse logic */ -static short hexTable[256]; /* conversion value */ -static Bool initialized = False; /* easier to fill in at run time */ - - -/* - * Table index for the hex values. Initialized once, first time. - * Used for translation value or delimiter significance lookup. - */ -static void -initHexTable(void) -{ - /* - * We build the table at run time for several reasons: - * - * 1. portable to non-ASCII machines. - * 2. still reentrant since we set the init flag after setting table. - * 3. easier to extend. - * 4. less prone to bugs. - */ - hexTable['0'] = 0; hexTable['1'] = 1; - hexTable['2'] = 2; hexTable['3'] = 3; - hexTable['4'] = 4; hexTable['5'] = 5; - hexTable['6'] = 6; hexTable['7'] = 7; - hexTable['8'] = 8; hexTable['9'] = 9; - hexTable['A'] = 10; hexTable['B'] = 11; - hexTable['C'] = 12; hexTable['D'] = 13; - hexTable['E'] = 14; hexTable['F'] = 15; - hexTable['a'] = 10; hexTable['b'] = 11; - hexTable['c'] = 12; hexTable['d'] = 13; - hexTable['e'] = 14; hexTable['f'] = 15; - - /* delimiters of significance are flagged w/ negative value */ - hexTable[' '] = -1; hexTable[','] = -1; - hexTable['}'] = -1; hexTable['\n'] = -1; - hexTable['\t'] = -1; - - initialized = True; -} - -/* - * read next hex value in the input stream, return -1 if EOF - */ -static int -NextInt(FILE *fstream) -{ - int ch; - int value = 0; - int gotone = 0; - int done = 0; - - /* loop, accumulate hex value until find delimiter */ - /* skip any initial delimiters found in read stream */ - - while (!done) { - ch = getc(fstream); - if (ch == EOF) { - value = -1; - done++; - } else { - /* trim high bits, check type and accumulate */ - ch &= 0xff; - if (isascii(ch) && isxdigit(ch)) { - value = (value << 4) + hexTable[ch]; - gotone++; - } else if ((hexTable[ch]) < 0 && gotone) - done++; - } - } - return value; -} - - -/* - * The data returned by the following routine is always in left-most byte - * first and left-most bit first. If it doesn't return BitmapSuccess then - * its arguments won't have been touched. This routine should look as much - * like the Xlib routine XReadBitmapfile as possible. - */ -int -XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height, - unsigned char **datap, int *x_hot, int *y_hot) -{ - unsigned char *data = NULL; /* working variable */ - char line[MAX_SIZE]; /* input line from file */ - int size; /* number of bytes of data */ - char name_and_type[MAX_SIZE]; /* an input line */ - char *type; /* for parsing */ - int value; /* from an input line */ - int version10p; /* boolean, old format */ - int padding; /* to handle alignment */ - int bytes_per_line; /* per scanline of data */ - unsigned int ww = 0; /* width */ - unsigned int hh = 0; /* height */ - int hx = -1; /* x hotspot */ - int hy = -1; /* y hotspot */ - -#undef Xmalloc /* see MALLOC_0_RETURNS_NULL in Xlibint.h */ -#define Xmalloc(size) malloc(size) - - /* first time initialization */ - if (initialized == False) initHexTable(); - - /* error cleanup and return macro */ -#define RETURN(code) { if (data) free (data); return code; } - - while (fgets(line, MAX_SIZE, fstream)) { - if (strlen(line) == MAX_SIZE-1) { - RETURN (BitmapFileInvalid); - } - if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (!strcmp("width", type)) - ww = (unsigned int) value; - if (!strcmp("height", type)) - hh = (unsigned int) value; - if (!strcmp("hot", type)) { - if (type-- == name_and_type || type-- == name_and_type) - continue; - if (!strcmp("x_hot", type)) - hx = value; - if (!strcmp("y_hot", type)) - hy = value; - } - continue; - } - - if (sscanf(line, "static short %s = {", name_and_type) == 1) - version10p = 1; - else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) - version10p = 0; - else if (sscanf(line, "static char %s = {", name_and_type) == 1) - version10p = 0; - else - continue; - - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (strcmp("bits[]", type)) - continue; - - if (!ww || !hh) - RETURN (BitmapFileInvalid); - - if ((ww % 16) && ((ww % 16) < 9) && version10p) - padding = 1; - else - padding = 0; - - bytes_per_line = (ww+7)/8 + padding; - - size = bytes_per_line * hh; - data = (unsigned char *) Xmalloc ((unsigned int) size); - if (!data) - RETURN (BitmapNoMemory); - - if (version10p) { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; (bytes += 2)) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *(ptr++) = value; - if (!padding || ((bytes+2) % bytes_per_line)) - *(ptr++) = value >> 8; - } - } else { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *ptr=value; - } - } - break; - } /* end while */ - - if (data == NULL) { - RETURN (BitmapFileInvalid); - } - - *datap = data; - data = NULL; - *width = ww; - *height = hh; - if (x_hot) *x_hot = hx; - if (y_hot) *y_hot = hy; - - RETURN (BitmapSuccess); -} - -#if defined(WIN32) -static int -access_file(char *path, char *pathbuf, int len_pathbuf, char **pathret) -{ - if (access (path, F_OK) == 0) { - if (strlen (path) < len_pathbuf) - *pathret = pathbuf; - else - *pathret = malloc (strlen (path) + 1); - if (*pathret) { - strcpy (*pathret, path); - return 1; - } - } - return 0; -} - -static int -AccessFile(char *path, char *pathbuf, int len_pathbuf, char **pathret) -{ -#ifndef MAX_PATH -#define MAX_PATH 512 -#endif - - unsigned long drives; - int i, len; - char* drive; - char buf[MAX_PATH]; - char* bufp; - - /* just try the "raw" name first and see if it works */ - if (access_file (path, pathbuf, len_pathbuf, pathret)) - return 1; - - /* try the places set in the environment */ - drive = getenv ("_XBASEDRIVE"); -#ifdef __UNIXOS2__ - if (!drive) - drive = getenv ("X11ROOT"); -#endif - if (!drive) - drive = "C:"; - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = malloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) free (bufp); - return 1; - } - -#ifndef __UNIXOS2__ - /* one last place to look */ - drive = getenv ("HOMEDRIVE"); - if (drive) { - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = malloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) free (bufp); - return 1; - } - } - - /* does OS/2 (with or with gcc-emx) have getdrives? */ - /* tried everywhere else, go fishing */ -#define C_DRIVE ('C' - 'A') -#define Z_DRIVE ('Z' - 'A') - drives = _getdrives (); - for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */ - if ((1 << i) & drives) { - len = 2 + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = malloc (len + 1); - *bufp = 'A' + i; - *(bufp + 1) = ':'; - *(bufp + 2) = '\0'; - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) free (bufp); - return 1; - } - } - } -#endif - return 0; -} - -FILE * -fopen_file(char *path, char *mode) -{ - char buf[MAX_PATH]; - char* bufp; - void* ret = NULL; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - if (AccessFile (path, buf, MAX_PATH, &bufp)) - ret = fopen (bufp, mode); - - (void) SetErrorMode (olderror); - - if (bufp != buf) free (bufp); - - return ret; -} - -#else -#define fopen_file fopen -#endif - - -int -XmuReadBitmapDataFromFile(_Xconst char *filename, unsigned int *width, - unsigned int *height, unsigned char **datap, - int *x_hot, int *y_hot) -{ - FILE *fstream; - int status; - -#ifdef __UNIXOS2__ - filename = __XOS2RedirRoot(filename); -#endif - if ((fstream = fopen_file (filename, "r")) == NULL) { - return BitmapOpenFailed; - } - status = XmuReadBitmapData(fstream, width, height, datap, x_hot, y_hot); - fclose (fstream); - return status; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ *
+ * Public entry points:
+ *
+ * XmuReadBitmapData read data from FILE descriptor
+ * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
+ * and return data
+ *
+ * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
+ * that way (but don't use common source code so that people can have one
+ * without the other).
+ */
+
+
+/*
+ * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xlibint.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/Xmu/Drawing.h>
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#endif
+
+#define MAX_SIZE 255
+
+/*
+ * Prototypes
+ */
+static void initHexTable(void);
+static int NextInt(FILE*);
+
+/* shared data for the image read/parse logic */
+static short hexTable[256]; /* conversion value */
+static Bool initialized = False; /* easier to fill in at run time */
+
+
+/*
+ * Table index for the hex values. Initialized once, first time.
+ * Used for translation value or delimiter significance lookup.
+ */
+static void
+initHexTable(void)
+{
+ /*
+ * We build the table at run time for several reasons:
+ *
+ * 1. portable to non-ASCII machines.
+ * 2. still reentrant since we set the init flag after setting table.
+ * 3. easier to extend.
+ * 4. less prone to bugs.
+ */
+ hexTable['0'] = 0; hexTable['1'] = 1;
+ hexTable['2'] = 2; hexTable['3'] = 3;
+ hexTable['4'] = 4; hexTable['5'] = 5;
+ hexTable['6'] = 6; hexTable['7'] = 7;
+ hexTable['8'] = 8; hexTable['9'] = 9;
+ hexTable['A'] = 10; hexTable['B'] = 11;
+ hexTable['C'] = 12; hexTable['D'] = 13;
+ hexTable['E'] = 14; hexTable['F'] = 15;
+ hexTable['a'] = 10; hexTable['b'] = 11;
+ hexTable['c'] = 12; hexTable['d'] = 13;
+ hexTable['e'] = 14; hexTable['f'] = 15;
+
+ /* delimiters of significance are flagged w/ negative value */
+ hexTable[' '] = -1; hexTable[','] = -1;
+ hexTable['}'] = -1; hexTable['\n'] = -1;
+ hexTable['\t'] = -1;
+
+ initialized = True;
+}
+
+/*
+ * read next hex value in the input stream, return -1 if EOF
+ */
+static int
+NextInt(FILE *fstream)
+{
+ int ch;
+ int value = 0;
+ int gotone = 0;
+ int done = 0;
+
+ /* loop, accumulate hex value until find delimiter */
+ /* skip any initial delimiters found in read stream */
+
+ while (!done) {
+ ch = getc(fstream);
+ if (ch == EOF) {
+ value = -1;
+ done++;
+ } else {
+ /* trim high bits, check type and accumulate */
+ ch &= 0xff;
+ if (isascii(ch) && isxdigit(ch)) {
+ value = (value << 4) + hexTable[ch];
+ gotone++;
+ } else if ((hexTable[ch]) < 0 && gotone)
+ done++;
+ }
+ }
+ return value;
+}
+
+
+/*
+ * The data returned by the following routine is always in left-most byte
+ * first and left-most bit first. If it doesn't return BitmapSuccess then
+ * its arguments won't have been touched. This routine should look as much
+ * like the Xlib routine XReadBitmapfile as possible.
+ */
+int
+XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height,
+ unsigned char **datap, int *x_hot, int *y_hot)
+{
+ unsigned char *data = NULL; /* working variable */
+ char line[MAX_SIZE]; /* input line from file */
+ int size; /* number of bytes of data */
+ char name_and_type[MAX_SIZE]; /* an input line */
+ char *type; /* for parsing */
+ int value; /* from an input line */
+ int version10p; /* boolean, old format */
+ int padding; /* to handle alignment */
+ int bytes_per_line; /* per scanline of data */
+ unsigned int ww = 0; /* width */
+ unsigned int hh = 0; /* height */
+ int hx = -1; /* x hotspot */
+ int hy = -1; /* y hotspot */
+
+#undef Xmalloc /* see MALLOC_0_RETURNS_NULL in Xlibint.h */
+#define Xmalloc(size) malloc(size)
+
+ /* first time initialization */
+ if (initialized == False) initHexTable();
+
+ /* error cleanup and return macro */
+#define RETURN(code) { if (data) free (data); return code; }
+
+ while (fgets(line, MAX_SIZE, fstream)) {
+ if (strlen(line) == MAX_SIZE-1) {
+ RETURN (BitmapFileInvalid);
+ }
+ if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (!strcmp("width", type))
+ ww = (unsigned int) value;
+ if (!strcmp("height", type))
+ hh = (unsigned int) value;
+ if (!strcmp("hot", type)) {
+ if (type-- == name_and_type || type-- == name_and_type)
+ continue;
+ if (!strcmp("x_hot", type))
+ hx = value;
+ if (!strcmp("y_hot", type))
+ hy = value;
+ }
+ continue;
+ }
+
+ if (sscanf(line, "static short %s = {", name_and_type) == 1)
+ version10p = 1;
+ else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
+ version10p = 0;
+ else if (sscanf(line, "static char %s = {", name_and_type) == 1)
+ version10p = 0;
+ else
+ continue;
+
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (strcmp("bits[]", type))
+ continue;
+
+ if (!ww || !hh)
+ RETURN (BitmapFileInvalid);
+
+ if ((ww % 16) && ((ww % 16) < 9) && version10p)
+ padding = 1;
+ else
+ padding = 0;
+
+ bytes_per_line = (ww+7)/8 + padding;
+
+ size = bytes_per_line * hh;
+ data = (unsigned char *) Xmalloc ((unsigned int) size);
+ if (!data)
+ RETURN (BitmapNoMemory);
+
+ if (version10p) {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *(ptr++) = value;
+ if (!padding || ((bytes+2) % bytes_per_line))
+ *(ptr++) = value >> 8;
+ }
+ } else {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *ptr=value;
+ }
+ }
+ break;
+ } /* end while */
+
+ if (data == NULL) {
+ RETURN (BitmapFileInvalid);
+ }
+
+ *datap = data;
+ data = NULL;
+ *width = ww;
+ *height = hh;
+ if (x_hot) *x_hot = hx;
+ if (y_hot) *y_hot = hy;
+
+ RETURN (BitmapSuccess);
+}
+
+#if defined(WIN32)
+static int
+access_file(_Xconst char *path, char *pathbuf, int len_pathbuf, char **pathret)
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = malloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
+AccessFile(_Xconst char *path, char *pathbuf, int len_pathbuf, char **pathret)
+{
+#ifndef MAX_PATH
+#define MAX_PATH 512
+#endif
+
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = malloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+FILE *
+fopen_file(_Xconst char *path, char *mode)
+{
+ char buf[MAX_PATH];
+ char* bufp=buf;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) free (bufp);
+
+ return ret;
+}
+
+#else
+#define fopen_file fopen
+#endif
+
+
+int
+XmuReadBitmapDataFromFile(_Xconst char *filename, unsigned int *width,
+ unsigned int *height, unsigned char **datap,
+ int *x_hot, int *y_hot)
+{
+ FILE *fstream;
+ int status;
+
+#ifdef __UNIXOS2__
+ filename = __XOS2RedirRoot(filename);
+#endif
+ if ((fstream = fopen_file (filename, "r")) == NULL) {
+ return BitmapOpenFailed;
+ }
+ status = XmuReadBitmapData(fstream, width, height, datap, x_hot, y_hot);
+ fclose (fstream);
+ return status;
+}
diff --git a/libXmu/src/ScrOfWin.c b/libXmu/src/ScrOfWin.c index b8fc09ad9..97cda3259 100644 --- a/libXmu/src/ScrOfWin.c +++ b/libXmu/src/ScrOfWin.c @@ -1,57 +1,57 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xmu/WinUtil.h> - -Screen * -XmuScreenOfWindow(Display *dpy, Window w) -{ - register int i; - Window root; - int x, y; /* dummy variables */ - unsigned int width, height, bw, depth; /* dummy variables */ - - if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height, - &bw, &depth)) { - return NULL; - } - for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */ - if (root == RootWindow (dpy, i)) { - return ScreenOfDisplay (dpy, i); - } - } - return NULL; -} - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/WinUtil.h>
+
+Screen *
+XmuScreenOfWindow(Display *dpy, Window w)
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth)) {
+ return NULL;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
diff --git a/libXmu/src/ShapeWidg.c b/libXmu/src/ShapeWidg.c index bb8c4fbb3..34149b37b 100644 --- a/libXmu/src/ShapeWidg.c +++ b/libXmu/src/ShapeWidg.c @@ -1,248 +1,248 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/IntrinsicP.h> -#include <X11/extensions/shape.h> -#include "Converters.h" -#include "Drawing.h" -#include "Misc.h" - -/* - * Prototypes - */ -static void ShapeEllipseOrRoundedRectangle(Widget, Bool, int, int); -static void ShapeError(Widget); -static void ShapeOval(Widget); -static void ShapeRectangle(Widget); - -/* - * Implementation - */ -Boolean -XmuReshapeWidget(Widget w, int shape_style, - int corner_width, int corner_height) -{ - switch (shape_style) - { - case XmuShapeRectangle: - ShapeRectangle(w); - break; - case XmuShapeOval: - ShapeOval(w); - break; - case XmuShapeEllipse: - case XmuShapeRoundedRectangle: - ShapeEllipseOrRoundedRectangle(w, shape_style == XmuShapeEllipse, - corner_width, corner_height); - break; - default: - ShapeError(w); - return (False); - } - return (True); -} - -static void -ShapeError(Widget w) -{ - String params[1]; - Cardinal num_params = 1; - - params[0] = XtName(w); - XtAppWarningMsg(XtWidgetToApplicationContext(w), - "shapeUnknown", "xmuReshapeWidget", "XmuLibrary", - "Unsupported shape style for Command widget \"%s\"", - params, &num_params); -} - -static void -ShapeRectangle(Widget w) -{ - XShapeCombineMask(XtDisplay(w), XtWindow(w), - ShapeBounding, 0, 0, None, ShapeSet); - XShapeCombineMask(XtDisplay(w), XtWindow(w), - ShapeClip, 0, 0, None, ShapeSet); -} - -/* - * Function: - * ShapeOval - * - * Parameters: - * w - widget to be reshaped - * - * Description: - * Reshapes a widget to a oval format. - * - * Notes: - * X11R6.3 behaviour changed. Now if the height is larger than the - * width, this function inverts the sense of the oval, instead of - * fallbacking to ellipse. - */ -static void -ShapeOval(Widget w) -{ - Display *dpy = XtDisplay(w); - int width = w->core.width; - int height = w->core.height; - Pixmap p; - XGCValues values; - GC gc; - int rad; - - if (width < 3 || height < 3) - return; - width += w->core.border_width << 1; - height += w->core.border_width << 1; - - p = XCreatePixmap(dpy, XtWindow(w), width, height, 1); - values.foreground = 0; - values.background = 1; - values.cap_style = CapRound; - values.line_width = Min(width, height); - gc = XCreateGC(dpy, p, - GCForeground | GCBackground | GCLineWidth | GCCapStyle, - &values); - XFillRectangle(dpy, p, gc, 0, 0, width, height); - XSetForeground(dpy, gc, 1); - - if (width < height) - { - rad = width >> 1; - XDrawLine(dpy, p, gc, rad, rad, rad, height - rad - 1); - } - else - { - rad = height >> 1; - XDrawLine(dpy, p, gc, rad, rad, width - rad - 1, rad); - } - XShapeCombineMask(dpy, XtWindow(w), ShapeBounding, - -(int)w->core.border_width, -(int)w->core.border_width, - p, ShapeSet); - if (w->core.border_width) - { - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, p, gc, 0, 0, width, height); - values.line_width = Min(w->core.width, w->core.height); - values.foreground = 1; - XChangeGC(dpy, gc, GCLineWidth | GCForeground, &values); - if (w->core.width < w->core.height) - { - rad = w->core.width >> 1; - XDrawLine(dpy, p, gc, rad, rad, rad, w->core.height - rad - 1); - } - else - { - rad = w->core.height >> 1; - XDrawLine(dpy, p, gc, rad, rad, w->core.width - rad - 1, rad); - } - XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet); - } - else - XShapeCombineMask(XtDisplay(w), XtWindow(w), - ShapeClip, 0, 0, None, ShapeSet); - - XFreePixmap(dpy, p); - XFreeGC(dpy, gc); -} - -/* - * Function: - * ShapeEllipseOrRoundedRectangle - * - * Parameters: - * w - widget to be reshaped - * ellipse - True if shape to ellise, rounded rectangle otherwise - * ew - horizontal radius of rounded rectangle - * eh - vertical radius of rouded rectangle - * - * Description: - * Based on the ellipse parameter, gives the widget a elliptical - * shape, or rounded rectangle shape. - * - * Notes: - * The GC is created with a line width of 2, what seens to draw the - * widget border correctly, if the width - height is not proportional. - */ -static void -ShapeEllipseOrRoundedRectangle(Widget w, Bool ellipse, int ew, int eh) -{ - Display *dpy = XtDisplay(w); - unsigned width = w->core.width; - unsigned height = w->core.height; - Pixmap p; - XGCValues values; - GC gc; - unsigned long mask; - - if (width < 3 || width < 3) - return; - width += w->core.border_width << 1; - height += w->core.border_width << 1; - - mask = GCForeground | GCLineWidth; - p = XCreatePixmap(dpy, XtWindow(w), width, height, 1); - - values.foreground = 0; - values.line_width = 2; - - gc = XCreateGC(dpy, p, mask, &values); - XFillRectangle(dpy, p, gc, 0, 0, width, height); - XSetForeground(dpy, gc, 1); - if (!ellipse) - XmuFillRoundedRectangle(dpy, p, gc, 1, 1, width - 2, height - 2, ew, eh); - else - { - XDrawArc(dpy, p, gc, 1, 1, width - 2, height - 2, 0, 360 * 64); - XFillArc(dpy, p, gc, 2, 2, width - 4, height - 4, 0, 360 * 64); - } - XShapeCombineMask(dpy, XtWindow(w), ShapeBounding, - -(int)w->core.border_width, -(int)w->core.border_width, - p, ShapeSet); - if (w->core.border_width) - { - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, p, gc, 0, 0, width, height); - XSetForeground(dpy, gc, 1); - if (!ellipse) - XmuFillRoundedRectangle(dpy, p, gc, 1, 1, - w->core.width - 2, w->core.height - 2, - ew, eh); - else - XFillArc(dpy, p, gc, 0, 0, w->core.width, w->core.height, - 0, 360 * 64); - XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet); - } - else - XShapeCombineMask(XtDisplay(w), XtWindow(w), - ShapeClip, 0, 0, None, ShapeSet); - - XFreePixmap(dpy, p); - XFreeGC(dpy, gc); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/extensions/shape.h>
+#include "Converters.h"
+#include "Drawing.h"
+#include "Misc.h"
+
+/*
+ * Prototypes
+ */
+static void ShapeEllipseOrRoundedRectangle(Widget, Bool, int, int);
+static void ShapeError(Widget);
+static void ShapeOval(Widget);
+static void ShapeRectangle(Widget);
+
+/*
+ * Implementation
+ */
+Boolean
+XmuReshapeWidget(Widget w, int shape_style,
+ int corner_width, int corner_height)
+{
+ switch (shape_style)
+ {
+ case XmuShapeRectangle:
+ ShapeRectangle(w);
+ break;
+ case XmuShapeOval:
+ ShapeOval(w);
+ break;
+ case XmuShapeEllipse:
+ case XmuShapeRoundedRectangle:
+ ShapeEllipseOrRoundedRectangle(w, shape_style == XmuShapeEllipse,
+ corner_width, corner_height);
+ break;
+ default:
+ ShapeError(w);
+ return (False);
+ }
+ return (True);
+}
+
+static void
+ShapeError(Widget w)
+{
+ String params[1];
+ Cardinal num_params = 1;
+
+ params[0] = XtName(w);
+ XtAppWarningMsg(XtWidgetToApplicationContext(w),
+ "shapeUnknown", "xmuReshapeWidget", "XmuLibrary",
+ "Unsupported shape style for Command widget \"%s\"",
+ params, &num_params);
+}
+
+static void
+ShapeRectangle(Widget w)
+{
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeBounding, 0, 0, None, ShapeSet);
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+}
+
+/*
+ * Function:
+ * ShapeOval
+ *
+ * Parameters:
+ * w - widget to be reshaped
+ *
+ * Description:
+ * Reshapes a widget to a oval format.
+ *
+ * Notes:
+ * X11R6.3 behaviour changed. Now if the height is larger than the
+ * width, this function inverts the sense of the oval, instead of
+ * fallbacking to ellipse.
+ */
+static void
+ShapeOval(Widget w)
+{
+ Display *dpy = XtDisplay(w);
+ int width = w->core.width;
+ int height = w->core.height;
+ Pixmap p;
+ XGCValues values;
+ GC gc;
+ int rad;
+
+ if (width < 3 || height < 3)
+ return;
+ width += w->core.border_width << 1;
+ height += w->core.border_width << 1;
+
+ p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
+ values.foreground = 0;
+ values.background = 1;
+ values.cap_style = CapRound;
+ values.line_width = Min(width, height);
+ gc = XCreateGC(dpy, p,
+ GCForeground | GCBackground | GCLineWidth | GCCapStyle,
+ &values);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+
+ if (width < height)
+ {
+ rad = width >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, rad, height - rad - 1);
+ }
+ else
+ {
+ rad = height >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, width - rad - 1, rad);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeBounding,
+ -(int)w->core.border_width, -(int)w->core.border_width,
+ p, ShapeSet);
+ if (w->core.border_width)
+ {
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ values.line_width = Min(w->core.width, w->core.height);
+ values.foreground = 1;
+ XChangeGC(dpy, gc, GCLineWidth | GCForeground, &values);
+ if (w->core.width < w->core.height)
+ {
+ rad = w->core.width >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, rad, w->core.height - rad - 1);
+ }
+ else
+ {
+ rad = w->core.height >> 1;
+ XDrawLine(dpy, p, gc, rad, rad, w->core.width - rad - 1, rad);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
+ }
+ else
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+
+ XFreePixmap(dpy, p);
+ XFreeGC(dpy, gc);
+}
+
+/*
+ * Function:
+ * ShapeEllipseOrRoundedRectangle
+ *
+ * Parameters:
+ * w - widget to be reshaped
+ * ellipse - True if shape to ellise, rounded rectangle otherwise
+ * ew - horizontal radius of rounded rectangle
+ * eh - vertical radius of rouded rectangle
+ *
+ * Description:
+ * Based on the ellipse parameter, gives the widget a elliptical
+ * shape, or rounded rectangle shape.
+ *
+ * Notes:
+ * The GC is created with a line width of 2, what seens to draw the
+ * widget border correctly, if the width - height is not proportional.
+ */
+static void
+ShapeEllipseOrRoundedRectangle(Widget w, Bool ellipse, int ew, int eh)
+{
+ Display *dpy = XtDisplay(w);
+ unsigned width = w->core.width;
+ unsigned height = w->core.height;
+ Pixmap p;
+ XGCValues values;
+ GC gc;
+ unsigned long mask;
+
+ if (width < 3 || width < 3)
+ return;
+ width += w->core.border_width << 1;
+ height += w->core.border_width << 1;
+
+ mask = GCForeground | GCLineWidth;
+ p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
+
+ values.foreground = 0;
+ values.line_width = 2;
+
+ gc = XCreateGC(dpy, p, mask, &values);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle(dpy, p, gc, 1, 1, width - 2, height - 2, ew, eh);
+ else
+ {
+ XDrawArc(dpy, p, gc, 1, 1, width - 2, height - 2, 0, 360 * 64);
+ XFillArc(dpy, p, gc, 2, 2, width - 4, height - 4, 0, 360 * 64);
+ }
+ XShapeCombineMask(dpy, XtWindow(w), ShapeBounding,
+ -(int)w->core.border_width, -(int)w->core.border_width,
+ p, ShapeSet);
+ if (w->core.border_width)
+ {
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, p, gc, 0, 0, width, height);
+ XSetForeground(dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle(dpy, p, gc, 1, 1,
+ w->core.width - 2, w->core.height - 2,
+ ew, eh);
+ else
+ XFillArc(dpy, p, gc, 0, 0, w->core.width, w->core.height,
+ 0, 360 * 64);
+ XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
+ }
+ else
+ XShapeCombineMask(XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet);
+
+ XFreePixmap(dpy, p);
+ XFreeGC(dpy, gc);
+}
diff --git a/libXmu/src/StdCmap.c b/libXmu/src/StdCmap.c index 5d2ce6160..8301d5ac4 100644 --- a/libXmu/src/StdCmap.c +++ b/libXmu/src/StdCmap.c @@ -1,233 +1,233 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -#define lowbit(x) ((x) & (~(x) + 1)) - -/* - * Prototypes - */ -/* argument restrictions */ -static Status valid_args(XVisualInfo*, unsigned long, unsigned long, - unsigned long, Atom); - -/* - * To create any one standard colormap, use XmuStandardColormap(). - * - * Create a standard colormap for the given screen, visualid, and visual - * depth, with the given red, green, and blue maximum values, with the - * given standard property name. Return a pointer to an XStandardColormap - * structure which describes the newly created colormap, upon success. - * Upon failure, return NULL. - * - * XmuStandardColormap() calls XmuCreateColormap() to create the map. - * - * Resources created by this function are not made permanent; that is the - * caller's responsibility. - */ - -XStandardColormap * -XmuStandardColormap(Display *dpy, int screen, VisualID visualid, - unsigned int depth, Atom property, Colormap cmap, - unsigned long red_max, unsigned long green_max, - unsigned long blue_max) - /* - * dpy - specifies X server connection - * screen - specifies display screen - * visualid - identifies the visual type - * depth - identifies the visual type - * property - a standard colormap property - * cmap - specifies colormap ID or None - * red_max, green_max, blue_max - allocations - */ -{ - XStandardColormap *stdcmap; - Status status; - XVisualInfo vinfo_template, *vinfo; - long vinfo_mask; - int n; - - /* Match the required visual information to an actual visual */ - vinfo_template.visualid = visualid; - vinfo_template.screen = screen; - vinfo_template.depth = depth; - vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask; - if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return NULL; - - /* Check the validity of the combination of visual characteristics, - * allocation, and colormap property. Create an XStandardColormap - * structure. - */ - - if (! valid_args(vinfo, red_max, green_max, blue_max, property) - || ((stdcmap = XAllocStandardColormap()) == NULL)) { - XFree((char *) vinfo); - return NULL; - } - - /* Fill in the XStandardColormap structure */ - - if (cmap == DefaultColormap(dpy, screen)) { - /* Allocating out of the default map, cannot use XFreeColormap() */ - Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1, - 0, 0, InputOnly, vinfo->visual, - (unsigned long) 0, - (XSetWindowAttributes *)NULL); - stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth); - XDestroyWindow(dpy, win); - stdcmap->colormap = cmap; - } else { - stdcmap->killid = ReleaseByFreeingColormap; - stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen), - vinfo->visual, AllocNone); - } - stdcmap->red_max = red_max; - stdcmap->green_max = green_max; - stdcmap->blue_max = blue_max; - if (property == XA_RGB_GRAY_MAP) - stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1; - else if (vinfo->class == TrueColor || vinfo->class == DirectColor) { - stdcmap->red_mult = lowbit(vinfo->red_mask); - stdcmap->green_mult = lowbit(vinfo->green_mask); - stdcmap->blue_mult = lowbit(vinfo->blue_mask); - } else { - stdcmap->red_mult = (red_max > 0) - ? (green_max + 1) * (blue_max + 1) : 0; - stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0; - stdcmap->blue_mult = (blue_max > 0) ? 1 : 0; - } - stdcmap->base_pixel = 0; /* base pixel may change */ - stdcmap->visualid = vinfo->visualid; - - /* Make the colormap */ - - status = XmuCreateColormap(dpy, stdcmap); - - /* Clean up */ - - XFree((char *) vinfo); - if (!status) { - - /* Free the colormap or the pixmap, if we created one */ - if (stdcmap->killid == ReleaseByFreeingColormap) - XFreeColormap(dpy, stdcmap->colormap); - else if (stdcmap->killid != None) - XFreePixmap(dpy, stdcmap->killid); - - XFree((char *) stdcmap); - return (XStandardColormap *) NULL; - } - return stdcmap; -} - -/****************************************************************************/ -static Status -valid_args(XVisualInfo *vinfo, unsigned long red_max, unsigned long green_max, - unsigned long blue_max, Atom property) - /* - * vinfo - specifies visual - * red_max, green_max, blue_max - specifies alloc - * property - specifies property name - */ -{ - unsigned long ncolors; /* number of colors requested */ - - /* Determine that the number of colors requested is <= map size */ - - if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) { - unsigned long mask; - - mask = vinfo->red_mask; - while (!(mask & 1)) - mask >>= 1; - if (red_max > mask) - return 0; - mask = vinfo->green_mask; - while (!(mask & 1)) - mask >>= 1; - if (green_max > mask) - return 0; - mask = vinfo->blue_mask; - while (!(mask & 1)) - mask >>= 1; - if (blue_max > mask) - return 0; - } else if (property == XA_RGB_GRAY_MAP) { - ncolors = red_max + green_max + blue_max + 1; - if (ncolors > vinfo->colormap_size) - return 0; - } else { - ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1); - if (ncolors > vinfo->colormap_size) - return 0; - } - - /* Determine that the allocation and visual make sense for the property */ - - switch (property) - { - case XA_RGB_DEFAULT_MAP: - if (red_max == 0 || green_max == 0 || blue_max == 0) - return 0; - break; - case XA_RGB_RED_MAP: - if (red_max == 0) - return 0; - break; - case XA_RGB_GREEN_MAP: - if (green_max == 0) - return 0; - break; - case XA_RGB_BLUE_MAP: - if (blue_max == 0) - return 0; - break; - case XA_RGB_BEST_MAP: - if (red_max == 0 || green_max == 0 || blue_max == 0) - return 0; - break; - case XA_RGB_GRAY_MAP: - if (red_max == 0 || blue_max == 0 || green_max == 0) - return 0; - break; - default: - return 0; - } - return 1; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/*
+ * Prototypes
+ */
+/* argument restrictions */
+static Status valid_args(XVisualInfo*, unsigned long, unsigned long,
+ unsigned long, Atom);
+
+/*
+ * To create any one standard colormap, use XmuStandardColormap().
+ *
+ * Create a standard colormap for the given screen, visualid, and visual
+ * depth, with the given red, green, and blue maximum values, with the
+ * given standard property name. Return a pointer to an XStandardColormap
+ * structure which describes the newly created colormap, upon success.
+ * Upon failure, return NULL.
+ *
+ * XmuStandardColormap() calls XmuCreateColormap() to create the map.
+ *
+ * Resources created by this function are not made permanent; that is the
+ * caller's responsibility.
+ */
+
+XStandardColormap *
+XmuStandardColormap(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Atom property, Colormap cmap,
+ unsigned long red_max, unsigned long green_max,
+ unsigned long blue_max)
+ /*
+ * dpy - specifies X server connection
+ * screen - specifies display screen
+ * visualid - identifies the visual type
+ * depth - identifies the visual type
+ * property - a standard colormap property
+ * cmap - specifies colormap ID or None
+ * red_max, green_max, blue_max - allocations
+ */
+{
+ XStandardColormap *stdcmap;
+ Status status;
+ XVisualInfo vinfo_template, *vinfo;
+ long vinfo_mask;
+ int n;
+
+ /* Match the required visual information to an actual visual */
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return NULL;
+
+ /* Check the validity of the combination of visual characteristics,
+ * allocation, and colormap property. Create an XStandardColormap
+ * structure.
+ */
+
+ if (! valid_args(vinfo, red_max, green_max, blue_max, property)
+ || ((stdcmap = XAllocStandardColormap()) == NULL)) {
+ XFree((char *) vinfo);
+ return NULL;
+ }
+
+ /* Fill in the XStandardColormap structure */
+
+ if (cmap == DefaultColormap(dpy, screen)) {
+ /* Allocating out of the default map, cannot use XFreeColormap() */
+ Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
+ 0, 0, InputOnly, vinfo->visual,
+ (unsigned long) 0,
+ (XSetWindowAttributes *)NULL);
+ stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
+ XDestroyWindow(dpy, win);
+ stdcmap->colormap = cmap;
+ } else {
+ stdcmap->killid = ReleaseByFreeingColormap;
+ stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
+ vinfo->visual, AllocNone);
+ }
+ stdcmap->red_max = red_max;
+ stdcmap->green_max = green_max;
+ stdcmap->blue_max = blue_max;
+ if (property == XA_RGB_GRAY_MAP)
+ stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
+ else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
+ stdcmap->red_mult = lowbit(vinfo->red_mask);
+ stdcmap->green_mult = lowbit(vinfo->green_mask);
+ stdcmap->blue_mult = lowbit(vinfo->blue_mask);
+ } else {
+ stdcmap->red_mult = (red_max > 0)
+ ? (green_max + 1) * (blue_max + 1) : 0;
+ stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
+ stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
+ }
+ stdcmap->base_pixel = 0; /* base pixel may change */
+ stdcmap->visualid = vinfo->visualid;
+
+ /* Make the colormap */
+
+ status = XmuCreateColormap(dpy, stdcmap);
+
+ /* Clean up */
+
+ XFree((char *) vinfo);
+ if (!status) {
+
+ /* Free the colormap or the pixmap, if we created one */
+ if (stdcmap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, stdcmap->colormap);
+ else if (stdcmap->killid != None)
+ XFreePixmap(dpy, stdcmap->killid);
+
+ XFree((char *) stdcmap);
+ return (XStandardColormap *) NULL;
+ }
+ return stdcmap;
+}
+
+/****************************************************************************/
+static Status
+valid_args(XVisualInfo *vinfo, unsigned long red_max, unsigned long green_max,
+ unsigned long blue_max, Atom property)
+ /*
+ * vinfo - specifies visual
+ * red_max, green_max, blue_max - specifies alloc
+ * property - specifies property name
+ */
+{
+ unsigned long ncolors; /* number of colors requested */
+
+ /* Determine that the number of colors requested is <= map size */
+
+ if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
+ unsigned long mask;
+
+ mask = vinfo->red_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (red_max > mask)
+ return 0;
+ mask = vinfo->green_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (green_max > mask)
+ return 0;
+ mask = vinfo->blue_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (blue_max > mask)
+ return 0;
+ } else if (property == XA_RGB_GRAY_MAP) {
+ ncolors = red_max + green_max + blue_max + 1;
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ } else {
+ ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ }
+
+ /* Determine that the allocation and visual make sense for the property */
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_RED_MAP:
+ if (red_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ if (green_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ if (blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BEST_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GRAY_MAP:
+ if (red_max == 0 || blue_max == 0 || green_max == 0)
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
diff --git a/libXmu/src/StrToBS.c b/libXmu/src/StrToBS.c index 0dd0be519..81ca312f0 100644 --- a/libXmu/src/StrToBS.c +++ b/libXmu/src/StrToBS.c @@ -1,145 +1,145 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include "Converters.h" -#include "CharSet.h" - -/* - * Prototypes - */ -static void InitializeQuarks(void); - -/* - * Initialization - */ -static XrmQuark QnotUseful, QwhenMapped, Qalways, Qdefault; -static Boolean haveQuarks; - -/* - * Implementation - */ -static void -InitializeQuarks(void) -{ - if (!haveQuarks) - { - char name[11]; - - XmuNCopyISOLatin1Lowered(name, XtEnotUseful, sizeof(name)); - QnotUseful = XrmStringToQuark(name); - XmuNCopyISOLatin1Lowered(name, XtEwhenMapped, sizeof(name)); - QwhenMapped = XrmStringToQuark(name); - XmuNCopyISOLatin1Lowered(name, XtEalways, sizeof(name)); - Qalways = XrmStringToQuark(name); - XmuNCopyISOLatin1Lowered(name, XtEdefault, sizeof(name)); - Qdefault = XrmStringToQuark(name); - haveQuarks = True; - } -} - -/*ARGSUSED*/ -void -XmuCvtStringToBackingStore(XrmValue *args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - XrmQuark q; - char name[11]; - static int backingStoreType; - - if (*num_args != 0) - XtWarning("String to BackingStore conversion needs no extra arguments"); - - InitializeQuarks(); - XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name)); - - q = XrmStringToQuark (name); - if (q == QnotUseful) - backingStoreType = NotUseful; - else if (q == QwhenMapped) - backingStoreType = WhenMapped; - else if (q == Qalways) - backingStoreType = Always; - else if (q == Qdefault) - backingStoreType = Always + WhenMapped + NotUseful; - else - { - XtStringConversionWarning((char *)fromVal->addr, XtRBackingStore); - return; - } - toVal->size = sizeof(int); - toVal->addr = (XPointer)&backingStoreType; -} - -/*ARGSUSED*/ -Boolean -XmuCvtBackingStoreToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal, - XtPointer *data) -{ - static String buffer; - Cardinal size; - - switch (*(int *)fromVal->addr) - { - case NotUseful: - buffer = XtEnotUseful; - break; - case WhenMapped: - buffer = XtEwhenMapped; - break; - case Always: - buffer = XtEalways; - break; - case (Always + WhenMapped + NotUseful): - buffer = XtEdefault; - break; - default: - XtWarning("Cannot convert BackingStore to String"); - toVal->addr = NULL; - toVal->size = 0; - return (False); - } - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size < size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = sizeof(String); - - return (True); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark QnotUseful, QwhenMapped, Qalways, Qdefault;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ char name[11];
+
+ XmuNCopyISOLatin1Lowered(name, XtEnotUseful, sizeof(name));
+ QnotUseful = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEwhenMapped, sizeof(name));
+ QwhenMapped = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEalways, sizeof(name));
+ Qalways = XrmStringToQuark(name);
+ XmuNCopyISOLatin1Lowered(name, XtEdefault, sizeof(name));
+ Qdefault = XrmStringToQuark(name);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToBackingStore(XrmValue *args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ XrmQuark q;
+ char name[11];
+ static int backingStoreType;
+
+ if (*num_args != 0)
+ XtWarning("String to BackingStore conversion needs no extra arguments");
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+
+ q = XrmStringToQuark (name);
+ if (q == QnotUseful)
+ backingStoreType = NotUseful;
+ else if (q == QwhenMapped)
+ backingStoreType = WhenMapped;
+ else if (q == Qalways)
+ backingStoreType = Always;
+ else if (q == Qdefault)
+ backingStoreType = Always + WhenMapped + NotUseful;
+ else
+ {
+ XtStringConversionWarning((char *)fromVal->addr, XtRBackingStore);
+ return;
+ }
+ toVal->size = sizeof(int);
+ toVal->addr = (XPointer)&backingStoreType;
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtBackingStoreToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(int *)fromVal->addr)
+ {
+ case NotUseful:
+ buffer = XtEnotUseful;
+ break;
+ case WhenMapped:
+ buffer = XtEwhenMapped;
+ break;
+ case Always:
+ buffer = XtEalways;
+ break;
+ case (Always + WhenMapped + NotUseful):
+ buffer = XtEdefault;
+ break;
+ default:
+ XtWarning("Cannot convert BackingStore to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/libXmu/src/StrToBmap.c b/libXmu/src/StrToBmap.c index 80df74bc7..0695982ad 100644 --- a/libXmu/src/StrToBmap.c +++ b/libXmu/src/StrToBmap.c @@ -1,147 +1,147 @@ -/* - -Copyright 1987, 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/*********************************************************** - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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 <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/StringDefs.h> -#include <X11/Xmu/Converters.h> -#include <X11/Xmu/Drawing.h> - - -/* - * XmuConvertStringToBitmap: - * - * creates a depth-1 Pixmap suitable for window manager icons. - * "string" represents a bitmap(1) filename which may be absolute, - * or relative to the global resource bitmapFilePath, class - * BitmapFilePath. If the resource is not defined, the default - * value is the build symbol BITMAPDIR. - * - * shares lots of code with XmuConvertStringToCursor. - * - * To use, include the following in your ClassInitialize procedure: - -static XtConvertArgRec screenConvertArg[] = { - {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen), sizeof(Screen *)} -}; - - XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap, - screenConvertArg, XtNumber(screenConvertArg)); - * - */ - -#define done(address, type) \ - { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; } - - -/*ARGSUSED*/ -void -XmuCvtStringToBitmap(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static Pixmap pixmap; /* static for cvt magic */ - char *name = (char *)fromVal->addr; - Screen *screen; - Display *dpy; - XrmDatabase db; - String fn; - unsigned int width, height; - int xhot, yhot; - unsigned char *data; - - if (*num_args != 1) - XtErrorMsg("wrongParameters","cvtStringToBitmap","XtToolkitError", - "String to pixmap conversion needs screen argument", - (String *)NULL, (Cardinal *)NULL); - - if (strcmp(name, "None") == 0) { - pixmap = None; - done(&pixmap, Pixmap); - return; - } - - if (strcmp(name, "ParentRelative") == 0) { - pixmap = ParentRelative; - done(&pixmap, Pixmap); - return; - } - - screen = *((Screen **) args[0].addr); - pixmap = XmuLocateBitmapFile (screen, name, - NULL, 0, NULL, NULL, NULL, NULL); - if (pixmap == None) { - dpy = DisplayOfScreen(screen); - db = XrmGetDatabase(dpy); - XrmSetDatabase(dpy, XtScreenDatabase(screen)); - fn = XtResolvePathname(dpy, "bitmaps", name, "", NULL, NULL, 0, NULL); - if (!fn) - fn = XtResolvePathname(dpy, "", name, ".xbm", NULL, NULL, 0, NULL); - XrmSetDatabase(dpy, db); - if (fn && - XmuReadBitmapDataFromFile (fn, &width, &height, &data, - &xhot, &yhot) == BitmapSuccess) { - pixmap = XCreatePixmapFromBitmapData (dpy, - RootWindowOfScreen(screen), - (char *) data, width, height, - 1, 0, 1); - XFree ((char *)data); - } - } - - if (pixmap != None) { - done (&pixmap, Pixmap); - } else { - XtStringConversionWarning (name, "Pixmap"); - return; - } -} - +/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/***********************************************************
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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 <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+
+
+/*
+ * XmuConvertStringToBitmap:
+ *
+ * creates a depth-1 Pixmap suitable for window manager icons.
+ * "string" represents a bitmap(1) filename which may be absolute,
+ * or relative to the global resource bitmapFilePath, class
+ * BitmapFilePath. If the resource is not defined, the default
+ * value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuConvertStringToCursor.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen), sizeof(Screen *)}
+};
+
+ XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+
+/*ARGSUSED*/
+void
+XmuCvtStringToBitmap(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Pixmap pixmap; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ Display *dpy;
+ XrmDatabase db;
+ String fn;
+ unsigned int width, height;
+ int xhot, yhot;
+ unsigned char *data;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToBitmap","XtToolkitError",
+ "String to pixmap conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (strcmp(name, "None") == 0) {
+ pixmap = None;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ if (strcmp(name, "ParentRelative") == 0) {
+ pixmap = ParentRelative;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ pixmap = XmuLocateBitmapFile (screen, name,
+ NULL, 0, NULL, NULL, NULL, NULL);
+ if (pixmap == None) {
+ dpy = DisplayOfScreen(screen);
+ db = XrmGetDatabase(dpy);
+ XrmSetDatabase(dpy, XtScreenDatabase(screen));
+ fn = XtResolvePathname(dpy, "bitmaps", name, "", NULL, NULL, 0, NULL);
+ if (!fn)
+ fn = XtResolvePathname(dpy, "", name, ".xbm", NULL, NULL, 0, NULL);
+ XrmSetDatabase(dpy, db);
+ if (fn &&
+ XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy,
+ RootWindowOfScreen(screen),
+ (char *) data, width, height,
+ 1, 0, 1);
+ XFree ((char *)data);
+ }
+ }
+
+ if (pixmap != None) {
+ done (&pixmap, Pixmap);
+ } else {
+ XtStringConversionWarning (name, "Pixmap");
+ return;
+ }
+}
+
diff --git a/libXmu/src/StrToCurs.c b/libXmu/src/StrToCurs.c index 4d72f80cb..9c998ffd0 100644 --- a/libXmu/src/StrToCurs.c +++ b/libXmu/src/StrToCurs.c @@ -1,351 +1,351 @@ -/* - -Copyright 1987, 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/*********************************************************** - -Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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 <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/StringDefs.h> -#include <X11/Xmu/Converters.h> -#include <X11/Xmu/Drawing.h> -#include <X11/Xmu/CurUtil.h> -#include <X11/Xmu/CharSet.h> - -#ifndef X_NOT_POSIX -#include <stdlib.h> -#ifdef _POSIX_SOURCE -#include <limits.h> -#else -#define _POSIX_SOURCE -#include <limits.h> -#undef _POSIX_SOURCE -#endif -#endif /* X_NOT_POSIX */ -#ifndef PATH_MAX -#ifdef WIN32 -#define PATH_MAX 512 -#else -#include <sys/param.h> -#endif -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif /* PATH_MAX */ - -/* Kludge source to avoid encountering broken shared library linkers - which insist on resolving references unused by the application, - and broken object file formats that don't correctly distinguish - references to procedures from references to data. - */ -#if defined(SUNSHLIB) || defined(SVR4) -#define XMU_KLUDGE -#endif - -/* - * XmuConvertStringToCursor: - * - * allows String to specify a standard cursor name (from cursorfont.h), a - * font name and glyph index of the form "FONT fontname index [[font] index]", - * or a bitmap file name (absolute, or relative to the global resource - * bitmapFilePath, class BitmapFilePath). If the resource is not - * defined, the default value is the build symbol BITMAPDIR. - * - * shares lots of code with XmuCvtStringToPixmap, but unfortunately - * can't use it as the hotspot info is lost. - * - * To use, include the following in your ClassInitialize procedure: - -static XtConvertArgRec screenConvertArg[] = { - {XtBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen), - sizeof(Screen *)} -}; - - XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor, - screenConvertArg, XtNumber(screenConvertArg)); - * - */ - -#define done(address, type) \ - { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; } - -#define FONTSPECIFIER "FONT " - -/*ARGSUSED*/ -void -XmuCvtStringToCursor(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static Cursor cursor; /* static for cvt magic */ - char *name = (char *)fromVal->addr; - Screen *screen; - register int i; - char maskname[PATH_MAX]; - Pixmap source, mask = 0; - /* XXX - make fg/bg resources */ - static XColor bgColor = {0, 0xffff, 0xffff, 0xffff}; - static XColor fgColor = {0, 0, 0, 0}; - int xhot, yhot; - int len; - - - if (*num_args != 1) - XtErrorMsg("wrongParameters","cvtStringToCursor","XtToolkitError", - "String to cursor conversion needs screen argument", - (String *)NULL, (Cardinal *)NULL); - - if (XmuCompareISOLatin1(name, "None") == 0) - { - cursor = None; - done(&cursor, Cursor); - return; - } - - screen = *((Screen **) args[0].addr); - - if (0 == strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER))) { - char source_name[PATH_MAX], mask_name[PATH_MAX]; - int source_char, mask_char, fields = 0; - Font source_font, mask_font; - XrmValue fromString, toFont; - XrmValue cvtArg; - Boolean success; - Display *dpy = DisplayOfScreen(screen); - char *strspec = NULL; - int strspeclen; -#ifdef XMU_KLUDGE - Cardinal num; -#endif - - strspeclen = strlen("FONT %s %d %s %d") + 21; - strspec = XtMalloc(strspeclen); - if (strspec != NULL) { - snprintf(strspec, strspeclen, "FONT %%%lds %%d %%%lds %%d", - (unsigned long)sizeof(source_name) - 1, - (unsigned long)sizeof(mask_name) - 1); - fields = sscanf(name, strspec, - source_name, &source_char, - mask_name, &mask_char); - XtFree(strspec); - } - if (fields < 2) { - XtStringConversionWarning(name, XtRCursor); - return; - } - - fromString.addr = source_name; - fromString.size = strlen(source_name) + 1; - toFont.addr = (XPointer) &source_font; - toFont.size = sizeof(Font); - cvtArg.addr = (XPointer) &dpy; - cvtArg.size = sizeof(Display *); - /* XXX using display of screen argument as message display */ -#ifdef XMU_KLUDGE - /* XXX Sacrifice caching */ - num = 1; - success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString, &toFont, - NULL); -#else - success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg, - (Cardinal)1, &fromString, &toFont, NULL); -#endif - if (!success) { - XtStringConversionWarning(name, XtRCursor); - return; - } - - switch (fields) { - case 2: /* defaulted mask font & char */ - mask_font = source_font; - mask_char = source_char; - break; - - case 3: /* defaulted mask font */ - mask_font = source_font; - mask_char = atoi(mask_name); - break; - - case 4: /* specified mask font & char */ - fromString.addr = mask_name; - fromString.size = strlen(mask_name) + 1; - toFont.addr = (XPointer) &mask_font; - toFont.size = sizeof(Font); - /* XXX using display of screen argument as message display */ -#ifdef XMU_KLUDGE - /* XXX Sacrifice caching */ - num = 1; - success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString, - &toFont, NULL); -#else - success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg, - (Cardinal)1, &fromString, &toFont, NULL); -#endif - if (!success) { - XtStringConversionWarning(name, XtRCursor); - return; - } - } - - cursor = XCreateGlyphCursor( DisplayOfScreen(screen), source_font, - mask_font, source_char, mask_char, - &fgColor, &bgColor ); - done(&cursor, Cursor); - return; - } - - i = XmuCursorNameToIndex (name); - if (i != -1) { - cursor = XCreateFontCursor (DisplayOfScreen(screen), i); - done(&cursor, Cursor); - return; - } - - if ((source = XmuLocateBitmapFile (screen, name, - maskname, (sizeof maskname) - 4, - NULL, NULL, &xhot, &yhot)) == None) { - XtStringConversionWarning (name, XtRCursor); - cursor = None; - done(&cursor, Cursor); - return; - } - len = strlen (maskname); - for (i = 0; i < 2; i++) { - strcpy (maskname + len, i == 0 ? "Mask" : "msk"); - if ((mask = XmuLocateBitmapFile (screen, maskname, NULL, 0, - NULL, NULL, NULL, NULL)) != None) - break; - } - - cursor = XCreatePixmapCursor( DisplayOfScreen(screen), source, mask, - &fgColor, &bgColor, xhot, yhot ); - XFreePixmap( DisplayOfScreen(screen), source ); - if (mask != None) XFreePixmap( DisplayOfScreen(screen), mask ); - - done(&cursor, Cursor); -} - -#define new_done(type, value) \ - { \ - if (toVal->addr != NULL) { \ - if (toVal->size < sizeof(type)) { \ - toVal->size = sizeof(type); \ - return False; \ - } \ - *(type*)(toVal->addr) = (value); \ - } \ - else { \ - static type static_val; \ - static_val = (value); \ - toVal->addr = (XPointer)&static_val; \ - } \ - toVal->size = sizeof(type); \ - return True; \ - } - -/* Function Name: XmuCvtStringToColorCursor - * Description: Converts a string into a colored cursor. - * Arguments: dpy - * args - an argument list (see below). - * num_args - number of elements in the argument list. - * fromVal - value to convert from. - * toVal - value to convert to. - * data - * Returns: True or False - */ - -/*ARGSUSED*/ -Boolean -XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal, - XtPointer *converter_data) -{ - Cursor cursor; - Screen *screen; - Pixel fg, bg; - Colormap c_map; - XColor colors[2]; - Cardinal number; - XrmValue ret_val; - - if (*num_args != 4) { - XtAppWarningMsg(XtDisplayToApplicationContext(dpy), - "wrongParameters","cvtStringToColorCursor","XmuError", - "String to color cursor conversion needs four arguments", - (String *)NULL, (Cardinal *)NULL); - return False; - } - - screen = *((Screen **) args[0].addr); - fg = *((Pixel *) args[1].addr); - bg = *((Pixel *) args[2].addr); - c_map = *((Colormap *) args[3].addr); - - number = 1; - XmuCvtStringToCursor(args, &number, fromVal, &ret_val); - - cursor = *((Cursor *) ret_val.addr); - - if (cursor == None || (fg == BlackPixelOfScreen(screen) - && bg == WhitePixelOfScreen(screen))) - new_done(Cursor, cursor); - - colors[0].pixel = fg; - colors[1].pixel = bg; - - XQueryColors (dpy, c_map, colors, 2); - XRecolorCursor(dpy, cursor, colors, colors + 1); - new_done(Cursor, cursor); -} - - - +/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/***********************************************************
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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 <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/CurUtil.h>
+#include <X11/Xmu/CharSet.h>
+
+#ifndef X_NOT_POSIX
+#include <stdlib.h>
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#ifndef PATH_MAX
+#ifdef WIN32
+#define PATH_MAX 512
+#else
+#include <sys/param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif /* PATH_MAX */
+
+/* Kludge source to avoid encountering broken shared library linkers
+ which insist on resolving references unused by the application,
+ and broken object file formats that don't correctly distinguish
+ references to procedures from references to data.
+ */
+#if defined(SUNSHLIB) || defined(SVR4)
+#define XMU_KLUDGE
+#endif
+
+/*
+ * XmuConvertStringToCursor:
+ *
+ * allows String to specify a standard cursor name (from cursorfont.h), a
+ * font name and glyph index of the form "FONT fontname index [[font] index]",
+ * or a bitmap file name (absolute, or relative to the global resource
+ * bitmapFilePath, class BitmapFilePath). If the resource is not
+ * defined, the default value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuCvtStringToPixmap, but unfortunately
+ * can't use it as the hotspot info is lost.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+};
+
+ XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+#define FONTSPECIFIER "FONT "
+
+/*ARGSUSED*/
+void
+XmuCvtStringToCursor(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Cursor cursor; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ register int i;
+ char maskname[PATH_MAX];
+ Pixmap source, mask = 0;
+ /* XXX - make fg/bg resources */
+ static XColor bgColor = {0, 0xffff, 0xffff, 0xffff};
+ static XColor fgColor = {0, 0, 0, 0};
+ int xhot, yhot;
+ int len;
+
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToCursor","XtToolkitError",
+ "String to cursor conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (XmuCompareISOLatin1(name, "None") == 0)
+ {
+ cursor = None;
+ done(&cursor, Cursor);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+
+ if (0 == strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER))) {
+ char source_name[PATH_MAX], mask_name[PATH_MAX];
+ int source_char, mask_char, fields = 0;
+ Font source_font, mask_font;
+ XrmValue fromString, toFont;
+ XrmValue cvtArg;
+ Boolean success;
+ Display *dpy = DisplayOfScreen(screen);
+ char *strspec = NULL;
+ int strspeclen;
+#ifdef XMU_KLUDGE
+ Cardinal num;
+#endif
+
+ strspeclen = strlen("FONT %s %d %s %d") + 21;
+ strspec = XtMalloc(strspeclen);
+ if (strspec != NULL) {
+ snprintf(strspec, strspeclen, "FONT %%%lds %%d %%%lds %%d",
+ (unsigned long)sizeof(source_name) - 1,
+ (unsigned long)sizeof(mask_name) - 1);
+ fields = sscanf(name, strspec,
+ source_name, &source_char,
+ mask_name, &mask_char);
+ XtFree(strspec);
+ }
+ if (fields < 2) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ fromString.addr = source_name;
+ fromString.size = strlen(source_name) + 1;
+ toFont.addr = (XPointer) &source_font;
+ toFont.size = sizeof(Font);
+ cvtArg.addr = (XPointer) &dpy;
+ cvtArg.size = sizeof(Display *);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString, &toFont,
+ NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ switch (fields) {
+ case 2: /* defaulted mask font & char */
+ mask_font = source_font;
+ mask_char = source_char;
+ break;
+
+ case 3: /* defaulted mask font */
+ mask_font = source_font;
+ mask_char = atoi(mask_name);
+ break;
+
+ case 4: /* specified mask font & char */
+ fromString.addr = mask_name;
+ fromString.size = strlen(mask_name) + 1;
+ toFont.addr = (XPointer) &mask_font;
+ toFont.size = sizeof(Font);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString,
+ &toFont, NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+ }
+
+ cursor = XCreateGlyphCursor( DisplayOfScreen(screen), source_font,
+ mask_font, source_char, mask_char,
+ &fgColor, &bgColor );
+ done(&cursor, Cursor);
+ return;
+ }
+
+ i = XmuCursorNameToIndex (name);
+ if (i != -1) {
+ cursor = XCreateFontCursor (DisplayOfScreen(screen), i);
+ done(&cursor, Cursor);
+ return;
+ }
+
+ if ((source = XmuLocateBitmapFile (screen, name,
+ maskname, (sizeof maskname) - 4,
+ NULL, NULL, &xhot, &yhot)) == None) {
+ XtStringConversionWarning (name, XtRCursor);
+ cursor = None;
+ done(&cursor, Cursor);
+ return;
+ }
+ len = strlen (maskname);
+ for (i = 0; i < 2; i++) {
+ strcpy (maskname + len, i == 0 ? "Mask" : "msk");
+ if ((mask = XmuLocateBitmapFile (screen, maskname, NULL, 0,
+ NULL, NULL, NULL, NULL)) != None)
+ break;
+ }
+
+ cursor = XCreatePixmapCursor( DisplayOfScreen(screen), source, mask,
+ &fgColor, &bgColor, xhot, yhot );
+ XFreePixmap( DisplayOfScreen(screen), source );
+ if (mask != None) XFreePixmap( DisplayOfScreen(screen), mask );
+
+ done(&cursor, Cursor);
+}
+
+#define new_done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+/* Function Name: XmuCvtStringToColorCursor
+ * Description: Converts a string into a colored cursor.
+ * Arguments: dpy
+ * args - an argument list (see below).
+ * num_args - number of elements in the argument list.
+ * fromVal - value to convert from.
+ * toVal - value to convert to.
+ * data
+ * Returns: True or False
+ */
+
+/*ARGSUSED*/
+Boolean
+XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *converter_data)
+{
+ Cursor cursor;
+ Screen *screen;
+ Pixel fg, bg;
+ Colormap c_map;
+ XColor colors[2];
+ Cardinal number;
+ XrmValue ret_val;
+
+ if (*num_args != 4) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToColorCursor","XmuError",
+ "String to color cursor conversion needs four arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ fg = *((Pixel *) args[1].addr);
+ bg = *((Pixel *) args[2].addr);
+ c_map = *((Colormap *) args[3].addr);
+
+ number = 1;
+ XmuCvtStringToCursor(args, &number, fromVal, &ret_val);
+
+ cursor = *((Cursor *) ret_val.addr);
+
+ if (cursor == None || (fg == BlackPixelOfScreen(screen)
+ && bg == WhitePixelOfScreen(screen)))
+ new_done(Cursor, cursor);
+
+ colors[0].pixel = fg;
+ colors[1].pixel = bg;
+
+ XQueryColors (dpy, c_map, colors, 2);
+ XRecolorCursor(dpy, cursor, colors, colors + 1);
+ new_done(Cursor, cursor);
+}
+
+
+
diff --git a/libXmu/src/StrToGrav.c b/libXmu/src/StrToGrav.c index 8d86fe51d..085c53a7e 100644 --- a/libXmu/src/StrToGrav.c +++ b/libXmu/src/StrToGrav.c @@ -1,148 +1,148 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/Xmu/Converters.h> -#include <X11/Xmu/CharSet.h> - -#define done(address, type) \ -{ (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; } - -/* - * Initialization - */ -static struct _namepair { - XrmQuark quark; - char *name; - XtGravity gravity; -} names[] = { - { NULLQUARK, XtEForget, ForgetGravity }, - { NULLQUARK, XtENorthWest, NorthWestGravity }, - { NULLQUARK, XtENorth, NorthGravity }, - { NULLQUARK, XtENorthEast, NorthEastGravity }, - { NULLQUARK, XtEWest, WestGravity }, - { NULLQUARK, XtECenter, CenterGravity }, - { NULLQUARK, XtEEast, EastGravity }, - { NULLQUARK, XtESouthWest, SouthWestGravity }, - { NULLQUARK, XtESouth, SouthGravity }, - { NULLQUARK, XtESouthEast, SouthEastGravity }, - { NULLQUARK, XtEStatic, StaticGravity }, - { NULLQUARK, XtEUnmap, UnmapGravity }, - { NULLQUARK, XtEleft, WestGravity }, - { NULLQUARK, XtEtop, NorthGravity }, - { NULLQUARK, XtEright, EastGravity }, - { NULLQUARK, XtEbottom, SouthGravity }, - { NULLQUARK, NULL, ForgetGravity } -}; - -/* - * This function is deprecated as of the addition of - * XtCvtStringToGravity in R6 - */ -void -XmuCvtStringToGravity(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static Boolean haveQuarks = False; - char name[10]; - XrmQuark q; - struct _namepair *np; - - if (*num_args != 0) - XtWarningMsg("wrongParameters","cvtStringToGravity","XtToolkitError", - "String to Gravity conversion needs no extra arguments", - (String *)NULL, (Cardinal *)NULL); - - if (!haveQuarks) - { - for (np = names; np->name; np++) - np->quark = XrmPermStringToQuark(np->name); - haveQuarks = True; - } - - XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name)); - q = XrmStringToQuark(name); - - for (np = names; np->name; np++) - { - if (np->quark == q) - { - done(&np->gravity, XtGravity); - return; - } - } - - XtStringConversionWarning((char *)fromVal->addr, XtRGravity); -} - -/*ARGSUSED*/ -Boolean -XmuCvtGravityToString(Display *dpy, XrmValue *args, Cardinal *num_args, - XrmValue *fromVal, XrmValue *toVal, XtPointer *data) -{ - static char *buffer; - Cardinal size; - struct _namepair *np; - XtGravity gravity; - - gravity = *(XtGravity *)fromVal->addr; - buffer = NULL; - for (np = names; np->name; np++) - if (np->gravity == gravity) - { - buffer = np->name; - break; - } - - if (!buffer) - { - XtAppWarning(XtDisplayToApplicationContext(dpy), - "Cannot convert Gravity to String"); - toVal->addr = NULL; - toVal->size = 0; - - return (False); - } - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size <= size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = size; - - return (True); -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/CharSet.h>
+
+#define done(address, type) \
+{ (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+/*
+ * Initialization
+ */
+static struct _namepair {
+ XrmQuark quark;
+ char *name;
+ XtGravity gravity;
+} names[] = {
+ { NULLQUARK, XtEForget, ForgetGravity },
+ { NULLQUARK, XtENorthWest, NorthWestGravity },
+ { NULLQUARK, XtENorth, NorthGravity },
+ { NULLQUARK, XtENorthEast, NorthEastGravity },
+ { NULLQUARK, XtEWest, WestGravity },
+ { NULLQUARK, XtECenter, CenterGravity },
+ { NULLQUARK, XtEEast, EastGravity },
+ { NULLQUARK, XtESouthWest, SouthWestGravity },
+ { NULLQUARK, XtESouth, SouthGravity },
+ { NULLQUARK, XtESouthEast, SouthEastGravity },
+ { NULLQUARK, XtEStatic, StaticGravity },
+ { NULLQUARK, XtEUnmap, UnmapGravity },
+ { NULLQUARK, XtEleft, WestGravity },
+ { NULLQUARK, XtEtop, NorthGravity },
+ { NULLQUARK, XtEright, EastGravity },
+ { NULLQUARK, XtEbottom, SouthGravity },
+ { NULLQUARK, NULL, ForgetGravity }
+};
+
+/*
+ * This function is deprecated as of the addition of
+ * XtCvtStringToGravity in R6
+ */
+void
+XmuCvtStringToGravity(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Boolean haveQuarks = False;
+ char name[10];
+ XrmQuark q;
+ struct _namepair *np;
+
+ if (*num_args != 0)
+ XtWarningMsg("wrongParameters","cvtStringToGravity","XtToolkitError",
+ "String to Gravity conversion needs no extra arguments",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (!haveQuarks)
+ {
+ for (np = names; np->name; np++)
+ np->quark = XrmPermStringToQuark(np->name);
+ haveQuarks = True;
+ }
+
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ for (np = names; np->name; np++)
+ {
+ if (np->quark == q)
+ {
+ done(&np->gravity, XtGravity);
+ return;
+ }
+ }
+
+ XtStringConversionWarning((char *)fromVal->addr, XtRGravity);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtGravityToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+ struct _namepair *np;
+ XtGravity gravity;
+
+ gravity = *(XtGravity *)fromVal->addr;
+ buffer = NULL;
+ for (np = names; np->name; np++)
+ if (np->gravity == gravity)
+ {
+ buffer = np->name;
+ break;
+ }
+
+ if (!buffer)
+ {
+ XtAppWarning(XtDisplayToApplicationContext(dpy),
+ "Cannot convert Gravity to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size <= size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = size;
+
+ return (True);
+}
diff --git a/libXmu/src/StrToJust.c b/libXmu/src/StrToJust.c index 03b38545d..7ad4e18a3 100644 --- a/libXmu/src/StrToJust.c +++ b/libXmu/src/StrToJust.c @@ -1,136 +1,136 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <string.h> -#include <X11/Intrinsic.h> -#include "Converters.h" -#include "CharSet.h" - -/* - * Prototypes - */ -static void InitializeQuarks(void); - -/* - * Initialization - */ -static XrmQuark Qleft, Qcenter, Qright; -static Boolean haveQuarks; - -/* - * Implementation - */ -static void -InitializeQuarks(void) -{ - if (!haveQuarks) - { - Qleft = XrmPermStringToQuark(XtEleft); - Qcenter = XrmPermStringToQuark(XtEcenter); - Qright = XrmPermStringToQuark(XtEright); - haveQuarks = True; - } -} - -/*ARGSUSED*/ -void -XmuCvtStringToJustify(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static XtJustify e; - XrmQuark q; - char *s = (char *)fromVal->addr; - char name[7]; - - if (s == NULL) - return; - - InitializeQuarks(); - XmuNCopyISOLatin1Lowered(name, s, sizeof(name)); - - q = XrmStringToQuark(name); - - toVal->size = sizeof(XtJustify); - toVal->addr = (XPointer)&e; - - if (q == Qleft) - e = XtJustifyLeft; - else if (q == Qcenter) - e = XtJustifyCenter; - else if (q == Qright) - e = XtJustifyRight; - else - { - toVal->addr = NULL; - XtStringConversionWarning((char *)fromVal->addr, XtRJustify); - } -} - -/*ARGSUSED*/ -Boolean -XmuCvtJustifyToString(Display *dpy, XrmValue* args, Cardinal *num_args, - XrmValue *fromVal, XrmValue *toVal, XtPointer *data) -{ - static String buffer; - Cardinal size; - - switch (*(XtJustify *)fromVal->addr) - { - case XtJustifyLeft: - buffer = XtEleft; - break; - case XtJustifyCenter: - buffer = XtEcenter; - break; - case XtJustifyRight: - buffer = XtEright; - break; - default: - XtWarning("Cannot convert Justify to String"); - toVal->addr = NULL; - toVal->size = 0; - return (False); - } - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size < size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = sizeof(String); - - return (True); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark Qleft, Qcenter, Qright;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ Qleft = XrmPermStringToQuark(XtEleft);
+ Qcenter = XrmPermStringToQuark(XtEcenter);
+ Qright = XrmPermStringToQuark(XtEright);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToJustify(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtJustify e;
+ XrmQuark q;
+ char *s = (char *)fromVal->addr;
+ char name[7];
+
+ if (s == NULL)
+ return;
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, s, sizeof(name));
+
+ q = XrmStringToQuark(name);
+
+ toVal->size = sizeof(XtJustify);
+ toVal->addr = (XPointer)&e;
+
+ if (q == Qleft)
+ e = XtJustifyLeft;
+ else if (q == Qcenter)
+ e = XtJustifyCenter;
+ else if (q == Qright)
+ e = XtJustifyRight;
+ else
+ {
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtRJustify);
+ }
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtJustifyToString(Display *dpy, XrmValue* args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XtJustify *)fromVal->addr)
+ {
+ case XtJustifyLeft:
+ buffer = XtEleft;
+ break;
+ case XtJustifyCenter:
+ buffer = XtEcenter;
+ break;
+ case XtJustifyRight:
+ buffer = XtEright;
+ break;
+ default:
+ XtWarning("Cannot convert Justify to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/libXmu/src/StrToLong.c b/libXmu/src/StrToLong.c index c0663f5ce..01a8b764e 100644 --- a/libXmu/src/StrToLong.c +++ b/libXmu/src/StrToLong.c @@ -1,80 +1,80 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Intrinsic.h> -#include <X11/Xmu/SysUtil.h> -#include <X11/Xmu/Converters.h> - -void -XmuCvtStringToLong(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static long l; - - if (*num_args != 0) - XtWarning("String to Long conversion needs no extra arguments"); - if (sscanf((char *)fromVal->addr, "%ld", &l) == 1) - { - toVal->size = sizeof(long); - toVal->addr = (XPointer)&l; - } - else - XtStringConversionWarning((char *)fromVal->addr, XtRLong); -} - -/*ARGSUSED*/ -Boolean -XmuCvtLongToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data) -{ - static char buffer[32]; - size_t size; - - if (*num_args != 0) - XtWarning("Long to String conversion needs no extra arguments"); - - XmuSnprintf(buffer, sizeof(buffer), "%ld", *(long *)fromVal->addr); - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size < size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = sizeof(String); - - return (True); -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xmu/Converters.h>
+
+void
+XmuCvtStringToLong(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static long l;
+
+ if (*num_args != 0)
+ XtWarning("String to Long conversion needs no extra arguments");
+ if (sscanf((char *)fromVal->addr, "%ld", &l) == 1)
+ {
+ toVal->size = sizeof(long);
+ toVal->addr = (XPointer)&l;
+ }
+ else
+ XtStringConversionWarning((char *)fromVal->addr, XtRLong);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtLongToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal, XtPointer *data)
+{
+ static char buffer[32];
+ size_t size;
+
+ if (*num_args != 0)
+ XtWarning("Long to String conversion needs no extra arguments");
+
+ XmuSnprintf(buffer, sizeof(buffer), "%ld", *(long *)fromVal->addr);
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/libXmu/src/StrToOrnt.c b/libXmu/src/StrToOrnt.c index 0c41c116c..585120131 100644 --- a/libXmu/src/StrToOrnt.c +++ b/libXmu/src/StrToOrnt.c @@ -1,126 +1,126 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Intrinsic.h> -#include <X11/StringDefs.h> -#include "Converters.h" -#include "CharSet.h" - -/* - * Prototypes - */ -static void InitializeQuarks(void); - -/* - * Initialization - */ -static XrmQuark Qhorizontal, Qvertical; -static Boolean haveQuarks; - -/* - * Implementation - */ -static void -InitializeQuarks(void) -{ - if (!haveQuarks) - { - Qhorizontal = XrmPermStringToQuark(XtEhorizontal); - Qvertical = XrmPermStringToQuark(XtEvertical); - haveQuarks = True; - } -} - -/*ARGSUSED*/ -void -XmuCvtStringToOrientation(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static XtOrientation orient; - XrmQuark q; - char name[11]; - - InitializeQuarks(); - XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name)); - q = XrmStringToQuark(name); - - toVal->size = sizeof(XtJustify); - toVal->addr = (XPointer)&orient; - - if (q == Qhorizontal) - orient = XtorientHorizontal; - else if (q == Qvertical) - orient = XtorientVertical; - else - { - toVal->addr = NULL; - XtStringConversionWarning((char *)fromVal->addr, XtROrientation); - } -} - -/*ARGSUSED*/ -Boolean -XmuCvtOrientationToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal, - XtPointer *data) -{ - static String buffer; - Cardinal size; - - switch (*(XtOrientation *)fromVal->addr) - { - case XtorientVertical: - buffer = XtEvertical; - break; - case XtorientHorizontal: - buffer = XtEhorizontal; - break; - default: - XtWarning("Cannot convert Orientation to String"); - toVal->addr = NULL; - toVal->size = 0; - return (False); - } - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size < size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = sizeof(String); - - return (True); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/*
+ * Prototypes
+ */
+static void InitializeQuarks(void);
+
+/*
+ * Initialization
+ */
+static XrmQuark Qhorizontal, Qvertical;
+static Boolean haveQuarks;
+
+/*
+ * Implementation
+ */
+static void
+InitializeQuarks(void)
+{
+ if (!haveQuarks)
+ {
+ Qhorizontal = XrmPermStringToQuark(XtEhorizontal);
+ Qvertical = XrmPermStringToQuark(XtEvertical);
+ haveQuarks = True;
+ }
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToOrientation(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static XtOrientation orient;
+ XrmQuark q;
+ char name[11];
+
+ InitializeQuarks();
+ XmuNCopyISOLatin1Lowered(name, (char *)fromVal->addr, sizeof(name));
+ q = XrmStringToQuark(name);
+
+ toVal->size = sizeof(XtJustify);
+ toVal->addr = (XPointer)&orient;
+
+ if (q == Qhorizontal)
+ orient = XtorientHorizontal;
+ else if (q == Qvertical)
+ orient = XtorientVertical;
+ else
+ {
+ toVal->addr = NULL;
+ XtStringConversionWarning((char *)fromVal->addr, XtROrientation);
+ }
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtOrientationToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+
+ switch (*(XtOrientation *)fromVal->addr)
+ {
+ case XtorientVertical:
+ buffer = XtEvertical;
+ break;
+ case XtorientHorizontal:
+ buffer = XtEhorizontal;
+ break;
+ default:
+ XtWarning("Cannot convert Orientation to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/libXmu/src/StrToShap.c b/libXmu/src/StrToShap.c index 298c91522..d047ff944 100644 --- a/libXmu/src/StrToShap.c +++ b/libXmu/src/StrToShap.c @@ -1,122 +1,122 @@ -/* - -Copyright 1988, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <string.h> -#include <X11/Intrinsic.h> -#include "Converters.h" -#include "CharSet.h" - -/* ARGSUSED */ -#define done(type, value) \ - { \ - if (toVal->addr != NULL) { \ - if (toVal->size < sizeof(type)) { \ - toVal->size = sizeof(type); \ - return False; \ - } \ - *(type*)(toVal->addr) = (value); \ - } \ - else { \ - static type static_val; \ - static_val = (value); \ - toVal->addr = (XtPointer)&static_val; \ - } \ - toVal->size = sizeof(type); \ - return True; \ - } - - -/*ARGSUSED*/ -Boolean -XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args, - XrmValue *from, XrmValue *toVal, XtPointer *data) -{ - String name = (String)from->addr; - - if (XmuCompareISOLatin1(name, XtERectangle) == 0) - done(int, XmuShapeRectangle); - if (XmuCompareISOLatin1(name, XtEOval) == 0) - done(int, XmuShapeOval); - if (XmuCompareISOLatin1(name, XtEEllipse) == 0) - done(int, XmuShapeEllipse); - if (XmuCompareISOLatin1(name, XtERoundedRectangle) == 0) - done(int, XmuShapeRoundedRectangle); - - XtDisplayStringConversionWarning(dpy, name, XtRShapeStyle); - - return (False); -} - -/*ARGSUSED*/ -Boolean -XmuCvtShapeStyleToString(Display *dpy, XrmValue *args, Cardinal *num_args, - XrmValue *fromVal, XrmValue *toVal, XtPointer *data) -{ - static char *buffer; - Cardinal size; - - switch (*(int *)fromVal->addr) - { - case XmuShapeRectangle: - buffer = XtERectangle; - break; - case XmuShapeOval: - buffer = XtEOval; - break; - case XmuShapeEllipse: - buffer = XtEEllipse; - break; - case XmuShapeRoundedRectangle: - buffer = XtERoundedRectangle; - break; - default: - XtAppWarning(XtDisplayToApplicationContext(dpy), - "Cannot convert ShapeStyle to String"); - toVal->addr = NULL; - toVal->size = 0; - - return (False); - } - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size <= size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = size; - - return (True); -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/* ARGSUSED */
+#define done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+/*ARGSUSED*/
+Boolean
+XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *from, XrmValue *toVal, XtPointer *data)
+{
+ String name = (String)from->addr;
+
+ if (XmuCompareISOLatin1(name, XtERectangle) == 0)
+ done(int, XmuShapeRectangle);
+ if (XmuCompareISOLatin1(name, XtEOval) == 0)
+ done(int, XmuShapeOval);
+ if (XmuCompareISOLatin1(name, XtEEllipse) == 0)
+ done(int, XmuShapeEllipse);
+ if (XmuCompareISOLatin1(name, XtERoundedRectangle) == 0)
+ done(int, XmuShapeRoundedRectangle);
+
+ XtDisplayStringConversionWarning(dpy, name, XtRShapeStyle);
+
+ return (False);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtShapeStyleToString(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
+{
+ static char *buffer;
+ Cardinal size;
+
+ switch (*(int *)fromVal->addr)
+ {
+ case XmuShapeRectangle:
+ buffer = XtERectangle;
+ break;
+ case XmuShapeOval:
+ buffer = XtEOval;
+ break;
+ case XmuShapeEllipse:
+ buffer = XtEEllipse;
+ break;
+ case XmuShapeRoundedRectangle:
+ buffer = XtERoundedRectangle;
+ break;
+ default:
+ XtAppWarning(XtDisplayToApplicationContext(dpy),
+ "Cannot convert ShapeStyle to String");
+ toVal->addr = NULL;
+ toVal->size = 0;
+
+ return (False);
+ }
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size <= size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = size;
+
+ return (True);
+}
diff --git a/libXmu/src/StrToWidg.c b/libXmu/src/StrToWidg.c index c22b82764..61225f3e9 100644 --- a/libXmu/src/StrToWidg.c +++ b/libXmu/src/StrToWidg.c @@ -1,225 +1,225 @@ -/* - -Copyright 1994, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * XmuCvtStringToWidget - * - * static XtConvertArgRec parentCvtArgs[] = { - * {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)}, - * }; - * - * matches the string against the name of the immediate children (normal - * or popup) of the parent. If none match, compares string to classname - * & returns first match. Case is significant. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/IntrinsicP.h> -#include <X11/StringDefs.h> -#include <X11/ObjectP.h> -#include <X11/Xmu/Converters.h> - -#define done(address, type) \ -{ \ - toVal->size = sizeof(type); \ - toVal->addr = (XPointer)address; \ - return; \ -} - -/*ARGSUSED*/ -void -XmuCvtStringToWidget(XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal) -{ - static Widget widget, *widgetP, parent; - XrmName name = XrmStringToName(fromVal->addr); - Cardinal i; - - if (*num_args != 1) - { - i = 0; - XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError", - "StringToWidget conversion needs parent arg", NULL, &i); - } - - parent = *(Widget*)args[0].addr; - /* try to match names of normal children */ - if (XtIsComposite(parent)) - { - i = ((CompositeWidget)parent)->composite.num_children; - for (widgetP = ((CompositeWidget)parent)->composite.children; - i; i--, widgetP++) - if ((*widgetP)->core.xrm_name == name) - { - widget = *widgetP; - done(&widget, Widget); - } - } - - /* try to match names of popup children */ - i = parent->core.num_popups; - for (widgetP = parent->core.popup_list; i; i--, widgetP++) - if ((*widgetP)->core.xrm_name == name) - { - widget = *widgetP; - done(&widget, Widget); - } - - /* try to match classes of normal children */ - if (XtIsComposite(parent)) - { - i = ((CompositeWidget)parent)->composite.num_children; - for (widgetP = ((CompositeWidget)parent)->composite.children; - i; i--, widgetP++) - if ((*widgetP)->core.widget_class->core_class.xrm_class == name) - { - widget = *widgetP; - done(&widget, Widget); - } - } - - /* try to match classes of popup children */ - i = parent->core.num_popups; - for (widgetP = parent->core.popup_list; i; i--, widgetP++) - if ((*widgetP)->core.widget_class->core_class.xrm_class == name) - { - widget = *widgetP; - done(&widget, Widget); - } - - XtStringConversionWarning(fromVal->addr, XtRWidget); - toVal->addr = NULL; - toVal->size = 0; -} - -#undef done - -#define newDone(type, value) \ - { \ - if (toVal->addr != NULL) { \ - if (toVal->size < sizeof(type)) { \ - toVal->size = sizeof(type); \ - return False; \ - } \ - *(type*)(toVal->addr) = (value); \ - } \ - else { \ - static type static_val; \ - static_val = (value); \ - toVal->addr = (XtPointer)&static_val; \ - } \ - toVal->size = sizeof(type); \ - return True; \ - } - - -/*ARGSUSED*/ -Boolean -XmuNewCvtStringToWidget(Display *dpy, XrmValue *args, Cardinal *num_args, - XrmValue *fromVal, XrmValue *toVal, - XtPointer *converter_data) -{ - Widget *widgetP, parent; - XrmName name = XrmStringToName(fromVal->addr); - int i; - - if (*num_args != 1) - XtAppWarningMsg(XtDisplayToApplicationContext(dpy), - "wrongParameters","cvtStringToWidget","xtToolkitError", - "String To Widget conversion needs parent argument", - (String *)NULL, (Cardinal *)NULL); - - parent = *(Widget*)args[0].addr; - /* try to match names of normal children */ - if (XtIsComposite(parent)) - { - i = ((CompositeWidget)parent)->composite.num_children; - for (widgetP = ((CompositeWidget)parent)->composite.children; - i; i--, widgetP++) - if ((*widgetP)->core.xrm_name == name) - newDone(Widget, *widgetP); - } - - /* try to match names of popup children */ - i = parent->core.num_popups; - for (widgetP = parent->core.popup_list; i; i--, widgetP++) - if ((*widgetP)->core.xrm_name == name) - newDone(Widget, *widgetP); - - /* try to match classes of normal children */ - if (XtIsComposite(parent)) - { - i = ((CompositeWidget)parent)->composite.num_children; - for (widgetP = ((CompositeWidget)parent)->composite.children; - i; i--, widgetP++) - if ((*widgetP)->core.widget_class->core_class.xrm_class == name) - newDone(Widget, *widgetP); - } - - /* try to match classes of popup children */ - i = parent->core.num_popups; - for (widgetP = parent->core.popup_list; i; i--, widgetP++) - if ((*widgetP)->core.widget_class->core_class.xrm_class == name) - newDone(Widget, *widgetP); - - XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XtRWidget); - return (False); -} - -/*ARGSUSED*/ -Boolean -XmuCvtWidgetToString(Display *dpy, XrmValuePtr args, Cardinal *num_args, - XrmValuePtr fromVal, XrmValuePtr toVal, - XtPointer *data) -{ - static String buffer; - Cardinal size; - Widget widget; - - widget = *(Widget *)fromVal->addr; - - if (widget) - buffer = XrmQuarkToString(widget->core.xrm_name); - else - buffer = "(null)"; - - size = strlen(buffer) + 1; - if (toVal->addr != NULL) - { - if (toVal->size < size) - { - toVal->size = size; - return (False); - } - strcpy((char *)toVal->addr, buffer); - } - else - toVal->addr = (XPointer)buffer; - toVal->size = sizeof(String); - - return (True); -} +/*
+
+Copyright 1994, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * XmuCvtStringToWidget
+ *
+ * static XtConvertArgRec parentCvtArgs[] = {
+ * {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)},
+ * };
+ *
+ * matches the string against the name of the immediate children (normal
+ * or popup) of the parent. If none match, compares string to classname
+ * & returns first match. Case is significant.
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ObjectP.h>
+#include <X11/Xmu/Converters.h>
+
+#define done(address, type) \
+{ \
+ toVal->size = sizeof(type); \
+ toVal->addr = (XPointer)address; \
+ return; \
+}
+
+/*ARGSUSED*/
+void
+XmuCvtStringToWidget(XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal)
+{
+ static Widget widget, *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ Cardinal i;
+
+ if (*num_args != 1)
+ {
+ i = 0;
+ XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError",
+ "StringToWidget conversion needs parent arg", NULL, &i);
+ }
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+
+ XtStringConversionWarning(fromVal->addr, XtRWidget);
+ toVal->addr = NULL;
+ toVal->size = 0;
+}
+
+#undef done
+
+#define newDone(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+/*ARGSUSED*/
+Boolean
+XmuNewCvtStringToWidget(Display *dpy, XrmValue *args, Cardinal *num_args,
+ XrmValue *fromVal, XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ Widget *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToWidget","xtToolkitError",
+ "String To Widget conversion needs parent argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+ }
+
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent))
+ {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+ }
+
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++)
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XtRWidget);
+ return (False);
+}
+
+/*ARGSUSED*/
+Boolean
+XmuCvtWidgetToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
+ XrmValuePtr fromVal, XrmValuePtr toVal,
+ XtPointer *data)
+{
+ static String buffer;
+ Cardinal size;
+ Widget widget;
+
+ widget = *(Widget *)fromVal->addr;
+
+ if (widget)
+ buffer = XrmQuarkToString(widget->core.xrm_name);
+ else
+ buffer = "(null)";
+
+ size = strlen(buffer) + 1;
+ if (toVal->addr != NULL)
+ {
+ if (toVal->size < size)
+ {
+ toVal->size = size;
+ return (False);
+ }
+ strcpy((char *)toVal->addr, buffer);
+ }
+ else
+ toVal->addr = (XPointer)buffer;
+ toVal->size = sizeof(String);
+
+ return (True);
+}
diff --git a/libXmu/src/UpdMapHint.c b/libXmu/src/UpdMapHint.c index 389b80213..cbd3ec05a 100644 --- a/libXmu/src/UpdMapHint.c +++ b/libXmu/src/UpdMapHint.c @@ -1,59 +1,59 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xmu/WinUtil.h> - -Bool -XmuUpdateMapHints(Display *dpy, Window w, XSizeHints *hints) -{ - static XSizeHints *shp = NULL; - - if (!hints) { /* get them first */ - long supp; - - if (!shp) { - shp = XAllocSizeHints(); - if (!shp) return False; - } - if (!XGetWMNormalHints (dpy, w, shp, &supp)) return False; - hints = shp; - } - hints->flags &= ~(PPosition|PSize); - hints->flags |= (USPosition|USSize); - XSetWMNormalHints (dpy, w, hints); - return True; -} - +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/WinUtil.h>
+
+Bool
+XmuUpdateMapHints(Display *dpy, Window w, XSizeHints *hints)
+{
+ static XSizeHints *shp = NULL;
+
+ if (!hints) { /* get them first */
+ long supp;
+
+ if (!shp) {
+ shp = XAllocSizeHints();
+ if (!shp) return False;
+ }
+ if (!XGetWMNormalHints (dpy, w, shp, &supp)) return False;
+ hints = shp;
+ }
+ hints->flags &= ~(PPosition|PSize);
+ hints->flags |= (USPosition|USSize);
+ XSetWMNormalHints (dpy, w, hints);
+ return True;
+}
+
diff --git a/libXmu/src/VisCmap.c b/libXmu/src/VisCmap.c index 0a35713ba..b982ab2aa 100644 --- a/libXmu/src/VisCmap.c +++ b/libXmu/src/VisCmap.c @@ -1,180 +1,180 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <math.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> -#include <X11/Xmu/StdCmap.h> - -/* - * To create all of the appropriate standard colormaps for a given visual on - * a given screen, use XmuVisualStandardColormaps. - * - * Define all appropriate standard colormap properties for the given visual. - * If replace is true, any previous definition will be removed. - * If retain is true, new properties will be retained for the duration of - * the server session. Return 0 on failure, non-zero on success. - * On failure, no new properties will be defined, and, old ones may have - * been removed if replace was True. - * - * Not all standard colormaps are meaningful to all visual classes. This - * routine will check and define the following properties for the following - * classes, provided that the size of the colormap is not too small. - * - * DirectColor and PseudoColor - * RGB_DEFAULT_MAP - * RGB_BEST_MAP - * RGB_RED_MAP - * RGB_GREEN_MAP - * RGB_BLUE_MAP - * RGB_GRAY_MAP - * - * TrueColor and StaticColor - * RGB_BEST_MAP - * - * GrayScale and StaticGray - * RGB_GRAY_MAP - */ - -Status -XmuVisualStandardColormaps(Display *dpy, int screen, VisualID visualid, - unsigned int depth, Bool replace, Bool retain) - /* - * dpy - specifies server connection - * screen - specifies screen number - * visualid - specifies the visual - * depth - specifies the visual - * replace specifies - whether to replace - * retain - specifies whether to retain - */ -{ - Status status; - int n; - long vinfo_mask; - XVisualInfo vinfo_template, *vinfo; - - status = 0; - vinfo_template.screen = screen; - vinfo_template.visualid = visualid; - vinfo_template.depth = depth; - vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask; - if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return 0; - - if (vinfo->colormap_size <= 2) { - /* Monochrome visuals have no standard maps; considered successful */ - XFree((char *) vinfo); - return 1; - } - - switch (vinfo->class) - { - case PseudoColor: - case DirectColor: - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_DEFAULT_MAP, replace,retain); - if (!status) break; - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GRAY_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_RED_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GREEN_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_BLUE_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); - break; - } - /* fall through */ - - case StaticColor: - case TrueColor: - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_BEST_MAP, replace, retain); - if (!status && (vinfo->class == PseudoColor || - vinfo->class == DirectColor)) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP); - } - break; - /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */ - - case GrayScale: - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_DEFAULT_MAP, replace, - retain); - if (! status) break; - /*FALLTHROUGH*/ - - case StaticGray: - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GRAY_MAP, replace, retain); - if (! status && vinfo->class == GrayScale) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - break; - } - } - - XFree((char *) vinfo); - return status; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * To create all of the appropriate standard colormaps for a given visual on
+ * a given screen, use XmuVisualStandardColormaps.
+ *
+ * Define all appropriate standard colormap properties for the given visual.
+ * If replace is true, any previous definition will be removed.
+ * If retain is true, new properties will be retained for the duration of
+ * the server session. Return 0 on failure, non-zero on success.
+ * On failure, no new properties will be defined, and, old ones may have
+ * been removed if replace was True.
+ *
+ * Not all standard colormaps are meaningful to all visual classes. This
+ * routine will check and define the following properties for the following
+ * classes, provided that the size of the colormap is not too small.
+ *
+ * DirectColor and PseudoColor
+ * RGB_DEFAULT_MAP
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_GRAY_MAP
+ *
+ * TrueColor and StaticColor
+ * RGB_BEST_MAP
+ *
+ * GrayScale and StaticGray
+ * RGB_GRAY_MAP
+ */
+
+Status
+XmuVisualStandardColormaps(Display *dpy, int screen, VisualID visualid,
+ unsigned int depth, Bool replace, Bool retain)
+ /*
+ * dpy - specifies server connection
+ * screen - specifies screen number
+ * visualid - specifies the visual
+ * depth - specifies the visual
+ * replace specifies - whether to replace
+ * retain - specifies whether to retain
+ */
+{
+ Status status;
+ int n;
+ long vinfo_mask;
+ XVisualInfo vinfo_template, *vinfo;
+
+ status = 0;
+ vinfo_template.screen = screen;
+ vinfo_template.visualid = visualid;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ if (vinfo->colormap_size <= 2) {
+ /* Monochrome visuals have no standard maps; considered successful */
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ switch (vinfo->class)
+ {
+ case PseudoColor:
+ case DirectColor:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,retain);
+ if (!status) break;
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_RED_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GREEN_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BLUE_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ break;
+ }
+ /* fall through */
+
+ case StaticColor:
+ case TrueColor:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BEST_MAP, replace, retain);
+ if (!status && (vinfo->class == PseudoColor ||
+ vinfo->class == DirectColor)) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP);
+ }
+ break;
+ /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */
+
+ case GrayScale:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,
+ retain);
+ if (! status) break;
+ /*FALLTHROUGH*/
+
+ case StaticGray:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (! status && vinfo->class == GrayScale) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+ }
+
+ XFree((char *) vinfo);
+ return status;
+}
diff --git a/libXmu/src/WidgetNode.c b/libXmu/src/WidgetNode.c index ac6c9ec9d..f790d103a 100644 --- a/libXmu/src/WidgetNode.c +++ b/libXmu/src/WidgetNode.c @@ -1,306 +1,306 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* - * Author: Jim Fulton, MIT X Consortium - */ - - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <X11/Xos.h> -#include <X11/IntrinsicP.h> -#include <X11/Xmu/CharSet.h> -#include <X11/Xmu/WidgetNode.h> - -/* - * Prototypes - */ -static char *binsearch(char*, char*, int, int, - int (*__compar)(_Xconst void*, _Xconst void*)); -static int compare_resource_entries(_Xconst void *a, _Xconst void *b); -static XmuWidgetNode *find_resource(XmuWidgetNode*, char*, Bool); -static void mark_resource_owner(XmuWidgetNode*); -/* - * Implementation - */ -static char * -binsearch(char *key, char *base, int nelems, int elemsize, - int compar(_Xconst void*, _Xconst void*)) - /* - * key - template of object to find - * base - beginning of array - * nelems - number of elements in array - * elemsize - sizeof an element - * compar - qsort-style compare function - */ -{ - int lower = 0, upper = nelems - 1; - - while (lower <= upper) { - int middle = (lower + upper) / 2; - char *p = base + middle * elemsize; - int res = (*compar) (p, key); - - if (res < 0) { - lower = middle + 1; - } else if (res == 0) { - return p; - } else { - upper = middle - 1; - } - } - - return NULL; -} - - -static int -compare_resource_entries(register _Xconst void *a, - register _Xconst void *b) -{ - return strcmp (((XtResourceList)a)->resource_name, - ((XtResourceList)b)->resource_name); -} - - -static XmuWidgetNode * -find_resource(XmuWidgetNode *node, char *name, Bool cons) -{ - register XmuWidgetNode *sup; - XtResource res; - -#define reslist ((char *) (cons ? sup->constraints : sup->resources)) -#define nreslist (int) (cons ? sup->nconstraints : sup->nresources) - - res.resource_name = name; - for (sup = node->superclass; - sup && (XtResourceList) binsearch ((char *) &res, - reslist, nreslist, - sizeof(XtResource), - compare_resource_entries); - node = sup, sup = sup->superclass) ; - -#undef reslist -#undef nreslist - - return node; -} - - -static void -mark_resource_owner(register XmuWidgetNode *node) -{ - register Cardinal i; - XtResourceList childres; - - childres = node->resources; - for (i = 0; i < node->nresources; i++, childres++) { - node->resourcewn[i] = find_resource (node, childres->resource_name, - False); - } - - childres = node->constraints; - for (i = 0; i < node->nconstraints; i++, childres++) { - node->constraintwn[i] = find_resource (node, childres->resource_name, - True); - } -} - - -/* - * Public Interfaces - */ - -void -XmuWnInitializeNodes(XmuWidgetNode *nodearray, int nnodes) -{ - int i; - XmuWidgetNode *wn; - - /* - * Assume that the node array is in alphabetic order, so we need to - * search backwards to make sure that the children are listed forward. - */ - for (i = nnodes - 1, wn = nodearray + (nnodes - 1); i >= 0; i--, wn--) { - WidgetClass superclass = XmuWnSuperclass(wn); - int j; - XmuWidgetNode *swn; - int lablen = strlen (wn->label); - int namelen = strlen (XmuWnClassname(wn)); - - wn->lowered_label = XtMalloc (lablen + namelen + 2); -#if 0 - /* XtMalloc exits if failed */ - if (!wn->lowered_label) { - fprintf (stderr, - "%s: unable to allocate %d bytes for widget name\n", - "XmuWnInitializeNodes", lablen + namelen + 2); - exit (1); - } -#endif - wn->lowered_classname = wn->lowered_label + (lablen + 1); - XmuCopyISOLatin1Lowered (wn->lowered_label, wn->label); - XmuCopyISOLatin1Lowered (wn->lowered_classname, XmuWnClassname(wn)); - wn->superclass = NULL; - wn->have_resources = False; - wn->resources = NULL; - wn->resourcewn = NULL; - wn->nresources = 0; - wn->constraints = NULL; - wn->constraintwn = NULL; - wn->nconstraints = 0; - wn->data = (XtPointer) NULL; - - /* - * walk up the superclass chain - */ - while (superclass) { - for (j = 0, swn = nodearray; j < nnodes; j++, swn++) { - if (superclass == XmuWnClass(swn)) { - wn->superclass = swn; - goto done; /* stupid C language */ - } - } - /* - * Hmm, we have a hidden superclass (such as in core in R4); just - * ignore it and keep on walking - */ - superclass = superclass->core_class.superclass; - } - done: - if (wn->superclass) { - wn->siblings = wn->superclass->children; - wn->superclass->children = wn; - } - } - - return; -} - - -void -XmuWnFetchResources(XmuWidgetNode *node, Widget toplevel, - XmuWidgetNode *topnode) -{ - Widget dummy; - XmuWidgetNode *wn; - - if (node->have_resources) return; - - dummy = XtCreateWidget (node->label, XmuWnClass(node), toplevel, - NULL, 0); - if (dummy) XtDestroyWidget (dummy); - - - /* - * walk up tree geting resources; since we've instantiated the widget, - * we know that all of our superclasses have been initialized - */ - for (wn = node; wn && !wn->have_resources; wn = wn->superclass) { - XtGetResourceList (XmuWnClass(wn), &wn->resources, &wn->nresources); - if (wn->resources) { - qsort ((char *) wn->resources, wn->nresources, - sizeof(XtResource), compare_resource_entries); - } - wn->resourcewn = (XmuWidgetNode **) XtCalloc (wn->nresources, - sizeof (XmuWidgetNode *)); - if (!wn->resourcewn) { - fprintf (stderr, - "%s: unable to calloc %d %ld byte widget node ptrs\n", - "XmuWnFetchResources", wn->nresources, - (unsigned long)sizeof (XmuWidgetNode *)); - exit (1); - } - - XtGetConstraintResourceList (XmuWnClass(wn), &wn->constraints, - &wn->nconstraints); - if (wn->constraints) { - qsort ((char *) wn->constraints, wn->nconstraints, - sizeof(XtResource), compare_resource_entries); - } - wn->constraintwn = (XmuWidgetNode **) - XtCalloc (wn->nconstraints, sizeof (XmuWidgetNode *)); - if (!wn->constraintwn) { - fprintf (stderr, - "%s: unable to calloc %d %ld byte widget node ptrs\n", - "XmuWnFetchResources", wn->nconstraints, - (unsigned long)sizeof (XmuWidgetNode *)); - exit (1); - } - - wn->have_resources = True; - if (wn == topnode) break; - } - - - /* - * Walk up tree removing all resources that appear in superclass; we can - * mash the resource list in place since it was copied out of widget. - */ - for (wn = node; wn; wn = wn->superclass) { - mark_resource_owner (wn); - if (wn == topnode) break; - } - - return; -} - - -int -XmuWnCountOwnedResources(XmuWidgetNode *node, XmuWidgetNode *ownernode, - Bool cons) -{ - register int i; - XmuWidgetNode **wn = (cons ? node->constraintwn : node->resourcewn); - int nmatches = 0; - - for (i = (cons ? node->nconstraints : node->nresources); i > 0; i--, wn++) - if (*wn == ownernode) nmatches++; - return nmatches; -} - - -XmuWidgetNode * -XmuWnNameToNode(XmuWidgetNode *nodelist, int nnodes, _Xconst char *name) -{ - int i; - XmuWidgetNode *wn; - char tmp[1024]; - - XmuNCopyISOLatin1Lowered(tmp, name, sizeof(tmp)); - for (i = 0, wn = nodelist; i < nnodes; i++, wn++) { - if (strcmp (tmp, wn->lowered_label) == 0 || - strcmp (tmp, wn->lowered_classname) == 0) { - return wn; - } - } - return NULL; -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xos.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/WidgetNode.h>
+
+/*
+ * Prototypes
+ */
+static char *binsearch(char*, char*, int, int,
+ int (*__compar)(_Xconst void*, _Xconst void*));
+static int compare_resource_entries(_Xconst void *a, _Xconst void *b);
+static XmuWidgetNode *find_resource(XmuWidgetNode*, char*, Bool);
+static void mark_resource_owner(XmuWidgetNode*);
+/*
+ * Implementation
+ */
+static char *
+binsearch(char *key, char *base, int nelems, int elemsize,
+ int (*compar)(_Xconst void*, _Xconst void*))
+ /*
+ * key - template of object to find
+ * base - beginning of array
+ * nelems - number of elements in array
+ * elemsize - sizeof an element
+ * compar - qsort-style compare function
+ */
+{
+ int lower = 0, upper = nelems - 1;
+
+ while (lower <= upper) {
+ int middle = (lower + upper) / 2;
+ char *p = base + middle * elemsize;
+ int res = (*compar) (p, key);
+
+ if (res < 0) {
+ lower = middle + 1;
+ } else if (res == 0) {
+ return p;
+ } else {
+ upper = middle - 1;
+ }
+ }
+
+ return NULL;
+}
+
+
+static int
+compare_resource_entries(register _Xconst void *a,
+ register _Xconst void *b)
+{
+ return strcmp (((XtResourceList)a)->resource_name,
+ ((XtResourceList)b)->resource_name);
+}
+
+
+static XmuWidgetNode *
+find_resource(XmuWidgetNode *node, char *name, Bool cons)
+{
+ register XmuWidgetNode *sup;
+ XtResource res;
+
+#define reslist ((char *) (cons ? sup->constraints : sup->resources))
+#define nreslist (int) (cons ? sup->nconstraints : sup->nresources)
+
+ res.resource_name = name;
+ for (sup = node->superclass;
+ sup && (XtResourceList) binsearch ((char *) &res,
+ reslist, nreslist,
+ sizeof(XtResource),
+ compare_resource_entries);
+ node = sup, sup = sup->superclass) ;
+
+#undef reslist
+#undef nreslist
+
+ return node;
+}
+
+
+static void
+mark_resource_owner(register XmuWidgetNode *node)
+{
+ register Cardinal i;
+ XtResourceList childres;
+
+ childres = node->resources;
+ for (i = 0; i < node->nresources; i++, childres++) {
+ node->resourcewn[i] = find_resource (node, childres->resource_name,
+ False);
+ }
+
+ childres = node->constraints;
+ for (i = 0; i < node->nconstraints; i++, childres++) {
+ node->constraintwn[i] = find_resource (node, childres->resource_name,
+ True);
+ }
+}
+
+
+/*
+ * Public Interfaces
+ */
+
+void
+XmuWnInitializeNodes(XmuWidgetNode *nodearray, int nnodes)
+{
+ int i;
+ XmuWidgetNode *wn;
+
+ /*
+ * Assume that the node array is in alphabetic order, so we need to
+ * search backwards to make sure that the children are listed forward.
+ */
+ for (i = nnodes - 1, wn = nodearray + (nnodes - 1); i >= 0; i--, wn--) {
+ WidgetClass superclass = XmuWnSuperclass(wn);
+ int j;
+ XmuWidgetNode *swn;
+ int lablen = strlen (wn->label);
+ int namelen = strlen (XmuWnClassname(wn));
+
+ wn->lowered_label = XtMalloc (lablen + namelen + 2);
+#if 0
+ /* XtMalloc exits if failed */
+ if (!wn->lowered_label) {
+ fprintf (stderr,
+ "%s: unable to allocate %d bytes for widget name\n",
+ "XmuWnInitializeNodes", lablen + namelen + 2);
+ exit (1);
+ }
+#endif
+ wn->lowered_classname = wn->lowered_label + (lablen + 1);
+ XmuCopyISOLatin1Lowered (wn->lowered_label, wn->label);
+ XmuCopyISOLatin1Lowered (wn->lowered_classname, XmuWnClassname(wn));
+ wn->superclass = NULL;
+ wn->have_resources = False;
+ wn->resources = NULL;
+ wn->resourcewn = NULL;
+ wn->nresources = 0;
+ wn->constraints = NULL;
+ wn->constraintwn = NULL;
+ wn->nconstraints = 0;
+ wn->data = (XtPointer) NULL;
+
+ /*
+ * walk up the superclass chain
+ */
+ while (superclass) {
+ for (j = 0, swn = nodearray; j < nnodes; j++, swn++) {
+ if (superclass == XmuWnClass(swn)) {
+ wn->superclass = swn;
+ goto done; /* stupid C language */
+ }
+ }
+ /*
+ * Hmm, we have a hidden superclass (such as in core in R4); just
+ * ignore it and keep on walking
+ */
+ superclass = superclass->core_class.superclass;
+ }
+ done:
+ if (wn->superclass) {
+ wn->siblings = wn->superclass->children;
+ wn->superclass->children = wn;
+ }
+ }
+
+ return;
+}
+
+
+void
+XmuWnFetchResources(XmuWidgetNode *node, Widget toplevel,
+ XmuWidgetNode *topnode)
+{
+ Widget dummy;
+ XmuWidgetNode *wn;
+
+ if (node->have_resources) return;
+
+ dummy = XtCreateWidget (node->label, XmuWnClass(node), toplevel,
+ NULL, 0);
+ if (dummy) XtDestroyWidget (dummy);
+
+
+ /*
+ * walk up tree geting resources; since we've instantiated the widget,
+ * we know that all of our superclasses have been initialized
+ */
+ for (wn = node; wn && !wn->have_resources; wn = wn->superclass) {
+ XtGetResourceList (XmuWnClass(wn), &wn->resources, &wn->nresources);
+ if (wn->resources) {
+ qsort ((char *) wn->resources, wn->nresources,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->resourcewn = (XmuWidgetNode **) XtCalloc (wn->nresources,
+ sizeof (XmuWidgetNode *));
+ if (!wn->resourcewn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %ld byte widget node ptrs\n",
+ "XmuWnFetchResources", wn->nresources,
+ (unsigned long)sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ XtGetConstraintResourceList (XmuWnClass(wn), &wn->constraints,
+ &wn->nconstraints);
+ if (wn->constraints) {
+ qsort ((char *) wn->constraints, wn->nconstraints,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->constraintwn = (XmuWidgetNode **)
+ XtCalloc (wn->nconstraints, sizeof (XmuWidgetNode *));
+ if (!wn->constraintwn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %ld byte widget node ptrs\n",
+ "XmuWnFetchResources", wn->nconstraints,
+ (unsigned long)sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ wn->have_resources = True;
+ if (wn == topnode) break;
+ }
+
+
+ /*
+ * Walk up tree removing all resources that appear in superclass; we can
+ * mash the resource list in place since it was copied out of widget.
+ */
+ for (wn = node; wn; wn = wn->superclass) {
+ mark_resource_owner (wn);
+ if (wn == topnode) break;
+ }
+
+ return;
+}
+
+
+int
+XmuWnCountOwnedResources(XmuWidgetNode *node, XmuWidgetNode *ownernode,
+ Bool cons)
+{
+ register int i;
+ XmuWidgetNode **wn = (cons ? node->constraintwn : node->resourcewn);
+ int nmatches = 0;
+
+ for (i = (cons ? node->nconstraints : node->nresources); i > 0; i--, wn++)
+ if (*wn == ownernode) nmatches++;
+ return nmatches;
+}
+
+
+XmuWidgetNode *
+XmuWnNameToNode(XmuWidgetNode *nodelist, int nnodes, _Xconst char *name)
+{
+ int i;
+ XmuWidgetNode *wn;
+ char tmp[1024];
+
+ XmuNCopyISOLatin1Lowered(tmp, name, sizeof(tmp));
+ for (i = 0, wn = nodelist; i < nnodes; i++, wn++) {
+ if (strcmp (tmp, wn->lowered_label) == 0 ||
+ strcmp (tmp, wn->lowered_classname) == 0) {
+ return wn;
+ }
+ }
+ return NULL;
+}
diff --git a/libXmu/src/Xct.c b/libXmu/src/Xct.c index 1db470ebb..258554c3a 100644 --- a/libXmu/src/Xct.c +++ b/libXmu/src/Xct.c @@ -1,684 +1,684 @@ -/* - -Copyright 1989, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xfuncs.h> -#include "Xct.h" -#include <stdio.h> - -#define UsedGraphic 0x0001 -#define UsedDirection 0x0002 - -typedef struct _XctPriv { - XctString ptr; - XctString ptrend; - unsigned flags; - XctHDirection *dirstack; - unsigned dirsize; - char **encodings; - unsigned enc_count; - XctString itembuf; - unsigned buf_count; -} *XctPriv; - -#define IsMore(priv) ((priv)->ptr != (priv)->ptrend) -#define AmountLeft(priv) ((priv)->ptrend - (priv)->ptr) - -#include <stdlib.h> - -#define HT 0x09 -#define NL 0x0a -#define ESC 0x1b -#define CSI 0x9b - -#define IsLegalC0(data, c) (((c) == HT) || ((c) == NL) || \ - (((data)->version > XctVersion) && \ - ((data)->flags & XctAcceptC0Extensions))) - -#define IsLegalC1(priv, c) (((data)->version > XctVersion) && \ - ((data)->flags & XctAcceptC1Extensions)) - -#define IsI2(c) (((c) >= 0x20) && ((c) <= 0x2f)) -#define IsI3(c) (((c) >= 0x30) && ((c) <= 0x3f)) -#define IsESCF(c) (((c) >= 0x30) && ((c) <= 0x7e)) -#define IsCSIF(c) (((c) >= 0x40) && ((c) <= 0x7e)) -#define IsC0(c) ((c) <= 0x1f) -#define IsGL(c) (((c) >= 0x20) && ((c) <= 0x7f)) -#define IsC1(c) (((c) >= 0x80) && ((c) <= 0x9f)) -#define IsGR(c) ((c) >= 0xa0) - -#define HasC 1 -#define HasGL 2 -#define HasGR 4 -#define ToGL 8 - -/* - * Prototypes - */ -static void ComputeGLGR(XctData); -static int Handle94GR(XctData, int); -static int Handle96GR(XctData, int); -static int HandleExtended(XctData data, int); -static int HandleGL(XctData, int); -static int HandleMultiGL(XctData, int); -static int HandleMultiGR(XctData data, int); -static void ShiftGRToGL(XctData, int); - -/* - * Implementation - */ -static void -ComputeGLGR(register XctData data) -{ - /* XXX this will need more work if more sets are registered */ - if ((data->GL_set_size == 94) && (data->GL_char_size == 1) && - (data->GL[0] == '\102') && - (data->GR_set_size == 96) && (data->GR_char_size == 1)) - data->GLGR_encoding = data->GR_encoding; - else if ((data->GL_set_size == 94) && (data->GL_char_size == 1) && - (data->GL[0] == '\112') && - (data->GR_set_size == 94) && (data->GR_char_size == 1)) - data->GLGR_encoding = data->GR_encoding; - else - data->GLGR_encoding = (char *)NULL; -} - -static int -HandleGL(register XctData data, int c) -{ - switch (c) { - case 0x42: - data->GL = "\102"; - data->GL_encoding = "ISO8859-1"; - break; - case 0x4a: - data->GL = "\112"; - data->GL_encoding = "JISX0201.1976-0"; - break; - default: - return 0; - } - data->GL_set_size = 94; - data->GL_char_size = 1; - ComputeGLGR(data); - return 1; -} - -static int -HandleMultiGL(register XctData data, int c) -{ - switch (c) { - case 0x41: - data->GL = "\101"; - data->GL_encoding = "GB2312.1980-0"; - break; - case 0x42: - data->GL = "\102"; - data->GL_encoding = "JISX0208.1983-0"; - break; - case 0x43: - data->GL = "\103"; - data->GL_encoding = "KSC5601.1987-0"; - break; - default: - return 0; - } - data->GL_set_size = 94; - data->GL_char_size = 2; -#ifdef notdef - if (c < 0x60) - data->GL_char_size = 2; - else if (c < 0x70) - data->GL_char_size = 3; - else - data->GL_char_size = 4; -#endif - data->GLGR_encoding = (char *)NULL; - return 1; -} - -static int -Handle94GR(register XctData data, int c) -{ - switch (c) { - case 0x49: - data->GR = "\111"; - data->GR_encoding = "JISX0201.1976-0"; - break; - default: - return 0; - } - data->priv->flags &= ~ToGL; - data->GR_set_size = 94; - data->GR_char_size = 1; - data->GLGR_encoding = (char *)NULL; - return 1; -} - -static int -Handle96GR(register XctData data, int c) -{ - switch (c) { - case 0x41: - data->GR = "\101"; - data->GR_encoding = "ISO8859-1"; - break; - case 0x42: - data->GR = "\102"; - data->GR_encoding = "ISO8859-2"; - break; - case 0x43: - data->GR = "\103"; - data->GR_encoding = "ISO8859-3"; - break; - case 0x44: - data->GR = "\104"; - data->GR_encoding = "ISO8859-4"; - break; - case 0x46: - data->GR = "\106"; - data->GR_encoding = "ISO8859-7"; - break; - case 0x47: - data->GR = "\107"; - data->GR_encoding = "ISO8859-6"; - break; - case 0x48: - data->GR = "\110"; - data->GR_encoding = "ISO8859-8"; - break; - case 0x4c: - data->GR = "\114"; - data->GR_encoding = "ISO8859-5"; - break; - case 0x4d: - data->GR = "\115"; - data->GR_encoding = "ISO8859-9"; - break; - default: - return 0; - } - data->priv->flags &= ~ToGL; - data->GR_set_size = 96; - data->GR_char_size = 1; - ComputeGLGR(data); - return 1; -} - -static int -HandleMultiGR(register XctData data, int c) -{ - switch (c) { - case 0x41: - data->GR = "\101"; - if (data->flags & XctShiftMultiGRToGL) - data->GR_encoding = "GB2312.1980-0"; - else - data->GR_encoding = "GB2312.1980-1"; - break; - case 0x42: - data->GR = "\102"; - if (data->flags & XctShiftMultiGRToGL) - data->GR_encoding = "JISX0208.1983-0"; - else - data->GR_encoding = "JISX0208.1983-1"; - break; - case 0x43: - data->GR = "\103"; - if (data->flags & XctShiftMultiGRToGL) - data->GR_encoding = "KSC5601.1987-0"; - else - data->GR_encoding = "KSC5601.1987-1"; - break; - default: - return 0; - } - if (data->flags & XctShiftMultiGRToGL) - data->priv->flags |= ToGL; - else - data->priv->flags &= ~ToGL; - data->GR_set_size = 94; - data->GR_char_size = 2; -#ifdef notdef - if (c < 0x60) - data->GR_char_size = 2; - else if (c < 0x70) - data->GR_char_size = 3; - else - data->GR_char_size = 4; -#endif - data->GLGR_encoding = (char *)NULL; - return 1; -} - -static int -HandleExtended(register XctData data, int c) -{ - register XctPriv priv = data->priv; - XctString enc = data->item + 6; - register XctString ptr = enc; - unsigned i, len; - - while (*ptr != 0x02) { - if (!*ptr || (++ptr == priv->ptr)) - return 0; - } - data->item = ptr + 1; - data->item_length = priv->ptr - data->item; - len = ptr - enc; - for (i = 0; - (i < priv->enc_count) && - strncmp(priv->encodings[i], (char *)enc, len); - i++) - ; - if (i == priv->enc_count) { - XctString cp; - - for (cp = enc; cp != ptr; cp++) { - if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f)) - return 0; - } - ptr = (XctString)malloc((unsigned)len + 1); - (void) memmove((char *)ptr, (char *)enc, len); - ptr[len] = 0x00; - priv->enc_count++; - if (priv->encodings) - priv->encodings = (char **)realloc( - (char *)priv->encodings, - priv->enc_count * sizeof(char *)); - else - priv->encodings = (char **)malloc(sizeof(char *)); - priv->encodings[i] = (char *)ptr; - } - data->encoding = priv->encodings[i]; - data->char_size = c - 0x30; - return 1; -} - -static void -ShiftGRToGL(register XctData data, int hasCdata) -{ - register XctPriv priv = data->priv; - register int i; - - if (data->item_length > priv->buf_count) { - priv->buf_count = data->item_length; - if (priv->itembuf) - priv->itembuf = (XctString)realloc((char *)priv->itembuf, - priv->buf_count); - else - priv->itembuf = (XctString)malloc(priv->buf_count); - } - (void) memmove((char *)priv->itembuf, (char *)data->item, - data->item_length); - data->item = priv->itembuf; - if (hasCdata) { - for (i = data->item_length; --i >= 0; ) { - if (IsGR(data->item[i])) - data->item[i] &= 0x7f; - } - } else { - for (i = data->item_length; --i >= 0; ) - data->item[i] &= 0x7f; - } -} - -/* Create an XctData structure for parsing a Compound Text string. */ -XctData -XctCreate(_Xconst unsigned char *string, int length, XctFlags flags) -{ - register XctData data; - register XctPriv priv; - - data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv)); - if (!data) - return data; - data->priv = priv = (XctPriv)(data + 1); - data->total_string = (XctString)string; - data->total_length = length; - data->flags = flags; - priv->dirstack = (XctHDirection *)NULL; - priv->dirsize = 0; - priv->encodings = (char **)NULL; - priv->enc_count = 0; - priv->itembuf = (XctString)NULL; - priv->buf_count = 0; - XctReset(data); - return data; -} - -/* Reset the XctData structure to re-parse the string from the beginning. */ -void -XctReset(register XctData data) -{ - register XctPriv priv = data->priv; - - priv->ptr = data->total_string; - priv->ptrend = data->total_string + data->total_length; - data->item = (XctString)NULL; - data->item_length = 0; - data->encoding = (char *)NULL; - data->char_size = 1; - data->horizontal = XctUnspecified; - data->horz_depth = 0; - priv->flags = 0; - data->GL_set_size = data->GR_set_size = 0; /* XXX */ - (void)HandleGL(data, (unsigned char)0x42); - (void)Handle96GR(data, (unsigned char)0x41); - data->version = 1; - data->can_ignore_exts = 0; - /* parse version, if present */ - if ((data->total_length >= 4) && - (priv->ptr[0] == ESC) && (priv->ptr[1] == 0x23) && - IsI2(priv->ptr[2]) && - ((priv->ptr[3] == 0x30) || (priv->ptr[3] == 0x31))) { - data->version = priv->ptr[2] - 0x1f; - if (priv->ptr[3] == 0x30) - data->can_ignore_exts = 1; - priv->ptr += 4; - } -} - -/* Parse the next "item" from the Compound Text string. The return value - * indicates what kind of item is returned. The item itself, and the current - * contextual state, are reported as components of the XctData structure. - */ -XctResult -XctNextItem(register XctData data) -{ - register XctPriv priv = data->priv; - unsigned char c; - int len, bits; - -#define NEXT data->item_length++; priv->ptr++ - - while (IsMore(priv)) { - data->item = priv->ptr; - data->item_length = 0; - c = *priv->ptr; - if (c == ESC) { - NEXT; - while (IsMore(priv) && IsI2(*priv->ptr)) { - NEXT; - } - if (!IsMore(priv)) - return XctError; - c = *priv->ptr; - NEXT; - if (!IsESCF(c)) - return XctError; - switch (data->item[1]) { - case 0x24: - if (data->item_length > 3) { - if (data->item[2] == 0x28) { - if (HandleMultiGL(data, c)) - continue; - } else if (data->item[2] == 0x29) { - if (HandleMultiGR(data, c)) - continue; - } - } - break; - case 0x25: - if ((data->item_length == 4) && (data->item[2] == 0x2f) && - (c <= 0x3f)) { - if ((AmountLeft(priv) < 2) || - (priv->ptr[0] < 0x80) || (priv->ptr[1] < 0x80)) - return XctError; - len = *priv->ptr - 0x80; - NEXT; - len = (len << 7) + (*priv->ptr - 0x80); - NEXT; - if (AmountLeft(priv) < len) - return XctError; - data->item_length += len; - priv->ptr += len; - if (c <= 0x34) { - if (!HandleExtended(data, c) || - ((data->horz_depth == 0) && - (priv->flags & UsedDirection))) - return XctError; - priv->flags |= UsedGraphic; - return XctExtendedSegment; - } - } - break; - case 0x28: - if (HandleGL(data, c)) - continue; - break; - case 0x29: - if (Handle94GR(data, c)) - continue; - break; - case 0x2d: - if (Handle96GR(data, c)) - continue; - break; - } - } else if (c == CSI) { - NEXT; - while (IsMore(priv) && IsI3(*priv->ptr)) { - NEXT; - } - while (IsMore(priv) && IsI2(*priv->ptr)) { - NEXT; - } - if (!IsMore(priv)) - return XctError; - c = *priv->ptr; - NEXT; - if (!IsCSIF(c)) - return XctError; - if (c == 0x5d) { - if ((data->item_length == 3) && - ((data->item[1] == 0x31) || (data->item[1] == 0x32))) { - data->horz_depth++; - if (priv->dirsize < data->horz_depth) { - priv->dirsize += 10; - if (priv->dirstack) - priv->dirstack = (XctHDirection *) - realloc((char *)priv->dirstack, - priv->dirsize * - sizeof(XctHDirection)); - else - priv->dirstack = (XctHDirection *) - malloc(priv->dirsize * - sizeof(XctHDirection)); - } - priv->dirstack[data->horz_depth - 1] = data->horizontal; - if (data->item[1] == 0x31) - data->horizontal = XctLeftToRight; - else - data->horizontal = XctRightToLeft; - if ((priv->flags & UsedGraphic) && - !(priv->flags & UsedDirection)) - return XctError; - priv->flags |= UsedDirection; - if (data->flags & XctHideDirection) - continue; - return XctHorizontal; - } else if (data->item_length == 2) { - if (!data->horz_depth) - return XctError; - data->horz_depth--; - data->horizontal = priv->dirstack[data->horz_depth]; - if (data->flags & XctHideDirection) - continue; - return XctHorizontal; - } - } - } else if (data->flags & XctSingleSetSegments) { - NEXT; - if IsC0(c) { - data->encoding = (char *)NULL; - data->char_size = 1; - if (IsLegalC0(data, c)) - return XctC0Segment; - } else if (IsGL(c)) { - data->encoding = data->GL_encoding; - data->char_size = data->GL_char_size; - while (IsMore(priv) && IsGL(*priv->ptr)) { - NEXT; - } - if (((data->char_size > 1) && - (data->item_length % data->char_size)) || - ((data->horz_depth == 0) && - (priv->flags & UsedDirection))) - return XctError; - priv->flags |= UsedGraphic; - return XctGLSegment; - } else if (IsC1(c)) { - data->encoding = (char *)NULL; - data->char_size = 1; - if (IsLegalC1(data, c)) - return XctC1Segment; - } else { - data->encoding = data->GR_encoding; - data->char_size = data->GR_char_size; - while (IsMore(priv) && IsGR(*priv->ptr)) { - NEXT; - } - if (((data->char_size > 1) && - (data->item_length % data->char_size)) || - ((data->horz_depth == 0) && - (priv->flags & UsedDirection))) - return XctError; - priv->flags |= UsedGraphic; - if (!(priv->flags & ToGL)) - return XctGRSegment; - ShiftGRToGL(data, 0); - return XctGLSegment; - } - } else { - bits = 0; - while (1) { - if (IsC0(c) || IsC1(c)) { - if ((c == ESC) || (c == CSI)) - break; - if (IsC0(c) ? !IsLegalC0(data, c) : !IsLegalC1(data, c)) - break; - bits |= HasC; - NEXT; - } else { - len = data->item_length; - if (IsGL(c)) { - if ((data->flags & XctShiftMultiGRToGL) && - (bits & HasGR)) - break; - NEXT; - bits |= HasGL; - while (IsMore(priv) && IsGL(*priv->ptr)) { - NEXT; - } - if ((data->GL_char_size > 1) && - ((data->item_length - len) % data->GL_char_size)) - return XctError; - } else { - if ((data->flags & XctShiftMultiGRToGL) && - (bits & HasGL)) - break; - NEXT; - bits |= HasGR; - while (IsMore(priv) && IsGR(*priv->ptr)) { - NEXT; - } - if ((data->GR_char_size > 1) && - ((data->item_length - len) % data->GR_char_size)) - return XctError; - } - } - if (!IsMore(priv)) - break; - c = *priv->ptr; - } - if (data->item_length) { - if (bits & (HasGL|HasGR)) { - priv->flags |= UsedGraphic; - if ((data->horz_depth == 0) && - (priv->flags & UsedDirection)) - return XctError; - if ((data->flags & XctShiftMultiGRToGL) && (bits & HasGR)) - ShiftGRToGL(data, bits & HasC); - } - if ((bits == (HasGL|HasGR)) || - (data->GLGR_encoding && !(bits & HasC))) { - data->encoding = data->GLGR_encoding; - if (data->GL_char_size == data->GR_char_size) - data->char_size = data->GL_char_size; - else - data->char_size = 0; - } else if (bits == HasGL) { - data->encoding = data->GL_encoding; - data->char_size = data->GL_char_size; - } else if (bits == HasGR) { - data->encoding = data->GR_encoding; - data->char_size = data->GR_char_size; - } else { - data->encoding = (char *)NULL; - data->char_size = 1; - if ((bits & HasGL) && - (data->GL_char_size != data->char_size)) - data->char_size = 0; - if ((bits & HasGR) && - (data->GR_char_size != data->char_size)) - data->char_size = 0; - } - return XctSegment; - } - NEXT; - } - if (data->version <= XctVersion) - return XctError; - if (data->flags & XctProvideExtensions) - return XctExtension; - if (!data->can_ignore_exts) - return XctError; - } - return XctEndOfText; -} - -/* Free all data associated with an XctDataStructure. */ -void -XctFree(register XctData data) -{ - unsigned i; - register XctPriv priv = data->priv; - - if (priv->dirstack) - free((char *)priv->dirstack); - if (data->flags & XctFreeString) - free((char *)data->total_string); - for (i = 0; i < priv->enc_count; i++) - free(priv->encodings[i]); - if (priv->encodings) - free((char *)priv->encodings); - if (priv->itembuf) - free((char *)priv->itembuf); - free((char *)data); -} +/*
+
+Copyright 1989, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xfuncs.h>
+#include "Xct.h"
+#include <stdio.h>
+
+#define UsedGraphic 0x0001
+#define UsedDirection 0x0002
+
+typedef struct _XctPriv {
+ XctString ptr;
+ XctString ptrend;
+ unsigned flags;
+ XctHDirection *dirstack;
+ unsigned dirsize;
+ char **encodings;
+ unsigned enc_count;
+ XctString itembuf;
+ unsigned buf_count;
+} *XctPriv;
+
+#define IsMore(priv) ((priv)->ptr != (priv)->ptrend)
+#define AmountLeft(priv) ((priv)->ptrend - (priv)->ptr)
+
+#include <stdlib.h>
+
+#define HT 0x09
+#define NL 0x0a
+#define ESC 0x1b
+#define CSI 0x9b
+
+#define IsLegalC0(data, c) (((c) == HT) || ((c) == NL) || \
+ (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC0Extensions)))
+
+#define IsLegalC1(priv, c) (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC1Extensions))
+
+#define IsI2(c) (((c) >= 0x20) && ((c) <= 0x2f))
+#define IsI3(c) (((c) >= 0x30) && ((c) <= 0x3f))
+#define IsESCF(c) (((c) >= 0x30) && ((c) <= 0x7e))
+#define IsCSIF(c) (((c) >= 0x40) && ((c) <= 0x7e))
+#define IsC0(c) ((c) <= 0x1f)
+#define IsGL(c) (((c) >= 0x20) && ((c) <= 0x7f))
+#define IsC1(c) (((c) >= 0x80) && ((c) <= 0x9f))
+#define IsGR(c) ((c) >= 0xa0)
+
+#define HasC 1
+#define HasGL 2
+#define HasGR 4
+#define ToGL 8
+
+/*
+ * Prototypes
+ */
+static void ComputeGLGR(XctData);
+static int Handle94GR(XctData, int);
+static int Handle96GR(XctData, int);
+static int HandleExtended(XctData data, int);
+static int HandleGL(XctData, int);
+static int HandleMultiGL(XctData, int);
+static int HandleMultiGR(XctData data, int);
+static void ShiftGRToGL(XctData, int);
+
+/*
+ * Implementation
+ */
+static void
+ComputeGLGR(register XctData data)
+{
+ /* XXX this will need more work if more sets are registered */
+ if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\102') &&
+ (data->GR_set_size == 96) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\112') &&
+ (data->GR_set_size == 94) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else
+ data->GLGR_encoding = (char *)NULL;
+}
+
+static int
+HandleGL(register XctData data, int c)
+{
+ switch (c) {
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "ISO8859-1";
+ break;
+ case 0x4a:
+ data->GL = "\112";
+ data->GL_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGL(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GL = "\101";
+ data->GL_encoding = "GB2312.1980-0";
+ break;
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "JISX0208.1983-0";
+ break;
+ case 0x43:
+ data->GL = "\103";
+ data->GL_encoding = "KSC5601.1987-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GL_char_size = 2;
+ else if (c < 0x70)
+ data->GL_char_size = 3;
+ else
+ data->GL_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle94GR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x49:
+ data->GR = "\111";
+ data->GR_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 1;
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle96GR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ data->GR_encoding = "ISO8859-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ data->GR_encoding = "ISO8859-2";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ data->GR_encoding = "ISO8859-3";
+ break;
+ case 0x44:
+ data->GR = "\104";
+ data->GR_encoding = "ISO8859-4";
+ break;
+ case 0x46:
+ data->GR = "\106";
+ data->GR_encoding = "ISO8859-7";
+ break;
+ case 0x47:
+ data->GR = "\107";
+ data->GR_encoding = "ISO8859-6";
+ break;
+ case 0x48:
+ data->GR = "\110";
+ data->GR_encoding = "ISO8859-8";
+ break;
+ case 0x4c:
+ data->GR = "\114";
+ data->GR_encoding = "ISO8859-5";
+ break;
+ case 0x4d:
+ data->GR = "\115";
+ data->GR_encoding = "ISO8859-9";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 96;
+ data->GR_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGR(register XctData data, int c)
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "GB2312.1980-0";
+ else
+ data->GR_encoding = "GB2312.1980-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "JISX0208.1983-0";
+ else
+ data->GR_encoding = "JISX0208.1983-1";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "KSC5601.1987-0";
+ else
+ data->GR_encoding = "KSC5601.1987-1";
+ break;
+ default:
+ return 0;
+ }
+ if (data->flags & XctShiftMultiGRToGL)
+ data->priv->flags |= ToGL;
+ else
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GR_char_size = 2;
+ else if (c < 0x70)
+ data->GR_char_size = 3;
+ else
+ data->GR_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+HandleExtended(register XctData data, int c)
+{
+ register XctPriv priv = data->priv;
+ XctString enc = data->item + 6;
+ register XctString ptr = enc;
+ unsigned i, len;
+
+ while (*ptr != 0x02) {
+ if (!*ptr || (++ptr == priv->ptr))
+ return 0;
+ }
+ data->item = ptr + 1;
+ data->item_length = priv->ptr - data->item;
+ len = ptr - enc;
+ for (i = 0;
+ (i < priv->enc_count) &&
+ strncmp(priv->encodings[i], (char *)enc, len);
+ i++)
+ ;
+ if (i == priv->enc_count) {
+ XctString cp;
+
+ for (cp = enc; cp != ptr; cp++) {
+ if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
+ return 0;
+ }
+ ptr = (XctString)malloc((unsigned)len + 1);
+ (void) memmove((char *)ptr, (char *)enc, len);
+ ptr[len] = 0x00;
+ priv->enc_count++;
+ if (priv->encodings)
+ priv->encodings = (char **)realloc(
+ (char *)priv->encodings,
+ priv->enc_count * sizeof(char *));
+ else
+ priv->encodings = (char **)malloc(sizeof(char *));
+ priv->encodings[i] = (char *)ptr;
+ }
+ data->encoding = priv->encodings[i];
+ data->char_size = c - 0x30;
+ return 1;
+}
+
+static void
+ShiftGRToGL(register XctData data, int hasCdata)
+{
+ register XctPriv priv = data->priv;
+ register int i;
+
+ if (data->item_length > priv->buf_count) {
+ priv->buf_count = data->item_length;
+ if (priv->itembuf)
+ priv->itembuf = (XctString)realloc((char *)priv->itembuf,
+ priv->buf_count);
+ else
+ priv->itembuf = (XctString)malloc(priv->buf_count);
+ }
+ (void) memmove((char *)priv->itembuf, (char *)data->item,
+ data->item_length);
+ data->item = priv->itembuf;
+ if (hasCdata) {
+ for (i = data->item_length; --i >= 0; ) {
+ if (IsGR(data->item[i]))
+ data->item[i] &= 0x7f;
+ }
+ } else {
+ for (i = data->item_length; --i >= 0; )
+ data->item[i] &= 0x7f;
+ }
+}
+
+/* Create an XctData structure for parsing a Compound Text string. */
+XctData
+XctCreate(_Xconst unsigned char *string, int length, XctFlags flags)
+{
+ register XctData data;
+ register XctPriv priv;
+
+ data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
+ if (!data)
+ return data;
+ data->priv = priv = (XctPriv)(data + 1);
+ data->total_string = (XctString)string;
+ data->total_length = length;
+ data->flags = flags;
+ priv->dirstack = (XctHDirection *)NULL;
+ priv->dirsize = 0;
+ priv->encodings = (char **)NULL;
+ priv->enc_count = 0;
+ priv->itembuf = (XctString)NULL;
+ priv->buf_count = 0;
+ XctReset(data);
+ return data;
+}
+
+/* Reset the XctData structure to re-parse the string from the beginning. */
+void
+XctReset(register XctData data)
+{
+ register XctPriv priv = data->priv;
+
+ priv->ptr = data->total_string;
+ priv->ptrend = data->total_string + data->total_length;
+ data->item = (XctString)NULL;
+ data->item_length = 0;
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ data->horizontal = XctUnspecified;
+ data->horz_depth = 0;
+ priv->flags = 0;
+ data->GL_set_size = data->GR_set_size = 0; /* XXX */
+ (void)HandleGL(data, (unsigned char)0x42);
+ (void)Handle96GR(data, (unsigned char)0x41);
+ data->version = 1;
+ data->can_ignore_exts = 0;
+ /* parse version, if present */
+ if ((data->total_length >= 4) &&
+ (priv->ptr[0] == ESC) && (priv->ptr[1] == 0x23) &&
+ IsI2(priv->ptr[2]) &&
+ ((priv->ptr[3] == 0x30) || (priv->ptr[3] == 0x31))) {
+ data->version = priv->ptr[2] - 0x1f;
+ if (priv->ptr[3] == 0x30)
+ data->can_ignore_exts = 1;
+ priv->ptr += 4;
+ }
+}
+
+/* Parse the next "item" from the Compound Text string. The return value
+ * indicates what kind of item is returned. The item itself, and the current
+ * contextual state, are reported as components of the XctData structure.
+ */
+XctResult
+XctNextItem(register XctData data)
+{
+ register XctPriv priv = data->priv;
+ unsigned char c;
+ int len, bits;
+
+#define NEXT data->item_length++; priv->ptr++
+
+ while (IsMore(priv)) {
+ data->item = priv->ptr;
+ data->item_length = 0;
+ c = *priv->ptr;
+ if (c == ESC) {
+ NEXT;
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsESCF(c))
+ return XctError;
+ switch (data->item[1]) {
+ case 0x24:
+ if (data->item_length > 3) {
+ if (data->item[2] == 0x28) {
+ if (HandleMultiGL(data, c))
+ continue;
+ } else if (data->item[2] == 0x29) {
+ if (HandleMultiGR(data, c))
+ continue;
+ }
+ }
+ break;
+ case 0x25:
+ if ((data->item_length == 4) && (data->item[2] == 0x2f) &&
+ (c <= 0x3f)) {
+ if ((AmountLeft(priv) < 2) ||
+ (priv->ptr[0] < 0x80) || (priv->ptr[1] < 0x80))
+ return XctError;
+ len = *priv->ptr - 0x80;
+ NEXT;
+ len = (len << 7) + (*priv->ptr - 0x80);
+ NEXT;
+ if (AmountLeft(priv) < len)
+ return XctError;
+ data->item_length += len;
+ priv->ptr += len;
+ if (c <= 0x34) {
+ if (!HandleExtended(data, c) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctExtendedSegment;
+ }
+ }
+ break;
+ case 0x28:
+ if (HandleGL(data, c))
+ continue;
+ break;
+ case 0x29:
+ if (Handle94GR(data, c))
+ continue;
+ break;
+ case 0x2d:
+ if (Handle96GR(data, c))
+ continue;
+ break;
+ }
+ } else if (c == CSI) {
+ NEXT;
+ while (IsMore(priv) && IsI3(*priv->ptr)) {
+ NEXT;
+ }
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsCSIF(c))
+ return XctError;
+ if (c == 0x5d) {
+ if ((data->item_length == 3) &&
+ ((data->item[1] == 0x31) || (data->item[1] == 0x32))) {
+ data->horz_depth++;
+ if (priv->dirsize < data->horz_depth) {
+ priv->dirsize += 10;
+ if (priv->dirstack)
+ priv->dirstack = (XctHDirection *)
+ realloc((char *)priv->dirstack,
+ priv->dirsize *
+ sizeof(XctHDirection));
+ else
+ priv->dirstack = (XctHDirection *)
+ malloc(priv->dirsize *
+ sizeof(XctHDirection));
+ }
+ priv->dirstack[data->horz_depth - 1] = data->horizontal;
+ if (data->item[1] == 0x31)
+ data->horizontal = XctLeftToRight;
+ else
+ data->horizontal = XctRightToLeft;
+ if ((priv->flags & UsedGraphic) &&
+ !(priv->flags & UsedDirection))
+ return XctError;
+ priv->flags |= UsedDirection;
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ } else if (data->item_length == 2) {
+ if (!data->horz_depth)
+ return XctError;
+ data->horz_depth--;
+ data->horizontal = priv->dirstack[data->horz_depth];
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ }
+ }
+ } else if (data->flags & XctSingleSetSegments) {
+ NEXT;
+ if IsC0(c) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC0(data, c))
+ return XctC0Segment;
+ } else if (IsGL(c)) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctGLSegment;
+ } else if (IsC1(c)) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC1(data, c))
+ return XctC1Segment;
+ } else {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ if (!(priv->flags & ToGL))
+ return XctGRSegment;
+ ShiftGRToGL(data, 0);
+ return XctGLSegment;
+ }
+ } else {
+ bits = 0;
+ while (1) {
+ if (IsC0(c) || IsC1(c)) {
+ if ((c == ESC) || (c == CSI))
+ break;
+ if (IsC0(c) ? !IsLegalC0(data, c) : !IsLegalC1(data, c))
+ break;
+ bits |= HasC;
+ NEXT;
+ } else {
+ len = data->item_length;
+ if (IsGL(c)) {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGR))
+ break;
+ NEXT;
+ bits |= HasGL;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GL_char_size > 1) &&
+ ((data->item_length - len) % data->GL_char_size))
+ return XctError;
+ } else {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGL))
+ break;
+ NEXT;
+ bits |= HasGR;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GR_char_size > 1) &&
+ ((data->item_length - len) % data->GR_char_size))
+ return XctError;
+ }
+ }
+ if (!IsMore(priv))
+ break;
+ c = *priv->ptr;
+ }
+ if (data->item_length) {
+ if (bits & (HasGL|HasGR)) {
+ priv->flags |= UsedGraphic;
+ if ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection))
+ return XctError;
+ if ((data->flags & XctShiftMultiGRToGL) && (bits & HasGR))
+ ShiftGRToGL(data, bits & HasC);
+ }
+ if ((bits == (HasGL|HasGR)) ||
+ (data->GLGR_encoding && !(bits & HasC))) {
+ data->encoding = data->GLGR_encoding;
+ if (data->GL_char_size == data->GR_char_size)
+ data->char_size = data->GL_char_size;
+ else
+ data->char_size = 0;
+ } else if (bits == HasGL) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ } else if (bits == HasGR) {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ } else {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if ((bits & HasGL) &&
+ (data->GL_char_size != data->char_size))
+ data->char_size = 0;
+ if ((bits & HasGR) &&
+ (data->GR_char_size != data->char_size))
+ data->char_size = 0;
+ }
+ return XctSegment;
+ }
+ NEXT;
+ }
+ if (data->version <= XctVersion)
+ return XctError;
+ if (data->flags & XctProvideExtensions)
+ return XctExtension;
+ if (!data->can_ignore_exts)
+ return XctError;
+ }
+ return XctEndOfText;
+}
+
+/* Free all data associated with an XctDataStructure. */
+void
+XctFree(register XctData data)
+{
+ unsigned i;
+ register XctPriv priv = data->priv;
+
+ if (priv->dirstack)
+ free((char *)priv->dirstack);
+ if (data->flags & XctFreeString)
+ free((char *)data->total_string);
+ for (i = 0; i < priv->enc_count; i++)
+ free(priv->encodings[i]);
+ if (priv->encodings)
+ free((char *)priv->encodings);
+ if (priv->itembuf)
+ free((char *)priv->itembuf);
+ free((char *)data);
+}
diff --git a/libXmu/src/config.h b/libXmu/src/config.h new file mode 100644 index 000000000..7206ebebd --- /dev/null +++ b/libXmu/src/config.h @@ -0,0 +1 @@ +#define HAS_SNPRINTF
\ No newline at end of file diff --git a/libXmu/src/makefile b/libXmu/src/makefile new file mode 100644 index 000000000..be4990997 --- /dev/null +++ b/libXmu/src/makefile @@ -0,0 +1,53 @@ +LIBRARY = libXmu + +INCLUDES := ..\include ..\include\X11\Xmu $(INCLUDES) + +DEFINES += XT_NO_SM BITMAPDIR="""bitmaps""" + +CSRCS = \ + ClientWin.c \ + CursorName.c \ + DefErrMsg.c \ + GetHost.c \ + Lower.c \ + AllCmap.c \ + Atoms.c \ + Clip.c \ + CloseHook.c \ + CmapAlloc.c \ + CrCmap.c \ + CrPixFBit.c \ + CvtCache.c \ + CvtStdSel.c \ + DelCmap.c \ + DisplayQue.c \ + Distinct.c \ + DrawLogo.c \ + DrRndRect.c \ + EditresCom.c \ + ExtAgent.c \ + FToCback.c \ + GrayPixmap.c \ + Initer.c \ + LocBitmap.c \ + Lookup.c \ + LookupCmap.c \ + RdBitF.c \ + ScrOfWin.c \ + ShapeWidg.c \ + StdCmap.c \ + StrToBS.c \ + StrToBmap.c \ + StrToCurs.c \ + StrToGrav.c \ + StrToJust.c \ + StrToLong.c \ + StrToOrnt.c \ + StrToShap.c \ + StrToWidg.c \ + UpdMapHint.c \ + VisCmap.c \ + WidgetNode.c \ + Xct.c \ + sharedlib.c + diff --git a/libXmu/src/sharedlib.c b/libXmu/src/sharedlib.c index 4bb8c3b5f..37363d7f6 100644 --- a/libXmu/src/sharedlib.c +++ b/libXmu/src/sharedlib.c @@ -1,73 +1,73 @@ -/* - -Copyright 1991, 1998 The Open Group - -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. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#if defined(SUNSHLIB) && !defined(SHAREDCODE) - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Atoms.h" - -struct _AtomRec { - char *name; - struct _DisplayRec* head; -}; - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define DeclareAtom(atom) \ -extern struct _AtomRec __##atom; \ -AtomPtr _##atom = &__##atom; -#else -#define DeclareAtom(atom) \ -extern struct _AtomRec __/**/atom; \ -AtomPtr _/**/atom = &__/**/atom; -#endif - -DeclareAtom(XA_ATOM_PAIR) -DeclareAtom(XA_CHARACTER_POSITION) -DeclareAtom(XA_CLASS) -DeclareAtom(XA_CLIENT_WINDOW) -DeclareAtom(XA_CLIPBOARD) -DeclareAtom(XA_COMPOUND_TEXT) -DeclareAtom(XA_DECNET_ADDRESS) -DeclareAtom(XA_DELETE) -DeclareAtom(XA_FILENAME) -DeclareAtom(XA_HOSTNAME) -DeclareAtom(XA_IP_ADDRESS) -DeclareAtom(XA_LENGTH) -DeclareAtom(XA_LIST_LENGTH) -DeclareAtom(XA_NAME) -DeclareAtom(XA_NET_ADDRESS) -DeclareAtom(XA_NULL) -DeclareAtom(XA_OWNER_OS) -DeclareAtom(XA_SPAN) -DeclareAtom(XA_TARGETS) -DeclareAtom(XA_TEXT) -DeclareAtom(XA_TIMESTAMP) -DeclareAtom(XA_USER) -DeclareAtom(XA_UTF8_STRING) - -#endif /* SUNSHLIB */ +/*
+
+Copyright 1991, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Atoms.h"
+
+struct _AtomRec {
+ char *name;
+ struct _DisplayRec* head;
+};
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define DeclareAtom(atom) \
+extern struct _AtomRec __##atom; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom) \
+extern struct _AtomRec __/**/atom; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR)
+DeclareAtom(XA_CHARACTER_POSITION)
+DeclareAtom(XA_CLASS)
+DeclareAtom(XA_CLIENT_WINDOW)
+DeclareAtom(XA_CLIPBOARD)
+DeclareAtom(XA_COMPOUND_TEXT)
+DeclareAtom(XA_DECNET_ADDRESS)
+DeclareAtom(XA_DELETE)
+DeclareAtom(XA_FILENAME)
+DeclareAtom(XA_HOSTNAME)
+DeclareAtom(XA_IP_ADDRESS)
+DeclareAtom(XA_LENGTH)
+DeclareAtom(XA_LIST_LENGTH)
+DeclareAtom(XA_NAME)
+DeclareAtom(XA_NET_ADDRESS)
+DeclareAtom(XA_NULL)
+DeclareAtom(XA_OWNER_OS)
+DeclareAtom(XA_SPAN)
+DeclareAtom(XA_TARGETS)
+DeclareAtom(XA_TEXT)
+DeclareAtom(XA_TIMESTAMP)
+DeclareAtom(XA_USER)
+DeclareAtom(XA_UTF8_STRING)
+
+#endif /* SUNSHLIB */
|