diff options
Diffstat (limited to 'xorg-server/Xext')
39 files changed, 2238 insertions, 2090 deletions
diff --git a/xorg-server/Xext/Makefile.am b/xorg-server/Xext/Makefile.am index 2f5c98b90..ac45f955a 100644 --- a/xorg-server/Xext/Makefile.am +++ b/xorg-server/Xext/Makefile.am @@ -26,6 +26,7 @@ BUILTIN_SRCS = \ sleepuntil.c \ sleepuntil.h \ sync.c \ + syncsrv.h \ xcmisc.c \ xtest.c @@ -62,6 +63,9 @@ endif XINERAMA_SRCS = panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c if XINERAMA BUILTIN_SRCS += $(XINERAMA_SRCS) +if XORG +sdk_HEADERS += panoramiXsrv.h panoramiX.h +endif endif # X-ACE extension: provides hooks for building security policy extensions @@ -69,6 +73,9 @@ endif XACE_SRCS = xace.c xace.h xacestr.h if XACE BUILTIN_SRCS += $(XACE_SRCS) +if XORG +sdk_HEADERS += xace.h xacestr.h +endif endif # SELinux extension: provides SELinux policy support for X objects diff --git a/xorg-server/Xext/Makefile.in b/xorg-server/Xext/Makefile.in index 7581a4de7..6c7a2e594 100644 --- a/xorg-server/Xext/Makefile.in +++ b/xorg-server/Xext/Makefile.in @@ -40,19 +40,24 @@ host_triplet = @host@ @RES_TRUE@am__append_3 = $(RES_SRCS) @SCREENSAVER_TRUE@am__append_4 = $(SCREENSAVER_SRCS) @XINERAMA_TRUE@am__append_5 = $(XINERAMA_SRCS) -@XACE_TRUE@am__append_6 = $(XACE_SRCS) -@XSELINUX_TRUE@am__append_7 = $(XSELINUX_SRCS) -@XCSECURITY_TRUE@am__append_8 = $(XCSECURITY_SRCS) -@XCALIBRATE_TRUE@am__append_9 = $(XCALIBRATE_SRCS) -@MULTIBUFFER_TRUE@am__append_10 = $(MULTIBUFFER_SRCS) -@XF86BIGFONT_TRUE@am__append_11 = $(BIGFONT_SRCS) -@DPMSExtension_TRUE@am__append_12 = $(DPMS_SRCS) +@XINERAMA_TRUE@@XORG_TRUE@am__append_6 = panoramiXsrv.h panoramiX.h +@XACE_TRUE@am__append_7 = $(XACE_SRCS) +@XACE_TRUE@@XORG_TRUE@am__append_8 = xace.h xacestr.h +@XSELINUX_TRUE@am__append_9 = $(XSELINUX_SRCS) +@XCSECURITY_TRUE@am__append_10 = $(XCSECURITY_SRCS) +@XCALIBRATE_TRUE@am__append_11 = $(XCALIBRATE_SRCS) +@MULTIBUFFER_TRUE@am__append_12 = $(MULTIBUFFER_SRCS) +@XF86BIGFONT_TRUE@am__append_13 = $(BIGFONT_SRCS) +@DPMSExtension_TRUE@am__append_14 = $(DPMS_SRCS) subdir = Xext DIST_COMMON = $(am__sdk_HEADERS_DIST) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ + $(top_srcdir)/m4/dolt.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/shave.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -62,13 +67,14 @@ CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ $(top_builddir)/include/xorg-config.h \ $(top_builddir)/include/xkb-config.h \ $(top_builddir)/include/xwin-config.h \ - $(top_builddir)/include/kdrive-config.h + $(top_builddir)/include/kdrive-config.h \ + $(top_builddir)/include/version-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libXext_la_LIBADD = am__libXext_la_SOURCES_DIST = bigreq.c geext.c shape.c sleepuntil.c \ - sleepuntil.h sync.c xcmisc.c xtest.c shm.c shmint.h \ + sleepuntil.h sync.c syncsrv.h xcmisc.c xtest.c shm.c shmint.h \ panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h \ panoramiXprocs.c panoramiXSwap.c xace.c xace.h xacestr.h \ security.c securitysrv.h xcalibrate.c xf86bigfont.c xvmain.c \ @@ -110,10 +116,10 @@ libXext_la_OBJECTS = $(am_libXext_la_OBJECTS) @XORG_TRUE@am_libXext_la_rpath = libXextbuiltin_la_LIBADD = am__libXextbuiltin_la_SOURCES_DIST = bigreq.c geext.c shape.c \ - sleepuntil.c sleepuntil.h sync.c xcmisc.c xtest.c shm.c \ - shmint.h panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h \ - panoramiXprocs.c panoramiXSwap.c xace.c xace.h xacestr.h \ - security.c securitysrv.h xcalibrate.c xf86bigfont.c + sleepuntil.c sleepuntil.h sync.c syncsrv.h xcmisc.c xtest.c \ + shm.c shmint.h panoramiX.c panoramiX.h panoramiXh.h \ + panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c xace.c xace.h \ + xacestr.h security.c securitysrv.h xcalibrate.c xf86bigfont.c @XORG_TRUE@am_libXextbuiltin_la_OBJECTS = $(am__objects_13) libXextbuiltin_la_OBJECTS = $(am_libXextbuiltin_la_OBJECTS) @XORG_TRUE@am_libXextbuiltin_la_rpath = @@ -139,7 +145,8 @@ SOURCES = $(libXext_la_SOURCES) $(libXextbuiltin_la_SOURCES) \ DIST_SOURCES = $(am__libXext_la_SOURCES_DIST) \ $(am__libXextbuiltin_la_SOURCES_DIST) \ $(am__libXextmodule_la_SOURCES_DIST) -am__sdk_HEADERS_DIST = xvdix.h xvmcext.h geext.h geint.h shmint.h +am__sdk_HEADERS_DIST = xvdix.h xvmcext.h geext.h geint.h shmint.h \ + panoramiXsrv.h panoramiX.h xace.h xacestr.h am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -171,6 +178,7 @@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_MAKEFLAGS = @AM_MAKEFLAGS@ APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ APPLE_APPLICATION_ID = @APPLE_APPLICATION_ID@ APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@ @@ -191,9 +199,12 @@ CCASDEPMODE = @CCASDEPMODE@ CCASFLAGS = @CCASFLAGS@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CHANGELOG_CMD = @CHANGELOG_CMD@ COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CWARNFLAGS = @CWARNFLAGS@ +CXX = @CXX@ CYGPATH_W = @CYGPATH_W@ DARWIN_LIBS = @DARWIN_LIBS@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -222,7 +233,9 @@ DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ DRIPROTO_LIBS = @DRIPROTO_LIBS@ DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_CFLAGS = @DRI_CFLAGS@ DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DRI_LIBS = @DRI_LIBS@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ @@ -231,9 +244,13 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +F77 = @F77@ +FC = @FC@ FGREP = @FGREP@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ GLX_DEFINES = @GLX_DEFINES@ GL_CFLAGS = @GL_CFLAGS@ @@ -272,12 +289,13 @@ LTCOMPILE = @LTCOMPILE@ LTCXXCOMPILE = @LTCXXCOMPILE@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ +MAIN_LIB = @MAIN_LIB@ +MAKEFLAGS = @MAKEFLAGS@ MAKEINFO = @MAKEINFO@ MAKE_HTML = @MAKE_HTML@ MAKE_PDF = @MAKE_PDF@ MAKE_PS = @MAKE_PS@ MAKE_TEXT = @MAKE_TEXT@ -MESA_SOURCE = @MESA_SOURCE@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ MKDIR_P = @MKDIR_P@ @@ -297,7 +315,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ @@ -307,6 +324,7 @@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PROJECTROOT = @PROJECTROOT@ PS2PDF = @PS2PDF@ +Q = @Q@ RANLIB = @RANLIB@ RAWCPP = @RAWCPP@ RAWCPPFLAGS = @RAWCPPFLAGS@ @@ -320,11 +338,10 @@ STRIP = @STRIP@ TSLIB_CFLAGS = @TSLIB_CFLAGS@ TSLIB_LIBS = @TSLIB_LIBS@ UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ -VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ -VENDOR_NAME = @VENDOR_NAME@ +V = @V@ VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ -VENDOR_RELEASE = @VENDOR_RELEASE@ VERSION = @VERSION@ +WINDRES = @WINDRES@ X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ XDMCP_CFLAGS = @XDMCP_CFLAGS@ @@ -360,6 +377,7 @@ XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ XORG_SYS_LIBS = @XORG_SYS_LIBS@ XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@ XPBPROXY_LIBS = @XPBPROXY_LIBS@ +XQUARTZ_SPARKLE = @XQUARTZ_SPARKLE@ XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ XSDL_INCS = @XSDL_INCS@ @@ -384,7 +402,6 @@ YFLAGS = @YFLAGS@ __XCONFIGFILE__ = @__XCONFIGFILE__@ abi_ansic = @abi_ansic@ abi_extension = @abi_extension@ -abi_font = @abi_font@ abi_videodrv = @abi_videodrv@ abi_xinput = @abi_xinput@ abs_builddir = @abs_builddir@ @@ -407,6 +424,7 @@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ +distcleancheck_listfiles = @distcleancheck_listfiles@ docdir = @docdir@ driverdir = @driverdir@ dvidir = @dvidir@ @@ -438,7 +456,9 @@ psdir = @psdir@ sbindir = @sbindir@ sdkdir = @sdkdir@ sharedstatedir = @sharedstatedir@ +shavedir = @shavedir@ srcdir = @srcdir@ +symbol_visibility = @symbol_visibility@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ @@ -455,17 +475,18 @@ top_srcdir = @top_srcdir@ @XORG_TRUE@noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod AM_CFLAGS = $(DIX_CFLAGS) -@XORG_TRUE@sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h +@XORG_TRUE@sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h \ +@XORG_TRUE@ $(am__append_6) $(am__append_8) # Sources always included in libXextbuiltin.la & libXext.la BUILTIN_SRCS = bigreq.c geext.c shape.c sleepuntil.c sleepuntil.h \ - sync.c xcmisc.c xtest.c $(am__append_1) $(am__append_5) \ - $(am__append_6) $(am__append_8) $(am__append_9) \ - $(am__append_11) + sync.c syncsrv.h xcmisc.c xtest.c $(am__append_1) \ + $(am__append_5) $(am__append_7) $(am__append_10) \ + $(am__append_11) $(am__append_13) # Sources always included in libXextmodule.la & libXext.la. That's right, zero. MODULE_SRCS = $(am__append_2) $(am__append_3) $(am__append_4) \ - $(am__append_7) $(am__append_10) $(am__append_12) + $(am__append_9) $(am__append_12) $(am__append_14) # Optional sources included if extension enabled by configure.ac rules diff --git a/xorg-server/Xext/bigreq.c b/xorg-server/Xext/bigreq.c index 1e807d820..582b670b0 100644 --- a/xorg-server/Xext/bigreq.c +++ b/xorg-server/Xext/bigreq.c @@ -26,7 +26,6 @@ from The Open Group. */ -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -37,7 +36,7 @@ from The Open Group. #include "os.h" #include "dixstruct.h" #include "extnsionst.h" -#include <X11/extensions/bigreqstr.h> +#include <X11/extensions/bigreqsproto.h> #include "opaque.h" #include "modinit.h" @@ -52,8 +51,7 @@ BigReqExtensionInit(INITARGS) } static int -ProcBigReqDispatch (client) - ClientPtr client; +ProcBigReqDispatch (ClientPtr client) { REQUEST(xBigReqEnableReq); xBigReqEnableReply rep; @@ -66,6 +64,7 @@ ProcBigReqDispatch (client) return BadRequest; REQUEST_SIZE_MATCH(xBigReqEnableReq); client->big_requests = TRUE; + memset(&rep, 0, sizeof(xBigReqEnableReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/xorg-server/Xext/dpms.c b/xorg-server/Xext/dpms.c index bad7aa64f..df63a8bf1 100644 --- a/xorg-server/Xext/dpms.c +++ b/xorg-server/Xext/dpms.c @@ -26,13 +26,6 @@ Equipment Corporation. ******************************************************************/ -/* - * HISTORY - * - * @(#)RCSfile: dpms.c,v Revision: 1.1.4.5 (DEC) Date: 1996/03/04 15:27:00 - */ - - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -44,42 +37,12 @@ Equipment Corporation. #include "dixstruct.h" #include "extnsionst.h" #include "opaque.h" -#define DPMS_SERVER -#include <X11/extensions/dpms.h> -#include <X11/extensions/dpmsstr.h> +#include <X11/extensions/dpmsproto.h> #include "dpmsproc.h" #include "modinit.h" -static DISPATCH_PROC(ProcDPMSDispatch); -static DISPATCH_PROC(SProcDPMSDispatch); -static DISPATCH_PROC(ProcDPMSGetVersion); -static DISPATCH_PROC(SProcDPMSGetVersion); -static DISPATCH_PROC(ProcDPMSGetTimeouts); -static DISPATCH_PROC(SProcDPMSGetTimeouts); -static DISPATCH_PROC(ProcDPMSSetTimeouts); -static DISPATCH_PROC(SProcDPMSSetTimeouts); -static DISPATCH_PROC(ProcDPMSEnable); -static DISPATCH_PROC(SProcDPMSEnable); -static DISPATCH_PROC(ProcDPMSDisable); -static DISPATCH_PROC(SProcDPMSDisable); -static DISPATCH_PROC(ProcDPMSForceLevel); -static DISPATCH_PROC(SProcDPMSForceLevel); -static DISPATCH_PROC(ProcDPMSInfo); -static DISPATCH_PROC(SProcDPMSInfo); -static DISPATCH_PROC(ProcDPMSCapable); -static DISPATCH_PROC(SProcDPMSCapable); - -void -DPMSExtensionInit(INITARGS) -{ - AddExtension(DPMSExtensionName, 0, 0, - ProcDPMSDispatch, SProcDPMSDispatch, - NULL, StandardMinorOpcode); -} - static int -ProcDPMSGetVersion(client) - ClientPtr client; +ProcDPMSGetVersion(ClientPtr client) { /* REQUEST(xDPMSGetVersionReq); */ xDPMSGetVersionReply rep; @@ -123,8 +86,7 @@ ProcDPMSCapable(ClientPtr client) } static int -ProcDPMSGetTimeouts(client) - ClientPtr client; +ProcDPMSGetTimeouts(ClientPtr client) { /* REQUEST(xDPMSGetTimeoutsReq); */ xDPMSGetTimeoutsReply rep; @@ -150,8 +112,7 @@ ProcDPMSGetTimeouts(client) } static int -ProcDPMSSetTimeouts(client) - ClientPtr client; +ProcDPMSSetTimeouts(ClientPtr client) { REQUEST(xDPMSSetTimeoutsReq); @@ -177,8 +138,7 @@ ProcDPMSSetTimeouts(client) } static int -ProcDPMSEnable(client) - ClientPtr client; +ProcDPMSEnable(ClientPtr client) { Bool was_enabled = DPMSEnabled; @@ -194,8 +154,7 @@ ProcDPMSEnable(client) } static int -ProcDPMSDisable(client) - ClientPtr client; +ProcDPMSDisable(ClientPtr client) { /* REQUEST(xDPMSDisableReq); */ @@ -209,8 +168,7 @@ ProcDPMSDisable(client) } static int -ProcDPMSForceLevel(client) - ClientPtr client; +ProcDPMSForceLevel(ClientPtr client) { REQUEST(xDPMSForceLevelReq); @@ -219,19 +177,10 @@ ProcDPMSForceLevel(client) if (!DPMSEnabled) return BadMatch; - if (stuff->level == DPMSModeOn) { - lastDeviceEventTime.milliseconds = - GetTimeInMillis(); - } else if (stuff->level == DPMSModeStandby) { - lastDeviceEventTime.milliseconds = - GetTimeInMillis() - DPMSStandbyTime; - } else if (stuff->level == DPMSModeSuspend) { - lastDeviceEventTime.milliseconds = - GetTimeInMillis() - DPMSSuspendTime; - } else if (stuff->level == DPMSModeOff) { - lastDeviceEventTime.milliseconds = - GetTimeInMillis() - DPMSOffTime; - } else { + if (stuff->level != DPMSModeOn && + stuff->level != DPMSModeStandby && + stuff->level != DPMSModeSuspend && + stuff->level != DPMSModeOff) { client->errorValue = stuff->level; return BadValue; } @@ -265,8 +214,7 @@ ProcDPMSInfo(ClientPtr client) } static int -ProcDPMSDispatch (client) - ClientPtr client; +ProcDPMSDispatch (ClientPtr client) { REQUEST(xReq); @@ -294,8 +242,7 @@ ProcDPMSDispatch (client) } static int -SProcDPMSGetVersion(client) - ClientPtr client; +SProcDPMSGetVersion(ClientPtr client) { int n; REQUEST(xDPMSGetVersionReq); @@ -320,8 +267,7 @@ SProcDPMSCapable(ClientPtr client) } static int -SProcDPMSGetTimeouts(client) - ClientPtr client; +SProcDPMSGetTimeouts(ClientPtr client) { REQUEST(xDPMSGetTimeoutsReq); int n; @@ -333,8 +279,7 @@ SProcDPMSGetTimeouts(client) } static int -SProcDPMSSetTimeouts(client) - ClientPtr client; +SProcDPMSSetTimeouts(ClientPtr client) { REQUEST(xDPMSSetTimeoutsReq); int n; @@ -349,8 +294,7 @@ SProcDPMSSetTimeouts(client) } static int -SProcDPMSEnable(client) - ClientPtr client; +SProcDPMSEnable(ClientPtr client) { REQUEST(xDPMSEnableReq); int n; @@ -362,8 +306,7 @@ SProcDPMSEnable(client) } static int -SProcDPMSDisable(client) - ClientPtr client; +SProcDPMSDisable(ClientPtr client) { REQUEST(xDPMSDisableReq); int n; @@ -375,8 +318,7 @@ SProcDPMSDisable(client) } static int -SProcDPMSForceLevel(client) - ClientPtr client; +SProcDPMSForceLevel(ClientPtr client) { REQUEST(xDPMSForceLevelReq); int n; @@ -390,8 +332,7 @@ SProcDPMSForceLevel(client) } static int -SProcDPMSInfo(client) - ClientPtr client; +SProcDPMSInfo(ClientPtr client) { REQUEST(xDPMSInfoReq); int n; @@ -403,8 +344,7 @@ SProcDPMSInfo(client) } static int -SProcDPMSDispatch (client) - ClientPtr client; +SProcDPMSDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) @@ -429,3 +369,11 @@ SProcDPMSDispatch (client) return BadRequest; } } + +void +DPMSExtensionInit(INITARGS) +{ + AddExtension(DPMSExtensionName, 0, 0, + ProcDPMSDispatch, SProcDPMSDispatch, + NULL, StandardMinorOpcode); +} diff --git a/xorg-server/Xext/dpmsproc.h b/xorg-server/Xext/dpmsproc.h index d57f57318..c1df56fdf 100644 --- a/xorg-server/Xext/dpmsproc.h +++ b/xorg-server/Xext/dpmsproc.h @@ -1,4 +1,3 @@ - /* Prototypes for functions that the DDX must provide */ #ifdef HAVE_DIX_CONFIG_H @@ -11,7 +10,6 @@ #include "dixstruct.h" int DPMSSet(ClientPtr client, int level); -int DPMSGet(int *plevel); Bool DPMSSupported(void); #endif diff --git a/xorg-server/Xext/dpmsstubs.c b/xorg-server/Xext/dpmsstubs.c index 0f59d5160..f0f54d293 100644 --- a/xorg-server/Xext/dpmsstubs.c +++ b/xorg-server/Xext/dpmsstubs.c @@ -39,11 +39,6 @@ Bool DPMSSupported(void) return FALSE; } -int DPMSGet(int *plevel) -{ - return -1; -} - int DPMSSet(ClientPtr client, int level) { return Success; diff --git a/xorg-server/Xext/geext.c b/xorg-server/Xext/geext.c index 7ab99517d..1ddcbb1f6 100644 --- a/xorg-server/Xext/geext.c +++ b/xorg-server/Xext/geext.c @@ -58,7 +58,6 @@ static const int version_requests[] = { /* Forward declarations */ static void SGEGenericEvent(xEvent* from, xEvent* to); -static void GERecalculateWinMask(WindowPtr pWin); #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) @@ -217,43 +216,6 @@ SGEGenericEvent(xEvent* from, xEvent* to) GEExtensions[gefrom->extension & 0x7F].evswap(gefrom, geto); } -/** - * Resource callback, invoked when the client disconnects and the associated - * GE masks must be destroyed. - */ -static int -GEClientGone(WindowPtr pWin, XID id) -{ - GenericClientMasksPtr gclmask; - GenericMaskPtr gmask, prev = NULL; - - if (!pWin || !pWin->optional) - return Success; - - gclmask = pWin->optional->geMasks; - for (gmask = gclmask->geClients; gmask; gmask = gmask->next) - { - if (gmask->resource == id) - { - if (prev) - { - prev->next = gmask->next; - xfree(gmask); - } else { - gclmask->geClients = NULL; - CheckWindowOptionalNeed(pWin); - GERecalculateWinMask(pWin); - xfree(gmask); - } - return Success; - } - prev = gmask; - } - - FatalError("Client not a GE client"); - return BadImplementation; -} - /* Init extension, register at server. * Since other extensions may rely on XGE (XInput does already), it is a good * idea to init XGE first, before any other extension. @@ -277,9 +239,6 @@ GEExtensionInit(void) GEErrorBase = extEntry->errorBase; GEEventType = GEEventBase; - RT_GECLIENT = CreateNewResourceType((DeleteType)GEClientGone); - RegisterResourceName(RT_GECLIENT, "GECLIENT"); - memset(GEExtensions, 0, sizeof(GEExtensions)); EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; @@ -302,16 +261,13 @@ GEExtensionInit(void) */ void GERegisterExtension(int extension, - void (*ev_swap)(xGenericEvent* from, xGenericEvent* to), - void (*ev_fill)(xGenericEvent* ev, DeviceIntPtr pDev, - WindowPtr pWin, GrabPtr pGrab)) + void (*ev_swap)(xGenericEvent* from, xGenericEvent* to)) { if ((extension & 0x7F) >= MAXEXTENSIONS) FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n"); /* extension opcodes are > 128, might as well save some space here */ GEExtensions[extension & 0x7f].evswap = ev_swap; - GEExtensions[extension & 0x7f].evfill = ev_fill; } @@ -326,149 +282,3 @@ GEInitEvent(xGenericEvent* ev, int extension) ev->length = 0; } -/* Recalculates the summary mask for the window. */ -static void -GERecalculateWinMask(WindowPtr pWin) -{ - int i; - GenericMaskPtr it; - GenericClientMasksPtr evmasks; - - if (!pWin->optional) - return; - - evmasks = pWin->optional->geMasks; - - for (i = 0; i < MAXEXTENSIONS; i++) - { - evmasks->eventMasks[i] = 0; - } - - it = pWin->optional->geMasks->geClients; - while(it) - { - for (i = 0; i < MAXEXTENSIONS; i++) - { - evmasks->eventMasks[i] |= it->eventMask[i]; - } - it = it->next; - } -} - -/* Set generic event mask for given window. */ -void -GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev, - WindowPtr pWin, int extension, Mask mask) -{ - GenericMaskPtr cli; - - extension = (extension & 0x7F); - - if (extension >= MAXEXTENSIONS) - { - ErrorF("Invalid extension number.\n"); - return; - } - - if (!pWin->optional && !MakeWindowOptional(pWin)) - { - ErrorF("GE: Could not make window optional.\n"); - return; - } - - if (mask) - { - GenericClientMasksPtr evmasks = pWin->optional->geMasks; - - /* check for existing client */ - cli = evmasks->geClients; - while(cli) - { - if (rClient(cli) == pClient && cli->dev == pDev) - break; - cli = cli->next; - } - if (!cli) - { - /* new client and/or new device */ - cli = (GenericMaskPtr)xcalloc(1, sizeof(GenericMaskRec)); - if (!cli) - { - ErrorF("GE: Insufficient memory to alloc client.\n"); - return; - } - cli->next = evmasks->geClients; - cli->resource = FakeClientID(pClient->index); - cli->dev = pDev; - evmasks->geClients = cli; - AddResource(cli->resource, RT_GECLIENT, (pointer)pWin); - } - cli->eventMask[extension] = mask; - } else - { - /* remove client. */ - cli = pWin->optional->geMasks->geClients; - if (rClient(cli) == pClient && cli->dev == pDev) - { - pWin->optional->geMasks->geClients = cli->next; - xfree(cli); - } else - { - GenericMaskPtr prev = cli; - cli = cli->next; - - while(cli) - { - if (rClient(cli) == pClient && cli->dev == pDev) - { - prev->next = cli->next; - xfree(cli); - break; - } - prev = cli; - cli = cli->next; - } - } - if (!cli) - return; - } - - GERecalculateWinMask(pWin); -} - -/** - * Return TRUE if the mask for the given device is set. - * @param pWin Window the event may be delivered to. - * @param pDev Device the device originating the event. May be NULL. - * @param extension Extension ID - * @param mask Event mask - */ -BOOL -GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev, - int extension, Mask mask) -{ - GenericMaskPtr gemask; - - if (!pWin->optional || !pWin->optional->geMasks) - return FALSE; - - extension &= 0x7F; - - if (!pWin->optional->geMasks->eventMasks[extension] & mask) - return FALSE; - - - gemask = pWin->optional->geMasks->geClients; - - while(gemask) - { - if ((!gemask->dev || gemask->dev == pDev) && - (gemask->eventMask[extension] & mask)) - return TRUE; - - gemask = gemask->next; - } - - return FALSE; -} - diff --git a/xorg-server/Xext/geext.h b/xorg-server/Xext/geext.h index 3d1665373..8e6dbeb24 100644 --- a/xorg-server/Xext/geext.h +++ b/xorg-server/Xext/geext.h @@ -34,46 +34,23 @@ from the author. #define _GEEXT_H_ #include <X11/extensions/geproto.h> - -/** - * This struct is used both in the window and by grabs to determine the event - * mask for a client. - * A window will have a linked list of these structs, with one entry per - * client per device, null-terminated. - * A grab has only one instance of this struct. - */ -typedef struct _GenericMaskRec { - struct _GenericMaskRec* next; - XID resource; /* id for the resource manager */ - DeviceIntPtr dev; - Mask eventMask[MAXEXTENSIONS]; /* one mask per extension */ -} GenericMaskRec, *GenericMaskPtr; - - -/* Struct to keep information about registered extensions - * - * evswap ... use to swap event fields for different byte ordered clients. - * evfill ... use to fill various event fields from the given parameters. - */ +/** Struct to keep information about registered extensions */ typedef struct _GEExtension { + /** Event swapping routine */ void (*evswap)(xGenericEvent* from, xGenericEvent* to); - void (*evfill)(xGenericEvent* ev, - DeviceIntPtr pDev, /* device */ - WindowPtr pWin, /* event window */ - GrabPtr pGrab /* current grab, may be NULL */ - ); } GEExtension, *GEExtensionPtr; /* All registered extensions and their handling functions. */ -extern GEExtension GEExtensions[MAXEXTENSIONS]; +extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; +/* Typecast to generic event */ +#define GEV(ev) ((xGenericEvent*)(ev)) /* Returns the extension offset from the event */ -#define GEEXT(ev) (((xGenericEvent*)(ev))->extension) +#define GEEXT(ev) (GEV(ev)->extension) +/* Return zero-based extension offset (offset - 128). Only for use in arrays */ #define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) -/* Typecast to generic event */ -#define GEV(ev) ((xGenericEvent*)(ev)) /* True if mask is set for extension on window */ #define GEMaskIsSet(pWin, extension, mask) \ ((pWin)->optional && \ @@ -86,29 +63,21 @@ extern GEExtension GEExtensions[MAXEXTENSIONS]; /* Returns the event_fill for the given event */ #define GEEventFill(ev) \ - GEExtensions[GEEXTIDX(xE)].evfill + GEExtensions[GEEXTIDX(ev)].evfill #define GEIsType(ev, ext, ev_type) \ - ((ev->u.u.type == GenericEvent) && \ - ((xGenericEvent*)(ev))->extension == ext && \ - ((xGenericEvent*)(ev))->evtype == ev_type) + ((GEV(ev)->type == GenericEvent) && \ + GEEXT(ev) == (ext) && \ + GEV(ev)->evtype == (ev_type)) /* Interface for other extensions */ -void GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev, - WindowPtr pWin, int extension, Mask mask); - -void GERegisterExtension( +extern _X_EXPORT void GERegisterExtension( int extension, - void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to), - void (*ev_fill)(xGenericEvent* ev, DeviceIntPtr pDev, - WindowPtr pWin, GrabPtr pGrab) - ); + void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to)); -void GEInitEvent(xGenericEvent* ev, int extension); -BOOL GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev, - int extension, Mask mask); +extern _X_EXPORT void GEInitEvent(xGenericEvent* ev, int extension); -void GEExtensionInit(void); +extern _X_EXPORT void GEExtensionInit(void); #endif /* _GEEXT_H_ */ diff --git a/xorg-server/Xext/geint.h b/xorg-server/Xext/geint.h index 60cba7d72..881d30661 100644 --- a/xorg-server/Xext/geint.h +++ b/xorg-server/Xext/geint.h @@ -29,7 +29,6 @@ #ifndef _GEINT_H_ #define _GEINT_H_ -#define NEED_EVENTS #include <X11/X.h> #include <X11/Xproto.h> #include "misc.h" @@ -38,10 +37,10 @@ #include "extnsionst.h" #include <X11/extensions/geproto.h> -extern int GEEventType; -extern int GEEventBase; -extern int GEErrorBase; -extern DevPrivateKey GEClientPrivateKey; +extern _X_EXPORT int GEEventType; +extern _X_EXPORT int GEEventBase; +extern _X_EXPORT int GEErrorBase; +extern _X_EXPORT DevPrivateKey GEClientPrivateKey; typedef struct _GEClientInfo { CARD32 major_version; @@ -50,7 +49,7 @@ typedef struct _GEClientInfo { #define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) -extern int (*ProcGEVector[/*GENumRequests*/])(ClientPtr); -extern int (*SProcGEVector[/*GENumRequests*/])(ClientPtr); +extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr); +extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr); #endif /* _GEINT_H_ */ diff --git a/xorg-server/Xext/mbuf.c b/xorg-server/Xext/mbuf.c index 39b8ba11e..55e732a9f 100644 --- a/xorg-server/Xext/mbuf.c +++ b/xorg-server/Xext/mbuf.c @@ -24,8 +24,6 @@ in this Software without prior written authorization from The Open Group. ********************************************************/ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -205,7 +203,7 @@ MultibufferExtensionInit() for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; - if (!(pMultibufferScreen = (MultibufferScreenPtr) xalloc (sizeof (MultibufferScreenRec)))) + if (!(pMultibufferScreen = xalloc (sizeof (MultibufferScreenRec)))) { for (j = 0; j < i; j++) xfree (dixLookupPrivate(&screenInfo.screens[j]->devPrivates, MultibufferScreenPrivKey)); @@ -350,8 +348,7 @@ CreateImageBuffers (pWin, nbuf, ids, action, hint) xRectangle clearRect; DestroyImageBuffers(pWin); - pMultibuffers = (MultibuffersPtr) xalloc (sizeof (MultibuffersRec) + - nbuf * sizeof (MultibufferRec)); + pMultibuffers = xalloc (sizeof (MultibuffersRec) + nbuf * sizeof (MultibufferRec)); if (!pMultibuffers) return BadAlloc; pMultibuffers->pWindow = pWin; @@ -433,7 +430,7 @@ ProcCreateImageBuffers (client) int len, nbuf, i, err, rc; REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); - len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof(xMbufCreateImageBuffersReq)); if (len == 0) return BadLength; rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); @@ -501,13 +498,13 @@ ProcDisplayImageBuffers (client) REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); - nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2); + nbuf = stuff->length - bytes_to_int32(sizeof (xMbufDisplayImageBuffersReq)); if (!nbuf) return Success; minDelay = stuff->minDelay; ids = (XID *) &stuff[1]; - ppMultibuffers = (MultibuffersPtr *) xalloc(nbuf * sizeof (MultibuffersPtr)); - pMultibuffer = (MultibufferPtr *) xalloc(nbuf * sizeof (MultibufferPtr)); + ppMultibuffers = xalloc(nbuf * sizeof (MultibuffersPtr)); + pMultibuffer = xalloc(nbuf * sizeof (MultibufferPtr)); if (!ppMultibuffers || !pMultibuffer) { if (ppMultibuffers) xfree(ppMultibuffers); @@ -595,7 +592,7 @@ ProcSetMBufferAttributes (client) pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadMatch; - len = stuff->length - (sizeof (xMbufSetMBufferAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq)); vmask = stuff->valueMask; if (len != Ones (vmask)) return BadLength; @@ -647,7 +644,7 @@ ProcGetMBufferAttributes (client) pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType); if (!pMultibuffers) return BadAccess; - ids = (XID *) xalloc (pMultibuffers->numMultibuffer * sizeof (XID)); + ids = xalloc (pMultibuffers->numMultibuffer * sizeof (XID)); if (!ids) return BadAlloc; for (i = 0; i < pMultibuffers->numMultibuffer; i++) @@ -690,7 +687,7 @@ ProcSetBufferAttributes (client) pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType); if (!pMultibuffer) return MultibufferErrorBase + MultibufferBadBuffer; - len = stuff->length - (sizeof (xMbufSetBufferAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq)); vmask = stuff->valueMask; if (len != Ones (vmask)) return BadLength; @@ -784,14 +781,13 @@ ProcGetBufferInfo (client) pDepth = &pScreen->allowedDepths[i]; nInfo += pDepth->numVids; } - pInfo = (xMbufBufferInfo *) - xalloc (nInfo * sizeof (xMbufBufferInfo)); + pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo)); if (!pInfo) return BadAlloc; rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.length = nInfo * (sizeof (xMbufBufferInfo) >> 2); + rep.length = nInfo * bytes_to_int32(sizeof (xMbufBufferInfo)); rep.normalInfo = nInfo; rep.stereoInfo = 0; if (client->swapped) @@ -1108,6 +1104,34 @@ SClobberNotifyEvent (from, to) to->state = from->state; } +RegionPtr CreateUnclippedWinSize(WindowPtr pWin); + +RegionPtr +CreateUnclippedWinSize (WindowPtr pWin) +{ + RegionPtr pRgn; + BoxRec box; + + box.x1 = pWin->drawable.x; + box.y1 = pWin->drawable.y; + box.x2 = pWin->drawable.x + (int) pWin->drawable.width; + box.y2 = pWin->drawable.y + (int) pWin->drawable.height; + pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1); + if (wBoundingShape (pWin) || wClipShape (pWin)) { + ScreenPtr pScreen; + pScreen = pWin->drawable.pScreen; + + REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x, + - pWin->drawable.y); + if (wBoundingShape (pWin)) + REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); + if (wClipShape (pWin)) + REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin)); + REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y); + } + return pRgn; +} + static void PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf) MultibufferPtr *pMultibuffer; @@ -1238,8 +1262,8 @@ DisplayImageBuffers (ids, nbuf) MultibuffersPtr *pMultibuffers; int i, j; - pMultibuffer = (MultibufferPtr *) xalloc (nbuf * sizeof *pMultibuffer + - nbuf * sizeof *pMultibuffers); + pMultibuffer = xalloc (nbuf * sizeof *pMultibuffer + + nbuf * sizeof *pMultibuffers); if (!pMultibuffer) return BadAlloc; pMultibuffers = (MultibuffersPtr *) (pMultibuffer + nbuf); @@ -1364,7 +1388,7 @@ MultibufferExpose (pMultibuffer, pRegion) numRects = REGION_NUM_RECTS(pRegion); pBox = REGION_RECTS(pRegion); - pEvent = (xEvent *) xalloc(numRects * sizeof(xEvent)); + pEvent = xalloc(numRects * sizeof(xEvent)); if (pEvent) { pe = pEvent; @@ -1718,7 +1742,7 @@ EventSelectForMultibuffer (pMultibuffer, client, mask) } if (!other) { /* new client that never selected events on this buffer before */ - other = (OtherClients *) xalloc (sizeof (OtherClients)); + other = xalloc (sizeof (OtherClients)); if (!other) return BadAlloc; other->mask = mask; diff --git a/xorg-server/Xext/mbufbf.c b/xorg-server/Xext/mbufbf.c index e929ab5fd..7d9d60a4f 100644 --- a/xorg-server/Xext/mbufbf.c +++ b/xorg-server/Xext/mbufbf.c @@ -25,8 +25,6 @@ in this Software without prior written authorization from The Open Group. */ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -223,7 +221,7 @@ bufMultibufferInit(pScreen, pMBScreen) pMBScreen->WrapScreenFuncs = bufWrapScreenFuncs; pMBScreen->ResetProc = bufResetProc; /* Create devPrivate part */ - pMBPriv = (mbufBufferPrivPtr) xalloc(sizeof *pMBPriv); + pMBPriv = xalloc(sizeof *pMBPriv); if (!pMBPriv) return (FALSE); @@ -613,8 +611,7 @@ bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum) if (!pGC) return; - prect = (xRectangle *)xalloc(REGION_NUM_RECTS(prgn) * - sizeof(xRectangle)); + prect = xalloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle)); if (!prect) { FreeScratchGC(pGC); diff --git a/xorg-server/Xext/mbufpx.c b/xorg-server/Xext/mbufpx.c index 21d525906..8421ba9eb 100644 --- a/xorg-server/Xext/mbufpx.c +++ b/xorg-server/Xext/mbufpx.c @@ -24,8 +24,6 @@ in this Software without prior written authorization from The Open Group. ********************************************************/ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -92,7 +90,7 @@ pixMultibufferInit(pScreen, pMBScreen) nInfo += pDepth->numVids; } - pInfo = (xMbufBufferInfo *) xalloc (nInfo * sizeof (xMbufBufferInfo)); + pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo)); if (!pInfo) return FALSE; @@ -116,7 +114,7 @@ pixMultibufferInit(pScreen, pMBScreen) * Setup the devPrivate to mbufScreenRec */ - pMBPriv = (mbufPixmapPrivPtr) xalloc(sizeof(* pMBPriv)); + pMBPriv = xalloc(sizeof(* pMBPriv)); if (!pMBPriv) { xfree(pInfo); @@ -263,7 +261,7 @@ MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion) int nrects = REGION_NUM_RECTS(pRegion); BoxPtr pbox = REGION_RECTS(pRegion); - pRects = (xRectangle *)xalloc(nrects * sizeof(xRectangle)); + pRects = xalloc(nrects * sizeof(xRectangle)); if (pRects) { int i; diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c index a1f4ce01e..c5fb70061 100644 --- a/xorg-server/Xext/panoramiX.c +++ b/xorg-server/Xext/panoramiX.c @@ -31,7 +31,6 @@ Equipment Corporation. #include <dmx-config.h> #endif -#define NEED_REPLIES #include <stdio.h> #include <X11/X.h> #include <X11/Xproto.h> @@ -73,9 +72,9 @@ extern VisualPtr glxMatchVisual(ScreenPtr pScreen, int PanoramiXPixWidth = 0; int PanoramiXPixHeight = 0; -_X_EXPORT int PanoramiXNumScreens = 0; +int PanoramiXNumScreens = 0; -_X_EXPORT PanoramiXData *panoramiXdataPtr = NULL; +PanoramiXData *panoramiXdataPtr = NULL; static RegionRec PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL}; static int PanoramiXNumDepths; @@ -83,14 +82,14 @@ static DepthPtr PanoramiXDepths; static int PanoramiXNumVisuals; static VisualPtr PanoramiXVisuals; -_X_EXPORT unsigned long XRC_DRAWABLE; -_X_EXPORT unsigned long XRT_WINDOW; -_X_EXPORT unsigned long XRT_PIXMAP; -_X_EXPORT unsigned long XRT_GC; -_X_EXPORT unsigned long XRT_COLORMAP; +unsigned long XRC_DRAWABLE; +unsigned long XRT_WINDOW; +unsigned long XRT_PIXMAP; +unsigned long XRT_GC; +unsigned long XRT_COLORMAP; static Bool VisualsEqual(VisualPtr, ScreenPtr, VisualPtr); -_X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual; +XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual; /* * Function prototypes @@ -330,7 +329,7 @@ XineramaDestroyClip(GCPtr pGC) Xinerama_GC_FUNC_EPILOGUE (pGC); } -_X_EXPORT int +int XineramaDeleteResource(pointer data, XID id) { xfree(data); @@ -355,9 +354,12 @@ PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen) { PanoramiXSearchData data; + pointer val; - if(!screen) - return LookupIDByType(id, type); + if(!screen) { + dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess); + return val; + } data.screen = screen; data.id = id; @@ -373,7 +375,7 @@ typedef struct _connect_callback_list { static XineramaConnectionCallbackList *ConnectionCallbackList = NULL; -_X_EXPORT Bool +Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)) { XineramaConnectionCallbackList *newlist; @@ -667,7 +669,7 @@ Bool PanoramiXCreateConnectionBlock(void) length += (depth->nVisuals * sizeof(xVisualType)); } - connSetupPrefix.length = length >> 2; + connSetupPrefix.length = bytes_to_int32(length); for (i = 0; i < PanoramiXNumDepths; i++) xfree(PanoramiXDepths[i].vids); @@ -841,7 +843,7 @@ PanoramiXConsolidate(void) AddResource(defmap->info[0].id, XRT_COLORMAP, defmap); } -_X_EXPORT VisualID +VisualID PanoramiXTranslateVisualID(int screen, VisualID orig) { ScreenPtr pOtherScreen = screenInfo.screens[screen]; @@ -1051,7 +1053,7 @@ ProcXineramaQueryScreens(ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; - rep.length = rep.number * sz_XineramaScreenInfo >> 2; + rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo); if (client->swapped) { int n; swaps (&rep.sequenceNumber, n); diff --git a/xorg-server/Xext/panoramiX.h b/xorg-server/Xext/panoramiX.h index 700c5a4f9..cca4c5249 100644 --- a/xorg-server/Xext/panoramiX.h +++ b/xorg-server/Xext/panoramiX.h @@ -41,9 +41,8 @@ Equipment Corporation. #define _PANORAMIX_H_ #define _PANORAMIX_SERVER -#include <X11/extensions/panoramiXext.h> +#include <X11/extensions/panoramiXproto.h> #undef _PANORAMIX_SERVER - #include "gcstruct.h" @@ -98,6 +97,4 @@ typedef struct { #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) -#define SKIP_FAKE_WINDOW(a) if(!LookupIDByType(a, XRT_WINDOW)) return - #endif /* _PANORAMIX_H_ */ diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 38199a5df..6834efb71 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -32,8 +32,6 @@ Equipment Corporation. #include <stdio.h> #include <X11/X.h> -#define NEED_REPLIES -#define NEED_EVENTS #include <X11/Xproto.h> #include "windowstr.h" #include "dixfontstr.h" @@ -69,20 +67,21 @@ int PanoramiXCreateWindow(ClientPtr client) PanoramiXRes *cmap = NULL; REQUEST(xCreateWindowReq); int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; - int result = 0, len, j; + int result, len, j; int orig_x, orig_y; XID orig_visual, tmp; Bool parentIsRoot; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - len = client->req_len - (sizeof(xCreateWindowReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); if (Ones(stuff->mask) != len) return BadLength; - if (!(parent = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->parent, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; if(stuff->class == CopyFromParent) stuff->class = parent->u.win.class; @@ -94,31 +93,34 @@ int PanoramiXCreateWindow(ClientPtr client) pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { - if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & CWBorderPixmap) { pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { - if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & CWColormap) { cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { - if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, DixReadAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; } } - if(!(newWin = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newWin = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newWin->type = XRT_WINDOW; @@ -172,18 +174,19 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) PanoramiXRes *cmap = NULL; REQUEST(xChangeWindowAttributesReq); int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; - int result = 0, len, j; + int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); if (Ones(stuff->valueMask) != len) return BadLength; - if (!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; if((win->u.win.class == InputOnly) && (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) @@ -193,27 +196,30 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { - if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->valueMask & CWBorderPixmap) { pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { - if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->valueMask & CWColormap) { cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1)); tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { - if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, DixReadAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; } } @@ -235,14 +241,15 @@ int PanoramiXChangeWindowAttributes(ClientPtr client) int PanoramiXDestroyWindow(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixDestroyAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = win->info[j].id; @@ -260,14 +267,15 @@ int PanoramiXDestroyWindow(ClientPtr client) int PanoramiXDestroySubwindows(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixDestroyAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = win->info[j].id; @@ -285,14 +293,15 @@ int PanoramiXDestroySubwindows(ClientPtr client) int PanoramiXChangeSaveSet(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xChangeSaveSetReq); REQUEST_SIZE_MATCH(xChangeSaveSetReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_BACKWARD(j) { stuff->window = win->info[j].id; @@ -307,20 +316,22 @@ int PanoramiXChangeSaveSet(ClientPtr client) int PanoramiXReparentWindow(ClientPtr client) { PanoramiXRes *win, *parent; - int result = 0, j; + int result, j; int x, y; Bool parentIsRoot; REQUEST(xReparentWindowReq); REQUEST_SIZE_MATCH(xReparentWindowReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; - if(!(parent = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->parent, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; x = stuff->x; y = stuff->y; @@ -344,14 +355,15 @@ int PanoramiXReparentWindow(ClientPtr client) int PanoramiXMapWindow(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_FORWARD(j) { stuff->id = win->info[j].id; @@ -366,14 +378,15 @@ int PanoramiXMapWindow(ClientPtr client) int PanoramiXMapSubwindows(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_FORWARD(j) { stuff->id = win->info[j].id; @@ -388,14 +401,15 @@ int PanoramiXMapSubwindows(ClientPtr client) int PanoramiXUnmapWindow(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_FORWARD(j) { stuff->id = win->info[j].id; @@ -410,14 +424,15 @@ int PanoramiXUnmapWindow(ClientPtr client) int PanoramiXUnmapSubwindows(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->id, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_FORWARD(j) { stuff->id = win->info[j].id; @@ -434,33 +449,36 @@ int PanoramiXConfigureWindow(ClientPtr client) PanoramiXRes *win; PanoramiXRes *sib = NULL; WindowPtr pWin; - int result = 0, j, len, sib_offset = 0, x = 0, y = 0; + int result, j, len, sib_offset = 0, x = 0, y = 0; int x_offset = -1; int y_offset = -1; REQUEST(xConfigureWindowReq); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); if (Ones(stuff->mask) != len) return BadLength; /* because we need the parent */ - if (!(pWin = (WindowPtr)SecurityLookupIDByType( - client, stuff->window, RT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&pWin, stuff->window, + RT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; - if (!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; if ((Mask)stuff->mask & CWSibling) { XID tmp; sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { - if(!(sib = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; } } @@ -498,14 +516,15 @@ int PanoramiXConfigureWindow(ClientPtr client) int PanoramiXCirculateWindow(ClientPtr client) { PanoramiXRes *win; - int result = 0, j; + int result, j; REQUEST(xCirculateWindowReq); REQUEST_SIZE_MATCH(xCirculateWindowReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS_FORWARD(j) { stuff->window = win->info[j].id; @@ -636,17 +655,18 @@ int PanoramiXTranslateCoords(ClientPtr client) int PanoramiXCreatePixmap(ClientPtr client) { PanoramiXRes *refDraw, *newPix; - int result = 0, j; + int result, j; REQUEST(xCreatePixmapReq); REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; - if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixReadAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newPix = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newPix->type = XRT_PIXMAP; @@ -674,16 +694,17 @@ int PanoramiXCreatePixmap(ClientPtr client) int PanoramiXFreePixmap(ClientPtr client) { PanoramiXRes *pix; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - if(!(pix = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_PIXMAP, DixDestroyAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP, + client, DixDestroyAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = pix->info[j].id; @@ -707,46 +728,50 @@ int PanoramiXCreateGC(ClientPtr client) PanoramiXRes *clip = NULL; REQUEST(xCreateGCReq); int tile_offset = 0, stip_offset = 0, clip_offset = 0; - int result = 0, len, j; + int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; - len = client->req_len - (sizeof(xCreateGCReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); if (Ones(stuff->mask) != len) return BadLength; - if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixReadAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if ((Mask)stuff->mask & GCTile) { tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & GCStipple) { stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & GCClipMask) { clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } - if(!(newGC = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newGC = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newGC->type = XRT_GC; @@ -783,41 +808,45 @@ int PanoramiXChangeGC(ClientPtr client) PanoramiXRes *clip = NULL; REQUEST(xChangeGCReq); int tile_offset = 0, stip_offset = 0, clip_offset = 0; - int result = 0, len, j; + int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xChangeGCReq); - len = client->req_len - (sizeof(xChangeGCReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); if (Ones(stuff->mask) != len) return BadLength; - if (!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; if ((Mask)stuff->mask & GCTile) { tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & GCStipple) { stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } if ((Mask)stuff->mask & GCClipMask) { clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } } @@ -841,18 +870,20 @@ int PanoramiXChangeGC(ClientPtr client) int PanoramiXCopyGC(ClientPtr client) { PanoramiXRes *srcGC, *dstGC; - int result = 0, j; + int result, j; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); - if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->srcGC, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; - if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dstGC, XRT_GC, DixWriteAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; FOR_NSCREENS(j) { stuff->srcGC = srcGC->info[j].id; @@ -868,14 +899,15 @@ int PanoramiXCopyGC(ClientPtr client) int PanoramiXSetDashes(ClientPtr client) { PanoramiXRes *gc; - int result = 0, j; + int result, j; REQUEST(xSetDashesReq); REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixWriteAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; FOR_NSCREENS_BACKWARD(j) { stuff->gc = gc->info[j].id; @@ -890,14 +922,15 @@ int PanoramiXSetDashes(ClientPtr client) int PanoramiXSetClipRectangles(ClientPtr client) { PanoramiXRes *gc; - int result = 0, j; + int result, j; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixWriteAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; FOR_NSCREENS_BACKWARD(j) { stuff->gc = gc->info[j].id; @@ -912,14 +945,15 @@ int PanoramiXSetClipRectangles(ClientPtr client) int PanoramiXFreeGC(ClientPtr client) { PanoramiXRes *gc; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_GC, DixDestroyAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC, + client, DixDestroyAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = gc->info[j].id; @@ -937,15 +971,16 @@ int PanoramiXFreeGC(ClientPtr client) int PanoramiXClearToBackground(ClientPtr client) { PanoramiXRes *win; - int result = 0, j, x, y; + int result, j, x, y; Bool isRoot; REQUEST(xClearAreaReq); REQUEST_SIZE_MATCH(xClearAreaReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; x = stuff->x; y = stuff->y; @@ -976,7 +1011,7 @@ int PanoramiXClearToBackground(ClientPtr client) int PanoramiXCopyArea(ClientPtr client) { - int j, result = 0, srcx, srcy, dstx, dsty; + int j, result, srcx, srcy, dstx, dsty; PanoramiXRes *gc, *src, *dst; Bool srcIsRoot = FALSE; Bool dstIsRoot = FALSE; @@ -985,24 +1020,27 @@ int PanoramiXCopyArea(ClientPtr client) REQUEST_SIZE_MATCH(xCopyAreaReq); - if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; srcShared = IS_SHARED_PIXMAP(src); - if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; dstShared = IS_SHARED_PIXMAP(dst); if(dstShared && srcShared) return (* SavedProcVector[X_CopyArea])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; if((dst->type == XRT_WINDOW) && dst->u.win.root) dstIsRoot = TRUE; @@ -1141,24 +1179,27 @@ int PanoramiXCopyPlane(ClientPtr client) REQUEST_SIZE_MATCH(xCopyPlaneReq); - if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->srcDrawable, XRC_DRAWABLE, DixReadAccess))) - return BadDrawable; + rc = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; srcShared = IS_SHARED_PIXMAP(src); - if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + rc = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; dstShared = IS_SHARED_PIXMAP(dst); if(dstShared && srcShared) return (* SavedProcVector[X_CopyPlane])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? BadGC : rc; if((dst->type == XRT_WINDOW) && dst->u.win.root) dstIsRoot = TRUE; @@ -1237,28 +1278,30 @@ int PanoramiXCopyPlane(ClientPtr client) int PanoramiXPolyPoint(ClientPtr client) { PanoramiXRes *gc, *draw; - int result = 0, npoint, j; + int result, npoint, j; xPoint *origPts; Bool isRoot; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyPoint])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); if (npoint > 0) { - origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); + origPts = xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1295,28 +1338,30 @@ int PanoramiXPolyPoint(ClientPtr client) int PanoramiXPolyLine(ClientPtr client) { PanoramiXRes *gc, *draw; - int result = 0, npoint, j; + int result, npoint, j; xPoint *origPts; Bool isRoot; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyLine])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; + npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); if (npoint > 0){ - origPts = (xPoint *) xalloc(npoint * sizeof(xPoint)); + origPts = xalloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); FOR_NSCREENS_FORWARD(j){ @@ -1352,7 +1397,7 @@ int PanoramiXPolyLine(ClientPtr client) int PanoramiXPolySegment(ClientPtr client) { - int result = 0, nsegs, i, j; + int result, nsegs, i, j; PanoramiXRes *gc, *draw; xSegment *origSegs; Bool isRoot; @@ -1360,16 +1405,18 @@ int PanoramiXPolySegment(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolySegmentReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolySegment])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1377,7 +1424,7 @@ int PanoramiXPolySegment(ClientPtr client) if(nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs > 0) { - origSegs = (xSegment *) xalloc(nsegs * sizeof(xSegment)); + origSegs = xalloc(nsegs * sizeof(xSegment)); memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); FOR_NSCREENS_FORWARD(j){ @@ -1413,7 +1460,7 @@ int PanoramiXPolySegment(ClientPtr client) int PanoramiXPolyRectangle(ClientPtr client) { - int result = 0, nrects, i, j; + int result, nrects, i, j; PanoramiXRes *gc, *draw; Bool isRoot; xRectangle *origRecs; @@ -1421,17 +1468,18 @@ int PanoramiXPolyRectangle(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyRectangle])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1439,7 +1487,7 @@ int PanoramiXPolyRectangle(ClientPtr client) if(nrects & 4) return BadLength; nrects >>= 3; if (nrects > 0){ - origRecs = (xRectangle *) xalloc(nrects * sizeof(xRectangle)); + origRecs = xalloc(nrects * sizeof(xRectangle)); memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1474,7 +1522,7 @@ int PanoramiXPolyRectangle(ClientPtr client) int PanoramiXPolyArc(ClientPtr client) { - int result = 0, narcs, i, j; + int result, narcs, i, j; PanoramiXRes *gc, *draw; Bool isRoot; xArc *origArcs; @@ -1482,16 +1530,18 @@ int PanoramiXPolyArc(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyArcReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyArc])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1499,7 +1549,7 @@ int PanoramiXPolyArc(ClientPtr client) if(narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs > 0){ - origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); + origArcs = xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1532,7 +1582,7 @@ int PanoramiXPolyArc(ClientPtr client) int PanoramiXFillPoly(ClientPtr client) { - int result = 0, count, j; + int result, count, j; PanoramiXRes *gc, *draw; Bool isRoot; DDXPointPtr locPts; @@ -1540,22 +1590,24 @@ int PanoramiXFillPoly(ClientPtr client) REQUEST_AT_LEAST_SIZE(xFillPolyReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_FillPoly])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; + count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); if (count > 0){ - locPts = (DDXPointPtr) xalloc(count * sizeof(DDXPointRec)); + locPts = xalloc(count * sizeof(DDXPointRec)); memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); FOR_NSCREENS_FORWARD(j){ @@ -1591,7 +1643,7 @@ int PanoramiXFillPoly(ClientPtr client) int PanoramiXPolyFillRectangle(ClientPtr client) { - int result = 0, things, i, j; + int result, things, i, j; PanoramiXRes *gc, *draw; Bool isRoot; xRectangle *origRects; @@ -1599,16 +1651,18 @@ int PanoramiXPolyFillRectangle(ClientPtr client) REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyFillRectangle])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1616,7 +1670,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client) if(things & 4) return BadLength; things >>= 3; if (things > 0){ - origRects = (xRectangle *) xalloc(things * sizeof(xRectangle)); + origRects = xalloc(things * sizeof(xRectangle)); memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); FOR_NSCREENS_FORWARD(j){ @@ -1652,22 +1706,24 @@ int PanoramiXPolyFillArc(ClientPtr client) { PanoramiXRes *gc, *draw; Bool isRoot; - int result = 0, narcs, i, j; + int result, narcs, i, j; xArc *origArcs; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyFillArc])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1675,7 +1731,7 @@ int PanoramiXPolyFillArc(ClientPtr client) IF_RETURN((narcs % sizeof(xArc)), BadLength); narcs /= sizeof(xArc); if (narcs > 0) { - origArcs = (xArc *) xalloc(narcs * sizeof(xArc)); + origArcs = xalloc(narcs * sizeof(xArc)); memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); FOR_NSCREENS_FORWARD(j){ @@ -1711,21 +1767,23 @@ int PanoramiXPutImage(ClientPtr client) { PanoramiXRes *gc, *draw; Bool isRoot; - int j, result = 0, orig_x, orig_y; + int j, result, orig_x, orig_y; REQUEST(xPutImageReq); REQUEST_AT_LEAST_SIZE(xPutImageReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PutImage])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1767,9 +1825,10 @@ int PanoramiXGetImage(ClientPtr client) return(BadValue); } - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; if(draw->type == XRT_PIXMAP) return (*SavedProcVector[X_GetImage])(client); @@ -1836,7 +1895,7 @@ int PanoramiXGetImage(ClientPtr client) } - xgi.length = (length + 3) >> 2; + xgi.length = bytes_to_int32(length); if (widthBytesLine == 0 || h == 0) linesPerBuf = 0; @@ -1908,22 +1967,24 @@ PanoramiXPolyText8(ClientPtr client) { PanoramiXRes *gc, *draw; Bool isRoot; - int result = 0, j; + int result, j; int orig_x, orig_y; REQUEST(xPolyTextReq); REQUEST_AT_LEAST_SIZE(xPolyTextReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyText8])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1947,22 +2008,24 @@ PanoramiXPolyText16(ClientPtr client) { PanoramiXRes *gc, *draw; Bool isRoot; - int result = 0, j; + int result, j; int orig_x, orig_y; REQUEST(xPolyTextReq); REQUEST_AT_LEAST_SIZE(xPolyTextReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_PolyText16])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1984,7 +2047,7 @@ PanoramiXPolyText16(ClientPtr client) int PanoramiXImageText8(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *gc, *draw; Bool isRoot; int orig_x, orig_y; @@ -1992,16 +2055,18 @@ int PanoramiXImageText8(ClientPtr client) REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_ImageText8])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2023,7 +2088,7 @@ int PanoramiXImageText8(ClientPtr client) int PanoramiXImageText16(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *gc, *draw; Bool isRoot; int orig_x, orig_y; @@ -2031,16 +2096,18 @@ int PanoramiXImageText16(ClientPtr client) REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; if(IS_SHARED_PIXMAP(draw)) return (*SavedProcVector[X_ImageText16])(client); - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -2064,16 +2131,17 @@ int PanoramiXImageText16(ClientPtr client) int PanoramiXCreateColormap(ClientPtr client) { PanoramiXRes *win, *newCmap; - int result = 0, j, orig_visual; + int result, j, orig_visual; REQUEST(xCreateColormapReq); REQUEST_SIZE_MATCH(xCreateColormapReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->window, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->window, + XRT_WINDOW, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; - if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newCmap = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; @@ -2102,16 +2170,17 @@ int PanoramiXCreateColormap(ClientPtr client) int PanoramiXFreeColormap(ClientPtr client) { PanoramiXRes *cmap; - int result = 0, j; + int result, j; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, DixDestroyAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixDestroyAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = cmap->info[j].id; @@ -2130,19 +2199,20 @@ int PanoramiXCopyColormapAndFree(ClientPtr client) { PanoramiXRes *cmap, *newCmap; - int result = 0, j; + int result, j; REQUEST(xCopyColormapAndFreeReq); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); client->errorValue = stuff->srcCmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->srcCmap, XRT_COLORMAP, - DixReadAccess | DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->srcCmap, + XRT_COLORMAP, client, + DixReadAccess | DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; - if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newCmap = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; @@ -2169,16 +2239,17 @@ PanoramiXCopyColormapAndFree(ClientPtr client) int PanoramiXInstallColormap(ClientPtr client) { REQUEST(xResourceReq); - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, DixReadAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->id = cmap->info[j].id; @@ -2192,16 +2263,17 @@ int PanoramiXInstallColormap(ClientPtr client) int PanoramiXUninstallColormap(ClientPtr client) { REQUEST(xResourceReq); - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->id, XRT_COLORMAP, DixReadAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j) { stuff->id = cmap->info[j].id; @@ -2214,7 +2286,7 @@ int PanoramiXUninstallColormap(ClientPtr client) int PanoramiXAllocColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorReq); @@ -2222,9 +2294,10 @@ int PanoramiXAllocColor(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; @@ -2237,7 +2310,7 @@ int PanoramiXAllocColor(ClientPtr client) int PanoramiXAllocNamedColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocNamedColorReq); @@ -2245,9 +2318,10 @@ int PanoramiXAllocNamedColor(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; @@ -2260,7 +2334,7 @@ int PanoramiXAllocNamedColor(ClientPtr client) int PanoramiXAllocColorCells(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorCellsReq); @@ -2268,9 +2342,10 @@ int PanoramiXAllocColorCells(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; @@ -2283,7 +2358,7 @@ int PanoramiXAllocColorCells(ClientPtr client) int PanoramiXAllocColorPlanes(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xAllocColorPlanesReq); @@ -2291,9 +2366,10 @@ int PanoramiXAllocColorPlanes(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; @@ -2307,7 +2383,7 @@ int PanoramiXAllocColorPlanes(ClientPtr client) int PanoramiXFreeColors(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xFreeColorsReq); @@ -2315,9 +2391,10 @@ int PanoramiXFreeColors(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j) { stuff->cmap = cmap->info[j].id; @@ -2329,7 +2406,7 @@ int PanoramiXFreeColors(ClientPtr client) int PanoramiXStoreColors(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xStoreColorsReq); @@ -2337,9 +2414,10 @@ int PanoramiXStoreColors(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; @@ -2352,7 +2430,7 @@ int PanoramiXStoreColors(ClientPtr client) int PanoramiXStoreNamedColor(ClientPtr client) { - int result = 0, j; + int result, j; PanoramiXRes *cmap; REQUEST(xStoreNamedColorReq); @@ -2360,9 +2438,10 @@ int PanoramiXStoreNamedColor(ClientPtr client) client->errorValue = stuff->cmap; - if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->cmap, XRT_COLORMAP, DixWriteAccess))) - return BadColor; + result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadColor : result; FOR_NSCREENS_BACKWARD(j){ stuff->cmap = cmap->info[j].id; diff --git a/xorg-server/Xext/panoramiXsrv.h b/xorg-server/Xext/panoramiXsrv.h index d5c3d9827..c77b11927 100644 --- a/xorg-server/Xext/panoramiXsrv.h +++ b/xorg-server/Xext/panoramiXsrv.h @@ -8,27 +8,27 @@ #include "panoramiX.h" -extern int PanoramiXNumScreens; -extern PanoramiXData *panoramiXdataPtr; -extern int PanoramiXPixWidth; -extern int PanoramiXPixHeight; +extern _X_EXPORT int PanoramiXNumScreens; +extern _X_EXPORT PanoramiXData *panoramiXdataPtr; +extern _X_EXPORT int PanoramiXPixWidth; +extern _X_EXPORT int PanoramiXPixHeight; -extern VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); -extern void PanoramiXConsolidate(void); -extern Bool PanoramiXCreateConnectionBlock(void); -extern PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int); -extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); -extern int XineramaDeleteResource(pointer, XID); +extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); +extern _X_EXPORT void PanoramiXConsolidate(void); +extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void); +extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int); +extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); +extern _X_EXPORT int XineramaDeleteResource(pointer, XID); -extern void XineramaReinitData(ScreenPtr); +extern _X_EXPORT void XineramaReinitData(ScreenPtr); -extern RegionRec XineramaScreenRegions[MAXSCREENS]; +extern _X_EXPORT RegionRec XineramaScreenRegions[MAXSCREENS]; -extern unsigned long XRC_DRAWABLE; -extern unsigned long XRT_WINDOW; -extern unsigned long XRT_PIXMAP; -extern unsigned long XRT_GC; -extern unsigned long XRT_COLORMAP; +extern _X_EXPORT unsigned long XRC_DRAWABLE; +extern _X_EXPORT unsigned long XRT_WINDOW; +extern _X_EXPORT unsigned long XRT_PIXMAP; +extern _X_EXPORT unsigned long XRT_GC; +extern _X_EXPORT unsigned long XRT_COLORMAP; /* * Drivers are allowed to wrap this function. Each wrapper can decide that the @@ -38,9 +38,9 @@ extern unsigned long XRT_COLORMAP; * screen 0. */ typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr); -extern XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr; +extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr; -extern void XineramaGetImageData( +extern _X_EXPORT void XineramaGetImageData( DrawablePtr *pDrawables, int left, int top, diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c index 86db7b0b9..18de4b540 100644 --- a/xorg-server/Xext/saver.c +++ b/xorg-server/Xext/saver.c @@ -27,8 +27,6 @@ in this Software without prior written authorization from the X Consortium. */ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -54,8 +52,7 @@ in this Software without prior written authorization from the X Consortium. #include "panoramiXsrv.h" #endif #ifdef DPMSExtension -#define DPMS_SERVER -#include <X11/extensions/dpms.h> +#include <X11/extensions/dpmsconst.h> #endif #include <stdio.h> @@ -144,7 +141,7 @@ static int ScreenSaverFreeSuspend( * entry from the per-screen queue. */ -static RESTYPE EventType; /* resource type for event masks */ +static RESTYPE SaverEventType; /* resource type for event masks */ typedef struct _ScreenSaverEvent *ScreenSaverEventPtr; @@ -237,7 +234,7 @@ static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex; dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v); #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) -#define New(t) ((t *) xalloc (sizeof (t))) +#define New(t) (xalloc (sizeof (t))) /**************** * ScreenSaverExtensionInit @@ -255,7 +252,7 @@ ScreenSaverExtensionInit(INITARGS) ScreenPtr pScreen; AttrType = CreateNewResourceType(ScreenSaverFreeAttr); - EventType = CreateNewResourceType(ScreenSaverFreeEvents); + SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents); SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend); for (i = 0; i < screenInfo.numScreens; i++) @@ -263,7 +260,7 @@ ScreenSaverExtensionInit(INITARGS) pScreen = screenInfo.screens[i]; SetScreenPrivate (pScreen, NULL); } - if (AttrType && EventType && SuspendType && + if (AttrType && SaverEventType && SuspendType && (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, ProcScreenSaverDispatch, SProcScreenSaverDispatch, NULL, StandardMinorOpcode))) @@ -274,8 +271,7 @@ ScreenSaverExtensionInit(INITARGS) } static void -CheckScreenPrivate (pScreen) - ScreenPtr pScreen; +CheckScreenPrivate (ScreenPtr pScreen) { SetupScreen (pScreen); @@ -291,8 +287,7 @@ CheckScreenPrivate (pScreen) } static ScreenSaverScreenPrivatePtr -MakeScreenPrivate (pScreen) - ScreenPtr pScreen; +MakeScreenPrivate (ScreenPtr pScreen) { SetupScreen (pScreen); @@ -311,9 +306,7 @@ MakeScreenPrivate (pScreen) } static unsigned long -getEventMask (pScreen, client) - ScreenPtr pScreen; - ClientPtr client; +getEventMask (ScreenPtr pScreen, ClientPtr client) { SetupScreen(pScreen); ScreenSaverEventPtr pEv; @@ -327,10 +320,7 @@ getEventMask (pScreen, client) } static Bool -setEventMask (pScreen, client, mask) - ScreenPtr pScreen; - ClientPtr client; - unsigned long mask; +setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask) { SetupScreen(pScreen); ScreenSaverEventPtr pEv, *pPrev; @@ -348,7 +338,7 @@ setEventMask (pScreen, client, mask) break; if (mask == 0) { - FreeResource (pEv->resource, EventType); + FreeResource (pEv->resource, SaverEventType); *pPrev = pEv->next; xfree (pEv); CheckScreenPrivate (pScreen); @@ -368,7 +358,7 @@ setEventMask (pScreen, client, mask) pEv->client = client; pEv->screen = pScreen; pEv->resource = FakeClientID (client->index); - if (!AddResource (pEv->resource, EventType, (pointer) pEv)) + if (!AddResource (pEv->resource, SaverEventType, (pointer) pEv)) return FALSE; } pEv->mask = mask; @@ -377,8 +367,7 @@ setEventMask (pScreen, client, mask) } static void -FreeAttrs (pAttr) - ScreenSaverAttrPtr pAttr; +FreeAttrs (ScreenSaverAttrPtr pAttr) { PixmapPtr pPixmap; CursorPtr pCursor; @@ -392,8 +381,7 @@ FreeAttrs (pAttr) } static void -FreeScreenAttr (pAttr) - ScreenSaverAttrPtr pAttr; +FreeScreenAttr (ScreenSaverAttrPtr pAttr) { FreeAttrs (pAttr); xfree (pAttr->values); @@ -401,9 +389,7 @@ FreeScreenAttr (pAttr) } static int -ScreenSaverFreeEvents (value, id) - pointer value; - XID id; +ScreenSaverFreeEvents (pointer value, XID id) { ScreenSaverEventPtr pOld = (ScreenSaverEventPtr)value; ScreenPtr pScreen = pOld->screen; @@ -424,9 +410,7 @@ ScreenSaverFreeEvents (value, id) } static int -ScreenSaverFreeAttr (value, id) - pointer value; - XID id; +ScreenSaverFreeAttr (pointer value, XID id) { ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr)value; ScreenPtr pScreen = pOldAttr->screen; @@ -487,10 +471,7 @@ ScreenSaverFreeSuspend (pointer value, XID id) } static void -SendScreenSaverNotify (pScreen, state, forced) - ScreenPtr pScreen; - int state; - Bool forced; +SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced) { ScreenSaverScreenPrivatePtr pPriv; ScreenSaverEventPtr pEv; @@ -533,8 +514,8 @@ SendScreenSaverNotify (pScreen, state, forced) } static void -SScreenSaverNotifyEvent (from, to) - xScreenSaverNotifyEvent *from, *to; +SScreenSaverNotifyEvent (xScreenSaverNotifyEvent *from, + xScreenSaverNotifyEvent *to) { to->type = from->type; to->state = from->state; @@ -547,16 +528,18 @@ SScreenSaverNotifyEvent (from, to) } static void -UninstallSaverColormap (pScreen) - ScreenPtr pScreen; +UninstallSaverColormap (ScreenPtr pScreen) { SetupScreen(pScreen); ColormapPtr pCmap; + int rc; if (pPriv && pPriv->installedMap != None) { - pCmap = (ColormapPtr) LookupIDByType (pPriv->installedMap, RT_COLORMAP); - if (pCmap) + rc = dixLookupResourceByType((pointer *)&pCmap, pPriv->installedMap, + RT_COLORMAP, serverClient, + DixUninstallAccess); + if (rc == Success) (*pCmap->pScreen->UninstallColormap) (pCmap); pPriv->installedMap = None; CheckScreenPrivate (pScreen); @@ -564,8 +547,7 @@ UninstallSaverColormap (pScreen) } static Bool -CreateSaverWindow (pScreen) - ScreenPtr pScreen; +CreateSaverWindow (ScreenPtr pScreen) { SetupScreen (pScreen); ScreenSaverStuffPtr pSaver; @@ -659,8 +641,7 @@ CreateSaverWindow (pScreen) wantMap = wColormap (pWin); if (wantMap == None) return TRUE; - installedMaps = (Colormap *) xalloc (pScreen->maxInstalledCmaps * - sizeof (Colormap)); + installedMaps = xalloc (pScreen->maxInstalledCmaps * sizeof (Colormap)); numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps) (pScreen, installedMaps); for (i = 0; i < numInstalled; i++) @@ -672,8 +653,9 @@ CreateSaverWindow (pScreen) if (i < numInstalled) return TRUE; - pCmap = (ColormapPtr) LookupIDByType (wantMap, RT_COLORMAP); - if (!pCmap) + result = dixLookupResourceByType((pointer *)&pCmap, wantMap, RT_COLORMAP, + serverClient, DixInstallAccess); + if (result != Success) return TRUE; pPriv->installedMap = wantMap; @@ -684,8 +666,7 @@ CreateSaverWindow (pScreen) } static Bool -DestroySaverWindow (pScreen) - ScreenPtr pScreen; +DestroySaverWindow (ScreenPtr pScreen) { SetupScreen(pScreen); ScreenSaverStuffPtr pSaver; @@ -706,10 +687,7 @@ DestroySaverWindow (pScreen) } static Bool -ScreenSaverHandle (pScreen, xstate, force) - ScreenPtr pScreen; - int xstate; - Bool force; +ScreenSaverHandle (ScreenPtr pScreen, int xstate, Bool force) { int state = 0; Bool ret = FALSE; @@ -740,8 +718,7 @@ ScreenSaverHandle (pScreen, xstate, force) } static int -ProcScreenSaverQueryVersion (client) - ClientPtr client; +ProcScreenSaverQueryVersion (ClientPtr client) { xScreenSaverQueryVersionReply rep; int n; @@ -761,8 +738,7 @@ ProcScreenSaverQueryVersion (client) } static int -ProcScreenSaverQueryInfo (client) - ClientPtr client; +ProcScreenSaverQueryInfo (ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); xScreenSaverQueryInfoReply rep; @@ -838,8 +814,7 @@ ProcScreenSaverQueryInfo (client) } static int -ProcScreenSaverSelectInput (client) - ClientPtr client; +ProcScreenSaverSelectInput (ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); DrawablePtr pDraw; @@ -899,7 +874,7 @@ ScreenSaverSetAttributes (ClientPtr client) if (ret != Success) return ret; - len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) @@ -1004,7 +979,7 @@ ScreenSaverSetAttributes (ClientPtr client) goto bail; } /* over allocate for override redirect */ - values = (unsigned long *) xalloc ((len + 1) * sizeof (unsigned long)); + values = xalloc ((len + 1) * sizeof (unsigned long)); if (!values) { ret = BadAlloc; @@ -1280,17 +1255,18 @@ ProcScreenSaverSetAttributes (ClientPtr client) PanoramiXRes *backPix = NULL; PanoramiXRes *bordPix = NULL; PanoramiXRes *cmap = NULL; - int i, status = 0, len; + int i, status, len; int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; XID orig_visual, tmp; REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + status = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (status != Success) + return (status == BadValue) ? BadDrawable : status; - len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; @@ -1298,9 +1274,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { - if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + status = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadPixmap : status; } } @@ -1308,9 +1286,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { - if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + status = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadPixmap : status; } } @@ -1318,9 +1298,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { - if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, DixReadAccess))) - return BadColor; + status = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadColor : status; } } @@ -1355,11 +1337,12 @@ ProcScreenSaverUnsetAttributes (ClientPtr client) if(!noPanoramiXExtension) { REQUEST(xScreenSaverUnsetAttributesReq); PanoramiXRes *draw; - int i; + int rc, i; - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; for(i = PanoramiXNumScreens - 1; i > 0; i--) { stuff->drawable = draw->info[i].id; @@ -1406,7 +1389,7 @@ ProcScreenSaverSuspend (ClientPtr client) * to the record, so the screensaver will be reenabled and the record freed * if the client disconnects without reenabling it first. */ - this = (ScreenSaverSuspensionPtr) xalloc (sizeof (ScreenSaverSuspensionRec)); + this = xalloc (sizeof (ScreenSaverSuspensionRec)); if (!this) return BadAlloc; @@ -1444,8 +1427,7 @@ static DISPATCH_PROC((*NormalVector[])) = { #define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0])) static int -ProcScreenSaverDispatch (client) - ClientPtr client; +ProcScreenSaverDispatch (ClientPtr client) { REQUEST(xReq); @@ -1455,8 +1437,7 @@ ProcScreenSaverDispatch (client) } static int -SProcScreenSaverQueryVersion (client) - ClientPtr client; +SProcScreenSaverQueryVersion (ClientPtr client) { REQUEST(xScreenSaverQueryVersionReq); int n; @@ -1467,8 +1448,7 @@ SProcScreenSaverQueryVersion (client) } static int -SProcScreenSaverQueryInfo (client) - ClientPtr client; +SProcScreenSaverQueryInfo (ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); int n; @@ -1480,8 +1460,7 @@ SProcScreenSaverQueryInfo (client) } static int -SProcScreenSaverSelectInput (client) - ClientPtr client; +SProcScreenSaverSelectInput (ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); int n; @@ -1494,8 +1473,7 @@ SProcScreenSaverSelectInput (client) } static int -SProcScreenSaverSetAttributes (client) - ClientPtr client; +SProcScreenSaverSetAttributes (ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); int n; @@ -1515,8 +1493,7 @@ SProcScreenSaverSetAttributes (client) } static int -SProcScreenSaverUnsetAttributes (client) - ClientPtr client; +SProcScreenSaverUnsetAttributes (ClientPtr client) { REQUEST(xScreenSaverUnsetAttributesReq); int n; @@ -1549,8 +1526,7 @@ static DISPATCH_PROC((*SwappedVector[])) = { }; static int -SProcScreenSaverDispatch (client) - ClientPtr client; +SProcScreenSaverDispatch (ClientPtr client) { REQUEST(xReq); diff --git a/xorg-server/Xext/security.c b/xorg-server/Xext/security.c index 1a90a82b1..42eb9f01d 100644 --- a/xorg-server/Xext/security.c +++ b/xorg-server/Xext/security.c @@ -37,7 +37,7 @@ in this Software without prior written authorization from The Open Group. #include "registry.h" #include "xacestr.h" #include "securitysrv.h" -#include <X11/extensions/securstr.h> +#include <X11/extensions/securproto.h> #include "modinit.h" /* Extension stuff */ @@ -408,7 +408,7 @@ SecurityEventSelectForAuthorization( } } - pEventClient = (OtherClients *) xalloc(sizeof(OtherClients)); + pEventClient = xalloc(sizeof(OtherClients)); if (!pEventClient) return BadAlloc; pEventClient->mask = mask; @@ -450,9 +450,9 @@ ProcSecurityGenerateAuthorization( /* check request length */ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq); - len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2; - len += (stuff->nbytesAuthProto + (unsigned)3) >> 2; - len += (stuff->nbytesAuthData + (unsigned)3) >> 2; + len = bytes_to_int32(SIZEOF(xSecurityGenerateAuthorizationReq)); + len += bytes_to_int32(stuff->nbytesAuthProto); + len += bytes_to_int32(stuff->nbytesAuthData); values = ((CARD32 *)stuff) + len; len += Ones(stuff->valueMask); if (client->req_len != len) @@ -520,7 +520,7 @@ ProcSecurityGenerateAuthorization( } protoname = (char *)&stuff[1]; - protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2); + protodata = protoname + bytes_to_int32(stuff->nbytesAuthProto); /* call os layer to generate the authorization */ @@ -540,7 +540,7 @@ ProcSecurityGenerateAuthorization( /* associate additional information with this auth ID */ - pAuth = (SecurityAuthorizationPtr)xalloc(sizeof(SecurityAuthorizationRec)); + pAuth = xalloc(sizeof(SecurityAuthorizationRec)); if (!pAuth) { err = BadAlloc; @@ -580,7 +580,7 @@ ProcSecurityGenerateAuthorization( /* tell client the auth id and data */ rep.type = X_Reply; - rep.length = (authdata_len + 3) >> 2; + rep.length = bytes_to_int32(authdata_len); rep.sequenceNumber = client->sequence; rep.authId = authId; rep.dataLength = authdata_len; @@ -623,13 +623,16 @@ ProcSecurityRevokeAuthorization( { REQUEST(xSecurityRevokeAuthorizationReq); SecurityAuthorizationPtr pAuth; + int rc; REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); - pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client, - stuff->authId, SecurityAuthorizationResType, DixDestroyAccess); - if (!pAuth) - return SecurityErrorBase + XSecurityBadAuthorization; + rc = dixLookupResourceByType((pointer *)&pAuth, stuff->authId, + SecurityAuthorizationResType, client, + DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? + SecurityErrorBase + XSecurityBadAuthorization : rc; FreeResource(stuff->authId, RT_NONE); return Success; @@ -685,10 +688,10 @@ SProcSecurityGenerateAuthorization( swaps(&stuff->nbytesAuthProto, n); swaps(&stuff->nbytesAuthData, n); swapl(&stuff->valueMask, n); - values_offset = ((stuff->nbytesAuthProto + (unsigned)3) >> 2) + - ((stuff->nbytesAuthData + (unsigned)3) >> 2); + values_offset = bytes_to_int32(stuff->nbytesAuthProto) + + bytes_to_int32(stuff->nbytesAuthData); if (values_offset > - stuff->length - (sz_xSecurityGenerateAuthorizationReq >> 2)) + stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) return BadLength; values = (CARD32 *)(&stuff[1]) + values_offset; nvalues = (((CARD32 *)stuff) + stuff->length) - values; diff --git a/xorg-server/Xext/shape.c b/xorg-server/Xext/shape.c index 332e58743..53167d140 100644 --- a/xorg-server/Xext/shape.c +++ b/xorg-server/Xext/shape.c @@ -24,8 +24,6 @@ in this Software without prior written authorization from The Open Group. ********************************************************/ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -43,8 +41,7 @@ in this Software without prior written authorization from The Open Group. #include "dixstruct.h" #include "resource.h" #include "opaque.h" -#define _SHAPE_SERVER_ /* don't want Xlib structures */ -#include <X11/extensions/shapestr.h> +#include <X11/extensions/shapeproto.h> #include "regionstr.h" #include "gcstruct.h" #include "modinit.h" @@ -65,18 +62,6 @@ static void SShapeNotifyEvent( xShapeNotifyEvent * /* from */, xShapeNotifyEvent * /* to */ ); -static int -RegionOperate ( - ClientPtr /* client */, - WindowPtr /* pWin */, - int /* kind */, - RegionPtr * /* destRgnp */, - RegionPtr /* srcRgn */, - int /* op */, - int /* xoff */, - int /* yoff */, - CreateDftPtr /* create */ - ); /* SendShapeNotify, CreateBoundingShape and CreateClipShape are used * externally by the Xfixes extension and are now defined in window.h @@ -109,7 +94,7 @@ static DISPATCH_PROC(SProcShapeSelectInput); #endif static int ShapeEventBase = 0; -static RESTYPE ClientType, EventType; /* resource types for event masks */ +static RESTYPE ClientType, ShapeEventType; /* resource types for event masks */ /* * each window has a list of clients requesting @@ -142,8 +127,8 @@ ShapeExtensionInit(void) ExtensionEntry *extEntry; ClientType = CreateNewResourceType(ShapeFreeClient); - EventType = CreateNewResourceType(ShapeFreeEvents); - if (ClientType && EventType && + ShapeEventType = CreateNewResourceType(ShapeFreeEvents); + if (ClientType && ShapeEventType && (extEntry = AddExtension(SHAPENAME, ShapeNumberEvents, 0, ProcShapeDispatch, SProcShapeDispatch, NULL, StandardMinorOpcode))) @@ -154,14 +139,15 @@ ShapeExtensionInit(void) } static int -RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) - ClientPtr client; - WindowPtr pWin; - int kind; - RegionPtr *destRgnp, srcRgn; - int op; - int xoff, yoff; - CreateDftPtr create; /* creates a reasonable *destRgnp */ +RegionOperate ( + ClientPtr client, + WindowPtr pWin, + int kind, + RegionPtr *destRgnp, + RegionPtr srcRgn, + int op, + int xoff, int yoff, + CreateDftPtr create) { ScreenPtr pScreen = pWin->drawable.pScreen; @@ -239,8 +225,7 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) } RegionPtr -CreateBoundingShape (pWin) - WindowPtr pWin; +CreateBoundingShape (WindowPtr pWin) { BoxRec extents; @@ -252,8 +237,7 @@ CreateBoundingShape (pWin) } RegionPtr -CreateClipShape (pWin) - WindowPtr pWin; +CreateClipShape (WindowPtr pWin) { BoxRec extents; @@ -265,13 +249,13 @@ CreateClipShape (pWin) } static int -ProcShapeQueryVersion (client) - ClientPtr client; +ProcShapeQueryVersion (ClientPtr client) { xShapeQueryVersionReply rep; int n; REQUEST_SIZE_MATCH (xShapeQueryVersionReq); + memset(&rep, 0, sizeof(xShapeQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -293,8 +277,7 @@ ProcShapeQueryVersion (client) *****************/ static int -ProcShapeRectangles (client) - ClientPtr client; +ProcShapeRectangles (ClientPtr client) { WindowPtr pWin; ScreenPtr pScreen; @@ -369,13 +352,14 @@ ProcPanoramiXShapeRectangles( { REQUEST(xShapeRectanglesReq); PanoramiXRes *win; - int j, result = 0; + int j, result; REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS(j) { stuff->dest = win->info[j].id; @@ -393,8 +377,7 @@ ProcPanoramiXShapeRectangles( static int -ProcShapeMask (client) - ClientPtr client; +ProcShapeMask (ClientPtr client) { WindowPtr pWin; ScreenPtr pScreen; @@ -468,18 +451,20 @@ ProcPanoramiXShapeMask( { REQUEST(xShapeMaskReq); PanoramiXRes *win, *pmap; - int j, result = 0; + int j, result; REQUEST_SIZE_MATCH (xShapeMaskReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; if(stuff->src != None) { - if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->src, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + result = dixLookupResourceByType((pointer *)&pmap, stuff->src, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadPixmap : result; } else pmap = NULL; @@ -500,8 +485,7 @@ ProcPanoramiXShapeMask( ************/ static int -ProcShapeCombine (client) - ClientPtr client; +ProcShapeCombine (ClientPtr client) { WindowPtr pSrcWin, pDestWin; ScreenPtr pScreen; @@ -597,17 +581,19 @@ ProcPanoramiXShapeCombine( { REQUEST(xShapeCombineReq); PanoramiXRes *win, *win2; - int j, result = 0; + int j, result; REQUEST_AT_LEAST_SIZE (xShapeCombineReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; - if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->src, XRT_WINDOW, DixReadAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win2, stuff->src, XRT_WINDOW, + client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS(j) { stuff->dest = win->info[j].id; @@ -624,8 +610,7 @@ ProcPanoramiXShapeCombine( *************/ static int -ProcShapeOffset (client) - ClientPtr client; +ProcShapeOffset (ClientPtr client) { WindowPtr pWin; ScreenPtr pScreen; @@ -670,13 +655,14 @@ ProcPanoramiXShapeOffset( { REQUEST(xShapeOffsetReq); PanoramiXRes *win; - int j, result = 0; + int j, result; REQUEST_AT_LEAST_SIZE (xShapeOffsetReq); - if(!(win = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->dest, XRT_WINDOW, DixWriteAccess))) - return BadWindow; + result = dixLookupResourceByType((pointer *)&win, stuff->dest, XRT_WINDOW, + client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadWindow : result; FOR_NSCREENS(j) { stuff->dest = win->info[j].id; @@ -689,8 +675,7 @@ ProcPanoramiXShapeOffset( static int -ProcShapeQueryExtents (client) - ClientPtr client; +ProcShapeQueryExtents (ClientPtr client) { REQUEST(xShapeQueryExtentsReq); WindowPtr pWin; @@ -703,6 +688,7 @@ ProcShapeQueryExtents (client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) return rc; + memset(&rep, 0, sizeof(xShapeQueryExtentsReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -754,18 +740,18 @@ ProcShapeQueryExtents (client) /*ARGSUSED*/ static int -ShapeFreeClient (data, id) - pointer data; - XID id; +ShapeFreeClient (pointer data, XID id) { ShapeEventPtr pShapeEvent; WindowPtr pWin; ShapeEventPtr *pHead, pCur, pPrev; + int rc; pShapeEvent = (ShapeEventPtr) data; pWin = pShapeEvent->window; - pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, EventType); - if (pHead) { + rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, + ShapeEventType, serverClient, DixReadAccess); + if (rc == Success) { pPrev = 0; for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next) pPrev = pCur; @@ -783,9 +769,7 @@ ShapeFreeClient (data, id) /*ARGSUSED*/ static int -ShapeFreeEvents (data, id) - pointer data; - XID id; +ShapeFreeEvents (pointer data, XID id) { ShapeEventPtr *pHead, pCur, pNext; @@ -800,8 +784,7 @@ ShapeFreeEvents (data, id) } static int -ProcShapeSelectInput (client) - ClientPtr client; +ProcShapeSelectInput (ClientPtr client) { REQUEST(xShapeSelectInputReq); WindowPtr pWin; @@ -813,8 +796,11 @@ ProcShapeSelectInput (client) rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess); if (rc != Success) return rc; - pHead = (ShapeEventPtr *)SecurityLookupIDByType(client, - pWin->drawable.id, EventType, DixWriteAccess); + rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, + ShapeEventType, client, DixWriteAccess); + if (rc != Success && rc != BadValue) + return rc; + switch (stuff->enable) { case xTrue: if (pHead) { @@ -830,8 +816,7 @@ ProcShapeSelectInput (client) } /* build the entry */ - pNewShapeEvent = (ShapeEventPtr) - xalloc (sizeof (ShapeEventRec)); + pNewShapeEvent = xalloc (sizeof (ShapeEventRec)); if (!pNewShapeEvent) return BadAlloc; pNewShapeEvent->next = 0; @@ -853,9 +838,9 @@ ProcShapeSelectInput (client) */ if (!pHead) { - pHead = (ShapeEventPtr *) xalloc (sizeof (ShapeEventPtr)); + pHead = xalloc (sizeof (ShapeEventPtr)); if (!pHead || - !AddResource (pWin->drawable.id, EventType, (pointer)pHead)) + !AddResource (pWin->drawable.id, ShapeEventType, (pointer)pHead)) { FreeResource (clientResource, RT_NONE); return BadAlloc; @@ -896,9 +881,7 @@ ProcShapeSelectInput (client) */ void -SendShapeNotify (pWin, which) - WindowPtr pWin; - int which; +SendShapeNotify (WindowPtr pWin, int which) { ShapeEventPtr *pHead, pShapeEvent; ClientPtr client; @@ -906,9 +889,11 @@ SendShapeNotify (pWin, which) BoxRec extents; RegionPtr region; BYTE shaped; + int rc; - pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, EventType); - if (!pHead) + rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, + ShapeEventType, serverClient, DixReadAccess); + if (rc != Success) return; switch (which) { case ShapeBounding: @@ -972,8 +957,7 @@ SendShapeNotify (pWin, which) } static int -ProcShapeInputSelected (client) - ClientPtr client; +ProcShapeInputSelected (ClientPtr client) { REQUEST(xShapeInputSelectedReq); WindowPtr pWin; @@ -986,8 +970,10 @@ ProcShapeInputSelected (client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) return rc; - pHead = (ShapeEventPtr *) SecurityLookupIDByType(client, - pWin->drawable.id, EventType, DixReadAccess); + rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, + ShapeEventType, client, DixReadAccess); + if (rc != Success && rc != BadValue) + return rc; enabled = xFalse; if (pHead) { for (pShapeEvent = *pHead; @@ -1013,8 +999,7 @@ ProcShapeInputSelected (client) } static int -ProcShapeGetRectangles (client) - ClientPtr client; +ProcShapeGetRectangles (ClientPtr client) { REQUEST(xShapeGetRectanglesReq); WindowPtr pWin; @@ -1044,7 +1029,7 @@ ProcShapeGetRectangles (client) } if (!region) { nrects = 1; - rects = (xRectangle *) xalloc (sizeof (xRectangle)); + rects = xalloc (sizeof (xRectangle)); if (!rects) return BadAlloc; switch (stuff->kind) { @@ -1071,7 +1056,7 @@ ProcShapeGetRectangles (client) BoxPtr box; nrects = REGION_NUM_RECTS(region); box = REGION_RECTS(region); - rects = (xRectangle *) xalloc (nrects * sizeof (xRectangle)); + rects = xalloc (nrects * sizeof (xRectangle)); if (!rects && nrects) return BadAlloc; for (i = 0; i < nrects; i++, box++) { @@ -1083,7 +1068,7 @@ ProcShapeGetRectangles (client) } rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.length = (nrects * sizeof (xRectangle)) >> 2; + rep.length = bytes_to_int32(nrects * sizeof (xRectangle)); rep.ordering = YXBanded; rep.nrects = nrects; if (client->swapped) { @@ -1099,8 +1084,7 @@ ProcShapeGetRectangles (client) } static int -ProcShapeDispatch (client) - ClientPtr client; +ProcShapeDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) { @@ -1148,8 +1132,7 @@ ProcShapeDispatch (client) } static void -SShapeNotifyEvent(from, to) - xShapeNotifyEvent *from, *to; +SShapeNotifyEvent(xShapeNotifyEvent *from, xShapeNotifyEvent *to) { to->type = from->type; to->kind = from->kind; @@ -1164,8 +1147,7 @@ SShapeNotifyEvent(from, to) } static int -SProcShapeQueryVersion (client) - ClientPtr client; +SProcShapeQueryVersion (ClientPtr client) { int n; REQUEST (xShapeQueryVersionReq); @@ -1175,8 +1157,7 @@ SProcShapeQueryVersion (client) } static int -SProcShapeRectangles (client) - ClientPtr client; +SProcShapeRectangles (ClientPtr client) { char n; REQUEST (xShapeRectanglesReq); @@ -1191,8 +1172,7 @@ SProcShapeRectangles (client) } static int -SProcShapeMask (client) - ClientPtr client; +SProcShapeMask (ClientPtr client) { char n; REQUEST (xShapeMaskReq); @@ -1207,8 +1187,7 @@ SProcShapeMask (client) } static int -SProcShapeCombine (client) - ClientPtr client; +SProcShapeCombine (ClientPtr client) { char n; REQUEST (xShapeCombineReq); @@ -1223,8 +1202,7 @@ SProcShapeCombine (client) } static int -SProcShapeOffset (client) - ClientPtr client; +SProcShapeOffset (ClientPtr client) { char n; REQUEST (xShapeOffsetReq); @@ -1238,8 +1216,7 @@ SProcShapeOffset (client) } static int -SProcShapeQueryExtents (client) - ClientPtr client; +SProcShapeQueryExtents (ClientPtr client) { char n; REQUEST (xShapeQueryExtentsReq); @@ -1251,8 +1228,7 @@ SProcShapeQueryExtents (client) } static int -SProcShapeSelectInput (client) - ClientPtr client; +SProcShapeSelectInput (ClientPtr client) { char n; REQUEST (xShapeSelectInputReq); @@ -1264,8 +1240,7 @@ SProcShapeSelectInput (client) } static int -SProcShapeInputSelected (client) - ClientPtr client; +SProcShapeInputSelected (ClientPtr client) { int n; REQUEST (xShapeInputSelectedReq); @@ -1277,8 +1252,7 @@ SProcShapeInputSelected (client) } static int -SProcShapeGetRectangles (client) - ClientPtr client; +SProcShapeGetRectangles (ClientPtr client) { REQUEST(xShapeGetRectanglesReq); char n; @@ -1290,8 +1264,7 @@ SProcShapeGetRectangles (client) } static int -SProcShapeDispatch (client) - ClientPtr client; +SProcShapeDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) { diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c index a48d2bd5b..dd097e605 100644 --- a/xorg-server/Xext/shm.c +++ b/xorg-server/Xext/shm.c @@ -38,8 +38,6 @@ in this Software without prior written authorization from The Open Group. #include <sys/shm.h> #include <unistd.h> #include <sys/stat.h> -#define NEED_REPLIES -#define NEED_EVENTS #include <X11/X.h> #include <X11/Xproto.h> #include "misc.h" @@ -54,8 +52,7 @@ in this Software without prior written authorization from The Open Group. #include "servermd.h" #include "shmint.h" #include "xace.h" -#define _XSHM_SERVER_ -#include <X11/extensions/shmstr.h> +#include <X11/extensions/shmproto.h> #include <X11/Xfuncproto.h> /* Needed for Solaris cross-zone shared memory extension */ @@ -132,9 +129,9 @@ static DISPATCH_PROC(SProcShmPutImage); static DISPATCH_PROC(SProcShmQueryVersion); static unsigned char ShmReqCode; -_X_EXPORT int ShmCompletionCode; -_X_EXPORT int BadShmSegCode; -_X_EXPORT RESTYPE ShmSegType; +int ShmCompletionCode; +int BadShmSegCode; +RESTYPE ShmSegType; static ShmDescPtr Shmsegs; static Bool sharedPixmaps; static ShmFuncsPtr shmFuncs[MAXSCREENS]; @@ -146,12 +143,11 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; #define VERIFY_SHMSEG(shmseg,shmdesc,client) \ { \ - shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \ - if (!shmdesc) \ - { \ - client->errorValue = shmseg; \ - return BadShmSegCode; \ - } \ + int rc; \ + rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \ + client, DixReadAccess); \ + if (rc != Success) \ + return (rc == BadValue) ? BadShmSegCode : rc; \ } #define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \ @@ -200,7 +196,7 @@ static Bool CheckForShmSyscall(void) if (shmid != -1) { /* Successful allocation - clean up */ - shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL); + shmctl(shmid, IPC_RMID, NULL); } else { @@ -267,11 +263,11 @@ ShmResetProc(ExtensionEntry *extEntry) for (i = 0; i < MAXSCREENS; i++) { - shmFuncs[i] = (ShmFuncsPtr)NULL; + shmFuncs[i] = NULL; } } -_X_EXPORT void +void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs) { shmFuncs[pScreen->myNum] = funcs; @@ -298,7 +294,7 @@ ShmDestroyPixmap (PixmapPtr pPixmap) return ret; } -_X_EXPORT void +void ShmRegisterFbFuncs(ScreenPtr pScreen) { shmFuncs[pScreen->myNum] = &fbFuncs; @@ -311,6 +307,7 @@ ProcShmQueryVersion(ClientPtr client) int n; REQUEST_SIZE_MATCH(xShmQueryVersionReq); + memset(&rep, 0, sizeof(xShmQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -424,7 +421,7 @@ ProcShmAttach(ClientPtr client) } else { - shmdesc = (ShmDescPtr) xalloc(sizeof(ShmDescRec)); + shmdesc = xalloc(sizeof(ShmDescRec)); if (!shmdesc) return BadAlloc; shmdesc->addr = shmat(stuff->shmid, 0, @@ -514,20 +511,22 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC, static int ProcPanoramiXShmPutImage(ClientPtr client) { - int j, result = 0, orig_x, orig_y; + int j, result, orig_x, orig_y; PanoramiXRes *draw, *gc; Bool sendEvent, isRoot; REQUEST(xShmPutImageReq); REQUEST_SIZE_MATCH(xShmPutImageReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -571,9 +570,10 @@ ProcPanoramiXShmGetImage(ClientPtr client) return(BadValue); } - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; if (draw->type == XRT_PIXMAP) return ProcShmGetImage(client); @@ -729,7 +729,7 @@ CreatePmap: VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + if(!(newPix = xalloc(sizeof(PanoramiXRes)))) return BadAlloc; newPix->type = XRT_PIXMAP; diff --git a/xorg-server/Xext/shmint.h b/xorg-server/Xext/shmint.h index f659fd23a..8f8a00d4f 100644 --- a/xorg-server/Xext/shmint.h +++ b/xorg-server/Xext/shmint.h @@ -23,17 +23,47 @@ #ifndef _SHMINT_H_ #define _SHMINT_H_ -#define _XSHM_SERVER_ -#include <X11/extensions/shmstr.h> +#include <X11/extensions/shmproto.h> #include "screenint.h" #include "pixmap.h" #include "gc.h" -void +#define XSHM_PUT_IMAGE_ARGS \ + DrawablePtr /* dst */, \ + GCPtr /* pGC */, \ + int /* depth */, \ + unsigned int /* format */, \ + int /* w */, \ + int /* h */, \ + int /* sx */, \ + int /* sy */, \ + int /* sw */, \ + int /* sh */, \ + int /* dx */, \ + int /* dy */, \ + char * /* data */ + +#define XSHM_CREATE_PIXMAP_ARGS \ + ScreenPtr /* pScreen */, \ + int /* width */, \ + int /* height */, \ + int /* depth */, \ + char * /* addr */ + +typedef struct _ShmFuncs { + PixmapPtr (* CreatePixmap)(XSHM_CREATE_PIXMAP_ARGS); + void (* PutImage)(XSHM_PUT_IMAGE_ARGS); +} ShmFuncs, *ShmFuncsPtr; + +extern _X_EXPORT void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); -void +extern _X_EXPORT void ShmRegisterFbFuncs(ScreenPtr pScreen); +extern _X_EXPORT RESTYPE ShmSegType; +extern _X_EXPORT int ShmCompletionCode; +extern _X_EXPORT int BadShmSegCode; + #endif /* _SHMINT_H_ */ diff --git a/xorg-server/Xext/sleepuntil.c b/xorg-server/Xext/sleepuntil.c index f8cedbe6e..2616a5e5b 100644 --- a/xorg-server/Xext/sleepuntil.c +++ b/xorg-server/Xext/sleepuntil.c @@ -77,14 +77,11 @@ static void SertafiedWakeupHandler( pointer /* LastSelectMask */ ); -_X_EXPORT int -ClientSleepUntil (client, revive, notifyFunc, closure) - ClientPtr client; - TimeStamp *revive; - void (*notifyFunc)( - ClientPtr /* client */, - pointer /* closure */); - pointer closure; +int +ClientSleepUntil (ClientPtr client, + TimeStamp *revive, + void (*notifyFunc)(ClientPtr, pointer), + pointer closure) { SertafiedPtr pRequest, pReq, pPrev; @@ -96,7 +93,7 @@ ClientSleepUntil (client, revive, notifyFunc, closure) SertafiedGeneration = serverGeneration; BlockHandlerRegistered = FALSE; } - pRequest = (SertafiedPtr) xalloc (sizeof (SertafiedRec)); + pRequest = xalloc (sizeof (SertafiedRec)); if (!pRequest) return FALSE; pRequest->pClient = client; @@ -138,9 +135,7 @@ ClientSleepUntil (client, revive, notifyFunc, closure) } static void -ClientAwaken (client, closure) - ClientPtr client; - pointer closure; +ClientAwaken (ClientPtr client, pointer closure) { if (!client->clientGone) AttendClient (client); @@ -148,9 +143,7 @@ ClientAwaken (client, closure) static int -SertafiedDelete (value, id) - pointer value; - XID id; +SertafiedDelete (pointer value, XID id) { SertafiedPtr pRequest = (SertafiedPtr)value; SertafiedPtr pReq, pPrev; @@ -172,10 +165,7 @@ SertafiedDelete (value, id) } static void -SertafiedBlockHandler (data, wt, LastSelectMask) - pointer data; /* unused */ - OSTimePtr wt; /* wait time */ - pointer LastSelectMask; +SertafiedBlockHandler (pointer data, OSTimePtr wt, pointer LastSelectMask) { SertafiedPtr pReq, pNext; unsigned long delay; @@ -208,10 +198,7 @@ SertafiedBlockHandler (data, wt, LastSelectMask) } static void -SertafiedWakeupHandler (data, i, LastSelectMask) - pointer data; - int i; - pointer LastSelectMask; +SertafiedWakeupHandler (pointer data, int i, pointer LastSelectMask) { SertafiedPtr pReq, pNext; TimeStamp now; diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c index a006ae95b..667f8ab78 100644 --- a/xorg-server/Xext/sync.c +++ b/xorg-server/Xext/sync.c @@ -34,7 +34,7 @@ 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 names of Digital or Olivetti +supporting documentation, and that the names of Digital or Olivetti not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Digital and Olivetti make no representations about the suitability of this software @@ -50,8 +50,6 @@ PERFORMANCE OF THIS SOFTWARE. */ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -67,9 +65,8 @@ PERFORMANCE OF THIS SOFTWARE. #include "dixstruct.h" #include "resource.h" #include "opaque.h" -#define _SYNC_SERVER -#include <X11/extensions/sync.h> -#include <X11/extensions/syncstr.h> +#include <X11/extensions/syncproto.h> +#include "syncsrv.h" #include <stdio.h> #if !defined(WIN32) @@ -97,173 +94,11 @@ static SyncCounter **SysCounterList = NULL; #define XSyncCAAllTrigger \ (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) -static int -FreeAlarm( - pointer /* addr */, - XID /* id */ -); - -static int -FreeAlarmClient( - pointer /* value */, - XID /* id */ -); - -static int -FreeAwait( - pointer /* addr */, - XID /* id */ -); - -static void -ServertimeBracketValues( - pointer /* pCounter */, - CARD64 * /* pbracket_less */, - CARD64 * /* pbracket_greater */ -); - -static void -ServertimeQueryValue( - pointer /* pCounter */, - CARD64 * /* pValue_return */ -); - -static void -ServertimeWakeupHandler( - pointer /* env */, - int /* rc */, - pointer /* LastSelectMask */ -); - -static int -SyncInitTrigger( - ClientPtr /* client */, - SyncTrigger * /* pTrigger */, - XSyncCounter /* counter */, - Mask /* changes */ -); - -static void -SAlarmNotifyEvent( - xSyncAlarmNotifyEvent * /* from */, - xSyncAlarmNotifyEvent * /* to */ -); - -static void -SCounterNotifyEvent( - xSyncCounterNotifyEvent * /* from */, - xSyncCounterNotifyEvent * /* to */ -); - -static void -ServertimeBlockHandler( - pointer /* env */, - struct timeval ** /* wt */, - pointer /* LastSelectMask */ -); - -static int -SyncAddTriggerToCounter( - SyncTrigger * /* pTrigger */ -); - -extern void -SyncAlarmCounterDestroyed( - SyncTrigger * /* pTrigger */ -); - -static void -SyncAlarmTriggerFired( - SyncTrigger * /* pTrigger */ -); - -static void -SyncAwaitTriggerFired( - SyncTrigger * /* pTrigger */ -); - -static int -SyncChangeAlarmAttributes( - ClientPtr /* client */, - SyncAlarm * /* pAlarm */, - Mask /* mask */, - CARD32 * /* values */ -); - -static Bool -SyncCheckTriggerNegativeComparison( - SyncTrigger * /* pTrigger */, - CARD64 /* oldval */ -); - -static Bool -SyncCheckTriggerNegativeTransition( - SyncTrigger * /* pTrigger */, - CARD64 /* oldval */ -); - -static Bool -SyncCheckTriggerPositiveComparison( - SyncTrigger * /* pTrigger */, - CARD64 /* oldval */ -); - -static Bool -SyncCheckTriggerPositiveTransition( - SyncTrigger * /* pTrigger */, - CARD64 /* oldval */ -); - -static SyncCounter * -SyncCreateCounter( - ClientPtr /* client */, - XSyncCounter /* id */, - CARD64 /* initialvalue */ -); +static void SyncComputeBracketValues(SyncCounter *, Bool); -static void SyncComputeBracketValues( - SyncCounter * /* pCounter */, - Bool /* startOver */ -); +static void SyncInitServerTime(void); -static void -SyncDeleteTriggerFromCounter( - SyncTrigger * /* pTrigger */ -); - -static Bool -SyncEventSelectForAlarm( - SyncAlarm * /* pAlarm */, - ClientPtr /* client */, - Bool /* wantevents */ -); - -static void -SyncInitServerTime( - void -); - -static void -SyncInitIdleTime( - void -); - -static void -SyncResetProc( - ExtensionEntry * /* extEntry */ -); - -static void -SyncSendAlarmNotifyEvents( - SyncAlarm * /* pAlarm */ -); - -static void -SyncSendCounterNotifyEvents( - ClientPtr /* client */, - SyncAwait ** /* ppAwait */, - int /* num_events */ -); +static void SyncInitIdleTime(void); static DISPATCH_PROC(ProcSyncAwait); static DISPATCH_PROC(ProcSyncChangeAlarm); @@ -301,8 +136,7 @@ static DISPATCH_PROC(SProcSyncSetPriority); * delete and add triggers on this list. */ static void -SyncDeleteTriggerFromCounter(pTrigger) - SyncTrigger *pTrigger; +SyncDeleteTriggerFromCounter(SyncTrigger *pTrigger) { SyncTriggerList *pCur; SyncTriggerList *pPrev; @@ -323,7 +157,7 @@ SyncDeleteTriggerFromCounter(pTrigger) pPrev->next = pCur->next; else pTrigger->pCounter->pTriglist = pCur->next; - + xfree(pCur); break; } @@ -331,15 +165,14 @@ SyncDeleteTriggerFromCounter(pTrigger) pPrev = pCur; pCur = pCur->next; } - + if (IsSystemCounter(pTrigger->pCounter)) SyncComputeBracketValues(pTrigger->pCounter, /*startOver*/ TRUE); } static int -SyncAddTriggerToCounter(pTrigger) - SyncTrigger *pTrigger; +SyncAddTriggerToCounter(SyncTrigger *pTrigger) { SyncTriggerList *pCur; @@ -353,7 +186,7 @@ SyncAddTriggerToCounter(pTrigger) return Success; } - if (!(pCur = (SyncTriggerList *)xalloc(sizeof(SyncTriggerList)))) + if (!(pCur = xalloc(sizeof(SyncTriggerList)))) return BadAlloc; pCur->pTrigger = pTrigger; @@ -367,7 +200,7 @@ SyncAddTriggerToCounter(pTrigger) } -/* Below are four possible functions that can be plugged into +/* Below are four possible functions that can be plugged into * pTrigger->CheckTrigger, corresponding to the four possible * test-types. These functions are called after the counter's * value changes but are also passed the old counter value @@ -377,14 +210,12 @@ SyncAddTriggerToCounter(pTrigger) * of the trigger. * * All of them include the condition pTrigger->pCounter == NULL. - * This is because the spec says that a trigger with a counter value + * This is because the spec says that a trigger with a counter value * of None is always TRUE. */ static Bool -SyncCheckTriggerPositiveComparison(pTrigger, oldval) - SyncTrigger *pTrigger; - CARD64 oldval; +SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval) { return (pTrigger->pCounter == NULL || XSyncValueGreaterOrEqual(pTrigger->pCounter->value, @@ -392,9 +223,7 @@ SyncCheckTriggerPositiveComparison(pTrigger, oldval) } static Bool -SyncCheckTriggerNegativeComparison(pTrigger, oldval) - SyncTrigger *pTrigger; - CARD64 oldval; +SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval) { return (pTrigger->pCounter == NULL || XSyncValueLessOrEqual(pTrigger->pCounter->value, @@ -402,9 +231,7 @@ SyncCheckTriggerNegativeComparison(pTrigger, oldval) } static Bool -SyncCheckTriggerPositiveTransition(pTrigger, oldval) - SyncTrigger *pTrigger; - CARD64 oldval; +SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval) { return (pTrigger->pCounter == NULL || (XSyncValueLessThan(oldval, pTrigger->test_value) && @@ -413,9 +240,7 @@ SyncCheckTriggerPositiveTransition(pTrigger, oldval) } static Bool -SyncCheckTriggerNegativeTransition(pTrigger, oldval) - SyncTrigger *pTrigger; - CARD64 oldval; +SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval) { return (pTrigger->pCounter == NULL || (XSyncValueGreaterThan(oldval, pTrigger->test_value) && @@ -423,14 +248,9 @@ SyncCheckTriggerNegativeTransition(pTrigger, oldval) pTrigger->test_value))); } - - -static int -SyncInitTrigger(client, pTrigger, counter, changes) - ClientPtr client; /* so we can set errorValue */ - SyncTrigger *pTrigger; - XSyncCounter counter; - Mask changes; +static int +SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XSyncCounter counter, + Mask changes) { SyncCounter *pCounter = pTrigger->pCounter; int rc; @@ -486,16 +306,16 @@ SyncInitTrigger(client, pTrigger, counter, changes) switch (pTrigger->test_type) { - case XSyncPositiveTransition: + case XSyncPositiveTransition: pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition; break; - case XSyncNegativeTransition: + case XSyncNegativeTransition: pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition; break; - case XSyncPositiveComparison: + case XSyncPositiveComparison: pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison; break; - case XSyncNegativeComparison: + case XSyncNegativeComparison: pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison; break; } @@ -511,7 +331,7 @@ SyncInitTrigger(client, pTrigger, counter, changes) if (pCounter == NULL) return BadMatch; - XSyncValueAdd(&pTrigger->test_value, pCounter->value, + XSyncValueAdd(&pTrigger->test_value, pCounter->value, pTrigger->wait_value, &overflow); if (overflow) { @@ -533,17 +353,16 @@ SyncInitTrigger(client, pTrigger, counter, changes) { SyncComputeBracketValues(pCounter, /*startOver*/ TRUE); } - + return Success; } /* AlarmNotify events happen in response to actions taken on an Alarm or - * the counter used by the alarm. AlarmNotify may be sent to multiple + * the counter used by the alarm. AlarmNotify may be sent to multiple * clients. The alarm maintains a list of clients interested in events. */ static void -SyncSendAlarmNotifyEvents(pAlarm) - SyncAlarm *pAlarm; +SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm) { SyncAlarmClientList *pcl; xSyncAlarmNotifyEvent ane; @@ -571,7 +390,7 @@ SyncSendAlarmNotifyEvents(pAlarm) ane.state = pAlarm->state; /* send to owner */ - if (pAlarm->events && !pAlarm->client->clientGone) + if (pAlarm->events && !pAlarm->client->clientGone) WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane); /* send to other interested clients */ @@ -586,23 +405,20 @@ SyncSendAlarmNotifyEvents(pAlarm) } -/* CounterNotify events only occur in response to an Await. The events +/* CounterNotify events only occur in response to an Await. The events * go only to the Awaiting client. */ static void -SyncSendCounterNotifyEvents(client, ppAwait, num_events) - ClientPtr client; - SyncAwait **ppAwait; - int num_events; +SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait, + int num_events) { xSyncCounterNotifyEvent *pEvents, *pev; int i; if (client->clientGone) return; - pev = pEvents = (xSyncCounterNotifyEvent *) - xalloc(num_events * sizeof(xSyncCounterNotifyEvent)); - if (!pEvents) + pev = pEvents = xalloc(num_events * sizeof(xSyncCounterNotifyEvent)); + if (!pEvents) return; UpdateCurrentTime(); for (i = 0; i < num_events; i++, ppAwait++, pev++) @@ -629,9 +445,8 @@ SyncSendCounterNotifyEvents(client, ppAwait, num_events) /* This function is called when an alarm's counter is destroyed. * It is plugged into pTrigger->CounterDestroyed (for alarm triggers). */ -void -SyncAlarmCounterDestroyed(pTrigger) - SyncTrigger *pTrigger; +static void +SyncAlarmCounterDestroyed(SyncTrigger *pTrigger) { SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; @@ -641,12 +456,11 @@ SyncAlarmCounterDestroyed(pTrigger) } -/* This function is called when an alarm "goes off." +/* This function is called when an alarm "goes off." * It is plugged into pTrigger->TriggerFired (for alarm triggers). */ static void -SyncAlarmTriggerFired(pTrigger) - SyncTrigger *pTrigger; +SyncAlarmTriggerFired(SyncTrigger *pTrigger) { SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; CARD64 new_test_value; @@ -686,7 +500,7 @@ SyncAlarmTriggerFired(pTrigger) { XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, pAlarm->delta, &overflow); - } while (!overflow && + } while (!overflow && (*paTrigger->CheckTrigger)(paTrigger, paTrigger->pCounter->value)); @@ -721,8 +535,7 @@ SyncAlarmTriggerFired(pTrigger) * (for Await triggers). */ static void -SyncAwaitTriggerFired(pTrigger) - SyncTrigger *pTrigger; +SyncAwaitTriggerFired(SyncTrigger *pTrigger) { SyncAwait *pAwait = (SyncAwait *)pTrigger; int numwaits; @@ -732,7 +545,7 @@ SyncAwaitTriggerFired(pTrigger) pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader; numwaits = pAwaitUnion->header.num_waitconditions; - ppAwait = (SyncAwait **)xalloc(numwaits * sizeof(SyncAwait *)); + ppAwait = xalloc(numwaits * sizeof(SyncAwait *)); if (!ppAwait) goto bail; @@ -815,9 +628,7 @@ bail: * any triggers depending on the counter will be checked. */ void -SyncChangeCounter(pCounter, newval) - SyncCounter *pCounter; - CARD64 newval; +SyncChangeCounter(SyncCounter *pCounter, CARD64 newval) { SyncTriggerList *ptl, *pnext; CARD64 oldval; @@ -842,10 +653,7 @@ SyncChangeCounter(pCounter, newval) /* loosely based on dix/events.c/EventSelectForWindow */ static Bool -SyncEventSelectForAlarm(pAlarm, client, wantevents) - SyncAlarm *pAlarm; - ClientPtr client; - Bool wantevents; +SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents) { SyncAlarmClientList *pClients; @@ -862,8 +670,8 @@ SyncEventSelectForAlarm(pAlarm, client, wantevents) { if (pClients->client == client) { - /* client's presence on the list indicates desire for - * events. If the client doesn't want events, remove it + /* client's presence on the list indicates desire for + * events. If the client doesn't want events, remove it * from the list. If the client does want events, do * nothing, since it's already got them. */ @@ -880,18 +688,18 @@ SyncEventSelectForAlarm(pAlarm, client, wantevents) */ if (!wantevents) - /* client doesn't want events, and we just discovered that it + /* client doesn't want events, and we just discovered that it * doesn't have them, so there's nothing to do. */ return Success; /* add new client to pAlarm->pEventClients */ - pClients = (SyncAlarmClientList *) xalloc(sizeof(SyncAlarmClientList)); + pClients = xalloc(sizeof(SyncAlarmClientList)); if (!pClients) return BadAlloc; - /* register it as a resource so it will be cleaned up + /* register it as a resource so it will be cleaned up * if the client dies */ @@ -913,12 +721,9 @@ SyncEventSelectForAlarm(pAlarm, client, wantevents) /* * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm */ -static int -SyncChangeAlarmAttributes(client, pAlarm, mask, values) - ClientPtr client; - SyncAlarm *pAlarm; - Mask mask; - CARD32 *values; +static int +SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask, + CARD32 *values) { int status; XSyncCounter counter; @@ -1015,20 +820,17 @@ SyncChangeAlarmAttributes(client, pAlarm, mask, values) static SyncCounter * -SyncCreateCounter(client, id, initialvalue) - ClientPtr client; - XSyncCounter id; - CARD64 initialvalue; +SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue) { SyncCounter *pCounter; - if (!(pCounter = (SyncCounter *) xalloc(sizeof(SyncCounter)))) - return (SyncCounter *)NULL; + if (!(pCounter = xalloc(sizeof(SyncCounter)))) + return NULL; if (!AddResource(id, RTCounter, (pointer) pCounter)) { - xfree((pointer) pCounter); - return (SyncCounter *)NULL; + xfree(pCounter); + return NULL; } pCounter->client = client; @@ -1040,36 +842,31 @@ SyncCreateCounter(client, id, initialvalue) return pCounter; } -static int FreeCounter( - pointer /*env*/, - XID /*id*/ -); +static int FreeCounter(void *, XID); /* * ***** System Counter utilities */ -pointer -SyncCreateSystemCounter(name, initial, resolution, counterType, - QueryValue, BracketValues) - char *name; - CARD64 initial; - CARD64 resolution; - SyncCounterType counterType; - void (*QueryValue) ( - pointer /* pCounter */, - CARD64 * /* pValue_return */); - void (*BracketValues) ( - pointer /* pCounter */, - CARD64 * /* pbracket_less */, - CARD64 * /* pbracket_greater */); +pointer +SyncCreateSystemCounter( + char *name, + CARD64 initial, + CARD64 resolution, + SyncCounterType counterType, + void (*QueryValue)(pointer /* pCounter */, + CARD64 * /* pValue_return */), + void (*BracketValues)(pointer /* pCounter */, + CARD64 * /* pbracket_less */, + CARD64 * /* pbracket_greater */) + ) { SyncCounter *pCounter; - SysCounterList = (SyncCounter **)xrealloc(SysCounterList, + SysCounterList = xrealloc(SysCounterList, (SyncNumSystemCounters+1)*sizeof(SyncCounter *)); if (!SysCounterList) - return (pointer)NULL; + return NULL; /* this function may be called before SYNC has been initialized, so we * have to make sure RTCounter is created. @@ -1079,21 +876,21 @@ SyncCreateSystemCounter(name, initial, resolution, counterType, RTCounter = CreateNewResourceType(FreeCounter); if (RTCounter == 0) { - return (pointer)NULL; + return NULL; } } - pCounter = SyncCreateCounter((ClientPtr)NULL, FakeClientID(0), initial); + pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial); if (pCounter) { SysCounterInfo *psci; - psci = (SysCounterInfo *)xalloc(sizeof(SysCounterInfo)); + psci = xalloc(sizeof(SysCounterInfo)); if (!psci) { FreeResource(pCounter->id, RT_NONE); - return (pointer) pCounter; + return pCounter; } pCounter->pSysCounterInfo = psci; psci->name = name; @@ -1105,21 +902,18 @@ SyncCreateSystemCounter(name, initial, resolution, counterType, XSyncMinValue(&psci->bracket_less); SysCounterList[SyncNumSystemCounters++] = pCounter; } - return (pointer) pCounter; + return pCounter; } void -SyncDestroySystemCounter(pSysCounter) - pointer pSysCounter; +SyncDestroySystemCounter(pointer pSysCounter) { SyncCounter *pCounter = (SyncCounter *)pSysCounter; FreeResource(pCounter->id, RT_NONE); } static void -SyncComputeBracketValues(pCounter, startOver) - SyncCounter *pCounter; - Bool startOver; +SyncComputeBracketValues(SyncCounter *pCounter, Bool startOver) { SyncTriggerList *pCur; SyncTrigger *pTrigger; @@ -1202,9 +996,7 @@ SyncComputeBracketValues(pCounter, startOver) /* ARGSUSED */ static int -FreeAlarm(addr, id) - pointer addr; - XID id; +FreeAlarm(void *addr, XID id) { SyncAlarm *pAlarm = (SyncAlarm *) addr; @@ -1229,9 +1021,7 @@ FreeAlarm(addr, id) */ /* ARGSUSED */ static int -FreeCounter(env, id) - pointer env; - XID id; +FreeCounter(void *env, XID id) { SyncCounter *pCounter = (SyncCounter *) env; SyncTriggerList *ptl, *pnext; @@ -1281,9 +1071,7 @@ FreeCounter(env, id) */ /* ARGSUSED */ static int -FreeAwait(addr, id) - pointer addr; - XID id; +FreeAwait(void *addr, XID id) { SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr; SyncAwait *pAwait; @@ -1296,7 +1084,7 @@ FreeAwait(addr, id) for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits; numwaits--, pAwait++) { - /* If the counter is being destroyed, FreeCounter will delete + /* If the counter is being destroyed, FreeCounter will delete * the trigger list itself, so don't do it here. */ SyncCounter *pCounter = pAwait->trigger.pCounter; @@ -1309,9 +1097,7 @@ FreeAwait(addr, id) /* loosely based on dix/events.c/OtherClientGone */ static int -FreeAlarmClient(value, id) - pointer value; /* must conform to DeleteType */ - XID id; +FreeAlarmClient(void *value, XID id) { SyncAlarm *pAlarm = (SyncAlarm *)value; SyncAlarmClientList *pCur, *pPrev; @@ -1327,7 +1113,7 @@ FreeAlarmClient(value, id) else pAlarm->pEventClients = pCur->next; xfree(pCur); - return(Success); + return Success; } } FatalError("alarm client not on event list"); @@ -1343,15 +1129,15 @@ FreeAlarmClient(value, id) /* * ** Initialize the extension */ -static int -ProcSyncInitialize(client) - ClientPtr client; +static int +ProcSyncInitialize(ClientPtr client) { xSyncInitializeReply rep; int n; REQUEST_SIZE_MATCH(xSyncInitializeReq); + memset(&rep, 0, sizeof(xSyncInitializeReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.majorVersion = SYNC_MAJOR_VERSION; @@ -1363,20 +1149,19 @@ ProcSyncInitialize(client) swaps(&rep.sequenceNumber, n); } WriteToClient(client, sizeof(rep), (char *) &rep); - return (client->noClientException); + return client->noClientException; } /* * ** Get list of system counters available through the extension */ -static int -ProcSyncListSystemCounters(client) - ClientPtr client; +static int +ProcSyncListSystemCounters(ClientPtr client) { xSyncListSystemCountersReply rep; int i, len; xSyncSystemCounter *list = NULL, *walklist = NULL; - + REQUEST_SIZE_MATCH(xSyncListSystemCountersReq); rep.type = X_Reply; @@ -1387,17 +1172,17 @@ ProcSyncListSystemCounters(client) { char *name = SysCounterList[i]->pSysCounterInfo->name; /* pad to 4 byte boundary */ - len += (sz_xSyncSystemCounter + strlen(name) + 3) & ~3; + len += pad_to_int32(sz_xSyncSystemCounter + strlen(name)); } if (len) { - walklist = list = (xSyncSystemCounter *) xalloc(len); + walklist = list = xalloc(len); if (!list) return BadAlloc; } - rep.length = len >> 2; + rep.length = bytes_to_int32(len); if (client->swapped) { @@ -1430,26 +1215,25 @@ ProcSyncListSystemCounters(client) pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter; strncpy(pname_in_reply, psci->name, namelen); - walklist = (xSyncSystemCounter *) (((char *)walklist) + - ((sz_xSyncSystemCounter + namelen + 3) & ~3)); + walklist = (xSyncSystemCounter *) (((char *)walklist) + + pad_to_int32(sz_xSyncSystemCounter + namelen)); } WriteToClient(client, sizeof(rep), (char *) &rep); - if (len) + if (len) { WriteToClient(client, len, (char *) list); xfree(list); } - return (client->noClientException); + return client->noClientException; } /* * ** Set client Priority */ -static int -ProcSyncSetPriority(client) - ClientPtr client; +static int +ProcSyncSetPriority(ClientPtr client) { REQUEST(xSyncSetPriorityReq); ClientPtr priorityclient; @@ -1483,9 +1267,8 @@ ProcSyncSetPriority(client) /* * ** Get client Priority */ -static int -ProcSyncGetPriority(client) - ClientPtr client; +static int +ProcSyncGetPriority(ClientPtr client) { REQUEST(xSyncGetPriorityReq); xSyncGetPriorityReply rep; @@ -1517,15 +1300,14 @@ ProcSyncGetPriority(client) WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep); - return (client->noClientException); + return client->noClientException; } /* * ** Create a new counter */ -static int -ProcSyncCreateCounter(client) - ClientPtr client; +static int +ProcSyncCreateCounter(ClientPtr client) { REQUEST(xSyncCreateCounterReq); CARD64 initial; @@ -1538,29 +1320,26 @@ ProcSyncCreateCounter(client) if (!SyncCreateCounter(client, stuff->cid, initial)) return BadAlloc; - return (client->noClientException); + return client->noClientException; } /* * ** Set Counter value */ -static int -ProcSyncSetCounter(client) - ClientPtr client; +static int +ProcSyncSetCounter(ClientPtr client) { REQUEST(xSyncSetCounterReq); SyncCounter *pCounter; CARD64 newvalue; + int rc; REQUEST_SIZE_MATCH(xSyncSetCounterReq); - pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->cid, - RTCounter, DixWriteAccess); - if (pCounter == NULL) - { - client->errorValue = stuff->cid; - return SyncErrorBase + XSyncBadCounter; - } + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc; if (IsSystemCounter(pCounter)) { @@ -1576,24 +1355,21 @@ ProcSyncSetCounter(client) /* * ** Change Counter value */ -static int -ProcSyncChangeCounter(client) - ClientPtr client; +static int +ProcSyncChangeCounter(ClientPtr client) { REQUEST(xSyncChangeCounterReq); SyncCounter *pCounter; CARD64 newvalue; Bool overflow; + int rc; REQUEST_SIZE_MATCH(xSyncChangeCounterReq); - pCounter = (SyncCounter *) SecurityLookupIDByType(client, stuff->cid, - RTCounter, DixWriteAccess); - if (pCounter == NULL) - { - client->errorValue = stuff->cid; - return SyncErrorBase + XSyncBadCounter; - } + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc; if (IsSystemCounter(pCounter)) { @@ -1606,7 +1382,7 @@ ProcSyncChangeCounter(client) if (overflow) { /* XXX 64 bit value can't fit in 32 bits; do the best we can */ - client->errorValue = stuff->value_hi; + client->errorValue = stuff->value_hi; return BadValue; } SyncChangeCounter(pCounter, newvalue); @@ -1616,22 +1392,20 @@ ProcSyncChangeCounter(client) /* * ** Destroy a counter */ -static int -ProcSyncDestroyCounter(client) - ClientPtr client; +static int +ProcSyncDestroyCounter(ClientPtr client) { REQUEST(xSyncDestroyCounterReq); SyncCounter *pCounter; + int rc; REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); - pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter, - RTCounter, DixDestroyAccess); - if (pCounter == NULL) - { - client->errorValue = stuff->counter; - return SyncErrorBase + XSyncBadCounter; - } + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter, + client, DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc; + if (IsSystemCounter(pCounter)) { client->errorValue = stuff->counter; @@ -1645,9 +1419,8 @@ ProcSyncDestroyCounter(client) /* * ** Await */ -static int -ProcSyncAwait(client) - ClientPtr client; +static int +ProcSyncAwait(ClientPtr client) { REQUEST(xSyncAwaitReq); int len, items; @@ -1675,10 +1448,10 @@ ProcSyncAwait(client) pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1]; - /* all the memory for the entire await list is allocated + /* all the memory for the entire await list is allocated * here in one chunk */ - pAwaitUnion = (SyncAwaitUnion *)xalloc((items+1) * sizeof(SyncAwaitUnion)); + pAwaitUnion = xalloc((items+1) * sizeof(SyncAwaitUnion)); if (!pAwaitUnion) return BadAlloc; @@ -1761,23 +1534,20 @@ ProcSyncAwait(client) /* * ** Query a counter */ -static int -ProcSyncQueryCounter(client) - ClientPtr client; +static int +ProcSyncQueryCounter(ClientPtr client) { REQUEST(xSyncQueryCounterReq); xSyncQueryCounterReply rep; SyncCounter *pCounter; + int rc; REQUEST_SIZE_MATCH(xSyncQueryCounterReq); - pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter, - RTCounter, DixReadAccess); - if (pCounter == NULL) - { - client->errorValue = stuff->counter; - return SyncErrorBase + XSyncBadCounter; - } + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, + RTCounter, client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc; rep.type = X_Reply; rep.length = 0; @@ -1802,16 +1572,15 @@ ProcSyncQueryCounter(client) swapl(&rep.value_lo, n); } WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep); - return (client->noClientException); + return client->noClientException; } /* * ** Create Alarm */ -static int -ProcSyncCreateAlarm(client) - ClientPtr client; +static int +ProcSyncCreateAlarm(ClientPtr client) { REQUEST(xSyncCreateAlarmReq); SyncAlarm *pAlarm; @@ -1824,12 +1593,12 @@ ProcSyncCreateAlarm(client) LEGAL_NEW_RESOURCE(stuff->id, client); vmask = stuff->valueMask; - len = client->req_len - (sizeof(xSyncCreateAlarmReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq)); /* the "extra" call to Ones accounts for the presence of 64 bit values */ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) return BadLength; - if (!(pAlarm = (SyncAlarm *) xalloc(sizeof(SyncAlarm)))) + if (!(pAlarm = xalloc(sizeof(SyncAlarm)))) { return BadAlloc; } @@ -1889,9 +1658,8 @@ ProcSyncCreateAlarm(client) /* * ** Change Alarm */ -static int -ProcSyncChangeAlarm(client) - ClientPtr client; +static int +ProcSyncChangeAlarm(ClientPtr client) { REQUEST(xSyncChangeAlarmReq); SyncAlarm *pAlarm; @@ -1900,20 +1668,18 @@ ProcSyncChangeAlarm(client) REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); - if (!(pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, DixWriteAccess))) - { - client->errorValue = stuff->alarm; - return SyncErrorBase + XSyncBadAlarm; - } + status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixWriteAccess); + if (status != Success) + return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status; vmask = stuff->valueMask; - len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq)); /* the "extra" call to Ones accounts for the presence of 64 bit values */ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) return BadLength; - if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask, + if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask, (CARD32 *)&stuff[1])) != Success) return status; @@ -1930,27 +1696,24 @@ ProcSyncChangeAlarm(client) return Success; } -static int -ProcSyncQueryAlarm(client) - ClientPtr client; +static int +ProcSyncQueryAlarm(ClientPtr client) { REQUEST(xSyncQueryAlarmReq); SyncAlarm *pAlarm; xSyncQueryAlarmReply rep; SyncTrigger *pTrigger; + int rc; REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); - pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, DixReadAccess); - if (!pAlarm) - { - client->errorValue = stuff->alarm; - return (SyncErrorBase + XSyncBadAlarm); - } + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixReadAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc; rep.type = X_Reply; - rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2; + rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)); rep.sequenceNumber = client->sequence; pTrigger = &pAlarm->trigger; @@ -1989,41 +1752,37 @@ ProcSyncQueryAlarm(client) } WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep); - return (client->noClientException); + return client->noClientException; } - -static int -ProcSyncDestroyAlarm(client) - ClientPtr client; +static int +ProcSyncDestroyAlarm(ClientPtr client) { + SyncAlarm *pAlarm; + int rc; REQUEST(xSyncDestroyAlarmReq); REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); - if (!((SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm, - RTAlarm, DixDestroyAccess))) - { - client->errorValue = stuff->alarm; - return SyncErrorBase + XSyncBadAlarm; - } + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc; FreeResource(stuff->alarm, RT_NONE); - return (client->noClientException); + return client->noClientException; } /* * ** Given an extension request, call the appropriate request procedure */ -static int -ProcSyncDispatch(client) - ClientPtr client; +static int +ProcSyncDispatch(ClientPtr client) { REQUEST(xReq); switch (stuff->data) { - case X_SyncInitialize: return ProcSyncInitialize(client); case X_SyncListSystemCounters: @@ -2061,9 +1820,8 @@ ProcSyncDispatch(client) * Boring Swapping stuff ... */ -static int -SProcSyncInitialize(client) - ClientPtr client; +static int +SProcSyncInitialize(ClientPtr client) { REQUEST(xSyncInitializeReq); char n; @@ -2074,9 +1832,8 @@ SProcSyncInitialize(client) return ProcSyncInitialize(client); } -static int -SProcSyncListSystemCounters(client) - ClientPtr client; +static int +SProcSyncListSystemCounters(ClientPtr client) { REQUEST(xSyncListSystemCountersReq); char n; @@ -2087,9 +1844,8 @@ SProcSyncListSystemCounters(client) return ProcSyncListSystemCounters(client); } -static int -SProcSyncCreateCounter(client) - ClientPtr client; +static int +SProcSyncCreateCounter(ClientPtr client) { REQUEST(xSyncCreateCounterReq); char n; @@ -2103,9 +1859,8 @@ SProcSyncCreateCounter(client) return ProcSyncCreateCounter(client); } -static int -SProcSyncSetCounter(client) - ClientPtr client; +static int +SProcSyncSetCounter(ClientPtr client) { REQUEST(xSyncSetCounterReq); char n; @@ -2119,9 +1874,8 @@ SProcSyncSetCounter(client) return ProcSyncSetCounter(client); } -static int -SProcSyncChangeCounter(client) - ClientPtr client; +static int +SProcSyncChangeCounter(ClientPtr client) { REQUEST(xSyncChangeCounterReq); char n; @@ -2135,9 +1889,8 @@ SProcSyncChangeCounter(client) return ProcSyncChangeCounter(client); } -static int -SProcSyncQueryCounter(client) - ClientPtr client; +static int +SProcSyncQueryCounter(ClientPtr client) { REQUEST(xSyncQueryCounterReq); char n; @@ -2149,9 +1902,8 @@ SProcSyncQueryCounter(client) return ProcSyncQueryCounter(client); } -static int -SProcSyncDestroyCounter(client) - ClientPtr client; +static int +SProcSyncDestroyCounter(ClientPtr client) { REQUEST(xSyncDestroyCounterReq); char n; @@ -2163,9 +1915,8 @@ SProcSyncDestroyCounter(client) return ProcSyncDestroyCounter(client); } -static int -SProcSyncAwait(client) - ClientPtr client; +static int +SProcSyncAwait(ClientPtr client) { REQUEST(xSyncAwaitReq); char n; @@ -2177,10 +1928,8 @@ SProcSyncAwait(client) return ProcSyncAwait(client); } - -static int -SProcSyncCreateAlarm(client) - ClientPtr client; +static int +SProcSyncCreateAlarm(ClientPtr client) { REQUEST(xSyncCreateAlarmReq); char n; @@ -2194,9 +1943,8 @@ SProcSyncCreateAlarm(client) return ProcSyncCreateAlarm(client); } -static int -SProcSyncChangeAlarm(client) - ClientPtr client; +static int +SProcSyncChangeAlarm(ClientPtr client) { REQUEST(xSyncChangeAlarmReq); char n; @@ -2209,9 +1957,8 @@ SProcSyncChangeAlarm(client) return ProcSyncChangeAlarm(client); } -static int -SProcSyncQueryAlarm(client) - ClientPtr client; +static int +SProcSyncQueryAlarm(ClientPtr client) { REQUEST(xSyncQueryAlarmReq); char n; @@ -2223,9 +1970,8 @@ SProcSyncQueryAlarm(client) return ProcSyncQueryAlarm(client); } -static int -SProcSyncDestroyAlarm(client) - ClientPtr client; +static int +SProcSyncDestroyAlarm(ClientPtr client) { REQUEST(xSyncDestroyAlarmReq); char n; @@ -2237,9 +1983,8 @@ SProcSyncDestroyAlarm(client) return ProcSyncDestroyAlarm(client); } -static int -SProcSyncSetPriority(client) - ClientPtr client; +static int +SProcSyncSetPriority(ClientPtr client) { REQUEST(xSyncSetPriorityReq); char n; @@ -2252,9 +1997,8 @@ SProcSyncSetPriority(client) return ProcSyncSetPriority(client); } -static int -SProcSyncGetPriority(client) - ClientPtr client; +static int +SProcSyncGetPriority(ClientPtr client) { REQUEST(xSyncGetPriorityReq); char n; @@ -2267,9 +2011,8 @@ SProcSyncGetPriority(client) } -static int -SProcSyncDispatch(client) - ClientPtr client; +static int +SProcSyncDispatch(ClientPtr client) { REQUEST(xReq); @@ -2312,9 +2055,8 @@ SProcSyncDispatch(client) * Event Swapping */ -static void -SCounterNotifyEvent(from, to) - xSyncCounterNotifyEvent *from, *to; +static void +SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to) { to->type = from->type; to->kind = from->kind; @@ -2330,9 +2072,8 @@ SCounterNotifyEvent(from, to) } -static void -SAlarmNotifyEvent(from, to) - xSyncAlarmNotifyEvent *from, *to; +static void +SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to) { to->type = from->type; to->kind = from->kind; @@ -2350,9 +2091,8 @@ SAlarmNotifyEvent(from, to) * ** Close everything down. ** This is fairly simple for now. */ /* ARGSUSED */ -static void -SyncResetProc(extEntry) - ExtensionEntry *extEntry; +static void +SyncResetProc(ExtensionEntry *extEntry) { xfree(SysCounterList); SysCounterList = NULL; @@ -2363,8 +2103,8 @@ SyncResetProc(extEntry) /* * ** Initialise the extension. */ -void -SyncExtensionInit(INITARGS) +void +SyncExtensionInit(void) { ExtensionEntry *extEntry; @@ -2433,10 +2173,8 @@ static XSyncValue *pnext_time; *** code inspired by multibuffer extension */ /*ARGSUSED*/ -static void ServertimeBlockHandler(env, wt, LastSelectMask) -pointer env; -struct timeval **wt; -pointer LastSelectMask; +static void +ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) { XSyncValue delay; unsigned long timeout; @@ -2448,7 +2186,7 @@ pointer LastSelectMask; if (XSyncValueGreaterOrEqual(Now, *pnext_time)) { timeout = 0; - } + } else { Bool overflow; @@ -2464,10 +2202,8 @@ pointer LastSelectMask; *** Wakeup Handler */ /*ARGSUSED*/ -static void ServertimeWakeupHandler(env, rc, LastSelectMask) -pointer env; -int rc; -pointer LastSelectMask; +static void +ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask) { if (pnext_time) { @@ -2481,19 +2217,15 @@ pointer LastSelectMask; } static void -ServertimeQueryValue(pCounter, pValue_return) - pointer pCounter; - CARD64 *pValue_return; +ServertimeQueryValue(void *pCounter, CARD64 *pValue_return) { GetTime(); *pValue_return = Now; } static void -ServertimeBracketValues(pCounter, pbracket_less, pbracket_greater) - pointer pCounter; - CARD64 *pbracket_less; - CARD64 *pbracket_greater; +ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less, + CARD64 *pbracket_greater) { if (!pnext_time && pbracket_greater) { @@ -2607,9 +2339,7 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask) } static void -IdleTimeWakeupHandler (pointer env, - int rc, - pointer LastSelectMask) +IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask) { XSyncValue idle; @@ -2628,8 +2358,7 @@ IdleTimeWakeupHandler (pointer env, } static void -IdleTimeBracketValues (pointer pCounter, - CARD64 *pbracket_less, +IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less, CARD64 *pbracket_greater) { Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater); diff --git a/xorg-server/Xext/syncsrv.h b/xorg-server/Xext/syncsrv.h new file mode 100644 index 000000000..00e0bda50 --- /dev/null +++ b/xorg-server/Xext/syncsrv.h @@ -0,0 +1,176 @@ +/* + +Copyright 1991, 1993, 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. + +*/ + +/*********************************************************** +Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts, +and Olivetti Research Limited, Cambridge, England. + + 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 names of Digital or Olivetti +not be used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL THEY 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. + +******************************************************************/ + +#ifndef _SYNCSRV_H_ +#define _SYNCSRV_H_ + +#define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */ + +typedef struct _SyncCounter { + ClientPtr client; /* Owning client. 0 for system counters */ + XSyncCounter id; /* resource ID */ + CARD64 value; /* counter value */ + struct _SyncTriggerList *pTriglist; /* list of triggers */ + Bool beingDestroyed; /* in process of going away */ + struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */ +} SyncCounter; + +/* + * The System Counter interface + */ + +typedef enum { + XSyncCounterNeverChanges, + XSyncCounterNeverIncreases, + XSyncCounterNeverDecreases, + XSyncCounterUnrestricted +} SyncCounterType; + +typedef struct _SysCounterInfo { + char *name; + CARD64 resolution; + CARD64 bracket_greater; + CARD64 bracket_less; + SyncCounterType counterType; /* how can this counter change */ + void (*QueryValue)( + pointer /*pCounter*/, + CARD64 * /*freshvalue*/ +); + void (*BracketValues)( + pointer /*pCounter*/, + CARD64 * /*lessthan*/, + CARD64 * /*greaterthan*/ +); +} SysCounterInfo; + + + +typedef struct _SyncTrigger { + SyncCounter *pCounter; + CARD64 wait_value; /* wait value */ + unsigned int value_type; /* Absolute or Relative */ + unsigned int test_type; /* transition or Comparision type */ + CARD64 test_value; /* trigger event threshold value */ + Bool (*CheckTrigger)( + struct _SyncTrigger * /*pTrigger*/, + CARD64 /*newval*/ + ); + void (*TriggerFired)( + struct _SyncTrigger * /*pTrigger*/ + ); + void (*CounterDestroyed)( + struct _SyncTrigger * /*pTrigger*/ + ); +} SyncTrigger; + +typedef struct _SyncTriggerList { + SyncTrigger *pTrigger; + struct _SyncTriggerList *next; +} SyncTriggerList; + +typedef struct _SyncAlarmClientList { + ClientPtr client; + XID delete_id; + struct _SyncAlarmClientList *next; +} SyncAlarmClientList; + +typedef struct _SyncAlarm { + SyncTrigger trigger; + ClientPtr client; + XSyncAlarm alarm_id; + CARD64 delta; + int events; + int state; + SyncAlarmClientList *pEventClients; +} SyncAlarm; + +typedef struct { + ClientPtr client; + CARD32 delete_id; + int num_waitconditions; +} SyncAwaitHeader; + +typedef struct { + SyncTrigger trigger; + CARD64 event_threshold; + SyncAwaitHeader *pHeader; +} SyncAwait; + +typedef union { + SyncAwaitHeader header; + SyncAwait await; +} SyncAwaitUnion; + + +extern pointer SyncCreateSystemCounter( + char * /* name */, + CARD64 /* inital_value */, + CARD64 /* resolution */, + SyncCounterType /* change characterization */, + void (* /*QueryValue*/ ) ( + pointer /* pCounter */, + CARD64 * /* pValue_return */), /* XXX prototype */ + void (* /*BracketValues*/) ( + pointer /* pCounter */, + CARD64 * /* pbracket_less */, + CARD64 * /* pbracket_greater */) +); + +extern void SyncChangeCounter( + SyncCounter * /* pCounter*/, + CARD64 /* new_value */ +); + +extern void SyncDestroySystemCounter( + pointer pCounter +); +extern void InitServertime(void); + +#endif /* _SYNCSRV_H_ */ diff --git a/xorg-server/Xext/xace.c b/xorg-server/Xext/xace.c index 8a8f8c61d..bf0e98fb0 100644 --- a/xorg-server/Xext/xace.c +++ b/xorg-server/Xext/xace.c @@ -1,6 +1,6 @@ /************************************************************ -Author: Eamon Walsh <ewalsh@epoch.ncsc.mil> +Author: Eamon Walsh <ewalsh@tycho.nsa.gov> Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -29,7 +29,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "gcstruct.h" #include "xacestr.h" -CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = {0}; +#define XSERV_t +#define TRANS_SERVER +#include <X11/Xtrans/Xtrans.h> +#include "../os/osdep.h" + +_X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS] = {0}; /* Special-cased hook functions. Called by Xserver. */ @@ -95,114 +100,104 @@ int XaceHook(int hook, ...) switch (hook) { case XACE_RESOURCE_ACCESS: { - XaceResourceAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, XID), - va_arg(ap, RESTYPE), - va_arg(ap, pointer), - va_arg(ap, RESTYPE), - va_arg(ap, pointer), - va_arg(ap, Mask), - Success /* default allow */ - }; + XaceResourceAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.id = va_arg(ap, XID); + rec.rtype = va_arg(ap, RESTYPE); + rec.res = va_arg(ap, pointer); + rec.ptype = va_arg(ap, RESTYPE); + rec.parent = va_arg(ap, pointer); + rec.access_mode = va_arg(ap, Mask); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_DEVICE_ACCESS: { - XaceDeviceAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, DeviceIntPtr), - va_arg(ap, Mask), - Success /* default allow */ - }; + XaceDeviceAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.dev = va_arg(ap, DeviceIntPtr); + rec.access_mode = va_arg(ap, Mask); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_SEND_ACCESS: { - XaceSendAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, DeviceIntPtr), - va_arg(ap, WindowPtr), - va_arg(ap, xEventPtr), - va_arg(ap, int), - Success /* default allow */ - }; + XaceSendAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.dev = va_arg(ap, DeviceIntPtr); + rec.pWin = va_arg(ap, WindowPtr); + rec.events = va_arg(ap, xEventPtr); + rec.count = va_arg(ap, int); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_RECEIVE_ACCESS: { - XaceReceiveAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, WindowPtr), - va_arg(ap, xEventPtr), - va_arg(ap, int), - Success /* default allow */ - }; + XaceReceiveAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.pWin = va_arg(ap, WindowPtr); + rec.events = va_arg(ap, xEventPtr); + rec.count = va_arg(ap, int); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_CLIENT_ACCESS: { - XaceClientAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, ClientPtr), - va_arg(ap, Mask), - Success /* default allow */ - }; + XaceClientAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.target = va_arg(ap, ClientPtr); + rec.access_mode = va_arg(ap, Mask); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_EXT_ACCESS: { - XaceExtAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, ExtensionEntry*), - DixGetAttrAccess, - Success /* default allow */ - }; + XaceExtAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.ext = va_arg(ap, ExtensionEntry*); + rec.access_mode = DixGetAttrAccess; + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_SERVER_ACCESS: { - XaceServerAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, Mask), - Success /* default allow */ - }; + XaceServerAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.access_mode = va_arg(ap, Mask); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_SCREEN_ACCESS: case XACE_SCREENSAVER_ACCESS: { - XaceScreenAccessRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, ScreenPtr), - va_arg(ap, Mask), - Success /* default allow */ - }; + XaceScreenAccessRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.screen = va_arg(ap, ScreenPtr); + rec.access_mode = va_arg(ap, Mask); + rec.status = Success; /* default allow */ calldata = &rec; prv = &rec.status; break; } case XACE_AUTH_AVAIL: { - XaceAuthAvailRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, XID) - }; + XaceAuthAvailRec rec; + rec.client = va_arg(ap, ClientPtr); + rec.authId = va_arg(ap, XID); calldata = &rec; break; } case XACE_KEY_AVAIL: { - XaceKeyAvailRec rec = { - va_arg(ap, xEventPtr), - va_arg(ap, DeviceIntPtr), - va_arg(ap, int) - }; + XaceKeyAvailRec rec; + rec.event = va_arg(ap, xEventPtr); + rec.keybd = va_arg(ap, DeviceIntPtr); + rec.count = va_arg(ap, int); calldata = &rec; break; } @@ -239,15 +234,14 @@ int XaceHook(int hook, ...) * region of the window will be destroyed (overwritten) in pBuf. */ void -XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h, - format, pBuf) - ClientPtr client; - RegionPtr pVisibleRegion; - long widthBytesLine; - DrawablePtr pDraw; - int x, y, w, h; - unsigned int format; - char * pBuf; +XaceCensorImage( + ClientPtr client, + RegionPtr pVisibleRegion, + long widthBytesLine, + DrawablePtr pDraw, + int x, int y, int w, int h, + unsigned int format, + char *pBuf) { ScreenPtr pScreen; RegionRec imageRegion; /* region representing x,y,w,h */ @@ -280,7 +274,7 @@ XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h, /* convert region to list-of-rectangles for PolyFillRect */ - pRects = (xRectangle *)xalloc(nRects * sizeof(xRectangle)); + pRects = xalloc(nRects * sizeof(xRectangle)); if (!pRects) { failed = TRUE; @@ -339,3 +333,18 @@ XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h, REGION_UNINIT(pScreen, &imageRegion); REGION_UNINIT(pScreen, &censorRegion); } /* XaceCensorImage */ + +/* + * Xtrans wrappers for use by modules + */ +int XaceGetConnectionNumber(ClientPtr client) +{ + XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn; + return _XSERVTransGetConnectionNumber(ci); +} + +int XaceIsLocal(ClientPtr client) +{ + XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn; + return _XSERVTransIsLocal(ci); +} diff --git a/xorg-server/Xext/xace.h b/xorg-server/Xext/xace.h index bd69bca98..6029d87d8 100644 --- a/xorg-server/Xext/xace.h +++ b/xorg-server/Xext/xace.h @@ -1,6 +1,6 @@ /************************************************************ -Author: Eamon Walsh <ewalsh@epoch.ncsc.mil> +Author: Eamon Walsh <ewalsh@tycho.nsa.gov> Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -56,23 +56,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define XACE_AUDIT_END 16 #define XACE_NUM_HOOKS 17 -extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; +extern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS]; /* Entry point for hook functions. Called by Xserver. + * Required by libdbe and libextmod */ -extern int XaceHook( +extern _X_EXPORT int XaceHook( int /*hook*/, ... /*appropriate args for hook*/ ); /* Special-cased hook functions */ -extern int XaceHookDispatch(ClientPtr ptr, int major); -extern int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, - PropertyPtr *ppProp, Mask access_mode); -extern int XaceHookSelectionAccess(ClientPtr ptr, +extern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major); +extern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin, + PropertyPtr *ppProp, Mask access_mode); +extern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection **ppSel, Mask access_mode); -extern void XaceHookAuditEnd(ClientPtr ptr, int result); +extern _X_EXPORT void XaceHookAuditEnd(ClientPtr ptr, int result); /* Register a callback for a given hook. */ @@ -84,11 +85,15 @@ extern void XaceHookAuditEnd(ClientPtr ptr, int result); #define XaceDeleteCallback(hook,callback,data) \ DeleteCallback(XaceHooks+(hook), callback, data) +/* XTrans wrappers for use by security modules + */ +extern _X_EXPORT int XaceGetConnectionNumber(ClientPtr ptr); +extern _X_EXPORT int XaceIsLocal(ClientPtr ptr); /* From the original Security extension... */ -extern void XaceCensorImage( +extern _X_EXPORT void XaceCensorImage( ClientPtr client, RegionPtr pVisibleRegion, long widthBytesLine, diff --git a/xorg-server/Xext/xacestr.h b/xorg-server/Xext/xacestr.h index ba115a427..84216c8c0 100644 --- a/xorg-server/Xext/xacestr.h +++ b/xorg-server/Xext/xacestr.h @@ -1,6 +1,6 @@ /************************************************************ -Author: Eamon Walsh <ewalsh@epoch.ncsc.mil> +Author: Eamon Walsh <ewalsh@tycho.nsa.gov> Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that diff --git a/xorg-server/Xext/xcalibrate.c b/xorg-server/Xext/xcalibrate.c index 3e05e6ca2..f923c17a1 100644 --- a/xorg-server/Xext/xcalibrate.c +++ b/xorg-server/Xext/xcalibrate.c @@ -24,8 +24,6 @@ #include <kdrive-config.h> #endif -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/X.h> #include <X11/Xproto.h> diff --git a/xorg-server/Xext/xcmisc.c b/xorg-server/Xext/xcmisc.c index 1ee173bd6..f644cb458 100644 --- a/xorg-server/Xext/xcmisc.c +++ b/xorg-server/Xext/xcmisc.c @@ -26,8 +26,6 @@ from The Open Group. */ -#define NEED_EVENTS -#define NEED_REPLIES #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -39,7 +37,7 @@ from The Open Group. #include "dixstruct.h" #include "extnsionst.h" #include "swaprep.h" -#include <X11/extensions/xcmiscstr.h> +#include <X11/extensions/xcmiscproto.h> #include "modinit.h" #if HAVE_STDINT_H @@ -66,8 +64,7 @@ XCMiscExtensionInit(INITARGS) } static int -ProcXCMiscGetVersion(client) - ClientPtr client; +ProcXCMiscGetVersion(ClientPtr client) { xXCMiscGetVersionReply rep; int n; @@ -88,8 +85,7 @@ ProcXCMiscGetVersion(client) } static int -ProcXCMiscGetXIDRange(client) - ClientPtr client; +ProcXCMiscGetXIDRange(ClientPtr client) { xXCMiscGetXIDRangeReply rep; int n; @@ -112,8 +108,7 @@ ProcXCMiscGetXIDRange(client) } static int -ProcXCMiscGetXIDList(client) - ClientPtr client; +ProcXCMiscGetXIDList(ClientPtr client) { REQUEST(xXCMiscGetXIDListReq); xXCMiscGetXIDListReply rep; @@ -152,8 +147,7 @@ ProcXCMiscGetXIDList(client) } static int -ProcXCMiscDispatch (client) - ClientPtr client; +ProcXCMiscDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) @@ -170,8 +164,7 @@ ProcXCMiscDispatch (client) } static int -SProcXCMiscGetVersion(client) - ClientPtr client; +SProcXCMiscGetVersion(ClientPtr client) { int n; REQUEST(xXCMiscGetVersionReq); @@ -184,8 +177,7 @@ SProcXCMiscGetVersion(client) } static int -SProcXCMiscGetXIDRange(client) - ClientPtr client; +SProcXCMiscGetXIDRange(ClientPtr client) { int n; REQUEST(xReq); @@ -195,8 +187,7 @@ SProcXCMiscGetXIDRange(client) } static int -SProcXCMiscGetXIDList(client) - ClientPtr client; +SProcXCMiscGetXIDList(ClientPtr client) { int n; REQUEST(xXCMiscGetXIDListReq); @@ -207,8 +198,7 @@ SProcXCMiscGetXIDList(client) } static int -SProcXCMiscDispatch (client) - ClientPtr client; +SProcXCMiscDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c index dabbdd6e0..aeea23313 100644 --- a/xorg-server/Xext/xf86bigfont.c +++ b/xorg-server/Xext/xf86bigfont.c @@ -72,8 +72,7 @@ #include "dixfontstr.h" #include "extnsionst.h" -#define _XF86BIGFONT_SERVER_ -#include <X11/extensions/xf86bigfstr.h> +#include <X11/extensions/xf86bigfproto.h> static void XF86BigfontResetProc( ExtensionEntry * /* extEntry */ @@ -125,7 +124,7 @@ CheckForShmSyscall(void) if (shmid != -1) { /* Successful allocation - clean up */ - shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL); + shmctl(shmid, IPC_RMID, NULL); } else { @@ -229,7 +228,7 @@ shmalloc( if (size < 3500) return (ShmDescPtr) NULL; - pDesc = (ShmDescRec *) xalloc(sizeof(ShmDescRec)); + pDesc = xalloc(sizeof(ShmDescRec)); if (!pDesc) return (ShmDescPtr) NULL; @@ -427,15 +426,15 @@ ProcXF86BigfontQueryFont( } #endif client->errorValue = stuff->id; /* EITHER font or gc */ - pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - DixGetAttrAccess); + dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, + client, DixGetAttrAccess); if (!pFont) { - GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, - DixGetAttrAccess); - if (!pGC) { - client->errorValue = stuff->id; + GC *pGC; + dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, + client, DixGetAttrAccess); + if (!pGC) return BadFont; /* procotol spec says only error is BadFont */ - } + pFont = pGC->font; } @@ -473,8 +472,7 @@ ProcXF86BigfontQueryFont( shmid = pDesc->shmid; } else { #endif - pCI = (xCharInfo *) - xalloc(nCharInfos * sizeof(xCharInfo)); + pCI = xalloc(nCharInfos * sizeof(xCharInfo)); if (!pCI) return BadAlloc; #ifdef HAS_SHM @@ -536,8 +534,7 @@ ProcXF86BigfontQueryFont( if (hashModulus > nCharInfos+1) hashModulus = nCharInfos+1; - tmp = (CARD16*) - xalloc((4*nCharInfos+1) * sizeof(CARD16)); + tmp = xalloc((4*nCharInfos+1) * sizeof(CARD16)); if (!tmp) { if (!pDesc) xfree(pCI); return BadAlloc; @@ -621,8 +618,7 @@ ProcXF86BigfontQueryFont( ? nUniqCharInfos * sizeof(xCharInfo) + (nCharInfos+1)/2 * 2 * sizeof(CARD16) : 0); - xXF86BigfontQueryFontReply* reply = - (xXF86BigfontQueryFontReply *) xalloc(rlength); + xXF86BigfontQueryFontReply* reply = xalloc(rlength); char* p; if (!reply) { if (nCharInfos > 0) { @@ -632,7 +628,7 @@ ProcXF86BigfontQueryFont( return BadAlloc; } reply->type = X_Reply; - reply->length = (rlength - sizeof(xGenericReply)) >> 2; + reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->sequenceNumber = client->sequence; reply->minBounds = pFont->info.ink_minbounds; reply->maxBounds = pFont->info.ink_maxbounds; diff --git a/xorg-server/Xext/xres.c b/xorg-server/Xext/xres.c index bdc534c91..9dd08b113 100644 --- a/xorg-server/Xext/xres.c +++ b/xorg-server/Xext/xres.c @@ -2,8 +2,6 @@ Copyright (c) 2002 XFree86 Inc */ -#define NEED_EVENTS -#define NEED_REPLIES #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -77,7 +75,7 @@ ProcXResQueryClients (ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num_clients = num_clients; - rep.length = rep.num_clients * sz_xXResClient >> 2; + rep.length = bytes_to_int32(rep.num_clients * sz_xXResClient); if (client->swapped) { int n; swaps (&rep.sequenceNumber, n); @@ -146,7 +144,7 @@ ProcXResQueryClientResources (ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num_types = num_types; - rep.length = rep.num_types * sz_xXResType >> 2; + rep.length = bytes_to_int32(rep.num_types * sz_xXResType); if (client->swapped) { int n; swaps (&rep.sequenceNumber, n); diff --git a/xorg-server/Xext/xselinux.c b/xorg-server/Xext/xselinux.c index 3124eb9b7..b9b16b6ce 100644 --- a/xorg-server/Xext/xselinux.c +++ b/xorg-server/Xext/xselinux.c @@ -1,6 +1,6 @@ /************************************************************ -Author: Eamon Walsh <ewalsh@epoch.ncsc.mil> +Author: Eamon Walsh <ewalsh@tycho.nsa.gov> Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -49,10 +49,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "scrnintstr.h" #include "selection.h" #include "xacestr.h" +#define _XSELINUX_NEED_FLASK #include "xselinux.h" -#define XSERV_t -#define TRANS_SERVER -#include <X11/Xtrans/Xtrans.h> #include "../os/osdep.h" #include "modinit.h" @@ -136,32 +134,6 @@ static unsigned numKnownEvents; static SELinuxAtomRec *knownAtoms; static unsigned numKnownAtoms; -/* dynamically allocated security classes and permissions */ -static struct security_class_mapping map[] = { - { "x_drawable", { "read", "write", "destroy", "create", "getattr", "setattr", "list_property", "get_property", "set_property", "", "", "list_child", "add_child", "remove_child", "hide", "show", "blend", "override", "", "", "", "", "send", "receive", "", "manage", NULL }}, - { "x_screen", { "", "", "", "", "getattr", "setattr", "saver_getattr", "saver_setattr", "", "", "", "", "", "", "hide_cursor", "show_cursor", "saver_hide", "saver_show", NULL }}, - { "x_gc", { "", "", "destroy", "create", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }}, - { "x_font", { "", "", "destroy", "create", "getattr", "", "", "", "", "", "", "", "add_glyph", "remove_glyph", "", "", "", "", "", "", "", "", "", "", "use", NULL }}, - { "x_colormap", { "read", "write", "destroy", "create", "getattr", "", "", "", "", "", "", "", "add_color", "remove_color", "", "", "", "", "", "", "install", "uninstall", "", "", "use", NULL }}, - { "x_property", { "read", "write", "destroy", "create", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "write", NULL }}, - { "x_selection", { "read", "", "", "setattr", "getattr", "setattr", NULL }}, - { "x_cursor", { "read", "write", "destroy", "create", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }}, - { "x_client", { "", "", "destroy", "", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "manage", NULL }}, - { "x_device", { "read", "write", "", "", "getattr", "setattr", "", "", "", "getfocus", "setfocus", "", "", "", "", "", "", "grab", "freeze", "force_cursor", "", "", "", "", "use", "manage", "", "bell", NULL }}, - { "x_server", { "record", "", "", "", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "grab", "", "", "", "", "", "", "", "manage", "debug", NULL }}, - { "x_extension", { "", "", "", "", "query", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }}, - { "x_event", { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "send", "receive", NULL }}, - { "x_synthetic_event", { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "send", "receive", NULL }}, - { "x_resource", { "read", "write", "write", "write", "read", "write", "read", "read", "write", "read", "write", "read", "write", "write", "write", "read", "read", "write", "write", "write", "write", "write", "write", "read", "read", "write", "read", "write", NULL }}, - { NULL } -}; - -/* x_resource "read" bits from the list above */ -#define SELinuxReadMask (DixReadAccess|DixGetAttrAccess|DixListPropAccess| \ - DixGetPropAccess|DixGetFocusAccess|DixListAccess| \ - DixShowAccess|DixBlendAccess|DixReceiveAccess| \ - DixUseAccess|DixDebugAccess) - /* forward declarations */ static void SELinuxScreen(CallbackListPtr *, pointer, pointer); @@ -460,8 +432,7 @@ SELinuxDoCheck(SELinuxSubjectRec *subj, SELinuxObjectRec *obj, static void SELinuxLabelClient(ClientPtr client) { - XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn; - int fd = _XSERVTransGetConnectionNumber(ci); + int fd = XaceGetConnectionNumber(client); SELinuxSubjectRec *subj; SELinuxObjectRec *obj; security_context_t ctx; @@ -479,7 +450,7 @@ SELinuxLabelClient(ClientPtr client) } /* For local clients, try and determine the executable name */ - if (_XSERVTransIsLocal(ci)) { + if (XaceIsLocal(client)) { struct ucred creds; socklen_t len = sizeof(creds); char path[PATH_MAX + 1]; @@ -613,7 +584,8 @@ SELinuxAudit(void *auditdata, { SELinuxAuditRec *audit = auditdata; ClientPtr client = audit->client; - char idNum[16], *propertyName, *selectionName; + char idNum[16]; + const char *propertyName, *selectionName; int major = -1, minor = -1; if (client) { @@ -941,6 +913,10 @@ SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata) security_id_t tsid; int rc; + /* Don't care about the new content check */ + if (rec->access_mode & DixPostAccess) + return; + subj = dixLookupPrivate(&rec->client->devPrivates, subjectKey); obj = dixLookupPrivate(&pProp->devPrivates, objectKey); @@ -1307,7 +1283,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid) } rep.type = X_Reply; - rep.length = (len + 3) >> 2; + rep.length = bytes_to_int32(len); rep.sequenceNumber = client->sequence; rep.context_len = len; @@ -1342,14 +1318,6 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) return BadAlloc; } - if (offset == CTX_DEV) { - /* Device create context currently requires manage permission */ - rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); - if (rc != Success) - goto out; - privPtr = &serverClient->devPrivates; - } - ptr = dixLookupPrivate(privPtr, subjectKey); pSid = (security_id_t *)(ptr + offset); sidput(*pSid); @@ -1361,7 +1329,7 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) avc_context_to_sid_raw(ctx, pSid) < 0) rc = BadValue; } -out: + xfree(ctx); return rc; } @@ -1534,8 +1502,8 @@ SELinuxPopulateItem(SELinuxListItemRec *i, PrivateRec **privPtr, CARD32 id, return BadValue; i->id = id; - i->octx_len = (strlen(i->octx) + 4) >> 2; - i->dctx_len = (strlen(i->dctx) + 4) >> 2; + i->octx_len = bytes_to_int32(strlen(i->octx) + 1); + i->dctx_len = bytes_to_int32(strlen(i->dctx) + 1); *size += i->octx_len + i->dctx_len + 3; return Success; diff --git a/xorg-server/Xext/xselinux.h b/xorg-server/Xext/xselinux.h index 7c3ffdcb7..e99f05b09 100644 --- a/xorg-server/Xext/xselinux.h +++ b/xorg-server/Xext/xselinux.h @@ -1,6 +1,6 @@ /************************************************************ -Author: Eamon Walsh <ewalsh@epoch.ncsc.mil> +Author: Eamon Walsh <ewalsh@tycho.nsa.gov> Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -139,6 +139,7 @@ typedef struct { } SELinuxListItemsReply; +#ifdef _XSELINUX_NEED_FLASK /* Private Flask definitions */ #define SECCLASS_X_DRAWABLE 1 #define SECCLASS_X_SCREEN 2 @@ -156,4 +157,395 @@ typedef struct { #define SECCLASS_X_FAKEEVENT 14 #define SECCLASS_X_RESOURCE 15 +/* Mapping from DixAccess bits to Flask permissions */ +static struct security_class_mapping map[] = { + { "x_drawable", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "list_property", /* DixListPropAccess */ + "get_property", /* DixGetPropAccess */ + "set_property", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "list_child", /* DixListAccess */ + "add_child", /* DixAddAccess */ + "remove_child", /* DixRemoveAccess */ + "hide", /* DixHideAccess */ + "show", /* DixShowAccess */ + "blend", /* DixBlendAccess */ + "override", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "send", /* DixSendAccess */ + "receive", /* DixReceiveAccess */ + "", /* DixUseAccess */ + "manage", /* DixManageAccess */ + NULL }}, + { "x_screen", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "saver_getattr", /* DixListPropAccess */ + "saver_setattr", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "hide_cursor", /* DixHideAccess */ + "show_cursor", /* DixShowAccess */ + "saver_hide", /* DixBlendAccess */ + "saver_show", /* DixGrabAccess */ + NULL }}, + { "x_gc", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + NULL }}, + { "x_font", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "add_glyph", /* DixAddAccess */ + "remove_glyph", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + NULL }}, + { "x_colormap", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "add_color", /* DixAddAccess */ + "remove_color", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "install", /* DixInstallAccess */ + "uninstall", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + NULL }}, + { "x_property", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "write", /* DixBlendAccess */ + NULL }}, + { "x_selection", + { "read", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "setattr", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + NULL }}, + { "x_cursor", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + NULL }}, + { "x_client", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "", /* DixUseAccess */ + "manage", /* DixManageAccess */ + NULL }}, + { "x_device", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "destroy", /* DixDestroyAccess */ + "create", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "list_property", /* DixListPropAccess */ + "get_property", /* DixGetPropAccess */ + "set_property", /* DixSetPropAccess */ + "getfocus", /* DixGetFocusAccess */ + "setfocus", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "add", /* DixAddAccess */ + "remove", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "grab", /* DixGrabAccess */ + "freeze", /* DixFreezeAccess */ + "force_cursor", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + "manage", /* DixManageAccess */ + "", /* DixDebugAccess */ + "bell", /* DixBellAccess */ + NULL }}, + { "x_server", + { "record", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "getattr", /* DixGetAttrAccess */ + "setattr", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "grab", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "", /* DixUseAccess */ + "manage", /* DixManageAccess */ + "debug", /* DixDebugAccess */ + NULL }}, + { "x_extension", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "query", /* DixGetAttrAccess */ + "", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "", /* DixSendAccess */ + "", /* DixReceiveAccess */ + "use", /* DixUseAccess */ + NULL }}, + { "x_event", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "", /* DixGetAttrAccess */ + "", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "send", /* DixSendAccess */ + "receive", /* DixReceiveAccess */ + NULL }}, + { "x_synthetic_event", + { "", /* DixReadAccess */ + "", /* DixWriteAccess */ + "", /* DixDestroyAccess */ + "", /* DixCreateAccess */ + "", /* DixGetAttrAccess */ + "", /* DixSetAttrAccess */ + "", /* DixListPropAccess */ + "", /* DixGetPropAccess */ + "", /* DixSetPropAccess */ + "", /* DixGetFocusAccess */ + "", /* DixSetFocusAccess */ + "", /* DixListAccess */ + "", /* DixAddAccess */ + "", /* DixRemoveAccess */ + "", /* DixHideAccess */ + "", /* DixShowAccess */ + "", /* DixBlendAccess */ + "", /* DixGrabAccess */ + "", /* DixFreezeAccess */ + "", /* DixForceAccess */ + "", /* DixInstallAccess */ + "", /* DixUninstallAccess */ + "send", /* DixSendAccess */ + "receive", /* DixReceiveAccess */ + NULL }}, + { "x_resource", + { "read", /* DixReadAccess */ + "write", /* DixWriteAccess */ + "write", /* DixDestroyAccess */ + "write", /* DixCreateAccess */ + "read", /* DixGetAttrAccess */ + "write", /* DixSetAttrAccess */ + "read", /* DixListPropAccess */ + "read", /* DixGetPropAccess */ + "write", /* DixSetPropAccess */ + "read", /* DixGetFocusAccess */ + "write", /* DixSetFocusAccess */ + "read", /* DixListAccess */ + "write", /* DixAddAccess */ + "write", /* DixRemoveAccess */ + "write", /* DixHideAccess */ + "read", /* DixShowAccess */ + "read", /* DixBlendAccess */ + "write", /* DixGrabAccess */ + "write", /* DixFreezeAccess */ + "write", /* DixForceAccess */ + "write", /* DixInstallAccess */ + "write", /* DixUninstallAccess */ + "write", /* DixSendAccess */ + "read", /* DixReceiveAccess */ + "read", /* DixUseAccess */ + "write", /* DixManageAccess */ + "read", /* DixDebugAccess */ + "write", /* DixBellAccess */ + NULL }}, + { NULL } +}; + +/* x_resource "read" bits from the list above */ +#define SELinuxReadMask (DixReadAccess|DixGetAttrAccess|DixListPropAccess| \ + DixGetPropAccess|DixGetFocusAccess|DixListAccess| \ + DixShowAccess|DixBlendAccess|DixReceiveAccess| \ + DixUseAccess|DixDebugAccess) + +#endif /* _XSELINUX_NEED_FLASK */ #endif /* _XSELINUX_H */ diff --git a/xorg-server/Xext/xtest.c b/xorg-server/Xext/xtest.c index e5ab7b451..0400062d8 100644 --- a/xorg-server/Xext/xtest.c +++ b/xorg-server/Xext/xtest.c @@ -31,8 +31,8 @@ #endif #include <X11/X.h> -#define NEED_EVENTS #include <X11/Xproto.h> +#include <X11/Xatom.h> #include "misc.h" #include "os.h" #include "dixstruct.h" @@ -43,16 +43,40 @@ #include "dixevents.h" #include "sleepuntil.h" #include "mi.h" -#define _XTEST_SERVER_ -#include <X11/extensions/XTest.h> -#include <X11/extensions/xteststr.h> +#include "xkbsrv.h" +#include "xkbstr.h" +#include <X11/extensions/xtestproto.h> #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> +#include "exglobals.h" +#include "mipointer.h" +#include "xserver-properties.h" +#include "exevents.h" #include "modinit.h" extern int DeviceValuator; -extern int DeviceMotionNotify; + +/* XTest events are sent during request processing and may be interruped by + * a SIGIO. We need a separate event list to avoid events overwriting each + * other's memory */ +static EventListPtr xtest_evlist; + +/* Used to store if a device is an XTest Virtual device */ +static int XTestDevicePrivateKeyIndex; +DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex; + +/** + * xtestpointer + * is the virtual pointer for XTest. It is the first slave + * device of the VCP. + * xtestkeyboard + * is the virtual keyboard for XTest. It is the first slave + * device of the VCK + * + * Neither of these devices can be deleted. + */ +DeviceIntPtr xtestpointer, xtestkeyboard; #ifdef PANORAMIX #include "panoramiX.h" @@ -81,11 +105,12 @@ XTestExtensionInit(INITARGS) AddExtension(XTestExtensionName, 0, 0, ProcXTestDispatch, SProcXTestDispatch, NULL, StandardMinorOpcode); + + xtest_evlist = InitEventList(GetMaximumEventsNum()); } static int -ProcXTestGetVersion(client) - ClientPtr client; +ProcXTestGetVersion(ClientPtr client) { xXTestGetVersionReply rep; int n; @@ -105,8 +130,7 @@ ProcXTestGetVersion(client) } static int -ProcXTestCompareCursor(client) - ClientPtr client; +ProcXTestCompareCursor(ClientPtr client) { REQUEST(xXTestCompareCursorReq); xXTestCompareCursorReply rep; @@ -144,8 +168,7 @@ ProcXTestCompareCursor(client) } static int -ProcXTestFakeInput(client) - ClientPtr client; +ProcXTestFakeInput(ClientPtr client) { REQUEST(xXTestFakeInputReq); int nev, n, type, rc; @@ -157,7 +180,6 @@ ProcXTestFakeInput(client) int valuators[MAX_VALUATORS] = {0}; int numValuators = 0; int firstValuator = 0; - EventListPtr events; int nevents = 0; int i; int base = 0; @@ -189,11 +211,34 @@ ProcXTestFakeInput(client) switch (type) { case XI_DeviceKeyPress: case XI_DeviceKeyRelease: + if (!dev->key) + { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; case XI_DeviceButtonPress: case XI_DeviceButtonRelease: + if (!dev->button) + { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; case XI_DeviceMotionNotify: + if (!dev->valuator) + { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; case XI_ProximityIn: case XI_ProximityOut: + if (!dev->proximity) + { + client->errorValue = ev->u.u.type; + return BadValue; + } break; default: client->errorValue = ev->u.u.type; @@ -221,7 +266,7 @@ ProcXTestFakeInput(client) flags |= POINTER_ABSOLUTE; } - if (nev == 1 && type == XI_DeviceMotionNotify && !dev->valuator) + if (nev > 1 && !dev->valuator) { client->errorValue = dv->first_valuator; return BadValue; @@ -296,8 +341,7 @@ ProcXTestFakeInput(client) return BadValue; } - if (dev->u.lastSlave) - dev = dev->u.lastSlave; + dev = GetXTestDevice(dev); } /* If the event has a time set, wait for it to pass */ @@ -334,14 +378,20 @@ ProcXTestFakeInput(client) { case KeyPress: case KeyRelease: - if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || - ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) + if (!dev->key) + return BadDevice; + + if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || + ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) { client->errorValue = ev->u.u.detail; return BadValue; } break; case MotionNotify: + if (!dev->valuator) + return BadDevice; + /* broken lib, XI events have root uninitialized */ if (extension || ev->u.keyButtonPointer.root == None) root = GetCurrentRootWindow(dev); @@ -368,12 +418,9 @@ ProcXTestFakeInput(client) break; case ButtonPress: case ButtonRelease: - if (!extension) - { - dev = PickPointer(client); - if (dev->u.lastSlave) - dev = dev->u.lastSlave; - } + if (!dev->button) + return BadDevice; + if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { client->errorValue = ev->u.u.detail; @@ -384,35 +431,32 @@ ProcXTestFakeInput(client) if (screenIsSaved == SCREEN_SAVER_ON) dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); - OsBlockSignals(); - GetEventList(&events); switch(type) { case MotionNotify: - nevents = GetPointerEvents(events, dev, type, 0, flags, + nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, firstValuator, numValuators, valuators); break; case ButtonPress: case ButtonRelease: - nevents = GetPointerEvents(events, dev, type, ev->u.u.detail, + nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail, flags, firstValuator, numValuators, valuators); break; case KeyPress: case KeyRelease: - nevents = GetKeyboardEvents(events, dev, type, ev->u.u.detail); + nevents = GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail); break; } for (i = 0; i < nevents; i++) - mieqEnqueue(dev, (events+i)->event); - OsReleaseSignals(); + mieqProcessDeviceEvent(dev, (InternalEvent*)(xtest_evlist+i)->event, NULL); + miPointerUpdateSprite(dev); return client->noClientException; } static int -ProcXTestGrabControl(client) - ClientPtr client; +ProcXTestGrabControl(ClientPtr client) { REQUEST(xXTestGrabControlReq); @@ -430,8 +474,7 @@ ProcXTestGrabControl(client) } static int -ProcXTestDispatch (client) - ClientPtr client; +ProcXTestDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) @@ -450,8 +493,7 @@ ProcXTestDispatch (client) } static int -SProcXTestGetVersion(client) - ClientPtr client; +SProcXTestGetVersion(ClientPtr client) { int n; REQUEST(xXTestGetVersionReq); @@ -463,8 +505,7 @@ SProcXTestGetVersion(client) } static int -SProcXTestCompareCursor(client) - ClientPtr client; +SProcXTestCompareCursor(ClientPtr client) { int n; REQUEST(xXTestCompareCursorReq); @@ -477,9 +518,7 @@ SProcXTestCompareCursor(client) } static int -XTestSwapFakeInput(client, req) - ClientPtr client; - xReq *req; +XTestSwapFakeInput(ClientPtr client, xReq *req) { int nev; xEvent *ev; @@ -503,8 +542,7 @@ XTestSwapFakeInput(client, req) } static int -SProcXTestFakeInput(client) - ClientPtr client; +SProcXTestFakeInput(ClientPtr client) { int n; REQUEST(xReq); @@ -517,8 +555,7 @@ SProcXTestFakeInput(client) } static int -SProcXTestGrabControl(client) - ClientPtr client; +SProcXTestGrabControl(ClientPtr client) { int n; REQUEST(xXTestGrabControlReq); @@ -529,8 +566,7 @@ SProcXTestGrabControl(client) } static int -SProcXTestDispatch (client) - ClientPtr client; +SProcXTestDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) @@ -547,3 +583,126 @@ SProcXTestDispatch (client) return BadRequest; } } + +/** + * Allocate an virtual slave device for xtest events, this + * is a slave device to inputInfo master devices + */ +void InitXTestDevices(void) +{ + if(AllocXTestDevice(serverClient, "Virtual core", + &xtestpointer, &xtestkeyboard, + inputInfo.pointer, inputInfo.keyboard) != Success) + FatalError("Failed to allocate XTest devices"); + + if (ActivateDevice(xtestpointer, TRUE) != Success || + ActivateDevice(xtestkeyboard, TRUE) != Success) + FatalError("Failed to activate XTest core devices."); + if (!EnableDevice(xtestpointer, TRUE) || + !EnableDevice(xtestkeyboard, TRUE)) + FatalError("Failed to enable XTest core devices."); + + AttachDevice(NULL, xtestpointer, inputInfo.pointer); + AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard); +} + +/** + * Don't allow changing the XTest property. + */ +static int +DeviceSetXTestProperty(DeviceIntPtr dev, Atom property, + XIPropertyValuePtr prop, BOOL checkonly) +{ + if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE)) + return BadAccess; + + return Success; +} + +/** + * Allocate a device pair that is initialised as a slave + * device with properties that identify the devices as belonging + * to XTest subsystem. + * This only creates the pair, Activate/Enable Device + * still need to be called. + */ +int AllocXTestDevice (ClientPtr client, char* name, + DeviceIntPtr* ptr, DeviceIntPtr* keybd, + DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) +{ + int retval; + int len = strlen(name); + char *xtestname = xcalloc(len + 7, 1 ); + char dummy = 1; + + strncpy( xtestname, name, len); + strncat( xtestname, " XTEST", 6 ); + + retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); + if ( retval == Success ){ + dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)master_ptr->id); + dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)master_keybd->id); + } + + xfree( xtestname ); + + XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), + XA_INTEGER, 8, PropModeReplace, 1, &dummy, + FALSE); + XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); + XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); + XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), + XA_INTEGER, 8, PropModeReplace, 1, &dummy, + FALSE); + XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); + XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); + + return retval; +} + +/** + * If master is NULL, return TRUE if the given device is an xtest device or + * FALSE otherwise. + * If master is not NULL, return TRUE if the given device is this master's + * xtest device. + */ +BOOL +IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master) +{ + int is_XTest = FALSE; + int mid; + void *tmp; /* shut up, gcc! */ + + if (IsMaster(dev)) + return is_XTest; + + tmp = dixLookupPrivate(&dev->devPrivates, XTestDevicePrivateKey); + mid = (int)tmp; + + /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest + * device */ + if ((!master && mid) || + (master && mid == master->id)) + is_XTest = TRUE; + + return is_XTest; +} + +/** + * @return The X Test virtual device for the given master. + */ +DeviceIntPtr +GetXTestDevice(DeviceIntPtr master) +{ + DeviceIntPtr it; + + for (it = inputInfo.devices; it; it = it->next) + { + if (IsXTestDevice(it, master)) + return it; + } + + /* This only happens if master is a slave device. don't do that */ + return NULL; +} + diff --git a/xorg-server/Xext/xvdisp.c b/xorg-server/Xext/xvdisp.c index de0128e14..04cd11a3f 100644 --- a/xorg-server/Xext/xvdisp.c +++ b/xorg-server/Xext/xvdisp.c @@ -42,8 +42,7 @@ SOFTWARE. #include <X11/extensions/Xvproto.h> #include "xvdix.h" #ifdef MITSHM -#define _XSHM_SERVER_ -#include <X11/extensions/shmstr.h> +#include <X11/extensions/shmproto.h> #endif #include "xvdisp.h" @@ -423,12 +422,12 @@ ProcXvQueryAdaptors(ClientPtr client) pa = pxvs->pAdaptors; while (na--) { - totalSize += (strlen(pa->name) + 3) & ~3; + totalSize += pad_to_int32(strlen(pa->name)); totalSize += pa->nFormats * sz_xvFormat; pa++; } - rep.length = totalSize >> 2; + rep.length = bytes_to_int32(totalSize); _WriteQueryAdaptorsReply(client, &rep); @@ -479,11 +478,7 @@ ProcXvQueryEncodings(ClientPtr client) REQUEST(xvQueryEncodingsReq); REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -502,11 +497,11 @@ ProcXvQueryEncodings(ClientPtr client) totalSize = ne * sz_xvEncodingInfo; while (ne--) { - totalSize += (strlen(pe->name) + 3) & ~3; + totalSize += pad_to_int32(strlen(pe->name)); pe++; } - rep.length = totalSize >> 2; + rep.length = bytes_to_int32(totalSize); _WriteQueryEncodingsReply(client, &rep); @@ -540,12 +535,7 @@ ProcXvPutVideo(ClientPtr client) REQUEST_SIZE_MATCH(xvPutVideoReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -560,17 +550,15 @@ ProcXvPutVideo(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; } - return XVCALL(diPutVideo)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int @@ -585,12 +573,7 @@ ProcXvPutStill(ClientPtr client) REQUEST_SIZE_MATCH(xvPutStillReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -605,17 +588,15 @@ ProcXvPutStill(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; } - return XVCALL(diPutStill)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int @@ -630,12 +611,7 @@ ProcXvGetVideo(ClientPtr client) REQUEST_SIZE_MATCH(xvGetVideoReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -650,17 +626,15 @@ ProcXvGetVideo(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; } - return XVCALL(diGetVideo)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int @@ -675,12 +649,7 @@ ProcXvGetStill(ClientPtr client) REQUEST_SIZE_MATCH(xvGetStillReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -695,17 +664,15 @@ ProcXvGetStill(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; } - return XVCALL(diGetStill)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int @@ -720,7 +687,7 @@ ProcXvSelectVideoNotify(ClientPtr client) if (rc != Success) return rc; - return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff); + return XvdiSelectVideoNotify(client, pDraw, stuff->onoff); } static int @@ -731,11 +698,7 @@ ProcXvSelectPortNotify(ClientPtr client) REQUEST(xvSelectPortNotifyReq); REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -743,7 +706,7 @@ ProcXvSelectPortNotify(ClientPtr client) return (status); } - return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff); + return XvdiSelectPortNotify(client, pPort, stuff->onoff); } static int @@ -755,11 +718,7 @@ ProcXvGrabPort(ClientPtr client) REQUEST(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -767,7 +726,7 @@ ProcXvGrabPort(ClientPtr client) return (status); } - status = XVCALL(diGrabPort)(client, pPort, stuff->time, &result); + status = XvdiGrabPort(client, pPort, stuff->time, &result); if (status != Success) { @@ -792,11 +751,7 @@ ProcXvUngrabPort(ClientPtr client) REQUEST(xvGrabPortReq); REQUEST_SIZE_MATCH(xvGrabPortReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -804,7 +759,7 @@ ProcXvUngrabPort(ClientPtr client) return (status); } - return XVCALL(diUngrabPort)(client, pPort, stuff->time); + return XvdiUngrabPort(client, pPort, stuff->time); } static int @@ -816,11 +771,7 @@ ProcXvStopVideo(ClientPtr client) REQUEST(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -832,7 +783,7 @@ ProcXvStopVideo(ClientPtr client) if (rc != Success) return rc; - return XVCALL(diStopVideo)(client, pPort, pDraw); + return XvdiStopVideo(client, pPort, pDraw); } static int @@ -843,11 +794,7 @@ ProcXvSetPortAttribute(ClientPtr client) REQUEST(xvSetPortAttributeReq); REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -861,8 +808,7 @@ ProcXvSetPortAttribute(ClientPtr client) return(BadAtom); } - status = XVCALL(diSetPortAttribute)(client, pPort, - stuff->attribute, stuff->value); + status = XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value); if (status == BadMatch) client->errorValue = stuff->attribute; @@ -882,11 +828,7 @@ ProcXvGetPortAttribute(ClientPtr client) REQUEST(xvGetPortAttributeReq); REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -900,7 +842,7 @@ ProcXvGetPortAttribute(ClientPtr client) return(BadAtom); } - status = XVCALL(diGetPortAttribute)(client, pPort, stuff->attribute, &value); + status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value); if (status != Success) { client->errorValue = stuff->attribute; @@ -927,11 +869,7 @@ ProcXvQueryBestSize(ClientPtr client) REQUEST(xvQueryBestSizeReq); REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -968,11 +906,7 @@ ProcXvQueryPortAttributes(ClientPtr client) REQUEST(xvQueryPortAttributesReq); REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -988,7 +922,7 @@ ProcXvQueryPortAttributes(ClientPtr client) for(i = 0, pAtt = pPort->pAdaptor->pAttributes; i < pPort->pAdaptor->nAttributes; i++, pAtt++) { - rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L; + rep.text_size += pad_to_int32(strlen(pAtt->name) + 1); } rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo) @@ -1004,7 +938,7 @@ ProcXvQueryPortAttributes(ClientPtr client) Info.flags = pAtt->flags; Info.min = pAtt->min_value; Info.max = pAtt->max_value; - Info.size = (size + 3) & ~3L; + Info.size = pad_to_int32(size); _WriteAttributeInfo(client, &Info); @@ -1028,12 +962,7 @@ ProcXvPutImage(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutImageReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -1048,7 +977,7 @@ ProcXvPutImage(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; @@ -1069,7 +998,7 @@ ProcXvPutImage(ClientPtr client) size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage, &width, &height, NULL, NULL); size += sizeof(xvPutImageReq); - size = (size + 3) >> 2; + size = bytes_to_int32(size); if((width < stuff->width) || (height < stuff->height)) return BadValue; @@ -1077,13 +1006,11 @@ ProcXvPutImage(ClientPtr client) if(client->req_len < size) return BadLength; - return XVCALL(diPutImage)(client, pDraw, pPort, pGC, - stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, - pImage, (unsigned char*)(&stuff[1]), FALSE, - stuff->width, stuff->height); + return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h, pImage, + (unsigned char*)(&stuff[1]), FALSE, + stuff->width, stuff->height); } #ifdef MITSHM @@ -1116,12 +1043,7 @@ ProcXvShmPutImage(ClientPtr client) REQUEST_SIZE_MATCH(xvShmPutImageReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if ((status = _AllocatePort(stuff->port, pPort)) != Success) { @@ -1136,7 +1058,7 @@ ProcXvShmPutImage(ClientPtr client) return (BadMatch); } - status = XVCALL(diMatchPort)(pPort, pDraw); + status = XvdiMatchPort(pPort, pDraw); if (status != Success) { return status; @@ -1152,11 +1074,10 @@ ProcXvShmPutImage(ClientPtr client) if(!pImage) return BadMatch; - if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType))) - { - client->errorValue = stuff->shmseg; - return BadShmSegCode; - } + status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg, + ShmSegType, serverClient, DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadShmSegCode : status; width = stuff->width; height = stuff->height; @@ -1168,13 +1089,11 @@ ProcXvShmPutImage(ClientPtr client) if((width < stuff->width) || (height < stuff->height)) return BadValue; - status = XVCALL(diPutImage)(client, pDraw, pPort, pGC, - stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char *)shmdesc->addr + stuff->offset, - stuff->send_event, stuff->width, stuff->height); + status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h, pImage, + (unsigned char *)shmdesc->addr + stuff->offset, + stuff->send_event, stuff->width, stuff->height); if((status == Success) && stuff->send_event) { xShmCompletionEvent ev; @@ -1219,11 +1138,7 @@ ProcXvQueryImageAttributes(ClientPtr client) REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); for(i = 0; i < pPort->pAdaptor->nImages; i++) { if(pPort->pAdaptor->pImages[i].id == stuff->id) { @@ -1282,16 +1197,12 @@ ProcXvListImageFormats(ClientPtr client) REQUEST_SIZE_MATCH(xvListImageFormatsReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num_formats = pPort->pAdaptor->nImages; - rep.length = pPort->pAdaptor->nImages * sz_xvImageFormatInfo >> 2; + rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo); _WriteListImageFormatsReply(client, &rep); @@ -1692,18 +1603,20 @@ SProcXvDispatch(ClientPtr client) static int XineramaXvStopVideo(ClientPtr client) { - int result = Success, i; + int result, i; PanoramiXRes *draw, *port; REQUEST(xvStopVideoReq); REQUEST_SIZE_MATCH(xvStopVideoReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; FOR_NSCREENS_BACKWARD(i) { if(port->info[i].id) { @@ -1721,13 +1634,14 @@ XineramaXvSetPortAttribute(ClientPtr client) { REQUEST(xvSetPortAttributeReq); PanoramiXRes *port; - int result = Success, i; + int result, i; REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; FOR_NSCREENS_BACKWARD(i) { if(port->info[i].id) { @@ -1746,21 +1660,24 @@ XineramaXvShmPutImage(ClientPtr client) PanoramiXRes *draw, *gc, *port; Bool send_event = stuff->send_event; Bool isRoot; - int result = Success, i, x, y; + int result, i, x, y; REQUEST_SIZE_MATCH(xvShmPutImageReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1795,21 +1712,24 @@ XineramaXvPutImage(ClientPtr client) REQUEST(xvPutImageReq); PanoramiXRes *draw, *gc, *port; Bool isRoot; - int result = Success, i, x, y; + int result, i, x, y; REQUEST_AT_LEAST_SIZE(xvPutImageReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1840,21 +1760,24 @@ XineramaXvPutVideo(ClientPtr client) REQUEST(xvPutImageReq); PanoramiXRes *draw, *gc, *port; Bool isRoot; - int result = Success, i, x, y; + int result, i, x, y; REQUEST_AT_LEAST_SIZE(xvPutVideoReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1885,21 +1808,24 @@ XineramaXvPutStill(ClientPtr client) REQUEST(xvPutImageReq); PanoramiXRes *draw, *gc, *port; Bool isRoot; - int result = Success, i, x, y; + int result, i, x, y; REQUEST_AT_LEAST_SIZE(xvPutImageReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, DixReadAccess))) - return BadGC; + result = dixLookupResourceByType((pointer *)&gc, stuff->gc, + XRT_GC, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadGC : result; - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, DixReadAccess))) - return _XvBadPort; + result = dixLookupResourceByType((pointer *)&port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? _XvBadPort : result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; diff --git a/xorg-server/Xext/xvdix.h b/xorg-server/Xext/xvdix.h index a516cf113..44f8f6b18 100644 --- a/xorg-server/Xext/xvdix.h +++ b/xorg-server/Xext/xvdix.h @@ -55,20 +55,22 @@ SOFTWARE. #include "scrnintstr.h" #include <X11/extensions/Xvproto.h> -extern unsigned long XvExtensionGeneration; -extern unsigned long XvScreenGeneration; -extern unsigned long XvResourceGeneration; - -extern int XvReqCode; -extern int XvEventBase; -extern int XvErrorBase; - -extern unsigned long XvRTPort; -extern unsigned long XvRTEncoding; -extern unsigned long XvRTGrab; -extern unsigned long XvRTVideoNotify; -extern unsigned long XvRTVideoNotifyList; -extern unsigned long XvRTPortNotify; +#ifndef XorgLoader +extern _X_EXPORT unsigned long XvExtensionGeneration; +extern _X_EXPORT unsigned long XvScreenGeneration; +extern _X_EXPORT unsigned long XvResourceGeneration; + +extern _X_EXPORT int XvReqCode; +extern _X_EXPORT int XvEventBase; +extern _X_EXPORT int XvErrorBase; + +extern _X_EXPORT unsigned long XvRTPort; +extern _X_EXPORT unsigned long XvRTEncoding; +extern _X_EXPORT unsigned long XvRTGrab; +extern _X_EXPORT unsigned long XvRTVideoNotify; +extern _X_EXPORT unsigned long XvRTVideoNotifyList; +extern _X_EXPORT unsigned long XvRTPortNotify; +#endif typedef struct { int numerator; @@ -199,17 +201,13 @@ typedef struct _XvPortRec { DevUnion devPriv; } XvPortRec, *XvPortPtr; -#define LOOKUP_PORT(_id, client)\ - ((XvPortPtr)LookupIDByType(_id, XvRTPort)) - -#define LOOKUP_ENCODING(_id, client)\ - ((XvEncodingPtr)LookupIDByType(_id, XvRTEncoding)) - -#define LOOKUP_VIDEONOTIFY_LIST(_id, client)\ - ((XvVideoNotifyPtr)LookupIDByType(_id, XvRTVideoNotifyList)) - -#define LOOKUP_PORTNOTIFY_LIST(_id, client)\ - ((XvPortNotifyPtr)LookupIDByType(_id, XvRTPortNotifyList)) +#define VALIDATE_XV_PORT(portID, pPort, mode)\ + {\ + int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\ + XvRTPort, client, mode);\ + if (rc != Success)\ + return (rc == BadValue) ? _XvBadPort : rc;\ + } typedef struct { int version, revision; @@ -234,54 +232,44 @@ typedef struct { #define _XvBadPort (XvBadPort+XvErrorBase) #define _XvBadEncoding (XvBadEncoding+XvErrorBase) -extern int ProcXvDispatch(ClientPtr); -extern int SProcXvDispatch(ClientPtr); +#ifndef XorgLoader +extern _X_EXPORT int ProcXvDispatch(ClientPtr); +extern _X_EXPORT int SProcXvDispatch(ClientPtr); -extern void XvExtensionInit(void); -extern int XvScreenInit(ScreenPtr); -extern DevPrivateKey XvGetScreenKey(void); -extern unsigned long XvGetRTPort(void); -extern int XvdiSendPortNotify(XvPortPtr, Atom, INT32); -extern int XvdiVideoStopped(XvPortPtr, int); +extern _X_EXPORT void XvExtensionInit(void); +extern _X_EXPORT int XvScreenInit(ScreenPtr); +extern _X_EXPORT DevPrivateKey XvGetScreenKey(void); +extern _X_EXPORT unsigned long XvGetRTPort(void); +extern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32); +extern _X_EXPORT int XvdiVideoStopped(XvPortPtr, int); -extern int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +extern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16); -extern int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +extern _X_EXPORT int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16); -extern int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +extern _X_EXPORT int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16); -extern int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +extern _X_EXPORT int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16); -extern int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +extern _X_EXPORT int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, INT16, INT16, CARD16, CARD16, INT16, INT16, CARD16, CARD16, XvImagePtr, unsigned char*, Bool, CARD16, CARD16); -extern int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL); -extern int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL); -extern int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); -extern int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*); -extern int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr); -extern int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr); -extern int XvdiMatchPort(XvPortPtr, DrawablePtr); -extern int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *); -extern int XvdiUngrabPort( ClientPtr, XvPortPtr, Time); - - -#if !defined(UNIXCPP) - -#define XVCALL(name) Xv##name - -#else - -#define XVCALL(name) Xv/**/name - -#endif - +extern _X_EXPORT int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL); +extern _X_EXPORT int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL); +extern _X_EXPORT int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); +extern _X_EXPORT int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*); +extern _X_EXPORT int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr); +extern _X_EXPORT int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr); +extern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr); +extern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *); +extern _X_EXPORT int XvdiUngrabPort( ClientPtr, XvPortPtr, Time); +#endif /* XorgLoader */ #endif /* XVDIX_H */ diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c index fcca724b0..7c8a3c3d4 100644 --- a/xorg-server/Xext/xvmain.c +++ b/xorg-server/Xext/xvmain.c @@ -153,7 +153,7 @@ static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int); ** */ -void +void XvExtensionInit(void) { ExtensionEntry *extEntry; @@ -248,7 +248,7 @@ CreateResourceTypes(void) } -_X_EXPORT int +int XvScreenInit(ScreenPtr pScreen) { XvScreenPtr pxvs; @@ -273,7 +273,7 @@ XvScreenInit(ScreenPtr pScreen) /* ALLOCATE SCREEN PRIVATE RECORD */ - pxvs = (XvScreenPtr) xalloc (sizeof (XvScreenRec)); + pxvs = xalloc (sizeof (XvScreenRec)); if (!pxvs) { ErrorF("XvScreenInit: Unable to allocate screen private structure\n"); @@ -323,13 +323,13 @@ XvResetProc(ExtensionEntry* extEntry) XvResetProcVector(); } -_X_EXPORT DevPrivateKey +DevPrivateKey XvGetScreenKey(void) { return XvScreenKey; } -_X_EXPORT unsigned long +unsigned long XvGetRTPort(void) { return XvRTPort; @@ -367,11 +367,10 @@ XvDestroyPixmap(PixmapPtr pPix) { XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted); - (void)(* pp->pAdaptor->ddStopVideo)((ClientPtr)NULL, pp, - pp->pDraw); + (void)(* pp->pAdaptor->ddStopVideo)(NULL, pp, pp->pDraw); - pp->pDraw = (DrawablePtr)NULL; - pp->client = (ClientPtr)NULL; + pp->pDraw = NULL; + pp->client = NULL; pp->time = currentTime; } pp++; @@ -419,11 +418,10 @@ XvDestroyWindow(WindowPtr pWin) { XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted); - (void)(* pp->pAdaptor->ddStopVideo)((ClientPtr)NULL, pp, - pp->pDraw); + (void)(* pp->pAdaptor->ddStopVideo)(NULL, pp, pp->pDraw); - pp->pDraw = (DrawablePtr)NULL; - pp->client = (ClientPtr)NULL; + pp->pDraw = NULL; + pp->client = NULL; pp->time = currentTime; } pp++; @@ -455,8 +453,8 @@ XvdiVideoStopped(XvPortPtr pPort, int reason) XvdiSendVideoNotify(pPort, pPort->pDraw, reason); - pPort->pDraw = (DrawablePtr)NULL; - pPort->client = (ClientPtr)NULL; + pPort->pDraw = NULL; + pPort->client = NULL; pPort->time = currentTime; return Success; @@ -472,7 +470,7 @@ XvdiDestroyPort(pointer pPort, XID id) static int XvdiDestroyGrab(pointer pGrab, XID id) { - ((XvGrabPtr)pGrab)->client = (ClientPtr)NULL; + ((XvGrabPtr)pGrab)->client = NULL; return Success; } @@ -481,7 +479,7 @@ XvdiDestroyVideoNotify(pointer pn, XID id) { /* JUST CLEAR OUT THE client POINTER FIELD */ - ((XvVideoNotifyPtr)pn)->client = (ClientPtr)NULL; + ((XvVideoNotifyPtr)pn)->client = NULL; return Success; } @@ -490,7 +488,7 @@ XvdiDestroyPortNotify(pointer pn, XID id) { /* JUST CLEAR OUT THE client POINTER FIELD */ - ((XvPortNotifyPtr)pn)->client = (ClientPtr)NULL; + ((XvPortNotifyPtr)pn)->client = NULL; return Success; } @@ -520,17 +518,13 @@ XvdiDestroyEncoding(pointer value, XID id) } static int -XvdiSendVideoNotify(pPort, pDraw, reason) - -XvPortPtr pPort; -DrawablePtr pDraw; -int reason; - +XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason) { xvEvent event; XvVideoNotifyPtr pn; - pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList); + dixLookupResourceByType((pointer *)&pn, pDraw->id, XvRTVideoNotifyList, + serverClient, DixReadAccess); while (pn) { @@ -857,7 +851,7 @@ XvdiGrabPort( if ((pPort->pDraw) && (client != pPort->client)) { - XVCALL(diStopVideo)((ClientPtr)NULL, pPort, pPort->pDraw); + XvdiStopVideo(NULL, pPort, pPort->pDraw); } pPort->grab.client = client; @@ -896,7 +890,7 @@ XvdiUngrabPort( /* FREE THE GRAB RESOURCE; AND SET THE GRAB CLIENT TO NULL */ FreeResource(pPort->grab.id, XvRTGrab); - pPort->grab.client = (ClientPtr)NULL; + pPort->grab.client = NULL; pPort->time = currentTime; @@ -912,10 +906,14 @@ XvdiSelectVideoNotify( BOOL onoff ){ XvVideoNotifyPtr pn,tpn,fpn; + int rc; /* FIND VideoNotify LIST */ - pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList); + rc = dixLookupResourceByType((pointer *)&pn, pDraw->id, XvRTVideoNotifyList, + client, DixWriteAccess); + if (rc != Success && rc != BadValue) + return rc; /* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */ @@ -926,9 +924,9 @@ XvdiSelectVideoNotify( if (!pn) { - if (!(tpn = (XvVideoNotifyPtr)xalloc(sizeof(XvVideoNotifyRec)))) + if (!(tpn = xalloc(sizeof(XvVideoNotifyRec)))) return BadAlloc; - tpn->next = (XvVideoNotifyPtr)NULL; + tpn->next = NULL; if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn)) { xfree(tpn); @@ -939,13 +937,13 @@ XvdiSelectVideoNotify( { /* LOOK TO SEE IF ENTRY ALREADY EXISTS */ - fpn = (XvVideoNotifyPtr)NULL; + fpn = NULL; tpn = pn; while (tpn) { if (tpn->client == client) { - if (!onoff) tpn->client = (ClientPtr)NULL; + if (!onoff) tpn->client = NULL; return Success; } if (!tpn->client) fpn = tpn; /* TAKE NOTE OF FREE ENTRY */ @@ -964,7 +962,7 @@ XvdiSelectVideoNotify( } else { - if (!(tpn = (XvVideoNotifyPtr)xalloc(sizeof(XvVideoNotifyRec)))) + if (!(tpn = xalloc(sizeof(XvVideoNotifyRec)))) return BadAlloc; tpn->next = pn->next; pn->next = tpn; @@ -974,7 +972,7 @@ XvdiSelectVideoNotify( /* INIT CLIENT PTR IN CASE WE CAN'T ADD RESOURCE */ /* ADD RESOURCE SO THAT IF CLIENT EXITS THE CLIENT PTR WILL BE CLEARED */ - tpn->client = (ClientPtr)NULL; + tpn->client = NULL; tpn->id = FakeClientID(client->index); AddResource(tpn->id, XvRTVideoNotify, tpn); @@ -993,7 +991,7 @@ XvdiSelectPortNotify( /* SEE IF CLIENT IS ALREADY IN LIST */ - tpn = (XvPortNotifyPtr)NULL; + tpn = NULL; pn = pPort->pNotify; while (pn) { @@ -1010,7 +1008,7 @@ XvdiSelectPortNotify( if (!onoff) { - pn->client = (ClientPtr)NULL; + pn->client = NULL; FreeResource(pn->id, XvRTPortNotify); } @@ -1022,7 +1020,7 @@ XvdiSelectPortNotify( if (!tpn) { - if (!(tpn = (XvPortNotifyPtr)xalloc(sizeof(XvPortNotifyRec)))) + if (!(tpn = xalloc(sizeof(XvPortNotifyRec)))) return BadAlloc; tpn->next = pPort->pNotify; pPort->pNotify = tpn; @@ -1065,7 +1063,7 @@ XvdiStopVideo( status = (* pPort->pAdaptor->ddStopVideo)(client, pPort, pDraw); - pPort->pDraw = (DrawablePtr)NULL; + pPort->pDraw = NULL; pPort->client = (ClientPtr)client; pPort->time = currentTime; @@ -1089,7 +1087,7 @@ XvdiPreemptVideo( status = (* pPort->pAdaptor->ddStopVideo)(client, pPort, pPort->pDraw); - pPort->pDraw = (DrawablePtr)NULL; + pPort->pDraw = NULL; pPort->client = (ClientPtr)client; pPort->time = currentTime; diff --git a/xorg-server/Xext/xvmc.c b/xorg-server/Xext/xvmc.c index ad1b8abc0..b7bb0fc1b 100644 --- a/xorg-server/Xext/xvmc.c +++ b/xorg-server/Xext/xvmc.c @@ -1,6 +1,4 @@ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -138,10 +136,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client) REQUEST(xvmcListSurfaceTypesReq); REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client))) { - client->errorValue = stuff->port; - return _XvBadPort; - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); if(XvMCScreenKey) { /* any adaptors at all */ ScreenPtr pScreen = pPort->pAdaptor->pScreen; @@ -158,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num = (adaptor) ? adaptor->num_surfaces : 0; - rep.length = rep.num * sizeof(xvmcSurfaceInfo) >> 2; + rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo)); WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep); @@ -194,10 +189,7 @@ ProcXvMCCreateContext(ClientPtr client) REQUEST(xvmcCreateContextReq); REQUEST_SIZE_MATCH(xvmcCreateContextReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client))) { - client->errorValue = stuff->port; - return _XvBadPort; - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); pScreen = pPort->pAdaptor->pScreen; @@ -275,11 +267,15 @@ ProcXvMCCreateContext(ClientPtr client) static int ProcXvMCDestroyContext(ClientPtr client) { + pointer val; + int rc; REQUEST(xvmcDestroyContextReq); REQUEST_SIZE_MATCH(xvmcDestroyContextReq); - if(!LookupIDByType(stuff->context_id, XvMCRTContext)) - return (XvMCBadContext + XvMCErrorBase); + rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext, + client, DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? XvMCBadContext + XvMCErrorBase : rc; FreeResource(stuff->context_id, RT_NONE); @@ -299,8 +295,10 @@ ProcXvMCCreateSurface(ClientPtr client) REQUEST(xvmcCreateSurfaceReq); REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq); - if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext))) - return (XvMCBadContext + XvMCErrorBase); + result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id, + XvMCRTContext, client, DixUseAccess); + if (result != Success) + return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result; pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); @@ -339,11 +337,15 @@ ProcXvMCCreateSurface(ClientPtr client) static int ProcXvMCDestroySurface(ClientPtr client) { + pointer val; + int rc; REQUEST(xvmcDestroySurfaceReq); REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq); - if(!LookupIDByType(stuff->surface_id, XvMCRTSurface)) - return (XvMCBadSurface + XvMCErrorBase); + rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface, + client, DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? XvMCBadSurface + XvMCErrorBase : rc; FreeResource(stuff->surface_id, RT_NONE); @@ -365,8 +367,10 @@ ProcXvMCCreateSubpicture(ClientPtr client) REQUEST(xvmcCreateSubpictureReq); REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq); - if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext))) - return (XvMCBadContext + XvMCErrorBase); + result = dixLookupResourceByType((pointer *)&pContext, stuff->context_id, + XvMCRTContext, client, DixUseAccess); + if (result != Success) + return (result == BadValue) ? XvMCBadContext + XvMCErrorBase : result; pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen); @@ -450,11 +454,15 @@ ProcXvMCCreateSubpicture(ClientPtr client) static int ProcXvMCDestroySubpicture(ClientPtr client) { + pointer val; + int rc; REQUEST(xvmcDestroySubpictureReq); REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq); - if(!LookupIDByType(stuff->subpicture_id, XvMCRTSubpicture)) - return (XvMCBadSubpicture + XvMCErrorBase); + rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture, + client, DixDestroyAccess); + if (rc != Success) + return (rc == BadValue) ? XvMCBadSubpicture + XvMCErrorBase : rc; FreeResource(stuff->subpicture_id, RT_NONE); @@ -477,10 +485,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client) REQUEST(xvmcListSubpictureTypesReq); REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq); - if(!(pPort = LOOKUP_PORT(stuff->port, client))) { - client->errorValue = stuff->port; - return _XvBadPort; - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); pScreen = pPort->pAdaptor->pScreen; @@ -514,7 +519,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client) if(surface->compatible_subpictures) rep.num = surface->compatible_subpictures->num_xvimages; - rep.length = rep.num * sizeof(xvImageFormatInfo) >> 2; + rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo)); WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep); @@ -573,11 +578,7 @@ ProcXvMCGetDRInfo(ClientPtr client) REQUEST(xvmcGetDRInfoReq); REQUEST_SIZE_MATCH(xvmcGetDRInfoReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client))) { - client->errorValue = stuff->port; - return _XvBadPort; - } + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); pScreen = pPort->pAdaptor->pScreen; pScreenPriv = XVMC_GET_PRIVATE(pScreen); @@ -587,8 +588,8 @@ ProcXvMCGetDRInfo(ClientPtr client) rep.major = pScreenPriv->major; rep.minor = pScreenPriv->minor; rep.patchLevel = pScreenPriv->patchLevel; - rep.nameLen = (strlen(pScreenPriv->clientDriverName) + 4) >> 2; - rep.busIDLen = (strlen(pScreenPriv->busID) + 4) >> 2; + rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1); + rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1); rep.length = rep.nameLen + rep.busIDLen; rep.nameLen <<=2; @@ -664,7 +665,7 @@ SProcXvMCDispatch (ClientPtr client) return BadImplementation; } -void +void XvMCExtensionInit(void) { ExtensionEntry *extEntry; @@ -712,7 +713,7 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) XvMCScreenKey = &XvMCScreenKeyIndex; - if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec)))) + if(!(pScreenPriv = xalloc(sizeof(XvMCScreenRec)))) return BadAlloc; dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv); diff --git a/xorg-server/Xext/xvmcext.h b/xorg-server/Xext/xvmcext.h index 9c019fee6..5b431260f 100644 --- a/xorg-server/Xext/xvmcext.h +++ b/xorg-server/Xext/xvmcext.h @@ -101,15 +101,18 @@ typedef struct { XvMCDestroySubpictureProcPtr DestroySubpicture; } XvMCAdaptorRec, *XvMCAdaptorPtr; -void XvMCExtensionInit(void); +#ifndef XorgLoader +extern _X_EXPORT void XvMCExtensionInit(void); -int XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr adapt); +extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen, + int num, + XvMCAdaptorPtr adapt); -XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id); +extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id); -int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name, +extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name, char *busID, int major, int minor, int patchLevel); - +#endif #endif /* _XVMC_H */ |