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.
(cherry picked from commit f8dd80d13b)

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2008-08-06 15:26:24 -07:00
parent c838a03e89
commit 1addf6fe23
21 changed files with 161 additions and 94 deletions

View File

@ -1054,7 +1054,7 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (ret == Success) if (ret == Success)
{ {
@ -1092,7 +1092,7 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (ret == Success) if (ret == Success)
{ {
@ -1186,7 +1186,7 @@ ScreenSaverSetAttributes (ClientPtr client)
break; break;
case CWColormap: case CWColormap:
cmap = (Colormap) *pVlist; cmap = (Colormap) *pVlist;
ret = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP, ret = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP,
client, DixUseAccess); client, DixUseAccess);
if (ret != Success) if (ret != Success)
{ {
@ -1210,7 +1210,7 @@ ScreenSaverSetAttributes (ClientPtr client)
} }
else else
{ {
ret = dixLookupResource((pointer *)&pCursor, cursorID, ret = dixLookupResourceByType((pointer *)&pCursor, cursorID,
RT_CURSOR, client, DixUseAccess); RT_CURSOR, client, DixUseAccess);
if (ret != Success) if (ret != Success)
{ {

View File

@ -1023,7 +1023,7 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
case ClientStateRunning: case ClientStateRunning:
state->authId = AuthorizationIDOfClient(pci->client); state->authId = AuthorizationIDOfClient(pci->client);
rc = dixLookupResource((pointer *)&pAuth, state->authId, rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient, SecurityAuthorizationResType, serverClient,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == Success) { if (rc == Success) {
@ -1038,7 +1038,7 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
case ClientStateGone: case ClientStateGone:
case ClientStateRetained: case ClientStateRetained:
rc = dixLookupResource((pointer *)&pAuth, state->authId, rc = dixLookupResourceByType((pointer *)&pAuth, state->authId,
SecurityAuthorizationResType, serverClient, SecurityAuthorizationResType, serverClient,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == Success) { if (rc == Success) {

View File

@ -428,7 +428,7 @@ ProcShapeMask (client)
if (stuff->src == None) if (stuff->src == None)
srcRgn = 0; srcRgn = 0;
else { else {
rc = dixLookupResource((pointer *)&pPixmap, stuff->src, RT_PIXMAP, rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->src, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (rc != Success) if (rc != Success)
return (rc == BadValue) ? BadPixmap : rc; return (rc == BadValue) ? BadPixmap : rc;

View File

@ -440,7 +440,7 @@ SyncInitTrigger(client, pTrigger, counter, changes)
{ {
if (counter == None) if (counter == None)
pCounter = NULL; pCounter = NULL;
else if (Success != (rc = dixLookupResource((pointer *)&pCounter, else if (Success != (rc = dixLookupResourceByType ((pointer *)&pCounter,
counter, RTCounter, client, DixReadAccess))) counter, RTCounter, client, DixReadAccess)))
{ {
client->errorValue = counter; client->errorValue = counter;

View File

@ -557,7 +557,7 @@ SELinuxLabelInitial(void)
SELinuxScreen(NULL, NULL, &srec); SELinuxScreen(NULL, NULL, &srec);
/* Do the default colormap */ /* Do the default colormap */
dixLookupResource(&unused, screenInfo.screens[i]->defColormap, dixLookupResourceByType(&unused, screenInfo.screens[i]->defColormap,
RT_COLORMAP, serverClient, DixCreateAccess); RT_COLORMAP, serverClient, DixCreateAccess);
} }
} }

View File

@ -124,7 +124,7 @@ ProcXTestCompareCursor(client)
else if (stuff->cursor == XTestCurrentCursor) else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor(ptr); pCursor = GetSpriteCursor(ptr);
else { else {
rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixReadAccess); client, DixReadAccess);
if (rc != Success) if (rc != Success)
{ {
@ -158,7 +158,7 @@ ProcXTestFakeInput(client)
int numValuators = 0; int numValuators = 0;
int firstValuator = 0; int firstValuator = 0;
EventListPtr events; EventListPtr events;
int nevents; int nevents = 0;
int i; int i;
int base = 0; int base = 0;
int flags = 0; int flags = 0;

View File

@ -1349,7 +1349,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
if (rcursor == None) if (rcursor == None)
cursor = NullCursor; cursor = NullCursor;
else { else {
rc = dixLookupResource((pointer *)&cursor, rcursor, RT_CURSOR, rc = dixLookupResourceByType((pointer *)&cursor, rcursor, RT_CURSOR,
client, DixUseAccess); client, DixUseAccess);
if (rc != Success) if (rc != Success)
{ {

View File

@ -144,7 +144,7 @@ ProcCompositeRedirectWindow (ClientPtr client)
REQUEST(xCompositeRedirectWindowReq); REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(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); DixSetAttrAccess|DixManageAccess|DixBlendAccess);
if (rc != Success) if (rc != Success)
{ {
@ -162,7 +162,7 @@ ProcCompositeRedirectSubwindows (ClientPtr client)
REQUEST(xCompositeRedirectSubwindowsReq); REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(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); DixSetAttrAccess|DixManageAccess|DixBlendAccess);
if (rc != Success) if (rc != Success)
{ {
@ -214,7 +214,7 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
REQUEST(xCompositeCreateRegionFromBorderClipReq); REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
{ {
@ -250,7 +250,7 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
REQUEST(xCompositeNameWindowPixmapReq); REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
{ {
@ -298,7 +298,7 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
int rc; int rc;
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client, rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc != Success) if (rc != Success)
{ {

View File

@ -298,14 +298,14 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
GlyphSharePtr pShare; GlyphSharePtr pShare;
DeviceIntPtr pDev; DeviceIntPtr pDev;
rc = dixLookupResource((pointer *)&sourcefont, source, RT_FONT, client, rc = dixLookupResourceByType((pointer *)&sourcefont, source, RT_FONT, client,
DixUseAccess); DixUseAccess);
if (rc != Success) if (rc != Success)
{ {
client->errorValue = source; client->errorValue = source;
return (rc == BadValue) ? BadFont : rc; return (rc == BadValue) ? BadFont : rc;
} }
rc = dixLookupResource((pointer *)&maskfont, mask, RT_FONT, client, rc = dixLookupResourceByType((pointer *)&maskfont, mask, RT_FONT, client,
DixUseAccess); DixUseAccess);
if (rc != Success && mask != None) if (rc != Success && mask != None)
{ {

View File

@ -115,48 +115,66 @@ LookupClient(XID id, ClientPtr client)
return (i == Success) ? pClient : NULL; return (i == Success) ? pClient : NULL;
} }
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByType */
_X_EXPORT pointer _X_EXPORT pointer
SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
Mask access_mode) Mask access_mode)
{ {
pointer retval; pointer retval;
int i = dixLookupResource(&retval, id, rtype, client, access_mode); int i = dixLookupResourceByType(&retval, id, rtype, client, access_mode);
static int warn = 1; static int warn = 1;
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() " ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupResource().\n"); "to use dixLookupResourceByType().\n");
return (i == Success) ? retval : NULL; return (i == Success) ? retval : NULL;
} }
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByClass */
_X_EXPORT pointer _X_EXPORT pointer
SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
Mask access_mode) Mask access_mode)
{ {
pointer retval; pointer retval;
int i = dixLookupResource(&retval, id, classes, client, access_mode); int i = dixLookupResourceByClass(&retval, id, classes, client, access_mode);
static int warn = 1; static int warn = 1;
if (warn > 0 && --warn) if (warn > 0 && --warn)
ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() " ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
"are deprecated. Please convert your driver/module " "are deprecated. Please convert your driver/module "
"to use dixLookupResource().\n"); "to use dixLookupResourceByClass().\n");
return (i == Success) ? retval : NULL; return (i == Success) ? retval : NULL;
} }
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByType */
_X_EXPORT pointer _X_EXPORT pointer
LookupIDByType(XID id, RESTYPE rtype) LookupIDByType(XID id, RESTYPE rtype)
{ {
return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess); return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess);
} }
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByClass */
_X_EXPORT pointer _X_EXPORT pointer
LookupIDByClass(XID id, RESTYPE classes) LookupIDByClass(XID id, RESTYPE classes)
{ {
return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess); 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 */ /* end deprecated functions */

View File

@ -1119,10 +1119,10 @@ ProcQueryFont(ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
client->errorValue = stuff->id; /* EITHER font or gc */ client->errorValue = stuff->id; /* EITHER font or gc */
rc = dixLookupResource((pointer *)&pFont, stuff->id, RT_FONT, client, rc = dixLookupResourceByType((pointer *)&pFont, stuff->id, RT_FONT, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == BadValue) { if (rc == BadValue) {
rc = dixLookupResource((pointer *)&pGC, stuff->id, RT_GC, client, rc = dixLookupResourceByType((pointer *)&pGC, stuff->id, RT_GC, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == Success) if (rc == Success)
pFont = pGC->font; pFont = pGC->font;
@ -1177,10 +1177,10 @@ ProcQueryTextExtents(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
client->errorValue = stuff->fid; /* EITHER font or gc */ client->errorValue = stuff->fid; /* EITHER font or gc */
rc = dixLookupResource((pointer *)&pFont, stuff->fid, RT_FONT, client, rc = dixLookupResourceByType((pointer *)&pFont, stuff->fid, RT_FONT, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == BadValue) { if (rc == BadValue) {
rc = dixLookupResource((pointer *)&pGC, stuff->fid, RT_GC, client, rc = dixLookupResourceByType((pointer *)&pGC, stuff->fid, RT_GC, client,
DixGetAttrAccess); DixGetAttrAccess);
if (rc == Success) if (rc == Success)
pFont = pGC->font; pFont = pGC->font;
@ -1325,7 +1325,7 @@ ProcFreePixmap(ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pMap, stuff->id, RT_PIXMAP, client, rc = dixLookupResourceByType((pointer *)&pMap, stuff->id, RT_PIXMAP, client,
DixDestroyAccess); DixDestroyAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2271,7 +2271,7 @@ ProcFreeColormap(ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pmap, stuff->id, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
DixDestroyAccess); DixDestroyAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2299,7 +2299,7 @@ ProcCopyColormapAndFree(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
mid = stuff->mid; mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client); LEGAL_NEW_RESOURCE(mid, client);
rc = dixLookupResource((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP, rc = dixLookupResourceByType((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
client, DixReadAccess|DixRemoveAccess); client, DixReadAccess|DixRemoveAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2324,7 +2324,7 @@ ProcInstallColormap(ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
DixInstallAccess); DixInstallAccess);
if (rc != Success) if (rc != Success)
goto out; goto out;
@ -2349,7 +2349,7 @@ ProcUninstallColormap(ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
DixUninstallAccess); DixUninstallAccess);
if (rc != Success) if (rc != Success)
goto out; goto out;
@ -2416,7 +2416,7 @@ ProcAllocColor (ClientPtr client)
REQUEST(xAllocColorReq); REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResource((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
DixAddAccess); DixAddAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2457,7 +2457,7 @@ ProcAllocNamedColor (ClientPtr client)
REQUEST(xAllocNamedColorReq); REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); 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); DixAddAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2508,7 +2508,7 @@ ProcAllocColorCells (ClientPtr client)
REQUEST(xAllocColorCellsReq); REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq); REQUEST_SIZE_MATCH(xAllocColorCellsReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixAddAccess); DixAddAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2575,7 +2575,7 @@ ProcAllocColorPlanes(ClientPtr client)
REQUEST(xAllocColorPlanesReq); REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq); REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client, rc = dixLookupResourceByType((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
DixAddAccess); DixAddAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2640,7 +2640,7 @@ ProcFreeColors(ClientPtr client)
REQUEST(xFreeColorsReq); REQUEST(xFreeColorsReq);
REQUEST_AT_LEAST_SIZE(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); DixRemoveAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2675,7 +2675,7 @@ ProcStoreColors (ClientPtr client)
REQUEST(xStoreColorsReq); REQUEST(xStoreColorsReq);
REQUEST_AT_LEAST_SIZE(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); DixWriteAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2709,7 +2709,7 @@ ProcStoreNamedColor (ClientPtr client)
REQUEST(xStoreNamedColorReq); REQUEST(xStoreNamedColorReq);
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); 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); DixWriteAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2743,7 +2743,7 @@ ProcQueryColors(ClientPtr client)
REQUEST(xQueryColorsReq); REQUEST(xQueryColorsReq);
REQUEST_AT_LEAST_SIZE(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); DixReadAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2795,7 +2795,7 @@ ProcLookupColor(ClientPtr client)
REQUEST(xLookupColorReq); REQUEST(xLookupColorReq);
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); 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); DixReadAccess);
if (rc == Success) if (rc == Success)
{ {
@ -2844,14 +2844,14 @@ ProcCreateCursor (ClientPtr client)
REQUEST_SIZE_MATCH(xCreateCursorReq); REQUEST_SIZE_MATCH(xCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client); 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); DixReadAccess);
if (rc != Success) { if (rc != Success) {
client->errorValue = stuff->source; client->errorValue = stuff->source;
return (rc == BadValue) ? BadPixmap : rc; return (rc == BadValue) ? BadPixmap : rc;
} }
rc = dixLookupResource((pointer *)&msk, stuff->mask, RT_PIXMAP, client, rc = dixLookupResourceByType((pointer *)&msk, stuff->mask, RT_PIXMAP, client,
DixReadAccess); DixReadAccess);
if (rc != Success) if (rc != Success)
{ {
@ -2949,7 +2949,7 @@ ProcFreeCursor (ClientPtr client)
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupResource((pointer *)&pCursor, stuff->id, RT_CURSOR, client, rc = dixLookupResourceByType((pointer *)&pCursor, stuff->id, RT_CURSOR, client,
DixDestroyAccess); DixDestroyAccess);
if (rc == Success) if (rc == Success)
{ {

View File

@ -216,7 +216,7 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
if (id == INVALID) if (id == INVALID)
return BadDrawable; return BadDrawable;
rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access); rc = dixLookupResourceByClass((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
if (rc == BadValue) if (rc == BadValue)
return BadDrawable; return BadDrawable;
@ -259,7 +259,7 @@ dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT)) if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT))
goto bad; goto bad;
rc = dixLookupResource(&pRes, rid, RC_ANY, client, DixGetAttrAccess); rc = dixLookupResourceByClass(&pRes, rid, RC_ANY, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
goto bad; goto bad;

View File

@ -4445,7 +4445,7 @@ ProcGrabPointer(ClientPtr client)
cursor = NullCursor; cursor = NullCursor;
else else
{ {
rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR, rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR,
client, DixUseAccess); client, DixUseAccess);
if (rc != Success) if (rc != Success)
{ {
@ -4545,7 +4545,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
newCursor = NullCursor; newCursor = NullCursor;
else else
{ {
int rc = dixLookupResource((pointer *)&newCursor, stuff->cursor, int rc = dixLookupResourceByType((pointer *)&newCursor, stuff->cursor,
RT_CURSOR, client, DixUseAccess); RT_CURSOR, client, DixUseAccess);
if (rc != Success) if (rc != Success)
{ {
@ -5146,7 +5146,7 @@ ProcGrabButton(ClientPtr client)
cursor = NullCursor; cursor = NullCursor;
else else
{ {
rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR, rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR,
client, DixUseAccess); client, DixUseAccess);
if (rc != Success) if (rc != Success)
if (!cursor) if (!cursor)
@ -5396,7 +5396,7 @@ ProcRecolorCursor(ClientPtr client)
REQUEST(xRecolorCursorReq); REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq); REQUEST_SIZE_MATCH(xRecolorCursorReq);
rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
client, DixWriteAccess); client, DixWriteAccess);
if (rc != Success) if (rc != Success)
{ {

View File

@ -273,7 +273,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else else
{ {
NEXTVAL(XID, newpix); NEXTVAL(XID, newpix);
rc = dixLookupResource((pointer *)&pPixmap, newpix, rc = dixLookupResourceByType((pointer *)&pPixmap, newpix,
RT_PIXMAP, client, DixReadAccess); RT_PIXMAP, client, DixReadAccess);
} }
if (rc == Success) if (rc == Success)
@ -310,7 +310,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else else
{ {
NEXTVAL(XID, newstipple) NEXTVAL(XID, newstipple)
rc = dixLookupResource((pointer *)&pPixmap, newstipple, rc = dixLookupResourceByType((pointer *)&pPixmap, newstipple,
RT_PIXMAP, client, DixReadAccess); RT_PIXMAP, client, DixReadAccess);
} }
if (rc == Success) if (rc == Success)
@ -353,7 +353,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else else
{ {
NEXTVAL(XID, newfont) NEXTVAL(XID, newfont)
rc = dixLookupResource((pointer *)&pFont, newfont, rc = dixLookupResourceByType((pointer *)&pFont, newfont,
RT_FONT, client, DixUseAccess); RT_FONT, client, DixUseAccess);
} }
if (rc == Success) if (rc == Success)
@ -420,7 +420,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
pPixmap = NullPixmap; pPixmap = NullPixmap;
} }
else { else {
rc = dixLookupResource((pointer *)&pPixmap, pid, rc = dixLookupResourceByType((pointer *)&pPixmap, pid,
RT_PIXMAP, client, RT_PIXMAP, client,
DixReadAccess); DixReadAccess);
if (rc != Success) { if (rc != Success) {

View File

@ -846,11 +846,10 @@ LegalNewID(XID id, ClientPtr client)
} }
_X_EXPORT int _X_EXPORT int
dixLookupResource(pointer *result, XID id, RESTYPE rtype, dixLookupResourceByType(pointer *result, XID id, RESTYPE rtype,
ClientPtr client, Mask mode) ClientPtr client, Mask mode)
{ {
int cid = CLIENT_ID(id); int cid = CLIENT_ID(id);
int istype = (rtype & TypeMask) && (rtype != RC_ANY);
ResourcePtr res = NULL; ResourcePtr res = NULL;
*result = NULL; *result = NULL;
@ -859,8 +858,38 @@ dixLookupResource(pointer *result, XID id, RESTYPE rtype,
res = clientTable[cid].resources[Hash(cid, id)]; res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next) for (; res; res = res->next)
if ((res->id == id) && ((istype && res->type == rtype) || if (res->id == id && res->type == rtype)
(!istype && 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;
}
_X_EXPORT 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; break;
} }
if (!res) if (!res)

View File

@ -1068,7 +1068,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
} }
else else
{ {
rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (rc == Success) if (rc == Success)
{ {
@ -1128,7 +1128,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
pixID = pWin->parent->border.pixmap->drawable.id; pixID = pWin->parent->border.pixmap->drawable.id;
} }
} }
rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP, rc = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (rc == Success) if (rc == Success)
{ {
@ -1290,7 +1290,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
error = BadMatch; error = BadMatch;
goto PatchUp; goto PatchUp;
} }
rc = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP, rc = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP,
client, DixUseAccess); client, DixUseAccess);
if (rc != Success) if (rc != Success)
{ {
@ -1366,7 +1366,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
} }
else else
{ {
rc = dixLookupResource((pointer *)&pCursor, cursorID, rc = dixLookupResourceByType((pointer *)&pCursor, cursorID,
RT_CURSOR, client, DixUseAccess); RT_CURSOR, client, DixUseAccess);
if (rc != Success) if (rc != Success)
{ {

View File

@ -218,13 +218,20 @@ extern pointer LookupClientResourceComplex(
FindComplexResType func, FindComplexResType func,
pointer cdata); pointer cdata);
extern int dixLookupResource( extern int dixLookupResourceByType(
pointer *result, pointer *result,
XID id, XID id,
RESTYPE rtype, RESTYPE rtype,
ClientPtr client, ClientPtr client,
Mask access_mode); Mask access_mode);
extern int dixLookupResourceByClass(
pointer *result,
XID id,
RESTYPE rclass,
ClientPtr client,
Mask access_mode);
extern void GetXIDRange( extern void GetXIDRange(
int /*client*/, int /*client*/,
Bool /*server*/, Bool /*server*/,
@ -244,29 +251,42 @@ extern RESTYPE TypeMask;
* Please use the noted replacements instead. * 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;
extern pointer SecurityLookupIDByType( extern pointer SecurityLookupIDByType(
ClientPtr client, ClientPtr client,
XID id, XID id,
RESTYPE rtype, RESTYPE rtype,
Mask access_mode); Mask access_mode) X_DEPRECATED;
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByClass */
extern pointer SecurityLookupIDByClass( extern pointer SecurityLookupIDByClass(
ClientPtr client, ClientPtr client,
XID id, XID id,
RESTYPE classes, RESTYPE classes,
Mask access_mode); Mask access_mode) X_DEPRECATED;
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByType */
extern pointer LookupIDByType( extern pointer LookupIDByType(
XID id, XID id,
RESTYPE rtype); RESTYPE rtype) X_DEPRECATED;
/* replaced by dixLookupResource */ /* replaced by dixLookupResourceByClass */
extern pointer LookupIDByClass( extern pointer LookupIDByClass(
XID id, XID id,
RESTYPE classes); RESTYPE classes) X_DEPRECATED;
#endif /* RESOURCE_H */ #endif /* RESOURCE_H */

View File

@ -1070,7 +1070,7 @@ ChangePicture (PicturePtr pPicture,
pAlpha = 0; pAlpha = 0;
else else
{ {
error = dixLookupResource((pointer *)&pAlpha, pid, error = dixLookupResourceByType((pointer *)&pAlpha, pid,
PictureType, client, PictureType, client,
DixReadAccess); DixReadAccess);
if (error != Success) if (error != Success)
@ -1131,7 +1131,7 @@ ChangePicture (PicturePtr pPicture,
else else
{ {
clipType = CT_PIXMAP; clipType = CT_PIXMAP;
error = dixLookupResource((pointer *)&pPixmap, pid, error = dixLookupResourceByType((pointer *)&pPixmap, pid,
RT_PIXMAP, client, RT_PIXMAP, client,
DixReadAccess); DixReadAccess);
if (error != Success) if (error != Success)

View File

@ -1009,7 +1009,7 @@ ProcRenderReferenceGlyphSet (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->gsid, client); LEGAL_NEW_RESOURCE(stuff->gsid, client);
rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType, rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->existing, GlyphSetType,
client, DixGetAttrAccess); client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
{ {
@ -1033,7 +1033,7 @@ ProcRenderFreeGlyphSet (ClientPtr client)
REQUEST(xRenderFreeGlyphSetReq); REQUEST(xRenderFreeGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixDestroyAccess); client, DixDestroyAccess);
if (rc != Success) if (rc != Success)
{ {
@ -1072,7 +1072,7 @@ ProcRenderAddGlyphs (ClientPtr client)
CARD32 component_alpha; CARD32 component_alpha;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, err = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixAddAccess); client, DixAddAccess);
if (err != Success) if (err != Success)
{ {
@ -1262,7 +1262,7 @@ ProcRenderFreeGlyphs (ClientPtr client)
CARD32 glyph; CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
client, DixRemoveAccess); client, DixRemoveAccess);
if (rc != Success) if (rc != Success)
{ {

View File

@ -863,7 +863,7 @@ ProcXFixesHideCursor (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesHideCursorReq); REQUEST_SIZE_MATCH (xXFixesHideCursorReq);
ret = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, ret = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess); client, DixGetAttrAccess);
if (ret != Success) { if (ret != Success) {
client->errorValue = stuff->window; client->errorValue = stuff->window;
@ -921,7 +921,7 @@ ProcXFixesShowCursor (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesShowCursorReq); REQUEST_SIZE_MATCH (xXFixesShowCursorReq);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess); client, DixGetAttrAccess);
if (rc != Success) { if (rc != Success) {
client->errorValue = stuff->window; client->errorValue = stuff->window;

View File

@ -115,7 +115,7 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq); REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE (stuff->region, client); LEGAL_NEW_RESOURCE (stuff->region, client);
rc = dixLookupResource((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP, rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP,
client, DixReadAccess); client, DixReadAccess);
if (rc != Success) if (rc != Success)
{ {
@ -160,7 +160,7 @@ ProcXFixesCreateRegionFromWindow (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq); REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE (stuff->region, client); LEGAL_NEW_RESOURCE (stuff->region, client);
rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess); client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
{ {
@ -682,7 +682,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
REQUEST(xXFixesSetWindowShapeRegionReq); REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq); REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
rc = dixLookupResource((pointer *)&pWin, stuff->dest, RT_WINDOW, rc = dixLookupResourceByType((pointer *)&pWin, stuff->dest, RT_WINDOW,
client, DixSetAttrAccess); client, DixSetAttrAccess);
if (rc != Success) if (rc != Success)
{ {