diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-05-31 21:26:59 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-05-31 21:26:59 +0000 |
commit | b1eab71a93cd8bf2b75ddf9f5ee320b917b60d65 (patch) | |
tree | acd89de2a51878bfa659050c04fb870c9a12253f /app/xfs/difs | |
parent | 0cb98bd993f3b94b7abf83b3568bc6a85aeba41c (diff) |
Update to xfs 1.1.3
Diffstat (limited to 'app/xfs/difs')
-rw-r--r-- | app/xfs/difs/atom.c | 4 | ||||
-rw-r--r-- | app/xfs/difs/cache.c | 382 | ||||
-rw-r--r-- | app/xfs/difs/dispatch.c | 122 | ||||
-rw-r--r-- | app/xfs/difs/events.c | 26 | ||||
-rw-r--r-- | app/xfs/difs/extensions.c | 27 | ||||
-rw-r--r-- | app/xfs/difs/fontinfo.c | 86 | ||||
-rw-r--r-- | app/xfs/difs/fonts.c | 96 | ||||
-rw-r--r-- | app/xfs/difs/main.c | 7 |
8 files changed, 174 insertions, 576 deletions
diff --git a/app/xfs/difs/atom.c b/app/xfs/difs/atom.c index 17ed085ea..00e05a58a 100644 --- a/app/xfs/difs/atom.c +++ b/app/xfs/difs/atom.c @@ -89,7 +89,7 @@ MakeAtom(const char *string, unsigned int len, Bool makeit) else if (fp > (*np)->fingerPrint) np = &((*np)->right); else { /* now start testing the strings */ - comp = strncmp(string, (*np)->string, (int) len); + comp = strncmp(string, (*np)->string, len); if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string)))) np = &((*np)->left); else if (comp > 0) @@ -115,7 +115,7 @@ MakeAtom(const char *string, unsigned int len, Bool makeit) fsfree(nd); return BAD_RESOURCE; } - strncpy(nd->string, string, (int) len); + strncpy(nd->string, string, len); nd->string[len] = 0; } if ((lastAtom + 1) >= tableLength) { diff --git a/app/xfs/difs/cache.c b/app/xfs/difs/cache.c deleted file mode 100644 index 06fca6c35..000000000 --- a/app/xfs/difs/cache.c +++ /dev/null @@ -1,382 +0,0 @@ -/* -Copyright 1987, 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 1990, 1991 Network Computing Devices; - * Portions Copyright 1987 by Digital Equipment Corporation - * - * 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, and that the names of Network Computing Devices, - * or Digital not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Network Computing Devices, or Digital - * make no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, OR DIGITAL 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. - * - */ - -#include "config.h" - -#include "cachestr.h" -#include "misc.h" - -#define INITBUCKETS 64 -#define INITHASHSIZE 6 -#define MAXHASHSIZE 11 - - -#define ENTRYOFFSET 22 -#define CACHE_ENTRY_MASK 0x3FFFFF -#define CACHE_ENTRY_BITS(id) ((id) & 0x1fc00000) -#define CACHE_ID(id) ((int)(CACHE_ENTRY_BITS(id) >> ENTRYOFFSET)) - -#define NullCacheEntry ((CacheEntryPtr) 0) - -#define MAX_NUM_CACHES 32 -/* XXX make this dynamic? */ -static CachePtr caches[MAX_NUM_CACHES]; -static int num_caches = 1; - -/*- - * Notes on cache implementation - * - * This is basically the X11 resource code, with some modifications - * to handle aging. - * - * Its currently optimized for lookup & store. Flushing old stuff - * is a lot slower than it should probably be, but there's tradeoffs - * in tuning. - */ - -Cache -CacheInit(unsigned long maxsize) -{ - Cache id = (Cache) num_caches; - CachePtr cache; - - cache = (CachePtr) fsalloc(sizeof(CacheRec)); - if (!cache) - return (Cache) 0; - cache->entries = (CacheEntryPtr *) - fsalloc(INITBUCKETS * sizeof(CacheEntryPtr)); - bzero((char *) cache->entries, (INITBUCKETS * sizeof(CacheEntryPtr))); - if (!cache->entries) { - fsfree(cache); - return (Cache) 0; - } - caches[id] = cache; - cache->elements = 0; - cache->buckets = INITBUCKETS; - cache->hashsize = INITHASHSIZE; - cache->maxsize = maxsize; - cache->cursize = 0; - cache->nextid = id << ENTRYOFFSET; - cache->id = id; - num_caches++; - return id; -} - -static int -hash(CacheID cid) -{ - CachePtr cache = caches[CACHE_ID(cid)]; - - switch (cache->hashsize) { -#ifdef DEBUG /* only need this if INITHASHSIZE < 6 */ - case 2: - return ((int) (0x03 & (cid ^ (cid >> 2) ^ (cid >> 8)))); - case 3: - return ((int) (0x07 & (cid ^ (cid >> 3) ^ (cid >> 9)))); - case 4: - return ((int) (0x0F & (cid ^ (cid >> 4) ^ (cid >> 10)))); - case 5: - return ((int) (0x01F & (cid ^ (cid >> 5) ^ (cid >> 11)))); -#endif - case 6: - return ((int) (0x03F & (cid ^ (cid >> 6) ^ (cid >> 12)))); - case 7: - return ((int) (0x07F & (cid ^ (cid >> 7) ^ (cid >> 13)))); - case 8: - return ((int) (0x0FF & (cid ^ (cid >> 8) ^ (cid >> 16)))); - case 9: - return ((int) (0x1FF & (cid ^ (cid >> 9)))); - case 10: - return ((int) (0x3FF & (cid ^ (cid >> 10)))); - case 11: - return ((int) (0x7FF & (cid ^ (cid >> 11)))); - } - return -1; -} - -static void -rebuild_cache(CachePtr cache) -{ - int j; - CacheEntryPtr cp, - next, - **tails, - *entries, - **tptr, - *cptr; - - assert(cache); - j = 2 * cache->buckets; - tails = (CacheEntryPtr **) ALLOCATE_LOCAL(j * sizeof(CacheEntryPtr *)); - if (!tails) - return; - entries = (CacheEntryPtr *) fsalloc(j * sizeof(CacheEntryPtr)); - if (!entries) { - DEALLOCATE_LOCAL(tails); - return; - } - for (cptr = entries, tptr = tails; --j >= 0; cptr++, tptr++) { - *cptr = NullCacheEntry; - *tptr = cptr; - } - cache->hashsize++; - for (j = cache->buckets, cptr = cache->entries; --j >= 0; cptr++) { - for (cp = *cptr; cp; cp = next) { - next = cp->next; - cp->next = NullCacheEntry; - tptr = &tails[hash(cp->id)]; - **tptr = cp; - *tptr = &cp->next; - } - } - DEALLOCATE_LOCAL(tails); - cache->buckets *= 2; - fsfree(cache->entries); - cache->entries = entries; -} - -/* - * throws out all existing entries - */ -void -CacheReset(void) -{ - CacheEntryPtr cp; - CachePtr cache; - int i, - j; - - for (j = 0; j < num_caches; j++) { - cache = caches[j]; - if (!cache) - continue; - for (i = 0; i < cache->buckets; i++) { - for (cp = cache->entries[i]; cp; cp = cp->next) { - cache->elements--; - cache->cursize -= cp->size; - (*cp->free_func) (cp->id, cp->data, CacheWasReset); - fsfree(cp); - } - cache->entries[i] = (CacheEntryPtr) 0; - } - assert(cache->cursize == 0); - } -} - -static void -flush_cache(CachePtr cache, unsigned long needed) -{ -/* XXX -- try to set oldprev properly inside search loop */ - CacheEntryPtr cp, - oldest, - *oldprev; - int oldbucket = -1, - i; - - while ((cache->cursize + needed) > cache->maxsize) { - oldest = (CacheEntryPtr) 0; - /* find oldest */ - for (i = 0; i < cache->buckets; i++) { - cp = cache->entries[i]; - if (!cp) - continue; - if (!oldest) { - oldbucket = i; - oldest = cp; - } - while (cp) { - if (cp->timestamp < oldest->timestamp) { - oldest = cp; - oldbucket = i; - } - cp = cp->next; - } - } - /* fixup list */ - oldprev = &cache->entries[oldbucket]; - cp = *oldprev; - for (; (cp = *oldprev) != NULL; oldprev = &cp->next) { - if (cp == oldest) { - *oldprev = oldest->next; - break; - } - } - /* clobber it */ - cache->elements--; - cache->cursize -= oldest->size; - (*oldest->free_func) (oldest->id, oldest->data, CacheEntryOld); - fsfree(oldest); - } -} - -void -CacheResize(Cache cid, unsigned newsize) -{ - CachePtr cache = caches[cid]; - - if (!cache) - return; - - if (newsize < cache->maxsize) { - /* have to toss some stuff */ - flush_cache(cache, cache->maxsize - newsize); - } - cache->maxsize = newsize; -} - -CacheID -CacheStoreMemory( - Cache cid, - pointer data, - unsigned long size, - CacheFree free_func) -{ - CacheID id; - CacheEntryPtr cp, - *head; - CachePtr cache = caches[cid]; - - if (size > cache->maxsize) /* beyond cache limits */ - return (CacheID) 0; - - if ((cache->elements >= 4 * cache->buckets) && - (cache->hashsize < MAXHASHSIZE)) { - rebuild_cache(cache); - } - id = cache->nextid++; - - if ((cache->cursize + size) > cache->maxsize) { - flush_cache(cache, size); - } - head = &cache->entries[hash(id)]; - cp = (CacheEntryPtr) fsalloc(sizeof(CacheEntryRec)); - if (!cp) { - return (CacheID) 0; - } - cp->next = *head; - cp->id = id; - cp->timestamp = GetTimeInMillis(); - cp->free_func = free_func; - cp->size = size; - cp->data = data; - cache->cursize += size; - cache->elements++; - *head = cp; - - return id; -} - -pointer -CacheFetchMemory( - CacheID cid, - Bool update) -{ - CachePtr cache = caches[CACHE_ID(cid)]; - CacheEntryPtr cp, - *head; - - head = &cache->entries[hash(cid)]; - for (cp = *head; cp; cp = cp->next) { - if (cp->id == cid) { - if (update) { - cp->timestamp = GetTimeInMillis(); - if (cp != *head) { /* put it in the front */ - cp->next = *head; - *head = cp; - } - } - return cp->data; - } - } - return (pointer) 0; -} - -void -CacheFreeMemory( - CacheID cid, - Bool notify) -{ - CachePtr cache = caches[CACHE_ID(cid)]; - CacheEntryPtr cp, - *prev, - *head; - int *elptr; - int elements; - Bool found = FALSE; - - head = &cache->entries[hash(cid)]; - elptr = &cache->elements; - prev = head; - while ((cp = *prev) != NullCacheEntry) { - if (cp->id == cid) { - *prev = cp->next; - elements = --*elptr; - if (notify) { - (*(cp->free_func)) (cid, cp->data, CacheEntryFreed); - } - cache->cursize -= cp->size; - fsfree(cp); - if (*elptr != elements) - prev = head; - found = TRUE; - } else { - prev = &cp->next; - } - } - if (!found) - FatalError("freeing cache entry %ld which isn't there\n", cid); -} - -/* ARGSUSED */ -void -CacheSimpleFree( - CacheID cid, - pointer data, - int reason) -{ - fsfree(data); -} diff --git a/app/xfs/difs/dispatch.c b/app/xfs/difs/dispatch.c index 8c549fa8f..6f8b2b61f 100644 --- a/app/xfs/difs/dispatch.c +++ b/app/xfs/difs/dispatch.c @@ -65,7 +65,6 @@ in this Software without prior written authorization from The Open Group. #include <X11/fonts/fontstruct.h> #include "site.h" #include "fsevents.h" -#include "cache.h" #include "globals.h" #include "difs.h" #include "access.h" @@ -168,7 +167,6 @@ Dispatch(void) /* flush all the caches */ if (dispatchException & DE_FLUSH) { NoticeF("flushing all caches\n"); - CacheReset(); dispatchException &= ~DE_FLUSH; } /* reset */ @@ -225,7 +223,6 @@ int ProcEstablishConnection(ClientPtr client) { fsConnClientPrefix *prefix; - fsConnSetup csp; int ret; pointer auth_data; char *ad; @@ -334,21 +331,23 @@ ProcEstablishConnection(ClientPtr client) SendErrToClient(client, FSBadAlloc, (pointer) 0); return FSBadAlloc; } - csp.status = auth_accept; - if (client->major_version == 1) - /* we implement backwards compatibility for version 1.0 */ - csp.major_version = client->major_version; - else - csp.major_version = FS_PROTOCOL; - csp.minor_version = FS_PROTOCOL_MINOR; - csp.num_alternates = num_alts; - csp.alternate_len = altlen; - csp.auth_len = auth_len >> 2; - csp.auth_index = auth_index; - if (client->swapped) { - WriteSConnSetup(client, &csp); - } else { - (void) WriteToClient(client, SIZEOF(fsConnSetup), (char *) &csp); + else { + fsConnSetup csp = { + .status = auth_accept, + /* we implement backwards compatibility for version 1.0 */ + .major_version = (client->major_version == 1) ? + client->major_version : FS_PROTOCOL, + .minor_version = FS_PROTOCOL_MINOR, + .num_alternates = num_alts, + .alternate_len = altlen, + .auth_len = auth_len >> 2, + .auth_index = auth_index + }; + if (client->swapped) { + WriteSConnSetup(client, &csp); + } else { + (void) WriteToClient(client, SIZEOF(fsConnSetup), (char *) &csp); + } } /* send the alternates info */ @@ -393,7 +392,14 @@ DoSendErrToClient( int error, pointer data) /* resource id, format, resolution, etc */ { - fsError rep; + fsError rep = { + .type = FS_Error, + .request = error, + .sequenceNumber = client->sequence, + .timestamp = GetTimeInMillis(), + .major_opcode = ((fsReq *) client->requestBuffer)->reqType, + .minor_opcode = MinorOpcodeOfRequest(client) + }; int extralen = 0; switch (error) { @@ -435,12 +441,6 @@ DoSendErrToClient( break; } - rep.type = FS_Error; - rep.sequenceNumber = client->sequence; - rep.request = error; - rep.major_opcode = ((fsReq *) client->requestBuffer)->reqType; - rep.minor_opcode = MinorOpcodeOfRequest(client), - rep.timestamp = GetTimeInMillis(); rep.length = (SIZEOF(fsError) + extralen) >> 2; WriteErrorToClient(client, &rep); @@ -472,7 +472,11 @@ ProcListCatalogues(ClientPtr client) int len, num; char *catalogues; - fsListCataloguesReply rep; + fsListCataloguesReply rep = { + .type = FS_Reply, + .sequenceNumber = client->sequence, + .num_replies = 0 + }; REQUEST(fsListCataloguesReq); REQUEST_AT_LEAST_SIZE(fsListCataloguesReq); @@ -480,10 +484,7 @@ ProcListCatalogues(ClientPtr client) num = ListCatalogues((char *)stuff + SIZEOF(fsListCataloguesReq), stuff->nbytes, stuff->maxNames, &catalogues, &len); - rep.type = FS_Reply; - rep.num_replies = 0; rep.num_catalogues = num; - rep.sequenceNumber = client->sequence; rep.length = (SIZEOF(fsListCataloguesReply) + len + 3) >> 2; WriteReplyToClient(client, SIZEOF(fsListCataloguesReply), &rep); @@ -534,7 +535,6 @@ ProcGetCatalogues(ClientPtr client) i, size; char *cp; - fsGetCataloguesReply rep; REQUEST(fsGetCataloguesReq); REQUEST_AT_LEAST_SIZE(fsGetCataloguesReq); @@ -546,12 +546,16 @@ ProcGetCatalogues(ClientPtr client) cp += size; } - rep.type = FS_Reply; - rep.num_catalogues = client->num_catalogues; - rep.sequenceNumber = client->sequence; - rep.length = (SIZEOF(fsGetCataloguesReply) + len + 3) >> 2; - - WriteReplyToClient(client, SIZEOF(fsGetCataloguesReply), &rep); + { + fsGetCataloguesReply rep = { + .type = FS_Reply, + .num_catalogues = client->num_catalogues, + .sequenceNumber = client->sequence, + .length = (SIZEOF(fsGetCataloguesReply) + len + 3) >> 2 + }; + + WriteReplyToClient(client, SIZEOF(fsGetCataloguesReply), &rep); + } (void) WriteToClient(client, len, client->catalogues); return client->noClientException; @@ -560,7 +564,6 @@ ProcGetCatalogues(ClientPtr client) int ProcCreateAC(ClientPtr client) { - fsCreateACReply rep; AuthPtr acp; AuthContextPtr authp; int accept, @@ -661,13 +664,17 @@ alloc_failure: return FSBadAlloc; } DEALLOCATE_LOCAL(acp); - rep.type = FS_Reply; - rep.status = accept; - rep.auth_index = index; - rep.sequenceNumber = client->sequence; - rep.length = (SIZEOF(fsCreateACReply) + size) >> 2; - - WriteReplyToClient(client, SIZEOF(fsCreateACReply), &rep); + { + fsCreateACReply rep = { + .type = FS_Reply, + .auth_index = index, + .sequenceNumber = client->sequence, + .status = accept, + .length = (SIZEOF(fsCreateACReply) + size) >> 2 + }; + + WriteReplyToClient(client, SIZEOF(fsCreateACReply), &rep); + } if (size) (void) WriteToClient(client, size, auth_data); @@ -759,8 +766,6 @@ ProcSetResolution(ClientPtr client) int ProcGetResolution(ClientPtr client) { - fsGetResolutionReply reply; - REQUEST(fsReq); REQUEST_AT_LEAST_SIZE(fsReq); @@ -771,13 +776,17 @@ ProcGetResolution(ClientPtr client) SendErrToClient(client, FSBadLength, &lengthword); return FSBadLength; } - reply.type = FS_Reply; - reply.num_resolutions = client->num_resolutions; - reply.sequenceNumber = client->sequence; - reply.length = (SIZEOF(fsGetResolutionReply) + - client->num_resolutions * SIZEOF(fsResolution)) >> 2; - - WriteReplyToClient(client, SIZEOF(fsGetResolutionReply), &reply); + else { + fsGetResolutionReply reply = { + .type = FS_Reply, + .num_resolutions = client->num_resolutions, + .sequenceNumber = client->sequence, + .length = (SIZEOF(fsGetResolutionReply) + + client->num_resolutions * SIZEOF(fsResolution)) >> 2 + }; + + WriteReplyToClient(client, SIZEOF(fsGetResolutionReply), &reply); + } if (client->swapped) client->pSwapReplyFunc = CopySwap16Write; @@ -855,7 +864,10 @@ ProcQueryXInfo(ClientPtr client) ClientFontPtr cfp; int err, lendata; - fsQueryXInfoReply reply; + fsQueryXInfoReply reply = { + .type = FS_Reply, + .sequenceNumber = client->sequence + }; fsPropInfo *prop_info; REQUEST(fsQueryXInfoReq); @@ -868,8 +880,6 @@ ProcQueryXInfo(ClientPtr client) SendErrToClient(client, FSBadFont, (pointer) &aligned_id); return FSBadFont; } - reply.type = FS_Reply; - reply.sequenceNumber = client->sequence; /* get the header */ fsPack_XFontInfoHeader(&cfp->font->info, &reply, client->major_version); diff --git a/app/xfs/difs/events.c b/app/xfs/difs/events.c index d70284290..01923b4e0 100644 --- a/app/xfs/difs/events.c +++ b/app/xfs/difs/events.c @@ -93,16 +93,16 @@ ProcSetEventMask(ClientPtr client) int ProcGetEventMask(ClientPtr client) { - fsGetEventMaskReply rep; + fsGetEventMaskReply rep = { + .type = FS_Reply, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsGetEventMaskReply) >> 2, + .event_mask = client->eventmask + }; REQUEST(fsGetEventMaskReq); REQUEST_AT_LEAST_SIZE(fsGetEventMaskReq); - rep.type = FS_Reply; - rep.sequenceNumber = client->sequence; - rep.length = SIZEOF(fsGetEventMaskReply) >> 2; - rep.event_mask = client->eventmask; - WriteReplyToClient(client, SIZEOF(fsGetEventMaskReply), &rep); return client->noClientException; } @@ -110,13 +110,13 @@ ProcGetEventMask(ClientPtr client) void SendKeepAliveEvent(ClientPtr client) { - fsKeepAliveEvent ev; - - ev.type = FS_Event; - ev.event_code = KeepAlive; - ev.sequenceNumber = client->sequence; - ev.length = SIZEOF(fsKeepAliveEvent) >> 2; - ev.timestamp = GetTimeInMillis(); + fsKeepAliveEvent ev = { + .type = FS_Event, + .event_code = KeepAlive, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsKeepAliveEvent) >> 2, + .timestamp = GetTimeInMillis() + }; #ifdef DEBUG fprintf(stderr, "client #%d is getting a KeepAlive\n", client->index); diff --git a/app/xfs/difs/extensions.c b/app/xfs/difs/extensions.c index 86ce68e42..eb31e766d 100644 --- a/app/xfs/difs/extensions.c +++ b/app/xfs/difs/extensions.c @@ -201,7 +201,12 @@ InitExtensions(void) int ProcQueryExtension(ClientPtr client) { - fsQueryExtensionReply reply; + fsQueryExtensionReply reply = { + .type = FS_Reply, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsQueryExtensionReply) >> 2, + .major_opcode = 0 + }; int i, j; @@ -209,11 +214,6 @@ ProcQueryExtension(ClientPtr client) REQUEST_AT_LEAST_SIZE(fsQueryExtensionReq); - reply.type = FS_Reply; - reply.length = SIZEOF(fsQueryExtensionReply) >> 2; - reply.major_opcode = 0; - reply.sequenceNumber = client->sequence; - if (!NumExtensions) { reply.present = fsFalse; } else { @@ -248,20 +248,19 @@ ProcQueryExtension(ClientPtr client) int ProcListExtensions(ClientPtr client) { - fsListExtensionsReply reply; + fsListExtensionsReply reply = { + .type = FS_Reply, + .nExtensions = NumExtensions, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsListExtensionsReply) >> 2 + }; char *bufptr, - *buffer; + *buffer = NULL; int total_length = 0; REQUEST(fsListExtensionsReq); REQUEST_SIZE_MATCH(fsListExtensionsReq); - reply.type = FS_Reply; - reply.nExtensions = NumExtensions; - reply.length = SIZEOF(fsListExtensionsReply) >> 2; - reply.sequenceNumber = client->sequence; - buffer = NULL; - if (NumExtensions) { int i, j; diff --git a/app/xfs/difs/fontinfo.c b/app/xfs/difs/fontinfo.c index 9c3e374ea..e950ae8a4 100644 --- a/app/xfs/difs/fontinfo.c +++ b/app/xfs/difs/fontinfo.c @@ -74,21 +74,6 @@ in this Software without prior written authorization from The Open Group. # endif #endif -void -CopyCharInfo( - CharInfoPtr ci, - fsXCharInfo *dst) -{ - xCharInfo *src = &ci->metrics; - - dst->ascent = src->ascent; - dst->descent = src->descent; - dst->left = src->leftSideBearing; - dst->right = src->rightSideBearing; - dst->width = src->characterWidth; - dst->attributes = src->attributes; -} - int convert_props( @@ -279,10 +264,8 @@ static Bool do_query_extents(ClientPtr client, pointer data) { int err; - unsigned long lendata, - num_extents; + unsigned long num_extents; fsXCharInfo *extents; - fsQueryXExtents8Reply reply; err = GetExtents (pPtr->client, pPtr->pfont, pPtr->flags, pPtr->nranges, pPtr->range, &num_extents, &extents); @@ -296,19 +279,21 @@ do_query_extents(ClientPtr client, pointer data) } if (err != Successful) { SendErrToClient(pPtr->client, FontToFSError(err), (pointer) 0); - goto finish; } - reply.type = FS_Reply; - reply.sequenceNumber = pPtr->client->sequence; - reply.num_extents = num_extents; - lendata = SIZEOF(fsXCharInfo) * num_extents; - reply.length = (SIZEOF(fsQueryXExtents8Reply) + lendata) >> 2; - if (client->swapped) - SwapExtents(extents, num_extents); - WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXExtents8Reply), &reply); - (void) WriteToClient(pPtr->client, lendata, (char *) extents); - fsfree((char *) extents); -finish: + else { + unsigned long lendata = SIZEOF(fsXCharInfo) * num_extents; + fsQueryXExtents8Reply reply = { + .type = FS_Reply, + .sequenceNumber = pPtr->client->sequence, + .num_extents = num_extents, + .length = (SIZEOF(fsQueryXExtents8Reply) + lendata) >> 2 + }; + if (client->swapped) + SwapExtents(extents, num_extents); + WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXExtents8Reply), &reply); + WriteToClient(pPtr->client, lendata, (char *) extents); + fsfree((char *) extents); + } if (pPtr->slept) ClientWakeup(pPtr->client); if (pPtr->pfont->unload_glyphs) /* For rasterizers that want to save memory */ @@ -367,7 +352,6 @@ do_query_bitmaps(ClientPtr client, pointer data) int data_size; fsOffset32 *offsets; pointer glyph_data; - fsQueryXBitmaps8Reply reply; int freedata; err = GetBitmaps (pPtr->client, pPtr->pfont, pPtr->format, @@ -384,26 +368,28 @@ do_query_bitmaps(ClientPtr client, pointer data) } if (err != Successful) { SendErrToClient(pPtr->client, FontToFSError(err), (pointer) 0); - goto finish; } - reply.type = FS_Reply; - reply.sequenceNumber = pPtr->client->sequence; - reply.replies_hint = 0; - reply.num_chars = num_glyphs; - reply.nbytes = data_size; - reply.length = (SIZEOF(fsQueryXBitmaps8Reply) + data_size + - (SIZEOF(fsOffset32) * num_glyphs) + 3) >> 2; - - WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXBitmaps8Reply), &reply); - if (client->swapped) - SwapLongs((long *)offsets, num_glyphs * 2); - (void) WriteToClient(pPtr->client, (num_glyphs * SIZEOF(fsOffset32)), - (char *) offsets); - (void) WriteToClient(pPtr->client, data_size, (char *) glyph_data); - fsfree((char *) offsets); - if (freedata) - fsfree((char *) glyph_data); -finish: + else { + fsQueryXBitmaps8Reply reply = { + .type = FS_Reply, + .sequenceNumber = pPtr->client->sequence, + .length = (SIZEOF(fsQueryXBitmaps8Reply) + data_size + + (SIZEOF(fsOffset32) * num_glyphs) + 3) >> 2, + .replies_hint = 0, + .num_chars = num_glyphs, + .nbytes = data_size + }; + + WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXBitmaps8Reply), &reply); + if (client->swapped) + SwapLongs((long *)offsets, num_glyphs * 2); + WriteToClient(pPtr->client, (num_glyphs * SIZEOF(fsOffset32)), + (char *) offsets); + WriteToClient(pPtr->client, data_size, (char *) glyph_data); + fsfree((char *) offsets); + if (freedata) + fsfree((char *) glyph_data); + } if (pPtr->slept) ClientWakeup(pPtr->client); if (pPtr->pfont->unload_glyphs) /* For rasterizers that want to save memory */ diff --git a/app/xfs/difs/fonts.c b/app/xfs/difs/fonts.c index 20ef7f0c8..6d4658991 100644 --- a/app/xfs/difs/fonts.c +++ b/app/xfs/difs/fonts.c @@ -95,14 +95,13 @@ FontToFSError(int err) } } -/* XXX -- these two funcs may want to be broken into macros */ -void +static inline void UseFPE(FontPathElementPtr fpe) { fpe->refcount++; } -void +static inline void FreeFPE(FontPathElementPtr fpe) { fpe->refcount--; @@ -122,7 +121,7 @@ FreeFPE(FontPathElementPtr fpe) * init_fpe() and free_fpe(), there shouldn't be any problem in using * freed data. */ -void +static void QueueFontWakeup(FontPathElementPtr fpe) { int i; @@ -151,7 +150,7 @@ QueueFontWakeup(FontPathElementPtr fpe) num_slept_fpes++; } -void +static void RemoveFontWakeup(FontPathElementPtr fpe) { int i, @@ -169,7 +168,7 @@ RemoveFontWakeup(FontPathElementPtr fpe) } /* ARGSUSED */ -void +static void FontWakeup(pointer data, int count, unsigned long *LastSelectMask) { int i; @@ -277,7 +276,6 @@ do_open_font(ClientPtr client, pointer data) *newname; int newlen; ClientFontPtr cfp; - fsOpenBitmapFontReply rep; Font orig; FontIDListPtr *idlist, ids; @@ -386,25 +384,26 @@ do_open_font(ClientPtr client, pointer data) err = AllocError; goto dropout; } - add_id_to_list(ids, cPtr->fontid); - /* send the reply */ - rep.type = FS_Reply; - rep.otherid = orig; - if (orig) - rep.otherid_valid = TRUE; - else - rep.otherid_valid = FALSE; - rep.cachable = pfont->info.cachable; - rep.sequenceNumber = client->sequence; - rep.length = SIZEOF(fsOpenBitmapFontReply) >> 2; - WriteReplyToClient(client, - SIZEOF(fsOpenBitmapFontReply), &rep); - if (pfont->refcnt == 0) { - if (!pfont->fpe) - pfont->fpe = fpe; - UseFPE(pfont->fpe); + else { + /* send the reply */ + fsOpenBitmapFontReply rep = { + .type = FS_Reply, + .otherid_valid = orig ? TRUE : FALSE, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsOpenBitmapFontReply) >> 2, + .otherid = orig, + .cachable = pfont->info.cachable + }; + WriteReplyToClient(client, + SIZEOF(fsOpenBitmapFontReply), &rep); + add_id_to_list(ids, cPtr->fontid); + if (pfont->refcnt == 0) { + if (!pfont->fpe) + pfont->fpe = fpe; + UseFPE(pfont->fpe); + } + pfont->refcnt++; } - pfont->refcnt++; dropout: if (err != Successful) { SendErrToClient(cPtr->client, FontToFSError(err), (pointer) &(cPtr->fontid)); @@ -430,7 +429,6 @@ OpenFont( char *name) { FontPtr pfont = (FontPtr)0; - fsOpenBitmapFontReply rep; OFclosurePtr c; FontIDListPtr *idlist, ids; @@ -488,24 +486,20 @@ OpenFont( if (!add_id_to_list(ids, fid)) { goto lowmem; } - pfont->refcnt++; - rep.type = FS_Reply; - if (ids->num > 1) - { - rep.otherid = ids->client_list[0]; - rep.otherid_valid = TRUE; - } - else - { - rep.otherid = 0; - rep.otherid_valid = FALSE; + else { + fsOpenBitmapFontReply rep = { + .type = FS_Reply, + .otherid_valid = (ids->num > 1) ? TRUE : FALSE, + .sequenceNumber = client->sequence, + .length = SIZEOF(fsOpenBitmapFontReply) >> 2, + .otherid = (ids->num > 1) ? ids->client_list[0] : 0, + .cachable = TRUE /* XXX */ + }; + WriteReplyToClient(client, + SIZEOF(fsOpenBitmapFontReply), &rep); + pfont->refcnt++; + return FSSuccess; } - rep.cachable = TRUE; /* XXX */ - rep.sequenceNumber = client->sequence; - rep.length = SIZEOF(fsOpenBitmapFontReply) >> 2; - WriteReplyToClient(client, - SIZEOF(fsOpenBitmapFontReply), &rep); - return FSSuccess; } c = (OFclosurePtr) fsalloc(sizeof(OFclosureRec)); if (!c) @@ -997,11 +991,13 @@ finish: for (i = 0; i < nnames; i++) stringLens += (names->length[i] <= 255) ? names->length[i] : 0; - reply.type = FS_Reply; - reply.length = (SIZEOF(fsListFontsReply) + stringLens + nnames + 3) >> 2; - reply.following = 0; - reply.nFonts = nnames; - reply.sequenceNumber = client->sequence; + reply = (fsListFontsReply) { + .type = FS_Reply, + .sequenceNumber = client->sequence, + .length = (SIZEOF(fsListFontsReply) + stringLens + nnames + 3) >> 2, + .following = 0, + .nFonts = nnames + }; bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); @@ -1457,10 +1453,6 @@ RegisterFPEFunctions( return num_fpe_types++; } -void -FreeFonts(void) -{ -} /* convenience functions for FS interface */ diff --git a/app/xfs/difs/main.c b/app/xfs/difs/main.c index 9e8e957c4..a202a537f 100644 --- a/app/xfs/difs/main.c +++ b/app/xfs/difs/main.c @@ -58,7 +58,6 @@ in this Software without prior written authorization from The Open Group. #include "misc.h" #include "globals.h" #include "servermd.h" -#include "cache.h" #include "site.h" #include "dispatch.h" #include "extentst.h" @@ -67,10 +66,6 @@ in this Software without prior written authorization from The Open Group. char *ConnectionInfo; int ConnInfoLen; -Cache serverCache; - -#define SERVER_CACHE_SIZE 10000 /* for random server cacheables */ - static Bool create_connection_block(void); char *configfilename; @@ -109,7 +104,6 @@ main(int argc, char *argv[]) OsInit(); if (serverGeneration == 1) { /* do first time init */ - serverCache = CacheInit(SERVER_CACHE_SIZE); CreateSockets(OldListenCount, OldListen); InitProcVectors(); clients = (ClientPtr *) fsalloc(MAXCLIENTS * sizeof(ClientPtr)); @@ -152,7 +146,6 @@ main(int argc, char *argv[]) #endif /* clean up per-cycle stuff */ - CacheReset(); CloseDownExtensions(); if ((dispatchException & DE_TERMINATE) || drone_server) break; |