diff options
author | Keith Packard <keithp@keithp.com> | 2008-08-06 15:26:24 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-03-09 13:08:09 -0700 |
commit | f8dd80d13bb5313a11b38b280f8ad3e22f0a6300 (patch) | |
tree | e0aea0e92304c050bb9eda0b7e4b71ad1d242e90 | |
parent | 0d9a42dc0380d1583889b6b6521bd5a2451735d4 (diff) |
Replace dixLookupResource by dixLookupResourceBy{Type,Class}
dixLookupResource attempted to automatically detect whether the caller
wanted a lookup by-type or by-class, unfortunately, it guessed wrong for
RT_NONE. Instead of trying to make the guess better, this patch just reverts
the unification and creates separate functions for each operation.
-rw-r--r-- | Xext/saver.c | 8 | ||||
-rw-r--r-- | Xext/security.c | 4 | ||||
-rw-r--r-- | Xext/shape.c | 2 | ||||
-rw-r--r-- | Xext/sync.c | 2 | ||||
-rw-r--r-- | Xext/xselinux.c | 2 | ||||
-rw-r--r-- | Xext/xtest.c | 6 | ||||
-rw-r--r-- | Xi/exevents.c | 2 | ||||
-rw-r--r-- | composite/compext.c | 10 | ||||
-rw-r--r-- | dix/cursor.c | 8 | ||||
-rw-r--r-- | dix/deprecated.c | 33 | ||||
-rw-r--r-- | dix/dispatch.c | 48 | ||||
-rw-r--r-- | dix/dixutils.c | 4 | ||||
-rw-r--r-- | dix/events.c | 10 | ||||
-rw-r--r-- | dix/gc.c | 8 | ||||
-rw-r--r-- | dix/resource.c | 39 | ||||
-rw-r--r-- | dix/window.c | 8 | ||||
-rw-r--r-- | include/resource.h | 39 | ||||
-rw-r--r-- | render/picture.c | 4 | ||||
-rw-r--r-- | render/render.c | 8 | ||||
-rw-r--r-- | xfixes/cursor.c | 4 | ||||
-rw-r--r-- | xfixes/region.c | 6 |
21 files changed, 161 insertions, 94 deletions
diff --git a/Xext/saver.c b/Xext/saver.c index cd6774928..357c2155f 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -1023,13 +1023,13 @@ ScreenSaverSetAttributes (ClientPtr client) goto PatchUp; } *values++ = ParentRelative; } else { - ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, + ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, client, DixReadAccess); if (ret == Success) { if ((pPixmap->drawable.depth != depth) || (pPixmap->drawable.pScreen != pScreen)) { @@ -1061,13 +1061,13 @@ ScreenSaverSetAttributes (ClientPtr client) goto PatchUp; } *values++ = CopyFromParent; } else { - ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, + ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, client, DixReadAccess); if (ret == Success) { if ((pPixmap->drawable.depth != depth) || (pPixmap->drawable.pScreen != pScreen)) { @@ -1155,13 +1155,13 @@ ScreenSaverSetAttributes (ClientPtr client) } } *values++ = xTrue; break; case CWColormap: cmap = (Colormap) *pVlist; - ret = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP, + ret = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP, client, DixUseAccess); if (ret != Success) { ret = (ret == BadValue) ? BadColor : ret; client->errorValue = cmap; goto PatchUp; @@ -1179,13 +1179,13 @@ ScreenSaverSetAttributes (ClientPtr client) if ( cursorID == None) { *values++ = None; } else { - ret = dixLookupResource((pointer *)&pCursor, cursorID, + ret = dixLookupResourceByType((pointer *)&pCursor, cursorID, RT_CURSOR, client, DixUseAccess); if (ret != Success) { ret = (ret == BadValue) ? BadCursor : ret; client->errorValue = cursorID; goto PatchUp; diff --git a/Xext/security.c b/Xext/security.c index fc4691b0e..c9077c87e 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -1012,13 +1012,13 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata) state->authId = None; state->haveState = TRUE; break; case ClientStateRunning: state->authId = AuthorizationIDOfClient(pci->client); - rc = dixLookupResource((pointer *)&pAuth, state->authId, + rc = dixLookupResourceByType((pointer *)&pAuth, state->authId, SecurityAuthorizationResType, serverClient, DixGetAttrAccess); if (rc == Success) { /* it is a generated authorization */ pAuth->refcnt++; if (pAuth->refcnt == 1 && pAuth->timer) @@ -1027,13 +1027,13 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata) state->trustLevel = pAuth->trustLevel; } break; case ClientStateGone: case ClientStateRetained: - rc = dixLookupResource((pointer *)&pAuth, state->authId, + rc = dixLookupResourceByType((pointer *)&pAuth, state->authId, SecurityAuthorizationResType, serverClient, DixGetAttrAccess); if (rc == Success) { /* it is a generated authorization */ pAuth->refcnt--; if (pAuth->refcnt == 0) diff --git a/Xext/shape.c b/Xext/shape.c index 2a6a38b7d..15d2c5c5a 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -408,13 +408,13 @@ ProcShapeMask (ClientPtr client) return BadValue; } pScreen = pWin->drawable.pScreen; if (stuff->src == None) srcRgn = 0; else { - rc = dixLookupResource((pointer *)&pPixmap, stuff->src, RT_PIXMAP, + rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->src, RT_PIXMAP, client, DixReadAccess); if (rc != Success) return (rc == BadValue) ? BadPixmap : rc; if (pPixmap->drawable.pScreen != pScreen || pPixmap->drawable.depth != 1) return BadMatch; diff --git a/Xext/sync.c b/Xext/sync.c index a30895ddf..adb732447 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -260,13 +260,13 @@ SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XSyncCounter counter, Bool newcounter = FALSE; if (changes & XSyncCACounter) { if (counter == None) pCounter = NULL; - else if (Success != (rc = dixLookupResource((pointer *)&pCounter, + else if (Success != (rc = dixLookupResourceByType ((pointer *)&pCounter, counter, RTCounter, client, DixReadAccess))) { client->errorValue = counter; return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc; } if (pCounter != pTrigger->pCounter) diff --git a/Xext/xselinux.c b/Xext/xselinux.c index f1003e637..cc973194f 100644 --- a/Xext/xselinux.c +++ b/Xext/xselinux.c @@ -550,13 +550,13 @@ SELinuxLabelInitial(void) for (i = 0; i < screenInfo.numScreens; i++) { /* Do the screen object */ srec.screen = screenInfo.screens[i]; SELinuxScreen(NULL, NULL, &srec); /* Do the default colormap */ - dixLookupResource(&unused, screenInfo.screens[i]->defColormap, + dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap, RT_COLORMAP, serverClient, DixCreateAccess); } } /* * Labels new resource objects. diff --git a/Xext/xtest.c b/Xext/xtest.c index 6f0d1acf3..fe3816e9c 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -120,14 +120,14 @@ ProcXTestCompareCursor(ClientPtr client) return rc; if (stuff->cursor == None) pCursor = NullCursor; else if (stuff->cursor == XTestCurrentCursor) pCursor = GetSpriteCursor(ptr); else { - rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, - client, DixReadAccess); + rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR, + client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->cursor; return (rc == BadValue) ? BadCursor : rc; } } @@ -153,13 +153,13 @@ ProcXTestFakeInput(ClientPtr client) Bool extension = FALSE; deviceValuator *dv = NULL; int valuators[MAX_VALUATORS] = {0}; int numValuators = 0; int firstValuator = 0; EventListPtr events; - int nevents; + int nevents = 0; int i; int base = 0; nev = (stuff->length << 2) - sizeof(xReq); if ((nev % sizeof(xEvent)) || !nev) return BadLength; diff --git a/Xi/exevents.c b/Xi/exevents.c index 6a48a8ed7..20e0fbbfa 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1260,13 +1260,13 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, if (rc != Success) return rc; } if (rcursor == None) cursor = NullCursor; else { - rc = dixLookupResource((pointer *)&cursor, rcursor, RT_CURSOR, + rc = dixLookupResourceByType((pointer *)&cursor, rcursor, RT_CURSOR, client, DixUseAccess); if (rc != Success) { client->errorValue = rcursor; return (rc == BadValue) ? BadCursor : rc; } diff --git a/composite/compext.c b/composite/compext.c index c1544021c..4fff20efa 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -141,13 +141,13 @@ ProcCompositeRedirectWindow (ClientPtr client) { WindowPtr pWin; int rc; REQUEST(xCompositeRedirectWindowReq); REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixSetAttrAccess|DixManageAccess|DixBlendAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } @@ -159,13 +159,13 @@ ProcCompositeRedirectSubwindows (ClientPtr client) { WindowPtr pWin; int rc; REQUEST(xCompositeRedirectSubwindowsReq); REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixSetAttrAccess|DixManageAccess|DixBlendAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } @@ -211,13 +211,13 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client) CompWindowPtr cw; RegionPtr pBorderClip, pRegion; int rc; REQUEST(xCompositeCreateRegionFromBorderClipReq); REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } @@ -247,13 +247,13 @@ ProcCompositeNameWindowPixmap (ClientPtr client) CompWindowPtr cw; PixmapPtr pPixmap; int rc; REQUEST(xCompositeNameWindowPixmapReq); REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } @@ -295,13 +295,13 @@ ProcCompositeGetOverlayWindow (ClientPtr client) ScreenPtr pScreen; CompScreenPtr cs; CompOverlayClientPtr pOc; int rc; REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } diff --git a/dix/cursor.c b/dix/cursor.c index d1248c444..7ab15df0c 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -295,21 +295,21 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, CursorPtr pCurs; int nscr; ScreenPtr pscr; GlyphSharePtr pShare; DeviceIntPtr pDev; - rc = dixLookupResource((pointer *)&sourcefont, source, RT_FONT, client, - DixUseAccess); + rc = dixLookupResourceByType((pointer *)&sourcefont, source, RT_FONT, client, + DixUseAccess); if (rc != Success) { client->errorValue = source; return (rc == BadValue) ? BadFont : rc; } - rc = dixLookupResource((pointer *)&maskfont, mask, RT_FONT, client, - DixUseAccess); + rc = dixLookupResourceByType((pointer *)&maskfont, mask, RT_FONT, client, + DixUseAccess); if (rc != Success && mask != None) { client->errorValue = mask; return (rc == BadValue) ? BadFont : rc; } if (sourcefont != maskfont) diff --git a/dix/deprecated.c b/dix/deprecated.c index d395c963a..5487b64bc 100644 --- a/dix/deprecated.c +++ b/dix/deprecated.c @@ -112,51 +112,68 @@ LookupClient(XID id, ClientPtr client) if (warn > 0 && --warn) ErrorF("Warning: LookupClient() is deprecated. Please convert your " "driver/module to use dixLookupClient().\n"); return (i == Success) ? pClient : NULL; } -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByType */ pointer SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask access_mode) { pointer retval; - int i = dixLookupResource(&retval, id, rtype, client, access_mode); + int i = dixLookupResourceByType(&retval, id, rtype, client, access_mode); static int warn = 1; if (warn > 0 && --warn) ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() " "are deprecated. Please convert your driver/module " - "to use dixLookupResource().\n"); + "to use dixLookupResourceByType().\n"); return (i == Success) ? retval : NULL; } -/* replaced by dixLookupResource */ pointer SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask access_mode) { pointer retval; - int i = dixLookupResource(&retval, id, classes, client, access_mode); + int i = dixLookupResourceByClass(&retval, id, classes, client, access_mode); static int warn = 1; if (warn > 0 && --warn) ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() " "are deprecated. Please convert your driver/module " - "to use dixLookupResource().\n"); + "to use dixLookupResourceByClass().\n"); return (i == Success) ? retval : NULL; } -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByType */ pointer LookupIDByType(XID id, RESTYPE rtype) { return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess); } -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByClass */ pointer LookupIDByClass(XID id, RESTYPE classes) { return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess); } +/* replaced by dixLookupResourceBy{Type,Class} */ +_X_EXPORT int +dixLookupResource (pointer *result, XID id, RESTYPE rtype, + ClientPtr client, Mask mode) +{ + Bool istype = ((rtype & TypeMask) && (rtype != RC_ANY)) || (rtype == RT_NONE); + + static int warn = 1; + if (warn > 0 && --warn) + ErrorF("Warning: dixLookupResource() " + "is deprecated. Please convert your driver/module " + "to use dixLookupResourceByType/dixLookupResourceByClass().\n"); + if (istype) + return dixLookupResourceByType (result, id, rtype, client, mode); + else + return dixLookupResourceByClass (result, id, rtype, client, mode); +} + /* end deprecated functions */ diff --git a/dix/dispatch.c b/dix/dispatch.c index a92804841..0ed95df8b 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1113,17 +1113,17 @@ ProcQueryFont(ClientPtr client) GC *pGC; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ - rc = dixLookupResource((pointer *)&pFont, stuff->id, RT_FONT, client, - DixGetAttrAccess); + rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, client, + DixGetAttrAccess); if (rc == BadValue) { - rc = dixLookupResource((pointer *)&pGC, stuff->id, RT_GC, client, - DixGetAttrAccess); + rc = dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, client, + DixGetAttrAccess); if (rc == Success) pFont = pGC->font; } if (rc != Success) return (rc == BadValue) ? BadFont: rc; @@ -1171,16 +1171,16 @@ ProcQueryTextExtents(ClientPtr client) unsigned long length; int rc; REQUEST(xQueryTextExtentsReq); REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); client->errorValue = stuff->fid; /* EITHER font or gc */ - rc = dixLookupResource((pointer *)&pFont, stuff->fid, RT_FONT, client, - DixGetAttrAccess); + rc = dixLookupResourceByType((pointer *)&pFont, stuff->fid, RT_FONT, client, + DixGetAttrAccess); if (rc == BadValue) { - rc = dixLookupResource((pointer *)&pGC, stuff->fid, RT_GC, client, + rc = dixLookupResourceByType((pointer *)&pGC, stuff->fid, RT_GC, client, DixGetAttrAccess); if (rc == Success) pFont = pGC->font; } if (rc != Success) return (rc == BadValue) ? BadFont: rc; @@ -1319,13 +1319,13 @@ ProcFreePixmap(ClientPtr client) { PixmapPtr pMap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupResource((pointer *)&pMap, stuff->id, RT_PIXMAP, client, + rc = dixLookupResourceByType((pointer *)&pMap, stuff->id, RT_PIXMAP, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } @@ -2266,13 +2266,13 @@ ProcFreeColormap(ClientPtr client) { ColormapPtr pmap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupResource((pointer *)&pmap, stuff->id, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pmap, stuff->id, RT_COLORMAP, client, DixDestroyAccess); if (rc == Success) { /* Freeing a default colormap is a no-op */ if (!(pmap->flags & IsDefault)) FreeResource(stuff->id, RT_NONE); @@ -2294,13 +2294,13 @@ ProcCopyColormapAndFree(ClientPtr client) REQUEST(xCopyColormapAndFreeReq); int rc; REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); - rc = dixLookupResource((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP, + rc = dixLookupResourceByType((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP, client, DixReadAccess|DixRemoveAccess); if (rc == Success) { rc = CopyColormapAndFree(mid, pSrcMap, client->index); if (client->noClientException != Success) return(client->noClientException); @@ -2319,13 +2319,13 @@ ProcInstallColormap(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, DixInstallAccess); if (rc != Success) goto out; rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) @@ -2344,13 +2344,13 @@ ProcUninstallColormap(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, DixUninstallAccess); if (rc != Success) goto out; rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) @@ -2410,13 +2410,13 @@ ProcAllocColor (ClientPtr client) ColormapPtr pmap; int rc; xAllocColorReply acr; REQUEST(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq); - rc = dixLookupResource((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client, DixAddAccess); if (rc == Success) { acr.type = X_Reply; acr.length = 0; acr.sequenceNumber = client->sequence; @@ -2451,13 +2451,13 @@ ProcAllocNamedColor (ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xAllocNamedColorReq); REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixAddAccess); if (rc == Success) { xAllocNamedColorReply ancr; ancr.type = X_Reply; @@ -2502,13 +2502,13 @@ ProcAllocColorCells (ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xAllocColorCellsReq); REQUEST_SIZE_MATCH(xAllocColorCellsReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixAddAccess); if (rc == Success) { xAllocColorCellsReply accr; int npixels, nmasks; long length; @@ -2569,13 +2569,13 @@ ProcAllocColorPlanes(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xAllocColorPlanesReq); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixAddAccess); if (rc == Success) { xAllocColorPlanesReply acpr; int npixels; long length; @@ -2634,13 +2634,13 @@ ProcFreeColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixRemoveAccess); if (rc == Success) { int count; if(pcmp->flags & AllAllocated) @@ -2669,13 +2669,13 @@ ProcStoreColors (ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { int count; count = (client->req_len << 2) - sizeof(xStoreColorsReq); @@ -2703,13 +2703,13 @@ ProcStoreNamedColor (ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreNamedColorReq); REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { xColorItem def; if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], @@ -2737,13 +2737,13 @@ ProcQueryColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xQueryColorsReq); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { int count; xrgb *prgbs; xQueryColorsReply qcr; @@ -2790,13 +2790,13 @@ ProcLookupColor(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xLookupColorReq); REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, + rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { xLookupColorReply lcr; if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, @@ -2839,20 +2839,20 @@ ProcCreateCursor (ClientPtr client) REQUEST(xCreateCursorReq); REQUEST_SIZE_MATCH(xCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); - rc = dixLookupResource((pointer *)&src, stuff->source, RT_PIXMAP, client, + rc = dixLookupResourceByType((pointer *)&src, stuff->source, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->source; return (rc == BadValue) ? BadPixmap : rc; } - rc = dixLookupResource((pointer *)&msk, stuff->mask, RT_PIXMAP, client, + rc = dixLookupResourceByType((pointer *)&msk, stuff->mask, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { if (stuff->mask != None) { client->errorValue = stuff->mask; @@ -2944,13 +2944,13 @@ ProcFreeCursor (ClientPtr client) { CursorPtr pCursor; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - rc = dixLookupResource((pointer *)&pCursor, stuff->id, RT_CURSOR, client, + rc = dixLookupResourceByType((pointer *)&pCursor, stuff->id, RT_CURSOR, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return (client->noClientException); } diff --git a/dix/dixutils.c b/dix/dixutils.c index a382be63f..1bdeee064 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -213,13 +213,13 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client, *pDraw = NULL; client->errorValue = id; if (id == INVALID) return BadDrawable; - rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access); + rc = dixLookupResourceByClass((pointer *)&pTmp, id, RC_DRAWABLE, client, access); if (rc == BadValue) return BadDrawable; if (rc != Success) return rc; if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE))) @@ -256,13 +256,13 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) pointer pRes; int rc = BadValue, clientIndex = CLIENT_ID(rid); if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT)) goto bad; - rc = dixLookupResource(&pRes, rid, RC_ANY, client, DixGetAttrAccess); + rc = dixLookupResourceByClass(&pRes, rid, RC_ANY, client, DixGetAttrAccess); if (rc != Success) goto bad; rc = XaceHook(XACE_CLIENT_ACCESS, client, clients[clientIndex], access); if (rc != Success) goto bad; diff --git a/dix/events.c b/dix/events.c index 8c9623bb4..fa6c46996 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4304,13 +4304,13 @@ ProcGrabPointer(ClientPtr client) return rc; } if (stuff->cursor == None) cursor = NullCursor; else { - rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR, + rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR, client, DixUseAccess); if (rc != Success) { client->errorValue = stuff->cursor; return (rc == BadValue) ? BadCursor : rc; } @@ -4405,14 +4405,14 @@ ProcChangeActivePointerGrab(ClientPtr client) return BadValue; } if (stuff->cursor == None) newCursor = NullCursor; else { - int rc = dixLookupResource((pointer *)&newCursor, stuff->cursor, - RT_CURSOR, client, DixUseAccess); + int rc = dixLookupResourceByType((pointer *)&newCursor, stuff->cursor, + RT_CURSOR, client, DixUseAccess); if (rc != Success) { client->errorValue = stuff->cursor; return (rc == BadValue) ? BadCursor : rc; } } @@ -5010,13 +5010,13 @@ ProcGrabButton(ClientPtr client) return rc; } if (stuff->cursor == None) cursor = NullCursor; else { - rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR, + rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR, client, DixUseAccess); if (rc != Success) if (!cursor) { client->errorValue = stuff->cursor; return (rc == BadValue) ? BadCursor : rc; @@ -5260,13 +5260,13 @@ ProcRecolorCursor(ClientPtr client) ScreenPtr pscr; Bool displayed; SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite; REQUEST(xRecolorCursorReq); REQUEST_SIZE_MATCH(xRecolorCursorReq); - rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, + rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR, client, DixWriteAccess); if (rc != Success) { client->errorValue = stuff->cursor; return (rc == BadValue) ? BadCursor : rc; } @@ -270,13 +270,13 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr NEXT_PTR(PixmapPtr, pPixmap); rc = Success; } else { NEXTVAL(XID, newpix); - rc = dixLookupResource((pointer *)&pPixmap, newpix, + rc = dixLookupResourceByType((pointer *)&pPixmap, newpix, RT_PIXMAP, client, DixReadAccess); } if (rc == Success) { if ((pPixmap->drawable.depth != pGC->depth) || (pPixmap->drawable.pScreen != pGC->pScreen)) @@ -307,13 +307,13 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr NEXT_PTR(PixmapPtr, pPixmap); rc = Success; } else { NEXTVAL(XID, newstipple) - rc = dixLookupResource((pointer *)&pPixmap, newstipple, + rc = dixLookupResourceByType((pointer *)&pPixmap, newstipple, RT_PIXMAP, client, DixReadAccess); } if (rc == Success) { if ((pPixmap->drawable.depth != 1) || (pPixmap->drawable.pScreen != pGC->pScreen)) @@ -350,13 +350,13 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr NEXT_PTR(FontPtr, pFont); rc = Success; } else { NEXTVAL(XID, newfont) - rc = dixLookupResource((pointer *)&pFont, newfont, + rc = dixLookupResourceByType((pointer *)&pFont, newfont, RT_FONT, client, DixUseAccess); } if (rc == Success) { pFont->refcnt++; if (pGC->font) @@ -417,13 +417,13 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr if (pid == None) { clipType = CT_NONE; pPixmap = NullPixmap; } else { - rc = dixLookupResource((pointer *)&pPixmap, pid, + rc = dixLookupResourceByType((pointer *)&pPixmap, pid, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { clientErrorValue = pid; error = (rc == BadValue) ? BadPixmap : rc; } diff --git a/dix/resource.c b/dix/resource.c index ec1d8cf4c..dc6945dd1 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -841,27 +841,56 @@ LegalNewID(XID id, ClientPtr client) return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) && ((clientTable[client->index].expectID <= id) || !LookupIDByClass(id, RC_ANY))); } int -dixLookupResource(pointer *result, XID id, RESTYPE rtype, - ClientPtr client, Mask mode) +dixLookupResourceByType(pointer *result, XID id, RESTYPE rtype, + ClientPtr client, Mask mode) { int cid = CLIENT_ID(id); - int istype = (rtype & TypeMask) && (rtype != RC_ANY); ResourcePtr res = NULL; *result = NULL; if ((cid < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) - if ((res->id == id) && ((istype && res->type == rtype) || - (!istype && res->type & rtype))) + if (res->id == id && res->type == rtype) + break; + } + if (!res) + return BadValue; + + if (client) { + client->errorValue = id; + cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, + res->value, RT_NONE, NULL, mode); + if (cid != Success) + return cid; + } + + *result = res->value; + return Success; +} + +int +dixLookupResourceByClass(pointer *result, XID id, RESTYPE rclass, + ClientPtr client, Mask mode) +{ + int cid = CLIENT_ID(id); + ResourcePtr res = NULL; + + *result = NULL; + + if ((cid < MAXCLIENTS) && clientTable[cid].buckets) { + res = clientTable[cid].resources[Hash(cid, id)]; + + for (; res; res = res->next) + if (res->id == id && (res->type & rclass)) break; } if (!res) return BadValue; if (client) { diff --git a/dix/window.c b/dix/window.c index 2a5da53ea..e2669f0c5 100644 --- a/dix/window.c +++ b/dix/window.c @@ -1059,13 +1059,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) borderRelative = TRUE; /* Note that the parent's backgroundTile's refcnt is NOT * incremented. */ } else { - rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, + rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, client, DixReadAccess); if (rc == Success) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || (pPixmap->drawable.pScreen != pScreen)) { @@ -1119,13 +1119,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) } else { pixID = pWin->parent->border.pixmap->drawable.id; } } - rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, + rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, client, DixReadAccess); if (rc == Success) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || (pPixmap->drawable.pScreen != pScreen)) { @@ -1281,13 +1281,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) } if (cmap == None) { error = BadMatch; goto PatchUp; } - rc = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP, + rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP, client, DixUseAccess); if (rc != Success) { error = (rc == BadValue) ? BadColor : rc; client->errorValue = cmap; goto PatchUp; @@ -1357,13 +1357,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) pCursor = rootCursor; else pCursor = (CursorPtr) None; } else { - rc = dixLookupResource((pointer *)&pCursor, cursorID, + rc = dixLookupResourceByType((pointer *)&pCursor, cursorID, RT_CURSOR, client, DixUseAccess); if (rc != Success) { error = (rc == BadValue) ? BadCursor : rc; client->errorValue = cursorID; goto PatchUp; diff --git a/include/resource.h b/include/resource.h index cb6e0644a..774f81b56 100644 --- a/include/resource.h +++ b/include/resource.h @@ -215,19 +215,26 @@ extern _X_EXPORT Bool LegalNewID( extern _X_EXPORT pointer LookupClientResourceComplex( ClientPtr client, RESTYPE type, FindComplexResType func, pointer cdata); -extern _X_EXPORT int dixLookupResource( +extern _X_EXPORT int dixLookupResourceByType( pointer *result, XID id, RESTYPE rtype, ClientPtr client, Mask access_mode); +extern _X_EXPORT int dixLookupResourceByClass( + pointer *result, + XID id, + RESTYPE rclass, + ClientPtr client, + Mask access_mode); + extern _X_EXPORT void GetXIDRange( int /*client*/, Bool /*server*/, XID * /*minp*/, XID * /*maxp*/); @@ -241,32 +248,46 @@ extern _X_EXPORT RESTYPE TypeMask; /* * These are deprecated compatibility functions and will be removed soon! * Please use the noted replacements instead. */ -/* replaced by dixLookupResource */ +#ifdef __GNUC__ +#define X_DEPRECATED __attribute__((deprecated)) +#else +#define X_DEPRECATED +#endif + +/* replaced by dixLookupResourceByType or dixLookupResourceByClass */ +extern int dixLookupResource( + pointer *result, + XID id, + RESTYPE rtype, + ClientPtr client, + Mask access_mode) X_DEPRECATED; + +/* replaced by dixLookupResourceByType */ extern _X_EXPORT pointer SecurityLookupIDByType( ClientPtr client, XID id, RESTYPE rtype, - Mask access_mode); + Mask access_mode) X_DEPRECATED; -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByClass */ extern _X_EXPORT pointer SecurityLookupIDByClass( ClientPtr client, XID id, RESTYPE classes, - Mask access_mode); + Mask access_mode) X_DEPRECATED; -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByType */ extern _X_EXPORT pointer LookupIDByType( XID id, - RESTYPE rtype); + RESTYPE rtype) X_DEPRECATED; -/* replaced by dixLookupResource */ +/* replaced by dixLookupResourceByClass */ extern _X_EXPORT pointer LookupIDByClass( XID id, - RESTYPE classes); + RESTYPE classes) X_DEPRECATED; #endif /* RESOURCE_H */ diff --git a/render/picture.c b/render/picture.c index f99c53f86..462125f05 100644 --- a/render/picture.c +++ b/render/picture.c @@ -1067,13 +1067,13 @@ ChangePicture (PicturePtr pPicture, Picture pid = NEXT_VAL(Picture); if (pid == None) pAlpha = 0; else { - error = dixLookupResource((pointer *)&pAlpha, pid, + error = dixLookupResourceByType((pointer *)&pAlpha, pid, PictureType, client, DixReadAccess); if (error != Success) { client->errorValue = pid; error = (error == BadValue) ? BadPixmap : error; @@ -1128,13 +1128,13 @@ ChangePicture (PicturePtr pPicture, clipType = CT_NONE; pPixmap = NullPixmap; } else { clipType = CT_PIXMAP; - error = dixLookupResource((pointer *)&pPixmap, pid, + error = dixLookupResourceByType((pointer *)&pPixmap, pid, RT_PIXMAP, client, DixReadAccess); if (error != Success) { client->errorValue = pid; error = (error == BadValue) ? BadPixmap : error; diff --git a/render/render.c b/render/render.c index abd0a68fa..270b8fb29 100644 --- a/render/render.c +++ b/render/render.c @@ -1005,13 +1005,13 @@ ProcRenderReferenceGlyphSet (ClientPtr client) REQUEST(xRenderReferenceGlyphSetReq); REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); - rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType, + rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->existing, GlyphSetType, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->existing; return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } @@ -1029,13 +1029,13 @@ ProcRenderFreeGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; int rc; REQUEST(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); - rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixDestroyAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } @@ -1068,13 +1068,13 @@ ProcRenderAddGlyphs (ClientPtr client) int i, screen; PicturePtr pSrc = NULL, pDst = NULL; PixmapPtr pSrcPix = NULL, pDstPix = NULL; CARD32 component_alpha; REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + err = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixAddAccess); if (err != Success) { client->errorValue = stuff->glyphset; return (err == BadValue) ? RenderErrBase + BadGlyphSet : err; } @@ -1258,13 +1258,13 @@ ProcRenderFreeGlyphs (ClientPtr client) GlyphSetPtr glyphSet; int rc, nglyph; CARD32 *gids; CARD32 glyph; REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, + rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixRemoveAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc; } diff --git a/xfixes/cursor.c b/xfixes/cursor.c index cd3df12bc..3f2698852 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -860,13 +860,13 @@ ProcXFixesHideCursor (ClientPtr client) CursorHideCountPtr pChc; REQUEST(xXFixesHideCursorReq); int ret; REQUEST_SIZE_MATCH (xXFixesHideCursorReq); - ret = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, + ret = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (ret != Success) { client->errorValue = stuff->window; return (ret == BadValue) ? BadWindow : ret; } @@ -918,13 +918,13 @@ ProcXFixesShowCursor (ClientPtr client) CursorHideCountPtr pChc; int rc; REQUEST(xXFixesShowCursorReq); REQUEST_SIZE_MATCH (xXFixesShowCursorReq); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } diff --git a/xfixes/region.c b/xfixes/region.c index 6db787f60..966eda051 100644 --- a/xfixes/region.c +++ b/xfixes/region.c @@ -112,13 +112,13 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client) int rc; REQUEST (xXFixesCreateRegionFromBitmapReq); REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq); LEGAL_NEW_RESOURCE (stuff->region, client); - rc = dixLookupResource((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP, + rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->bitmap; return (rc == BadValue) ? BadPixmap : rc; } @@ -157,13 +157,13 @@ ProcXFixesCreateRegionFromWindow (ClientPtr client) WindowPtr pWin; int rc; REQUEST (xXFixesCreateRegionFromWindowReq); REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq); LEGAL_NEW_RESOURCE (stuff->region, client); - rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->window; return (rc == BadValue) ? BadWindow : rc; } @@ -679,13 +679,13 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client) RegionPtr pRegion; RegionPtr *pDestRegion; int rc; REQUEST(xXFixesSetWindowShapeRegionReq); REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq); - rc = dixLookupResource((pointer *)&pWin, stuff->dest, RT_WINDOW, + rc = dixLookupResourceByType((pointer *)&pWin, stuff->dest, RT_WINDOW, client, DixSetAttrAccess); if (rc != Success) { client->errorValue = stuff->dest; return (rc == BadValue) ? BadWindow : rc; } |