aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/dixfonts.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-09 05:23:48 +0000
committermarha <marha@users.sourceforge.net>2009-09-09 05:23:48 +0000
commit81f91c615982e50bb62708201569c33a3cd3d973 (patch)
tree4f32ecc48a3b7b5e76642f3792338263c53879bd /xorg-server/dix/dixfonts.c
parentb571a562410f565af2bdde52d9f7f9a23ffae04f (diff)
parenta915739887477b28d924ecc8417ee107d125bd6c (diff)
downloadvcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.gz
vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.bz2
vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.zip
svn merge https://vcxsrv.svn.sourceforge.net/svnroot/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/dix/dixfonts.c')
-rw-r--r--xorg-server/dix/dixfonts.c130
1 files changed, 63 insertions, 67 deletions
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index 02f9d6de8..527060486 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -48,7 +48,6 @@ Equipment Corporation.
******************************************************************/
-#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -71,10 +70,6 @@ Equipment Corporation.
#include <stdio.h>
#endif
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#endif
-
#ifdef XF86BIGFONT
#define _XF86BIGFONT_SERVER_
#include <X11/extensions/xf86bigfont.h>
@@ -143,8 +138,9 @@ SetDefaultFont(char *defaultfontname)
(unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success)
return FALSE;
- pf = (FontPtr) LookupIDByType(fid, RT_FONT);
- if (pf != (FontPtr) NULL) last_pf = pf;
+ err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
+ DixReadAccess);
+ if (err == Success) last_pf = pf;
if (last_pf == (FontPtr) NULL)
return FALSE;
defaultFont = last_pf;
@@ -400,7 +396,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna
#ifdef FONTDEBUG
char *f;
- f = (char *)xalloc(lenfname + 1);
+ f = xalloc(lenfname + 1);
memmove(f, pfontname, lenfname);
f[lenfname] = '\0';
ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
@@ -437,10 +433,10 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna
return Success;
}
}
- c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
+ c = xalloc(sizeof(OFclosureRec));
if (!c)
return BadAlloc;
- c->fontname = (char *) xalloc(lenfname);
+ c->fontname = xalloc(lenfname);
c->origFontName = pfontname;
c->origFontNameLen = lenfname;
if (!c->fontname) {
@@ -451,8 +447,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna
* copy the current FPE list, so that if it gets changed by another client
* while we're blocking, the request still appears atomic
*/
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xalloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list) {
xfree(c->fontname);
xfree(c);
@@ -686,7 +681,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
}
if (err == FontNameAlias) {
if (resolved) xfree(resolved);
- resolved = (char *) xalloc(resolvedlen + 1);
+ resolved = xalloc(resolvedlen + 1);
if (resolved)
memmove(resolved, tmpname, resolvedlen + 1);
}
@@ -741,7 +736,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
c->haveSaved = TRUE;
if (c->savedName)
xfree(c->savedName);
- c->savedName = (char *)xalloc(namelen + 1);
+ c->savedName = xalloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
c->savedNameLen = namelen;
@@ -797,12 +792,13 @@ finish:
for (i = 0; i < nnames; i++)
stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
+ memset(&reply, 0, sizeof(xListFontsReply));
reply.type = X_Reply;
- reply.length = (stringLens + nnames + 3) >> 2;
+ reply.length = bytes_to_int32(stringLens + nnames);
reply.nFonts = nnames;
reply.sequenceNumber = client->sequence;
- bufptr = bufferStart = (char *) xalloc(reply.length << 2);
+ bufptr = bufferStart = xalloc(reply.length << 2);
if (!bufptr && reply.length) {
SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
@@ -823,7 +819,7 @@ finish:
}
}
nnames = reply.nFonts;
- reply.length = (stringLens + nnames + 3) >> 2;
+ reply.length = bytes_to_int32(stringLens + nnames);
client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
(void) WriteToClient(client, stringLens + nnames, bufferStart);
@@ -862,10 +858,9 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
if (i != Success)
return i;
- if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
+ if (!(c = xalloc(sizeof *c)))
return BadAlloc;
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xalloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list) {
xfree(c);
return BadAlloc;
@@ -1004,7 +999,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
c->savedNumFonts = numFonts;
if (c->savedName)
xfree(c->savedName);
- c->savedName = (char *)xalloc(namelen + 1);
+ c->savedName = xalloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
aliascount = 20;
@@ -1053,6 +1048,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
err = AllocError;
break;
}
+ memset(reply + c->length, 0, length - c->length);
c->reply = reply;
c->length = length;
}
@@ -1063,9 +1059,9 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
namelen = strlen(name);
}
reply->type = X_Reply;
- reply->length = (sizeof *reply - sizeof(xGenericReply) +
+ reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
pFontInfo->nprops * sizeof(xFontProp) +
- namelen + 3) >> 2;
+ namelen);
reply->sequenceNumber = client->sequence;
reply->nameLength = namelen;
reply->minBounds = pFontInfo->ink_minbounds;
@@ -1103,8 +1099,8 @@ finish:
bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
finalReply.type = X_Reply;
finalReply.sequenceNumber = client->sequence;
- finalReply.length = (sizeof(xListFontsWithInfoReply)
- - sizeof(xGenericReply)) >> 2;
+ finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply));
WriteSwappedDataToClient(client, length, &finalReply);
bail:
if (c->slept)
@@ -1138,10 +1134,9 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
if (i != Success)
return i;
- if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
+ if (!(c = xalloc(sizeof *c)))
goto badAlloc;
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xalloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list)
{
xfree(c);
@@ -1209,17 +1204,18 @@ doPolyText(ClientPtr client, PTclosurePtr c)
}
/* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, DixWriteAccess))
+ if (c->slept && c->pDraw)
{
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client and avoid further
- rendering while we clean up after ourself. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- c->pDraw = (DrawablePtr)0;
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
}
client_state = c->slept ? SLEEPING : NEVER_SLEPT;
@@ -1241,12 +1237,11 @@ doPolyText(ClientPtr client, PTclosurePtr c)
| ((Font)*(c->pElt+3)) << 8
| ((Font)*(c->pElt+2)) << 16
| ((Font)*(c->pElt+1)) << 24;
- pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
- DixReadAccess);
- if (!pFont)
+ err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
+ client, DixReadAccess);
+ if (err != Success)
{
- client->errorValue = fid;
- err = BadFont;
+ err = (err == BadValue) ? BadFont : err;
/* restore pFont and fid for step 4 (described below) */
pFont = oldpFont;
fid = oldfid;
@@ -1328,7 +1323,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
/* Step 1 */
/* Allocate a malloc'd closure structure to replace
the local one we were passed */
- new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
+ new_closure = xalloc(sizeof(PTclosureRec));
if (!new_closure)
{
err = BadAlloc;
@@ -1338,7 +1333,7 @@ doPolyText(ClientPtr client, PTclosurePtr c)
c = new_closure;
len = c->endReq - c->pElt;
- c->data = (unsigned char *)xalloc(len);
+ c->data = xalloc(len);
if (!c->data)
{
xfree(c);
@@ -1494,17 +1489,18 @@ doImageText(ClientPtr client, ITclosurePtr c)
}
/* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, DixWriteAccess))
+ if (c->slept && c->pDraw)
{
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
}
lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
@@ -1520,7 +1516,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
in doPolyText, but much simpler because the
request structure is much simpler. */
- new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
+ new_closure = xalloc(sizeof(ITclosureRec));
if (!new_closure)
{
err = BadAlloc;
@@ -1529,7 +1525,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
*new_closure = *c;
c = new_closure;
- data = (unsigned char *)xalloc(c->nChars * c->itemSize);
+ data = xalloc(c->nChars * c->itemSize);
if (!data)
{
xfree(c);
@@ -1666,7 +1662,7 @@ FreeFontPath(FontPathElementPtr *list, int n, Bool force)
}
FreeFPE(list[i]);
}
- xfree((char *) list);
+ xfree(list);
}
static FontPathElementPtr
@@ -1693,8 +1689,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
unsigned char *cp = paths;
FontPathElementPtr fpe = NULL, *fplist;
- fplist = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * npaths);
+ fplist = xalloc(sizeof(FontPathElementPtr) * npaths);
if (!fplist) {
*bad = 0;
return BadAlloc;
@@ -1735,13 +1730,13 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
/* if error or can't do it, act like it's a new one */
if (!fpe)
{
- fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
+ fpe = xalloc(sizeof(FontPathElementRec));
if (!fpe)
{
err = BadAlloc;
goto bail;
}
- fpe->name = (char *) xalloc(len + 1);
+ fpe->name = xalloc(len + 1);
if (!fpe->name)
{
xfree(fpe);
@@ -1829,7 +1824,7 @@ SetDefaultFontPath(char *path)
/* get enough for string, plus values -- use up commas */
len = strlen(path) + 1;
- nump = cp = newpath = (unsigned char *) xalloc(len);
+ nump = cp = newpath = xalloc(len);
if (!newpath)
return BadAlloc;
pp = (unsigned char *) path;
@@ -1915,7 +1910,7 @@ InitFonts (void)
}
int
-GetDefaultPointSize ()
+GetDefaultPointSize (void)
{
return 120;
}
@@ -2022,12 +2017,13 @@ FreeFonts(void)
FontPtr
find_old_font(XID id)
{
- return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
- DixUnknownAccess);
+ pointer pFont;
+ dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
+ return (FontPtr)pFont;
}
Font
-GetNewFontClientID()
+GetNewFontClientID(void)
{
return FakeClientID(0);
}