f78b12e570284aa8291f4ca1add24937fd107403vboxsync/***********************************************************
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncCopyright 1987, 1998 The Open Group
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncthe above copyright notice appear in all copies and that both that
f78b12e570284aa8291f4ca1add24937fd107403vboxsynccopyright notice and this permission notice appear in supporting
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncdocumentation.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncThe above copyright notice and this permission notice shall be included in
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncall copies or substantial portions of the Software.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncin this Software without prior written authorization from The Open Group.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync All Rights Reserved
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncPermission to use, copy, modify, and distribute this software and its
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncdocumentation for any purpose and without fee is hereby granted,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncprovided that the above copyright notice appear in all copies and that
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncboth that copyright notice and this permission notice appear in
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncsupporting documentation, and that the name of Digital not be
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncused in advertising or publicity pertaining to distribution of the
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncsoftware without specific, written prior permission.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncSOFTWARE.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncCopyright 1992, 1993 Data General Corporation;
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncCopyright 1992, 1993 OMRON Corporation
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncdocumentation for any purpose is hereby granted without fee, provided that the
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncabove copyright notice appear in all copies and that both that copyright
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncnotice and this permission notice appear in supporting documentation, and that
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncneither the name OMRON or DATA GENERAL be used in advertising or publicity
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncpertaining to distribution of the software without specific, written prior
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncpermission of the party whose name is to be used. Neither OMRON or
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncDATA GENERAL make any representation about the suitability of this software
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncfor any purpose. It is provided "as is" without express or implied warranty.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncOMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncIN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncOF THIS SOFTWARE.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync******************************************************************/
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef MISC_H
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MISC_H 1
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * X internal definitions
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/Xosdefs.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/Xfuncproto.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/Xmd.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/X.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/Xdefs.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <stddef.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <stdint.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef MAXSCREENS
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXSCREENS 16
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXCLIENTS 256
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXEXTENSIONS 128
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXFORMATS 8
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXDEVICES 40 /* input devices */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define EXTENSION_EVENT_BASE 64
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define EXTENSION_BASE 128
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef uint32_t ATOM;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef TRUE
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define TRUE 1
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define FALSE 0
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef _XTYPEDEF_CALLBACKLISTPTR
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define _XTYPEDEF_CALLBACKLISTPTR
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _xReq *xReqPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define NullBox ((BoxPtr)0)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MILLI_PER_MIN (1000 * 60)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MILLI_PER_SECOND (1000)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync /* this next is used with None and ParentRelative to tell
f78b12e570284aa8291f4ca1add24937fd107403vboxsync PaintWin() what to use to paint the background. Also used
f78b12e570284aa8291f4ca1add24937fd107403vboxsync in the macro IS_VALID_PIXMAP */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define USE_BACKGROUND_PIXEL 3
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define USE_BORDER_PIXEL 3
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* byte swap a 32-bit literal */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define lswapl(x) ((((x) & 0xff) << 24) |\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (((x) & 0xff00) << 8) |\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (((x) & 0xff0000) >> 8) |\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (((x) >> 24) & 0xff))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* byte swap a short literal */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef min
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef max
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define min(a, b) (((a) < (b)) ? (a) : (b))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define max(a, b) (((a) > (b)) ? (a) : (b))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* abs() is a function, not a macro; include the file declaring
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * it in case we haven't done that yet.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <stdlib.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef Fabs
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* this assumes b > 0 */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * return the least significant bit in x which is set
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * This works on 1's complement and 2's complement machines.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * If you care about the extra instruction on 2's complement
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * machines, change to ((x) & (-(x)))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define lowbit(x) ((x) & (~(x) + 1))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* XXX Not for modules */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <limits.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#if !defined(MAXSHORT) || !defined(MINSHORT) || \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync !defined(MAXINT) || !defined(MININT)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/*
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Some implementations #define these through <math.h>, so preclude
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * #include'ing it later.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <math.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef MAXSHORT
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXSHORT SHRT_MAX
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef MINSHORT
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MINSHORT SHRT_MIN
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef MAXINT
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MAXINT INT_MAX
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#undef MININT
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define MININT INT_MIN
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <assert.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <ctype.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <stdio.h> /* for fopen, etc... */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef PATH_MAX
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#include <sys/param.h>
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef PATH_MAX
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifdef MAXPATHLEN
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define PATH_MAX MAXPATHLEN
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#else
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define PATH_MAX 1024
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/**
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Calculate the number of bytes needed to hold bits.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @param bits The minimum number of bits needed.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @return The number of bytes needed to hold bits.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncstatic inline int
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncbits_to_bytes(const int bits) {
f78b12e570284aa8291f4ca1add24937fd107403vboxsync return ((bits + 7) >> 3);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/**
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Calculate the number of 4-byte units needed to hold the given number of
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * bytes.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @param bytes The minimum number of bytes needed.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @return The number of 4-byte units needed to hold bytes.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncstatic inline int
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncbytes_to_int32(const int bytes) {
f78b12e570284aa8291f4ca1add24937fd107403vboxsync return (((bytes) + 3) >> 2);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/**
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Calculate the number of bytes (in multiples of 4) needed to hold bytes.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @param bytes The minimum number of bytes needed.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @return The closest multiple of 4 that is equal or higher than bytes.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncstatic inline int
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncpad_to_int32(const int bytes) {
f78b12e570284aa8291f4ca1add24937fd107403vboxsync return (((bytes) + 3) & ~3);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern char**
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncxstrtokenize(const char *str, const char* separators);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/**
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * Compare the two version numbers comprising of major.minor.
f78b12e570284aa8291f4ca1add24937fd107403vboxsync *
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * @return A value less than 0 if a is less than b, 0 if a is equal to b,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * or a value greater than 0
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncstatic inline int
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncversion_compare(uint16_t a_major, uint16_t a_minor,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync uint16_t b_major, uint16_t b_minor)
f78b12e570284aa8291f4ca1add24937fd107403vboxsync{
f78b12e570284aa8291f4ca1add24937fd107403vboxsync int a, b;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync a = a_major << 16 | a_minor;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync b = b_major << 16 | b_minor;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync return (a - b);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync}
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* some macros to help swap requests, replies, and events */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define LengthRestB(stuff) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((client->req_len << 2) - sizeof(*stuff))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define LengthRestS(stuff) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((client->req_len << 1) - (sizeof(*stuff) >> 1))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define LengthRestL(stuff) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync (client->req_len - (sizeof(*stuff) >> 2))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SwapRestS(stuff) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define SwapRestL(stuff) \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* byte swap a 32-bit value */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define swapl(x, n) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync n = ((char *) (x))[0];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[0] = ((char *) (x))[3];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[3] = n;\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync n = ((char *) (x))[1];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[1] = ((char *) (x))[2];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[2] = n; }
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* byte swap a short */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define swaps(x, n) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync n = ((char *) (x))[0];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[0] = ((char *) (x))[1];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) (x))[1] = n; }
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* copy 32-bit value from src to dst byteswapping on the way */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define cpswapl(src, dst) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *)&(dst))[0] = ((char *) &(src))[3];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *)&(dst))[1] = ((char *) &(src))[2];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *)&(dst))[2] = ((char *) &(src))[1];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *)&(dst))[3] = ((char *) &(src))[0]; }
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* copy short from src to dst byteswapping on the way */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define cpswaps(src, dst) { \
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) &(dst))[0] = ((char *) &(src))[1];\
f78b12e570284aa8291f4ca1add24937fd107403vboxsync ((char *) &(dst))[1] = ((char *) &(src))[0]; }
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT void SwapLongs(
f78b12e570284aa8291f4ca1add24937fd107403vboxsync CARD32 *list,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned long count);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT void SwapShorts(
f78b12e570284aa8291f4ca1add24937fd107403vboxsync short *list,
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned long count);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT void MakePredeclaredAtoms(void);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT int Ones(
f78b12e570284aa8291f4ca1add24937fd107403vboxsync unsigned long /*mask*/);
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _xPoint *DDXPointPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct pixman_box16 *BoxPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _xEvent *xEventPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _xRectangle *xRectanglePtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _GrabRec *GrabPtr;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync/* typedefs from other places - duplicated here to minimize the amount
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * of unnecessary junk that one would normally have to include to get
f78b12e570284aa8291f4ca1add24937fd107403vboxsync * these symbols defined
f78b12e570284aa8291f4ca1add24937fd107403vboxsync */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#ifndef _XTYPEDEF_CHARINFOPTR
f78b12e570284aa8291f4ca1add24937fd107403vboxsynctypedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#define _XTYPEDEF_CHARINFOPTR
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT unsigned long globalSerialNumber;
f78b12e570284aa8291f4ca1add24937fd107403vboxsyncextern _X_EXPORT unsigned long serverGeneration;
f78b12e570284aa8291f4ca1add24937fd107403vboxsync
f78b12e570284aa8291f4ca1add24937fd107403vboxsync#endif /* MISC_H */