summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
commit491f741a1b34f20831a30fa017e422154127d54f (patch)
tree4ebe3fde6123a4ed6c62a3df78ee9621802388b0
parent58396f7f075f465fe9fb7580af16c96ad0a88738 (diff)
-rw-r--r--config.cpp5
-rw-r--r--difs/atom.c25
-rw-r--r--difs/cache.c66
-rw-r--r--difs/charinfo.c120
-rw-r--r--difs/difsutils.c159
-rw-r--r--difs/dispatch.c205
-rw-r--r--difs/events.c23
-rw-r--r--difs/extensions.c44
-rw-r--r--difs/fontinfo.c174
-rw-r--r--difs/fonts.c597
-rw-r--r--difs/initfonts.c63
-rw-r--r--difs/main.c51
-rw-r--r--difs/resource.c106
-rw-r--r--difs/swaprep.c215
-rw-r--r--difs/swapreq.c91
-rw-r--r--difs/tables.c74
-rw-r--r--include/access.h18
-rw-r--r--include/accstr.h16
-rw-r--r--include/auth.h3
-rw-r--r--include/cache.h20
-rw-r--r--include/client.h22
-rw-r--r--include/clientstr.h19
-rw-r--r--include/closestr.h2
-rw-r--r--include/difsfn.h8
-rw-r--r--include/difsfnst.h2
-rw-r--r--include/extentst.h25
-rw-r--r--include/misc.h33
-rw-r--r--include/os.h125
-rw-r--r--include/osstruct.h15
-rw-r--r--include/servermd.h4
-rw-r--r--os/access.c34
-rw-r--r--os/config.c238
-rw-r--r--os/configstr.h9
-rw-r--r--os/connection.c107
-rw-r--r--os/error.c111
-rw-r--r--os/io.c114
-rw-r--r--os/osdep.h25
-rw-r--r--os/osglue.c60
-rw-r--r--os/osinit.c4
-rw-r--r--os/utils.c271
-rw-r--r--os/waitfor.c29
-rw-r--r--xfs.man69
42 files changed, 1922 insertions, 1479 deletions
diff --git a/config.cpp b/config.cpp
index 73f049f..cd4a08c 100644
--- a/config.cpp
+++ b/config.cpp
@@ -8,3 +8,8 @@ error-file = FSERRORS
XCOMM in decipoints
default-point-size = 120
default-resolutions = 75,75,100,100
+
+XCOMM font cache control, specified in KB
+cache-hi-mark = 2048
+cache-low-mark = 1433
+cache-balance = 70
diff --git a/difs/atom.c b/difs/atom.c
index 40ead2b..ed42894 100644
--- a/difs/atom.c
+++ b/difs/atom.c
@@ -50,9 +50,11 @@ in this Software without prior written authorization from The Open Group.
* @(#)atom.c 4.1 5/2/91
*
*/
+/* $XFree86: xc/programs/xfs/difs/atom.c,v 3.4 2001/12/14 20:01:33 dawes Exp $ */
#include "misc.h"
-#include "resource.h"
+#include "fsresource.h"
+#include "difs.h"
#define InitialTableSize 100
#define FSA_LAST_PREDEFINED 0 /* only None is predefined */
@@ -71,10 +73,7 @@ static unsigned long tableLength;
static NodePtr *nodeTable;
Atom
-MakeAtom(string, len, makeit)
- char *string;
- unsigned len;
- Bool makeit;
+MakeAtom(char *string, unsigned int len, Bool makeit)
{
register NodePtr *np;
unsigned i;
@@ -142,15 +141,14 @@ MakeAtom(string, len, makeit)
return None;
}
-ValidAtom(atom)
- Atom atom;
+int
+ValidAtom(Atom atom)
{
return (atom != None) && (atom <= lastAtom);
}
char *
-NameForAtom(atom)
- Atom atom;
+NameForAtom(Atom atom)
{
NodePtr node;
@@ -162,14 +160,13 @@ NameForAtom(atom)
}
static void
-atom_error()
+atom_error(void)
{
FatalError("initializing atoms\n");
}
static void
-free_atom(patom)
- NodePtr patom;
+free_atom(NodePtr patom)
{
if (patom->left)
free_atom(patom->left);
@@ -181,7 +178,7 @@ free_atom(patom)
}
static void
-free_all_atoms()
+free_all_atoms(void)
{
if (atomRoot == (NodePtr) NULL)
return;
@@ -193,7 +190,7 @@ free_all_atoms()
}
void
-InitAtoms()
+InitAtoms(void)
{
free_all_atoms();
tableLength = InitialTableSize;
diff --git a/difs/cache.c b/difs/cache.c
index e8b6280..e8c8573 100644
--- a/difs/cache.c
+++ b/difs/cache.c
@@ -47,6 +47,8 @@ in this Software without prior written authorization from The Open Group.
* @(#)cache.c 4.2 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/difs/cache.c,v 1.7 2002/10/15 01:45:02 dawes Exp $ */
+
#include "cachestr.h"
#include "misc.h"
@@ -79,8 +81,7 @@ static int num_caches = 1;
*/
Cache
-CacheInit(maxsize)
- unsigned long maxsize;
+CacheInit(unsigned long maxsize)
{
Cache id = (Cache) num_caches;
CachePtr cache;
@@ -108,8 +109,7 @@ CacheInit(maxsize)
}
static int
-hash(cid)
- CacheID cid;
+hash(CacheID cid)
{
CachePtr cache = caches[CACHE_ID(cid)];
@@ -141,8 +141,7 @@ hash(cid)
}
static void
-rebuild_cache(cache)
- CachePtr cache;
+rebuild_cache(CachePtr cache)
{
int j;
CacheEntryPtr cp,
@@ -186,7 +185,7 @@ rebuild_cache(cache)
* throws out all existing entries
*/
void
-CacheReset()
+CacheReset(void)
{
CacheEntryPtr cp;
CachePtr cache;
@@ -211,15 +210,13 @@ CacheReset()
}
static void
-flush_cache(cache, needed)
- CachePtr cache;
- unsigned long needed;
+flush_cache(CachePtr cache, unsigned long needed)
{
/* XXX -- try to set oldprev properly inside search loop */
CacheEntryPtr cp,
oldest,
*oldprev;
- int oldbucket,
+ int oldbucket = -1,
i;
while ((cache->cursize + needed) > cache->maxsize) {
@@ -234,19 +231,19 @@ flush_cache(cache, needed)
oldest = cp;
}
while (cp) {
- if (cp->timestamp < oldest->timestamp) {
+ if (cp->timestamp < oldest->timestamp) {
oldest = cp;
oldbucket = i;
- }
+ }
cp = cp->next;
- }
+ }
}
/* fixup list */
oldprev = &cache->entries[oldbucket];
cp = *oldprev;
- for (; cp = *oldprev; oldprev = &cp->next) {
+ for (; (cp = *oldprev) != 0; oldprev = &cp->next) {
if (cp == oldest) {
- *oldprev = oldest->next;
+ *oldprev = oldest->next;
break;
}
}
@@ -259,8 +256,7 @@ flush_cache(cache, needed)
}
void
-CacheResize(cid, newsize)
- Cache cid;
+CacheResize(Cache cid, unsigned newsize)
{
CachePtr cache = caches[cid];
@@ -275,11 +271,11 @@ CacheResize(cid, newsize)
}
CacheID
-CacheStoreMemory(cid, data, size, free_func)
- Cache cid;
- pointer data;
- unsigned long size;
- CacheFree free_func;
+CacheStoreMemory(
+ Cache cid,
+ pointer data,
+ unsigned long size,
+ CacheFree free_func)
{
CacheID id;
CacheEntryPtr cp,
@@ -317,9 +313,9 @@ CacheStoreMemory(cid, data, size, free_func)
}
pointer
-CacheFetchMemory(cid, update)
- CacheID cid;
- Bool update;
+CacheFetchMemory(
+ CacheID cid,
+ Bool update)
{
CachePtr cache = caches[CACHE_ID(cid)];
CacheEntryPtr cp,
@@ -341,10 +337,10 @@ CacheFetchMemory(cid, update)
return (pointer) 0;
}
-int
-CacheFreeMemory(cid, notify)
- CacheID cid;
- Bool notify;
+void
+CacheFreeMemory(
+ CacheID cid,
+ Bool notify)
{
CachePtr cache = caches[CACHE_ID(cid)];
CacheEntryPtr cp,
@@ -374,15 +370,15 @@ CacheFreeMemory(cid, notify)
}
}
if (!found)
- FatalError("Freeing cache entry %d which isn't there\n", cid);
+ FatalError("freeing cache entry %d which isn't there\n", cid);
}
/* ARGSUSED */
void
-CacheSimpleFree(cid, data, reason)
- CacheID cid;
- pointer data;
- int reason;
+CacheSimpleFree(
+ CacheID cid,
+ pointer data,
+ int reason)
{
fsfree(data);
}
diff --git a/difs/charinfo.c b/difs/charinfo.c
index f664311..a9b7ad0 100644
--- a/difs/charinfo.c
+++ b/difs/charinfo.c
@@ -49,16 +49,19 @@ in this Software without prior written authorization from The Open Group.
* This file was once on the other side of
* the font library interface as util/fsfuncs.c.
*/
+/* $XFree86: xc/programs/xfs/difs/charinfo.c,v 1.12 2001/12/14 20:01:33 dawes Exp $ */
#include <X11/Xos.h>
#include "misc.h"
#include "fontstruct.h"
+#include "fontutil.h"
#include "clientstr.h"
#define FSMD_H
#include "FSproto.h"
+#include "difs.h"
-extern void TwoByteSwap();
-extern void FourByteSwap();
+extern void TwoByteSwap(unsigned char *, int);
+extern void FourByteSwap(unsigned char *, int);
#define GLWIDTHBYTESPADDED(bits,nbytes) \
((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
@@ -74,16 +77,21 @@ extern void FourByteSwap();
#define n2dChars(pfi) (((pfi)->lastRow - (pfi)->firstRow + 1) * \
((pfi)->lastCol - (pfi)->firstCol + 1))
+#if 0
static CharInfoRec junkDefault;
+#endif
+
+typedef int (*MetricsFunc)(FontPtr, unsigned long, unsigned char *,
+ FontEncoding, unsigned long *, CharInfoPtr *);
static int
-getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
- FontPtr pfont;
- int num_ranges;
- fsRange *range;
- Bool ink_metrics;
- int *nump; /* return */
- CharInfoPtr **retp; /* return */
+getCharInfos (
+ FontPtr pfont,
+ int num_ranges,
+ fsRange *range,
+ Bool ink_metrics,
+ int *nump, /* return */
+ CharInfoPtr **retp) /* return */
{
CharInfoPtr *xchars, *xci;
int nchars;
@@ -94,8 +102,6 @@ getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
int firstRow = pinfo->firstRow;
int lastRow = pinfo->lastRow;
int lastCol = pinfo->lastCol;
- int minCol, maxCol;
- int num_cols = lastCol - firstCol + 1;
fsRange local_range, *rp;
int i;
FontEncoding encoding;
@@ -103,7 +109,7 @@ getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
unsigned long glyphCount;
unsigned short defaultCh;
CharInfoPtr defaultPtr;
- int (*metrics_func) ();
+ MetricsFunc metrics_func;
/*
* compute nchars
@@ -133,9 +139,10 @@ getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
xchars = (CharInfoPtr *) fsalloc (sizeof (CharInfoPtr) * nchars);
if (!xchars)
return AllocError;
+ bzero (xchars, sizeof (CharInfoPtr) * nchars);
if (ink_metrics)
- metrics_func = pfont->get_metrics;
+ metrics_func = (MetricsFunc)pfont->get_metrics;
else
metrics_func = pfont->get_glyphs;
@@ -168,9 +175,11 @@ getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
fsfree (xchars);
return err;
}
+#if 0
if (glyphCount != 1 ||
- *xci == defaultPtr && defaultCh != ((r<<8)+c))
+ (*xci == defaultPtr && defaultCh != ((r<<8)+c)))
*xci = &junkDefault;
+#endif
xci++;
}
}
@@ -181,14 +190,14 @@ getCharInfos (pfont, num_ranges, range, ink_metrics, nump, retp)
}
int
-GetExtents(client, pfont, flags, num_ranges, range, num_extents, data)
- ClientPtr client;
- FontPtr pfont;
- Mask flags;
- unsigned long num_ranges;
- fsRange *range;
- unsigned long *num_extents; /* return */
- fsXCharInfo **data; /* return */
+GetExtents(
+ ClientPtr client,
+ FontPtr pfont,
+ Mask flags,
+ unsigned long num_ranges,
+ fsRange *range,
+ unsigned long *num_extents, /* return */
+ fsXCharInfo **data) /* return */
{
unsigned long size;
fsXCharInfo *ci;
@@ -239,36 +248,35 @@ GetExtents(client, pfont, flags, num_ranges, range, num_extents, data)
}
static int
-packGlyphs (client, pfont, format, flags, num_ranges, range, tsize, num_glyphs,
- offsets, data, freeData)
- ClientPtr client;
- FontPtr pfont;
- int format;
- Mask flags;
- unsigned long num_ranges;
- fsRange *range;
- int *tsize;
- unsigned long *num_glyphs;
- fsOffset32 **offsets;
- pointer *data;
- int *freeData;
+packGlyphs (
+ ClientPtr client,
+ FontPtr pfont,
+ int format,
+ Mask flags,
+ unsigned long num_ranges,
+ fsRange *range,
+ int *tsize,
+ unsigned long *num_glyphs,
+ fsOffset32 **offsets,
+ pointer *data,
+ int *freeData)
{
int i;
fsOffset32 *lengths, *l;
unsigned long size = 0;
- pointer gdata,
- gd;
+ pointer gdata;
+ unsigned char *gd;
int bitorder, byteorder, scanlinepad, scanlineunit, mappad;
- int height, dstbpr, charsize;
- int dst_off, src_off;
+ int height = 0, dstbpr = 0, charsize = 0;
+ int dst_off = 0, src_off;
Bool contiguous, reformat;
- long nchars;
+ int nchars;
int src_glyph_pad = pfont->glyph;
int src_bit_order = pfont->bit;
int src_byte_order = pfont->byte;
int err;
- int max_ascent, max_descent;
- int min_left, max_right;
+ int max_ascent = 0, max_descent = 0;
+ int min_left = 0, max_right;
int srcbpr;
int lshift = 0, rshift = 0, dst_left_bytes = 0, src_left_bytes = 0;
unsigned char *srcp;
@@ -599,19 +607,18 @@ packGlyphs (client, pfont, format, flags, num_ranges, range, tsize, num_glyphs,
/* ARGSUSED */
int
-GetBitmaps(client, pfont, format, flags, num_ranges, range,
- size, num_glyphs, offsets, data, freeData)
- ClientPtr client;
- FontPtr pfont;
- fsBitmapFormat format;
- Mask flags;
- unsigned long num_ranges;
- fsRange *range;
- int *size;
- unsigned long *num_glyphs;
- fsOffset32 **offsets;
- pointer *data;
- int *freeData;
+GetBitmaps(
+ ClientPtr client,
+ FontPtr pfont,
+ fsBitmapFormat format,
+ Mask flags,
+ unsigned long num_ranges,
+ fsRange *range,
+ int *size,
+ unsigned long *num_glyphs,
+ fsOffset32 **offsets,
+ pointer *data,
+ int *freeData)
{
int err;
@@ -620,7 +627,8 @@ GetBitmaps(client, pfont, format, flags, num_ranges, range,
*size = 0;
*data = (pointer) 0;
- err = LoadGlyphRanges(client, pfont, TRUE, num_ranges * 2, 0, range);
+ err = LoadGlyphRanges(client, pfont, TRUE, num_ranges * 2, 0,
+ (fsChar2b *)range);
if (err != Successful)
return err;
diff --git a/difs/difsutils.c b/difs/difsutils.c
index cbe1b2a..0f47d30 100644
--- a/difs/difsutils.c
+++ b/difs/difsutils.c
@@ -46,8 +46,12 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/difsutils.c,v 1.7 2001/12/14 20:01:33 dawes Exp $ */
#define XK_LATIN1
+
+#include <difsutils.h>
+
#include <stdio.h>
#include <ctype.h>
#include "misc.h"
@@ -67,14 +71,13 @@ static int num_resolutions;
static int default_point_size = 120;
AuthContextPtr
-GetClientAuthorization()
+GetClientAuthorization(void)
{
return currentClient->auth;
}
void
-SetDefaultPointSize(ps)
- int ps;
+SetDefaultPointSize(int ps)
{
int i;
@@ -84,8 +87,7 @@ SetDefaultPointSize(ps)
}
int
-SetDefaultResolutions(str)
- char *str;
+SetDefaultResolutions(char *str)
{
int num,
numr = 0,
@@ -151,8 +153,7 @@ SetDefaultResolutions(str)
}
FontResolutionPtr
-GetClientResolutions(num)
- int *num;
+GetClientResolutions(int *num)
{
/* return the client's if it has them, otherwise the default values */
if (currentClient->num_resolutions) {
@@ -165,7 +166,7 @@ GetClientResolutions(num)
}
int
-GetDefaultPointSize()
+GetDefaultPointSize(void)
{
FontResolutionPtr res;
int num;
@@ -178,25 +179,19 @@ GetDefaultPointSize()
}
Bool
-XpClientIsBitmapClient(client)
- ClientPtr client;
+XpClientIsBitmapClient(ClientPtr client)
{
return TRUE;
}
Bool
-XpClientIsPrintClient(client, fpe)
- ClientPtr client;
- FontPathElementPtr fpe;
+XpClientIsPrintClient(ClientPtr client, FontPathElementPtr fpe)
{
return FALSE;
}
void
-CopyISOLatin1Lowered(dest, source, length)
- register unsigned char *dest,
- *source;
- int length;
+CopyISOLatin1Lowered(unsigned char *dest, unsigned char *source, int length)
{
register int i;
@@ -214,10 +209,10 @@ CopyISOLatin1Lowered(dest, source, length)
}
int
-strncmpnocase(first, second, n)
+strncmpnocase(
char *first,
- *second;
- int n;
+ char *second,
+ int n)
{
register unsigned char *ap,
*bp;
@@ -256,15 +251,15 @@ strncmpnocase(first, second, n)
}
void
-NoopDDA()
+NoopDDA(void)
{
}
/* host list manipulation */
int
-AddHost(list, addr)
- HostList *list;
- HostAddress *addr;
+AddHost(
+ HostList *list,
+ HostAddress *addr)
{
HostAddress *new;
@@ -286,9 +281,9 @@ AddHost(list, addr)
}
int
-RemoveHost(list, addr)
- HostList *list;
- HostAddress *addr;
+RemoveHost(
+ HostList *list,
+ HostAddress *addr)
{
HostAddress *t,
*last;
@@ -316,9 +311,9 @@ RemoveHost(list, addr)
}
Bool
-ValidHost(list, addr)
- HostList list;
- HostAddress *addr;
+ValidHost(
+ HostList list,
+ HostAddress *addr)
{
HostAddress *t;
@@ -337,10 +332,10 @@ ValidHost(list, addr)
/* block & wakeup handlers */
typedef struct _BlockHandler {
- void (*BlockHandler) ();
- void (*WakeupHandler) ();
- pointer blockData;
- Bool deleted;
+ BlockHandlerProcPtr BlockHandler;
+ DifsWakeupFunc WakeupHandler;
+ pointer blockData;
+ Bool deleted;
} BlockHandlerRec, *BlockHandlerPtr;
static BlockHandlerPtr handlers;
@@ -350,10 +345,11 @@ static Bool inHandler;
static Bool handlerDeleted;
/* called from the OS layer */
-BlockHandler(pTimeout, pReadmask)
- pointer pTimeout; /* DIX doesn't want to know how OS represents
+void
+BlockHandler(
+ OSTimePtr pTimeout, /* DIX doesn't want to know how OS represents
* time */
- pointer pReadmask; /* nor how it represents the set of
+ pointer pReadmask) /* nor how it represents the set of
* descriptors */
{
register int i,
@@ -376,9 +372,10 @@ BlockHandler(pTimeout, pReadmask)
}
-WakeupHandler(result, pReadmask)
- int result; /* result from the wait */
- pointer pReadmask; /* the resulting descriptor mask */
+void
+WakeupHandler(
+ int result, /* result from the wait */
+ unsigned long * pReadmask) /* the resulting descriptor mask */
{
register int i,
j;
@@ -404,10 +401,10 @@ WakeupHandler(result, pReadmask)
*/
Bool
-RegisterBlockAndWakeupHandlers(blockHandler, wakeupHandler, blockData)
- void (*blockHandler) ();
- void (*wakeupHandler) ();
- pointer blockData;
+RegisterBlockAndWakeupHandlers(
+ BlockHandlerProcPtr blockHandler,
+ DifsWakeupFunc wakeupHandler,
+ pointer blockData)
{
BlockHandlerPtr new;
@@ -427,10 +424,10 @@ RegisterBlockAndWakeupHandlers(blockHandler, wakeupHandler, blockData)
}
void
-RemoveBlockAndWakeupHandlers(blockHandler, wakeupHandler, blockData)
- void (*blockHandler) ();
- void (*wakeupHandler) ();
- pointer blockData;
+RemoveBlockAndWakeupHandlers(
+ BlockHandlerProcPtr blockHandler,
+ DifsWakeupFunc wakeupHandler,
+ pointer blockData)
{
int i;
@@ -450,7 +447,8 @@ RemoveBlockAndWakeupHandlers(blockHandler, wakeupHandler, blockData)
}
}
-InitBlockAndWakeupHandlers()
+void
+InitBlockAndWakeupHandlers(void)
{
fsfree(handlers);
handlers = (BlockHandlerPtr) 0;
@@ -468,7 +466,7 @@ static WorkQueuePtr *workQueueLast = &workQueue;
/* ARGSUSED */
void
-ProcessWorkQueue()
+ProcessWorkQueue(void)
{
WorkQueuePtr q,
n,
@@ -503,10 +501,10 @@ ProcessWorkQueue()
}
Bool
-QueueWorkProc(function, client, data)
- Bool (*function) ();
- ClientPtr client;
- pointer data;
+QueueWorkProc(
+ Bool (*function) (ClientPtr, pointer),
+ ClientPtr client,
+ pointer data)
{
WorkQueuePtr q;
@@ -533,17 +531,17 @@ QueueWorkProc(function, client, data)
typedef struct _SleepQueue {
struct _SleepQueue *next;
ClientPtr client;
- Bool (*function) ();
+ Bool (*function) (ClientPtr, pointer);
pointer closure;
} SleepQueueRec, *SleepQueuePtr;
static SleepQueuePtr sleepQueue = NULL;
Bool
-ClientSleep(client, function, data)
- ClientPtr client;
- Bool (*function) ();
- pointer data;
+ClientSleep(
+ ClientPtr client,
+ Bool (*function) (ClientPtr, pointer),
+ pointer data)
{
SleepQueuePtr q;
@@ -561,8 +559,7 @@ ClientSleep(client, function, data)
}
Bool
-ClientSignal(client)
- ClientPtr client;
+ClientSignal(ClientPtr client)
{
SleepQueuePtr q;
@@ -573,8 +570,8 @@ ClientSignal(client)
return FALSE;
}
-ClientWakeup(client)
- ClientPtr client;
+void
+ClientWakeup(ClientPtr client)
{
SleepQueuePtr q,
*prev;
@@ -595,8 +592,7 @@ ClientWakeup(client)
}
Bool
-ClientIsAsleep(client)
- ClientPtr client;
+ClientIsAsleep(ClientPtr client)
{
SleepQueuePtr q;
@@ -606,33 +602,37 @@ ClientIsAsleep(client)
return FALSE;
}
-unsigned long *
-Xalloc(m)
- unsigned long m;
+pointer
+Xalloc(unsigned long m)
{
return fsalloc(m);
}
-unsigned long *
-Xrealloc(n, m)
- unsigned long *n,
- m;
+pointer
+Xrealloc(pointer n, unsigned long m)
{
return fsrealloc(n, m);
}
void
-Xfree(n)
- unsigned long *n;
+Xfree(unsigned long *n)
{
fsfree(n);
}
+pointer
+Xcalloc(unsigned long n)
+{
+ pointer ret;
+
+ ret = fsalloc(n);
+ if (ret && n)
+ bzero(ret, n);
+ return ret;
+}
+
int
-set_font_authorizations(authorizations, authlen, client)
-char **authorizations;
-int *authlen;
-ClientPtr client;
+set_font_authorizations(char **authorizations, int *authlen, ClientPtr client)
{
#define AUTH1_NAME "hp-hostname-1"
#define AUTH2_NAME "hp-printername-1"
@@ -666,8 +666,7 @@ ClientPtr client;
}
int
-client_auth_generation(client)
-ClientPtr client;
+client_auth_generation(ClientPtr client)
{
return client->auth_generation;
}
diff --git a/difs/dispatch.c b/difs/dispatch.c
index ae0a563..0ee934a 100644
--- a/difs/dispatch.c
+++ b/difs/dispatch.c
@@ -46,23 +46,30 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/dispatch.c,v 3.13 2002/10/15 01:45:02 dawes Exp $ */
+
+#include <stdlib.h>
+#include "dispatch.h"
+#include "swapreq.h"
+#include "swaprep.h"
#include "FS.h"
#include "FSproto.h"
#include "clientstr.h"
#include "authstr.h"
-#include "misc.h"
#include "osstruct.h"
#include "extentst.h"
#include "globals.h"
-#include "resource.h"
+#include "fsresource.h"
#include "difsfnst.h"
#include "fontstruct.h"
#include "site.h"
-#include "events.h"
+#include "fsevents.h"
#include "cache.h"
+#include "globals.h"
+#include "difs.h"
-static void kill_all_clients();
+static void kill_all_clients(void);
char dispatchException = 0;
char isItTimeToYield;
@@ -79,16 +86,6 @@ extern char *configfilename;
extern Bool drone_server;
-extern void NotImplemented();
-
-extern int (*InitialVector[3]) ();
-extern int (*ProcVector[NUM_PROC_VECTORS]) ();
-extern int (*SwappedProcVector[NUM_PROC_VECTORS]) ();
-extern void (*EventSwapVector[NUM_EVENT_VECTORS]) ();
-extern void (*ReplySwapVector[NUM_PROC_VECTORS]) ();
-
-extern void Swap32Write(), Swap16Write(), CopySwap16Write();
-
#define MAJOROP ((fsReq *)client->requestBuffer)->reqType
#define ALL_FORMAT_BITS (BitmapFormatByteOrderMask | \
@@ -103,7 +100,8 @@ extern void Swap32Write(), Swap16Write(), CopySwap16Write();
BitmapFormatMaskScanLinePad | \
BitmapFormatMaskScanLineUnit)
-Dispatch()
+void
+Dispatch(void)
{
int nready,
result;
@@ -147,8 +145,10 @@ Dispatch()
op = MAJOROP;
if (op >= NUM_PROC_VECTORS)
result = ProcBadRequest (client);
- else
+ else if (*client->requestVector[op] != NULL)
result = (*client->requestVector[op]) (client);
+ else
+ result = FSBadRequest;
}
if (result != FSSuccess) {
if (client->noClientException != FSSuccess)
@@ -165,7 +165,7 @@ Dispatch()
if (dispatchException) {
/* re-read the config file */
if (dispatchException & DE_RECONFIG) {
- NoticeF("Re-reading config file\n");
+ NoticeF("re-reading config file\n");
if (ReadConfigFile(configfilename) != FSSuccess)
ErrorF("couldn't parse config file\n");
SetConfigValues();
@@ -186,6 +186,8 @@ Dispatch()
if (dispatchException & DE_TERMINATE) {
NoticeF("terminating\n");
kill_all_clients();
+ CloseSockets();
+ CloseErrors();
exit(0);
break;
}
@@ -196,8 +198,7 @@ Dispatch()
}
int
-ProcInitialConnection(client)
- ClientPtr client;
+ProcInitialConnection(ClientPtr client)
{
REQUEST(fsFakeReq);
fsConnClientPrefix *prefix;
@@ -209,8 +210,12 @@ ProcInitialConnection(client)
return (client->noClientException = -2);
if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l'))) {
+ int status;
+
client->swapped = TRUE;
- SwapConnClientPrefix(prefix);
+ status = SwapConnClientPrefix(client, prefix);
+ if (status != FSSuccess)
+ return (status);
}
client->major_version = prefix->major_version;
client->minor_version = prefix->minor_version;
@@ -224,14 +229,13 @@ ProcInitialConnection(client)
}
int
-ProcEstablishConnection(client)
- ClientPtr client;
+ProcEstablishConnection(ClientPtr client)
{
fsConnClientPrefix *prefix;
fsConnSetup csp;
int ret;
- pointer auth_data,
- ad;
+ pointer auth_data;
+ char *ad;
char *server_auth_data;
AuthPtr client_auth;
int i,
@@ -245,7 +249,7 @@ ProcEstablishConnection(client)
REQUEST(fsFakeReq);
prefix = (fsConnClientPrefix *) stuff+1;
- auth_data = (pointer) prefix + sz_fsConnClientPrefix;
+ auth_data = prefix + sz_fsConnClientPrefix;
client_auth = (AuthPtr) ALLOCATE_LOCAL(prefix->num_auths * sizeof(AuthRec));
if (!client_auth) {
SendErrToClient(client, FSBadAlloc, (pointer) 0);
@@ -255,6 +259,12 @@ ProcEstablishConnection(client)
/* build up a list of the stuff */
for (i = 0, ad = auth_data; i < (int)prefix->num_auths; i++) {
+ if (ad - (char *)auth_data > (stuff->length << 2) - 4) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
/* copy carefully in case wire data is not aligned */
client_auth[i].namelen = (((unsigned char *)ad)[0] << 8) +
((unsigned char *)ad)[1];
@@ -267,6 +277,15 @@ ProcEstablishConnection(client)
client_auth[i].data = (char *) ad;
ad += client_auth[i].datalen;
}
+ if (!(int)prefix->num_auths)
+ ad += 4;
+ if (ad - (char *)auth_data > (stuff->length << 2)) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
+
num_alts = ListAlternateServers(&altservers);
for (i = 0, altlen = 0; i < num_alts; i++) {
/* subset + len + namelen + pad */
@@ -378,10 +397,10 @@ ProcEstablishConnection(client)
*/
void
-SendErrToClient(client, error, data)
- ClientPtr client;
- int error;
- pointer data; /* resource id, format, resolution, etc */
+DoSendErrToClient(
+ ClientPtr client,
+ int error,
+ pointer data) /* resource id, format, resolution, etc */
{
fsError rep;
int extralen = 0;
@@ -409,7 +428,7 @@ SendErrToClient(client, error, data)
SwapShorts((short *) data, 1);
/* note sneaky hack */
rep.pad = *(CARD16 *) data;
- data += 2;
+ data = (char *)data + 2;
extralen = 4;
}
break;
@@ -441,16 +460,14 @@ SendErrToClient(client, error, data)
/* ARGSUSED */
int
-ProcBadRequest(client)
- ClientPtr client;
+ProcBadRequest(ClientPtr client)
{
SendErrToClient(client, FSBadRequest, NULL);
return FSBadRequest;
}
int
-ProcNoop(client)
- ClientPtr client;
+ProcNoop(ClientPtr client)
{
REQUEST(fsReq);
REQUEST_AT_LEAST_SIZE(fsReq);
@@ -459,8 +476,7 @@ ProcNoop(client)
}
int
-ProcListCatalogues(client)
- ClientPtr client;
+ProcListCatalogues(ClientPtr client)
{
int len,
num;
@@ -486,8 +502,7 @@ ProcListCatalogues(client)
}
int
-ProcSetCatalogues(client)
- ClientPtr client;
+ProcSetCatalogues(ClientPtr client)
{
char *new_cat;
int err,
@@ -522,8 +537,7 @@ ProcSetCatalogues(client)
}
int
-ProcGetCatalogues(client)
- ClientPtr client;
+ProcGetCatalogues(ClientPtr client)
{
int len,
i,
@@ -553,8 +567,7 @@ ProcGetCatalogues(client)
}
int
-ProcCreateAC(client)
- ClientPtr client;
+ProcCreateAC(ClientPtr client)
{
fsCreateACReply rep;
AuthPtr acp;
@@ -564,7 +577,7 @@ ProcCreateAC(client)
err,
index,
size;
- pointer ad;
+ char *ad;
char *auth_data;
REQUEST(fsCreateACReq);
@@ -587,7 +600,15 @@ ProcCreateAC(client)
}
}
/* build up a list of the stuff */
- for (i = 0, ad = (pointer)stuff + SIZEOF(fsCreateACReq); i < (int)stuff->num_auths; i++) {
+ for (i = 0, ad = (char *)stuff + SIZEOF(fsCreateACReq);
+ i < (int)stuff->num_auths; i++) {
+ if (ad - (char *)stuff + SIZEOF(fsCreateACReq) >
+ (stuff->length << 2) - 4) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
/* copy carefully in case data is not aligned */
acp[i].namelen = (((unsigned char *)ad)[0] << 8) +
((unsigned char *)ad)[1];
@@ -600,6 +621,14 @@ ProcCreateAC(client)
acp[i].data = (char *) ad;
ad += acp[i].datalen;
}
+ if (!(int)stuff->num_auths)
+ ad += 4;
+ if (ad - (char *)stuff > (stuff->length << 2)) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
/* XXX needs work for AuthContinue */
index = stuff->num_auths;
@@ -658,9 +687,7 @@ alloc_failure:
/* ARGSUSED */
int
-DeleteAuthCont (value, id)
- pointer value;
- FSID id;
+DeleteAuthCont (pointer value, FSID id)
{
AuthContextPtr authp = (AuthContextPtr) value;
@@ -673,8 +700,7 @@ DeleteAuthCont (value, id)
}
int
-ProcFreeAC(client)
- ClientPtr client;
+ProcFreeAC(ClientPtr client)
{
AuthContextPtr authp;
@@ -694,8 +720,7 @@ ProcFreeAC(client)
}
int
-ProcSetAuthorization(client)
- ClientPtr client;
+ProcSetAuthorization(ClientPtr client)
{
AuthContextPtr acp;
@@ -713,14 +738,20 @@ ProcSetAuthorization(client)
}
int
-ProcSetResolution(client)
- ClientPtr client;
+ProcSetResolution(ClientPtr client)
{
fsResolution *new_res;
REQUEST(fsSetResolutionReq);
REQUEST_AT_LEAST_SIZE(fsSetResolutionReq);
+ if ((stuff->length << 2) - SIZEOF(fsSetResolutionReq) <
+ stuff->num_resolutions * SIZEOF(fsResolution)) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, &lengthword);
+ return FSBadLength;
+ }
new_res = (fsResolution *)
fsalloc(SIZEOF(fsResolution) * stuff->num_resolutions);
if (!new_res) {
@@ -737,14 +768,20 @@ ProcSetResolution(client)
}
int
-ProcGetResolution(client)
- ClientPtr client;
+ProcGetResolution(ClientPtr client)
{
fsGetResolutionReply reply;
REQUEST(fsReq);
REQUEST_AT_LEAST_SIZE(fsReq);
+ if ((stuff->length << 2) - SIZEOF(fsResolution) < client->num_resolutions *
+ sizeof(fsResolution)) {
+ int lengthword = stuff->length;
+
+ SendErrToClient(client, FSBadLength, &lengthword);
+ return FSBadLength;
+ }
reply.type = FS_Reply;
reply.num_resolutions = client->num_resolutions;
reply.sequenceNumber = client->sequence;
@@ -756,14 +793,13 @@ ProcGetResolution(client)
client->pSwapReplyFunc = CopySwap16Write;
WriteSwappedDataToClient(client,
- (client->num_resolutions * SIZEOF(fsResolution)), client->resolutions);
+ (client->num_resolutions * SIZEOF(fsResolution)), (short *)client->resolutions);
return client->noClientException;
}
int
-ProcListFonts(client)
- ClientPtr client;
+ProcListFonts(ClientPtr client)
{
REQUEST(fsListFontsReq);
REQUEST_FIXED_SIZE(fsListFontsReq, stuff->nbytes);
@@ -774,8 +810,7 @@ ProcListFonts(client)
}
int
-ProcListFontsWithXInfo(client)
- ClientPtr client;
+ProcListFontsWithXInfo(ClientPtr client)
{
REQUEST(fsListFontsWithXInfoReq);
REQUEST_FIXED_SIZE(fsListFontsWithXInfoReq, stuff->nbytes);
@@ -785,8 +820,7 @@ ProcListFontsWithXInfo(client)
}
int
-ProcOpenBitmapFont(client)
- ClientPtr client;
+ProcOpenBitmapFont(ClientPtr client)
{
FontPtr pfont;
int nbytes,
@@ -825,9 +859,9 @@ ProcOpenBitmapFont(client)
return err;
}
}
+
int
-ProcQueryXInfo(client)
- ClientPtr client;
+ProcQueryXInfo(ClientPtr client)
{
ClientFontPtr cfp;
int err,
@@ -881,8 +915,7 @@ ProcQueryXInfo(client)
}
int
-ProcQueryXExtents(client)
- ClientPtr client;
+ProcQueryXExtents(ClientPtr client)
{
ClientFontPtr cfp;
int err;
@@ -903,7 +936,7 @@ ProcQueryXExtents(client)
/* get the extents */
err = QueryExtents(client, cfp, item_size,
stuff->num_ranges, stuff->range,
- (pointer)stuff + SIZEOF(fsQueryXExtents8Req));
+ (char *)stuff + SIZEOF(fsQueryXExtents8Req));
if (err != FSSuccess) {
return err;
@@ -912,8 +945,7 @@ ProcQueryXExtents(client)
}
int
-ProcQueryXBitmaps(client)
- ClientPtr client;
+ProcQueryXBitmaps(ClientPtr client)
{
ClientFontPtr cfp;
int err;
@@ -940,7 +972,7 @@ ProcQueryXBitmaps(client)
/* get the glyphs */
err = QueryBitmaps(client, cfp, item_size, stuff->format,
stuff->num_ranges, stuff->range,
- (pointer)stuff + SIZEOF(fsQueryXBitmaps8Req));
+ (char *)stuff + SIZEOF(fsQueryXBitmaps8Req));
if (err != FSSuccess) {
return err;
@@ -950,8 +982,7 @@ ProcQueryXBitmaps(client)
}
int
-ProcCloseFont(client)
- ClientPtr client;
+ProcCloseFont(ClientPtr client)
{
ClientFontPtr cfp;
@@ -970,8 +1001,7 @@ ProcCloseFont(client)
}
void
-CloseDownClient(client)
- ClientPtr client;
+DoCloseDownClient(ClientPtr client)
{
if (client->clientGone != CLIENT_GONE) {
DeleteClientFontStuff(client);
@@ -981,7 +1011,7 @@ CloseDownClient(client)
}
if (ClientIsAsleep(client))
- ClientSignal(client);
+ ClientSignal((pointer)client);
else
{
FreeClientResources(client);
@@ -1012,7 +1042,7 @@ CloseDownClient(client)
}
static void
-kill_all_clients()
+kill_all_clients(void)
{
int i;
@@ -1023,25 +1053,26 @@ kill_all_clients()
}
void
-InitProcVectors()
+InitProcVectors(void)
{
int i;
for (i = 0; i < NUM_PROC_VECTORS; i++) {
if (!ProcVector[i]) {
ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
- ReplySwapVector[i] = NotImplemented;
+ ReplySwapVector[i] = (ReplySwapFunc)NotImplemented;
}
}
for (i = FSLASTEvent; i < NUM_EVENT_VECTORS; i++) {
- EventSwapVector[i] = NotImplemented;
+ EventSwapVector[i] = (EventSwapFunc)NotImplemented;
}
}
-InitClient(client, i, ospriv)
- ClientPtr client;
- int i;
- pointer ospriv;
+void
+InitClient(
+ ClientPtr client,
+ int i,
+ pointer ospriv)
{
client->index = i;
client->sequence = 0;
@@ -1061,13 +1092,11 @@ InitClient(client, i, ospriv)
}
ClientPtr
-NextAvailableClient(ospriv)
- pointer ospriv;
+NextAvailableClient(pointer ospriv)
{
int i;
ClientPtr client;
fsFakeReq data;
- extern long MaxClients;
i = nextFreeClientID;
if (i == MaxClients)
@@ -1102,8 +1131,8 @@ NextAvailableClient(ospriv)
return client;
}
-MarkClientException(client)
- ClientPtr client;
+void
+MarkClientException(ClientPtr client)
{
client->noClientException = -2;
}
diff --git a/difs/events.c b/difs/events.c
index cd75ad4..0475eac 100644
--- a/difs/events.c
+++ b/difs/events.c
@@ -46,22 +46,24 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/events.c,v 3.7 2001/12/14 20:01:34 dawes Exp $ */
+
+#include <swaprep.h>
#include "clientstr.h"
#include "FSproto.h"
#include "globals.h"
-#include "events.h"
+#include "fsevents.h"
+#include "dispatch.h"
+#include "difs.h"
-extern void (*EventSwapVector[NUM_EVENT_VECTORS]) ();
static Mask lastEventMask = FontChangeNotifyMask;
#define AllEventMasks (lastEventMask | (lastEventMask - 1))
void
-WriteErrorToClient(client, error)
- ClientPtr client;
- fsError *error;
+WriteErrorToClient(ClientPtr client, fsError *error)
{
if (client->swapped) {
fsError errorTo;
@@ -75,14 +77,13 @@ WriteErrorToClient(client, error)
}
int
-ProcSetEventMask(client)
- ClientPtr client;
+ProcSetEventMask(ClientPtr client)
{
REQUEST(fsSetEventMaskReq);
REQUEST_AT_LEAST_SIZE(fsSetEventMaskReq);
if (stuff->event_mask & ~AllEventMasks) {
- SendErrToClient(client, FSBadEventMask, (pointer) stuff->event_mask);
+ SendErrToClient(client, FSBadEventMask, (pointer) &stuff->event_mask);
return FSBadEventMask;
}
client->eventmask = stuff->event_mask;
@@ -90,8 +91,7 @@ ProcSetEventMask(client)
}
int
-ProcGetEventMask(client)
- ClientPtr client;
+ProcGetEventMask(ClientPtr client)
{
fsGetEventMaskReply rep;
@@ -107,8 +107,7 @@ ProcGetEventMask(client)
}
void
-SendKeepAliveEvent(client)
- ClientPtr client;
+SendKeepAliveEvent(ClientPtr client)
{
fsKeepAliveEvent ev;
diff --git a/difs/extensions.c b/difs/extensions.c
index 5c1f8b0..caf790a 100644
--- a/difs/extensions.c
+++ b/difs/extensions.c
@@ -46,11 +46,14 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/extensions.c,v 1.7 2001/12/14 20:01:34 dawes Exp $ */
#include "FSproto.h"
#include "misc.h"
#include "clientstr.h"
#include "extentst.h"
+#include "difs.h"
+#include "dispatch.h"
#define EXTENSION_BASE 128
#define EXTENSION_EVENT_BASE 64
@@ -58,9 +61,6 @@ in this Software without prior written authorization from The Open Group.
#define LAST_ERROR 255
static ExtensionEntry **extensions = (ExtensionEntry **) NULL;
-extern int (*ProcVector[]) ();
-extern int (*SwappedProcVector[]) ();
-extern void (*ReplySwapVector[]) ();
int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
@@ -68,15 +68,14 @@ static int NumExtensions = 0;
ExtensionEntry *
-AddExtension(name, num_events, num_errors, main_proc, smain_proc,
- closedown_proc, minorop_proc)
- char *name;
- int num_events;
- int num_errors;
- int (*main_proc) ();
- int (*smain_proc) ();
- void (*closedown_proc) ();
- unsigned short (*minorop_proc) ();
+AddExtension(
+ char *name,
+ int num_events,
+ int num_errors,
+ int (*main_proc) (ClientPtr),
+ int (*smain_proc) (ClientPtr),
+ void (*closedown_proc) (struct _ExtensionEntry *),
+ unsigned short (*minorop_proc) (ClientPtr))
{
int i;
ExtensionEntry *ext,
@@ -135,9 +134,7 @@ AddExtension(name, num_events, num_errors, main_proc, smain_proc,
}
Bool
-AddExtensionAlias(alias, ext)
- char *alias;
- ExtensionEntry *ext;
+AddExtensionAlias(char *alias, ExtensionEntry *ext)
{
char *name;
char **aliases;
@@ -156,15 +153,13 @@ AddExtensionAlias(alias, ext)
}
unsigned short
-StandardMinorOpcode(client)
- ClientPtr client;
+StandardMinorOpcode(ClientPtr client)
{
return ((fsReq *) client->requestBuffer)->data;
}
unsigned short
-MinorOpcodeOfRequest(client)
- ClientPtr client;
+MinorOpcodeOfRequest(ClientPtr client)
{
unsigned char major;
@@ -177,7 +172,8 @@ MinorOpcodeOfRequest(client)
return (*extensions[major]->MinorOpcode) (client);
}
-CloseDownExtensions()
+void
+CloseDownExtensions(void)
{
int i,
j;
@@ -198,13 +194,12 @@ CloseDownExtensions()
}
void
-InitExtensions()
+InitExtensions(void)
{
}
int
-ProcQueryExtension(client)
- ClientPtr client;
+ProcQueryExtension(ClientPtr client)
{
fsQueryExtensionReply reply;
int i,
@@ -251,8 +246,7 @@ ProcQueryExtension(client)
}
int
-ProcListExtensions(client)
- ClientPtr client;
+ProcListExtensions(ClientPtr client)
{
fsListExtensionsReply reply;
char *bufptr,
diff --git a/difs/fontinfo.c b/difs/fontinfo.c
index 50ee743..1193ae4 100644
--- a/difs/fontinfo.c
+++ b/difs/fontinfo.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/fontinfo.c,v 1.11 2002/10/15 01:45:02 dawes Exp $ */
#include "FS.h"
#include "FSproto.h"
@@ -56,13 +57,15 @@ in this Software without prior written authorization from The Open Group.
#include "fontstruct.h"
#include "closestr.h"
#include "globals.h"
-
-extern void (*ReplySwapVector[NUM_PROC_VECTORS]) ();
+#include "difs.h"
+#include "dispatch.h"
+#include <swapreq.h>
+#include <swaprep.h>
void
-CopyCharInfo(ci, dst)
- CharInfoPtr ci;
- fsXCharInfo *dst;
+CopyCharInfo(
+ CharInfoPtr ci,
+ fsXCharInfo *dst)
{
xCharInfo *src = &ci->metrics;
@@ -76,9 +79,9 @@ CopyCharInfo(ci, dst)
int
-convert_props(pinfo, props)
- FontInfoPtr pinfo;
- fsPropInfo **props;
+convert_props(
+ FontInfoPtr pinfo,
+ fsPropInfo **props)
{
int i;
int data_len, cur_off;
@@ -93,7 +96,7 @@ convert_props(pinfo, props)
for (i = 0; i < pinfo->nprops; i++)
{
data_len += strlen(NameForAtom(pinfo->props[i].name));
- if (pinfo->isStringProp[i])
+ if (NULL != pinfo->isStringProp && pinfo->isStringProp[i])
data_len += strlen(NameForAtom(pinfo->props[i].value));
}
@@ -105,7 +108,7 @@ convert_props(pinfo, props)
+ data_len);
if (!ptr)
return AllocError;
- string_base = ptr + SIZEOF(fsPropInfo) + SIZEOF(fsPropOffset) * pinfo->nprops;
+ string_base = (char *)ptr + SIZEOF(fsPropInfo) + SIZEOF(fsPropOffset) * pinfo->nprops;
/*
* copy in the header
@@ -116,21 +119,21 @@ convert_props(pinfo, props)
/*
* compute the offsets and copy the string data
*/
- off_ptr = ptr + SIZEOF(fsPropInfo);
+ off_ptr = (char *)ptr + SIZEOF(fsPropInfo);
cur_off = 0;
for (i = 0; i < pinfo->nprops; i++)
{
local_offset.name.position = cur_off;
str = NameForAtom(pinfo->props[i].name);
local_offset.name.length = strlen(str);
- memmove( string_base+cur_off, str, local_offset.name.length);
+ memmove( (char *)string_base+cur_off, str, local_offset.name.length);
cur_off += local_offset.name.length;
- if (pinfo->isStringProp[i])
+ if (NULL != pinfo->isStringProp && pinfo->isStringProp[i])
{
local_offset.value.position = cur_off;
str = NameForAtom(pinfo->props[i].value);
local_offset.value.length = strlen(str);
- memmove( string_base+cur_off, str, local_offset.value.length);
+ memmove( (char *)string_base+cur_off, str, local_offset.value.length);
cur_off += local_offset.value.length;
local_offset.type = PropTypeString;
} else {
@@ -139,7 +142,7 @@ convert_props(pinfo, props)
local_offset.type = PropTypeSigned;
}
memmove( off_ptr, &local_offset, SIZEOF(fsPropOffset));
- off_ptr += SIZEOF(fsPropOffset);
+ off_ptr = (char *)off_ptr + SIZEOF(fsPropOffset);
}
assert(off_ptr == string_base);
@@ -155,18 +158,18 @@ convert_props(pinfo, props)
* a list of ranges
*/
static fsRange *
-build_range(type, src, item_size, num, all, pfi)
- Bool type;
- pointer src;
- int item_size;
- int *num;
- Bool *all;
- FontInfoPtr pfi;
+build_range(
+ Bool type,
+ pointer src,
+ int item_size,
+ int *num,
+ Bool *all,
+ FontInfoPtr pfi)
{
fsRange *new = (fsRange *) 0,
*np;
unsigned long src_num;
- int i;
+ unsigned long i;
if (type) { /* range flag is set, deal with data as a list
* of char2bs */
@@ -204,7 +207,7 @@ build_range(type, src, item_size, num, all, pfi)
*num = np - new;
return new;
} else { /* deal with data as a list of characters */
- pointer pp = src;
+ unsigned char *pp = src;
src_num = *num;
np = new = (fsRange *) fsalloc(SIZEOF(fsRange) * src_num);
@@ -242,9 +245,7 @@ build_range(type, src, item_size, num, all, pfi)
* the bytes of char2b backwards
*/
static void
-swap_char2b (values, number)
- fsChar2b *values;
- int number;
+swap_char2b (fsChar2b *values, int number)
{
fsChar2b temp;
int i;
@@ -256,11 +257,10 @@ swap_char2b (values, number)
}
}
+#define pPtr ((QEclosurePtr) data)
static Bool
-do_query_extents(client, c)
- ClientPtr client;
- QEclosurePtr c;
+do_query_extents(ClientPtr client, pointer data)
{
int err;
unsigned long lendata,
@@ -268,55 +268,55 @@ do_query_extents(client, c)
fsXCharInfo *extents;
fsQueryXExtents8Reply reply;
- err = GetExtents (c->client, c->pfont,
- c->flags, c->nranges, c->range, &num_extents, &extents);
+ err = GetExtents (pPtr->client, pPtr->pfont,
+ pPtr->flags, pPtr->nranges, pPtr->range, &num_extents, &extents);
if (err == Suspended) {
- if (!c->slept) {
- c->pfont->unload_glyphs = 0; /* Not a safe call for this font */
- c->slept = TRUE;
- ClientSleep(client, do_query_extents, (pointer) c);
+ if (!pPtr->slept) {
+ pPtr->pfont->unload_glyphs = 0; /* Not a safe call for this font */
+ pPtr->slept = TRUE;
+ ClientSleep(client, do_query_extents, (pointer) pPtr);
}
return TRUE;
}
if (err != Successful) {
- SendErrToClient(c->client, FontToFSError(err), (pointer) 0);
+ SendErrToClient(pPtr->client, FontToFSError(err), (pointer) 0);
goto finish;
}
reply.type = FS_Reply;
- reply.sequenceNumber = c->client->sequence;
+ 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(c->client, SIZEOF(fsQueryXExtents8Reply), &reply);
- (void) WriteToClient(c->client, lendata, (char *) extents);
+ WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXExtents8Reply), &reply);
+ (void) WriteToClient(pPtr->client, lendata, (char *) extents);
fsfree((char *) extents);
finish:
- if (c->slept)
- ClientWakeup(c->client);
- if (c->pfont->unload_glyphs) /* For rasterizers that want to save memory */
- (*c->pfont->unload_glyphs)(c->pfont);
- fsfree(c->range);
- fsfree(c);
+ if (pPtr->slept)
+ ClientWakeup(pPtr->client);
+ if (pPtr->pfont->unload_glyphs) /* For rasterizers that want to save memory */
+ (*pPtr->pfont->unload_glyphs)(pPtr->pfont);
+ fsfree(pPtr->range);
+ fsfree(pPtr);
return TRUE;
}
int
-QueryExtents(client, cfp, item_size, nranges, range_flag, range_data)
- ClientPtr client;
- ClientFontPtr cfp;
- int item_size;
- int nranges;
- Bool range_flag;
- pointer range_data;
+QueryExtents(
+ ClientPtr client,
+ ClientFontPtr cfp,
+ int item_size,
+ int nranges,
+ Bool range_flag,
+ pointer range_data)
{
QEclosurePtr c;
fsRange *fixed_range;
Bool all_glyphs = FALSE;
if (item_size == 2 && client->major_version == 1)
- swap_char2b (range_data, nranges);
+ swap_char2b ((fsChar2b *)range_data, nranges);
fixed_range = build_range(range_flag, range_data, item_size,
&nranges, &all_glyphs, &cfp->font->info);
@@ -336,81 +336,83 @@ QueryExtents(client, cfp, item_size, nranges, range_flag, range_data)
c->nranges = nranges;
c->range = fixed_range;
- (void) do_query_extents(client, c);
+ (void) do_query_extents(client, (pointer) c);
return FSSuccess;
}
+#undef pPtr
+#define pPtr ((QBclosurePtr) data)
+
static Bool
-do_query_bitmaps(client, c)
- ClientPtr client;
- QBclosurePtr c;
+do_query_bitmaps(ClientPtr client, pointer data)
{
int err;
- unsigned long num_glyphs, data_size;
+ unsigned long num_glyphs;
+ int data_size;
fsOffset32 *offsets;
pointer glyph_data;
fsQueryXBitmaps8Reply reply;
int freedata;
- err = GetBitmaps (c->client, c->pfont, c->format,
- c->flags, c->nranges, c->range,
+ err = GetBitmaps (pPtr->client, pPtr->pfont, pPtr->format,
+ pPtr->flags, pPtr->nranges, pPtr->range,
&data_size, &num_glyphs, &offsets, &glyph_data, &freedata);
if (err == Suspended) {
- if (!c->slept) {
- c->pfont->unload_glyphs = 0; /* Not a safe call for this font */
- c->slept = TRUE;
- ClientSleep(client, do_query_bitmaps, (pointer) c);
+ if (!pPtr->slept) {
+ pPtr->pfont->unload_glyphs = 0; /* Not a safe call for this font */
+ pPtr->slept = TRUE;
+ ClientSleep(client, do_query_bitmaps, (pointer) pPtr);
}
return TRUE;
}
if (err != Successful) {
- SendErrToClient(c->client, FontToFSError(err), (pointer) 0);
+ SendErrToClient(pPtr->client, FontToFSError(err), (pointer) 0);
goto finish;
}
reply.type = FS_Reply;
- reply.sequenceNumber = c->client->sequence;
+ 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(c->client, SIZEOF(fsQueryXBitmaps8Reply), &reply);
+ WriteReplyToClient(pPtr->client, SIZEOF(fsQueryXBitmaps8Reply), &reply);
if (client->swapped)
SwapLongs((long *)offsets, num_glyphs * 2);
- (void) WriteToClient(c->client, (num_glyphs * SIZEOF(fsOffset32)),
+ (void) WriteToClient(pPtr->client, (num_glyphs * SIZEOF(fsOffset32)),
(char *) offsets);
- (void) WriteToClient(c->client, data_size, (char *) glyph_data);
+ (void) WriteToClient(pPtr->client, data_size, (char *) glyph_data);
fsfree((char *) offsets);
if (freedata)
fsfree((char *) glyph_data);
finish:
- if (c->slept)
- ClientWakeup(c->client);
- if (c->pfont->unload_glyphs) /* For rasterizers that want to save memory */
- (*c->pfont->unload_glyphs)(c->pfont);
- fsfree(c->range);
- fsfree(c);
+ if (pPtr->slept)
+ ClientWakeup(pPtr->client);
+ if (pPtr->pfont->unload_glyphs) /* For rasterizers that want to save memory */
+ (*pPtr->pfont->unload_glyphs)(pPtr->pfont);
+ fsfree(pPtr->range);
+ fsfree(pPtr);
return TRUE;
}
int
-QueryBitmaps(client, cfp, item_size, format, nranges, range_flag, range_data)
- ClientPtr client;
- ClientFontPtr cfp;
- int item_size;
- fsBitmapFormat format;
- int nranges;
- Bool range_flag;
- pointer range_data;
+QueryBitmaps(
+ ClientPtr client,
+ ClientFontPtr cfp,
+ int item_size,
+ fsBitmapFormat format,
+ int nranges,
+ Bool range_flag,
+ pointer range_data)
{
QBclosurePtr c;
fsRange *fixed_range;
Bool all_glyphs = FALSE;
if (item_size == 2 && client->major_version == 1)
- swap_char2b (range_data, nranges);
+ swap_char2b ((fsChar2b *)range_data, nranges);
fixed_range = build_range(range_flag, range_data, item_size,
&nranges, &all_glyphs, &cfp->font->info);
@@ -430,6 +432,6 @@ QueryBitmaps(client, cfp, item_size, format, nranges, range_flag, range_data)
c->range = fixed_range;
c->format = format;
- (void) do_query_bitmaps(client, c);
+ (void) do_query_bitmaps(client, (pointer) c);
return FSSuccess;
}
diff --git a/difs/fonts.c b/difs/fonts.c
index a3f6a9f..95fea42 100644
--- a/difs/fonts.c
+++ b/difs/fonts.c
@@ -46,20 +46,22 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/fonts.c,v 3.13 2001/12/14 20:01:34 dawes Exp $ */
#include "FS.h"
#include "FSproto.h"
#include <stdio.h>
+#include <stdlib.h>
#include <X11/Xos.h>
#include "clientstr.h"
-#include "resource.h"
+#include "fsresource.h"
#include "difsfnst.h"
#include "fontstruct.h"
#include "closestr.h"
#include "globals.h"
-
-extern void (*ReplySwapVector[NUM_PROC_VECTORS]) ();
-extern FSID FakeClientID();
+#include "difs.h"
+#include "dispatch.h"
+#include "swaprep.h"
static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
static int num_fpes = 0;
@@ -75,8 +77,7 @@ extern FontPatternCachePtr fontPatternCache;
#define NUM_IDS_PER_CLIENT 5
int
-FontToFSError(err)
- int err;
+FontToFSError(int err)
{
switch (err) {
case Successful:
@@ -97,15 +98,13 @@ FontToFSError(err)
/* XXX -- these two funcs may want to be broken into macros */
void
-UseFPE(fpe)
- FontPathElementPtr fpe;
+UseFPE(FontPathElementPtr fpe)
{
fpe->refcount++;
}
void
-FreeFPE(fpe)
- FontPathElementPtr fpe;
+FreeFPE(FontPathElementPtr fpe)
{
fpe->refcount--;
if (fpe->refcount == 0) {
@@ -125,8 +124,7 @@ FreeFPE(fpe)
* freed data.
*/
void
-QueueFontWakeup(fpe)
- FontPathElementPtr fpe;
+QueueFontWakeup(FontPathElementPtr fpe)
{
int i;
FontPathElementPtr *new;
@@ -155,8 +153,7 @@ QueueFontWakeup(fpe)
}
void
-RemoveFontWakeup(fpe)
- FontPathElementPtr fpe;
+RemoveFontWakeup(FontPathElementPtr fpe)
{
int i,
j;
@@ -174,10 +171,7 @@ RemoveFontWakeup(fpe)
/* ARGSUSED */
void
-FontWakeup(data, count, LastSelectMask)
- pointer data;
- int count;
- unsigned long *LastSelectMask;
+FontWakeup(pointer data, int count, unsigned long *LastSelectMask)
{
int i;
FontPathElementPtr fpe;
@@ -192,9 +186,7 @@ FontWakeup(data, count, LastSelectMask)
}
static Bool
-add_id_to_list(ids, fid)
- FontIDListPtr ids;
- Font fid;
+add_id_to_list(FontIDListPtr ids, Font fid)
{
Font *newlist;
@@ -215,9 +207,7 @@ add_id_to_list(ids, fid)
}
static void
-remove_id_from_list(ids, fid)
- FontIDListPtr ids;
- Font fid;
+remove_id_from_list(FontIDListPtr ids, Font fid)
{
int i;
@@ -235,8 +225,8 @@ remove_id_from_list(ids, fid)
assert(0);
}
-static FontIDListPtr
-make_clients_id_list()
+static FontIDListPtr
+make_clients_id_list(void)
{
FontIDListPtr ids;
Font *fids;
@@ -256,8 +246,7 @@ make_clients_id_list()
}
static void
-free_svrPrivate(svrPrivate)
- pointer svrPrivate;
+free_svrPrivate(pointer svrPrivate)
{
int i;
FontIDListPtr *idlist, ids;
@@ -275,14 +264,15 @@ free_svrPrivate(svrPrivate)
}
}
+#undef cPtr
+#define cPtr ((OFclosurePtr )data)
+
static Bool
-do_open_font(client, c)
- ClientPtr client;
- OFclosurePtr c;
+do_open_font(ClientPtr client, pointer data)
{
FontPtr pfont = NullFont;
- FontPathElementPtr fpe;
- int err;
+ FontPathElementPtr fpe = NULL;
+ int err = 0;
int i;
char *alias,
*newname;
@@ -295,45 +285,45 @@ do_open_font(client, c)
int aliascount = 20;
if (client->clientGone == CLIENT_GONE) {
- if (c->current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current_fpe];
+ if (cPtr->current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current_fpe];
(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
}
err = Successful;
goto dropout;
}
- while (c->current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current_fpe];
+ while (cPtr->current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current_fpe];
err = (*fpe_functions[fpe->type].open_font)
- ((pointer) c->client, fpe, c->flags,
- c->fontname, c->fnamelen, c->format, c->format_mask,
- c->fontid, &pfont, &alias,
- c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
- c->non_cachable_font :
+ ((pointer) cPtr->client, fpe, cPtr->flags,
+ cPtr->fontname, cPtr->fnamelen, cPtr->format, cPtr->format_mask,
+ cPtr->fontid, &pfont, &alias,
+ cPtr->non_cachable_font && cPtr->non_cachable_font->fpe == fpe ?
+ cPtr->non_cachable_font :
(FontPtr)0);
if (err == FontNameAlias && alias) {
newlen = strlen(alias);
- newname = (char *) fsrealloc(c->fontname, newlen);
+ newname = (char *) fsrealloc(cPtr->fontname, newlen);
if (!newname) {
err = AllocError;
break;
}
memmove( newname, alias, newlen);
- c->fontname = newname;
- c->fnamelen = newlen;
- c->current_fpe = 0;
+ cPtr->fontname = newname;
+ cPtr->fnamelen = newlen;
+ cPtr->current_fpe = 0;
if (--aliascount <= 0) break;
continue;
}
if (err == BadFontName) {
- c->current_fpe++;
+ cPtr->current_fpe++;
continue;
}
if (err == Suspended) {
- if (!c->slept) {
- c->slept = TRUE;
- ClientSleep(client, do_open_font, (pointer) c);
+ if (!cPtr->slept) {
+ cPtr->slept = TRUE;
+ ClientSleep(client, do_open_font, (pointer) cPtr);
}
return TRUE;
}
@@ -352,15 +342,15 @@ do_open_font(client, c)
goto dropout;
}
cfp->font = pfont;
- cfp->clientindex = c->client->index;
+ cfp->clientindex = cPtr->client->index;
- if (fontPatternCache && pfont != c->non_cachable_font)
- CacheFontPattern(fontPatternCache, c->orig_name, c->orig_len, pfont);
+ if (fontPatternCache && pfont != cPtr->non_cachable_font)
+ CacheFontPattern(fontPatternCache, cPtr->orig_name, cPtr->orig_len, pfont);
/* either pull out the other id or make the array */
if (pfont->refcnt != 0) {
idlist = (FontIDListPtr *) pfont->svrPrivate;
- ids = idlist[c->client->index];
+ ids = idlist[cPtr->client->index];
if (!ids) {
ids = make_clients_id_list();
if (!ids) {
@@ -368,7 +358,7 @@ do_open_font(client, c)
fsfree(cfp);
goto dropout;
}
- idlist[c->client->index] = ids;
+ idlist[cPtr->client->index] = ids;
}
orig = (ids->num > 0) ? ids->client_list[0] : (Font)0;
} else {
@@ -386,18 +376,18 @@ do_open_font(client, c)
goto dropout;
}
bzero((char *) idlist, (sizeof(FontIDListPtr) * MAXCLIENTS));
- idlist[c->client->index] = ids;
+ idlist[cPtr->client->index] = ids;
orig = (Font) 0;
pfont->svrPrivate = (pointer) idlist;
}
- if (!AddResource(c->client->index, c->fontid, RT_FONT, (pointer) cfp)) {
+ if (!AddResource(cPtr->client->index, cPtr->fontid, RT_FONT, (pointer) cfp)) {
fsfree(cfp);
free_svrPrivate(pfont->svrPrivate);
pfont->svrPrivate = (pointer) 0;
err = AllocError;
goto dropout;
}
- add_id_to_list(ids, c->fontid);
+ add_id_to_list(ids, cPtr->fontid);
/* send the reply */
rep.type = FS_Reply;
rep.otherid = orig;
@@ -418,27 +408,27 @@ do_open_font(client, c)
pfont->refcnt++;
dropout:
if (err != Successful) {
- SendErrToClient(c->client, FontToFSError(err), (pointer) &(c->fontid));
+ SendErrToClient(cPtr->client, FontToFSError(err), (pointer) &(cPtr->fontid));
}
- if (c->slept)
- ClientWakeup(c->client);
- for (i = 0; i < c->num_fpes; i++) {
- FreeFPE(c->fpe_list[i]);
+ if (cPtr->slept)
+ ClientWakeup(cPtr->client);
+ for (i = 0; i < cPtr->num_fpes; i++) {
+ FreeFPE(cPtr->fpe_list[i]);
}
- fsfree(c->fpe_list);
- fsfree(c->fontname);
- fsfree(c);
+ fsfree(cPtr->fpe_list);
+ fsfree(cPtr->fontname);
+ fsfree(cPtr);
return TRUE;
}
int
-OpenFont(client, fid, format, format_mask, namelen, name)
- ClientPtr client;
- Font fid;
- fsBitmapFormat format;
- fsBitmapFormatMask format_mask;
- int namelen;
- char *name;
+OpenFont(
+ ClientPtr client,
+ Font fid,
+ fsBitmapFormat format,
+ fsBitmapFormatMask format_mask,
+ int namelen,
+ char *name)
{
FontPtr pfont = (FontPtr)0;
fsOpenBitmapFontReply rep;
@@ -552,13 +542,12 @@ OpenFont(client, fid, format, format_mask, namelen, name)
c->format_mask = format_mask;
c->non_cachable_font = pfont;
- (void) do_open_font(client, c);
+ (void) do_open_font(client, (pointer) c);
return FSSuccess;
}
static int
-close_font(pfont)
- FontPtr pfont;
+close_font(FontPtr pfont)
{
FontPathElementPtr fpe;
@@ -575,9 +564,9 @@ close_font(pfont)
}
int
-CloseClientFont(cfp, fid)
- ClientFontPtr cfp;
- FSID fid;
+CloseClientFont(
+ ClientFontPtr cfp,
+ FSID fid)
{
FontIDListPtr *idlist;
FontIDListPtr ids;
@@ -594,12 +583,11 @@ CloseClientFont(cfp, fid)
}
/*
- * search all the knwon FPE prefixes looking for one to match the given
+ * search all the known FPE prefixes looking for one to match the given
* FPE name
*/
static int
-determine_fpe_type(name)
- char *name;
+determine_fpe_type(char *name)
{
int i;
for (i = 0; i < num_fpe_types; i++) {
@@ -610,9 +598,7 @@ determine_fpe_type(name)
}
static void
-free_font_path(list, n)
- FontPathElementPtr *list;
- int n;
+free_font_path(FontPathElementPtr *list, int n)
{
int i;
@@ -622,19 +608,19 @@ free_font_path(list, n)
fsfree((char *) list);
}
-static FontPathElementPtr
-find_existing_fpe(list, num, name, len)
- FontPathElementPtr *list;
- int num;
- char *name;
- int len;
+static FontPathElementPtr
+find_existing_fpe(
+ FontPathElementPtr *list,
+ int num,
+ char *name,
+ int len)
{
FontPathElementPtr fpe;
int i;
for (i = 0; i < num; i++) {
fpe = list[i];
- if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
+ if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
return fpe;
}
return (FontPathElementPtr) 0;
@@ -646,18 +632,17 @@ find_existing_fpe(list, num, name, len)
* paths should be a counted string
*/
static int
-set_font_path_elements(npaths, paths, bad)
- int npaths;
- char *paths;
- int *bad;
+set_font_path_elements(
+ int npaths,
+ char *paths,
+ int *bad)
{
- int i,
- err;
+ int i, validpaths, err = 0;
int len;
int type;
char *cp = paths;
- FontPathElementPtr fpe,
- *fplist;
+ char *name;
+ FontPathElementPtr fpe, *fplist;
fplist = (FontPathElementPtr *)
fsalloc(sizeof(FontPathElementPtr) * npaths);
@@ -669,10 +654,9 @@ set_font_path_elements(npaths, paths, bad)
if (fpe_functions[i].set_path_hook)
(*fpe_functions[i].set_path_hook) ();
}
- for (i = 0; i < npaths; i++) {
+ for (i = 0, validpaths = 0; i < npaths; i++) {
len = *cp++;
if (len) {
- char *name;
/* if it's already in our active list, just reset it */
/*
* note that this can miss FPE's in limbo -- may be worth catching
@@ -684,7 +668,7 @@ set_font_path_elements(npaths, paths, bad)
if (err == Successful) {
UseFPE(fpe);/* since it'll be decref'd later when freed
* from the old list */
- fplist[i] = fpe;
+ fplist[validpaths++] = fpe;
cp += len;
continue;
}
@@ -700,9 +684,9 @@ set_font_path_elements(npaths, paths, bad)
type = determine_fpe_type(name);
if (type == -1)
{
+ NoticeF("ignoring font path element %s (bad font path descriptor)\n", name);
fsfree(name);
- err = FSBadName;
- goto bail;
+ continue;
}
/* must be new -- make it */
fpe = (FontPathElementPtr) fsalloc(sizeof(FontPathElementRec));
@@ -714,19 +698,32 @@ set_font_path_elements(npaths, paths, bad)
fpe->type = type;
fpe->name = name;
fpe->refcount = 1;
- fplist[i] = fpe;
cp += len;
fpe->name_length = len;
err = (*fpe_functions[fpe->type].init_fpe) (fpe);
if (err != Successful) {
+ NoticeF("ignoring font path element %s (unreadable)\n", fpe->name);
fsfree(fpe->name);
fsfree(fpe);
- err = FontToFSError(err);
- goto bail;
+ continue;
}
+ fplist[validpaths++] = fpe;
}
}
+ if (validpaths < npaths) {
+ FontPathElementPtr *ftmp = (FontPathElementPtr *)
+ fsrealloc(fplist, sizeof(FontPathElementPtr) * validpaths);
+
+ if (!ftmp)
+ goto bail;
+ fplist = ftmp;
+ npaths = validpaths;
+ }
+ if (validpaths == 0) {
+ err = FontToFSError(err);
+ goto bail;
+ }
free_font_path(font_path_elements, num_fpes);
font_path_elements = fplist;
num_fpes = npaths;
@@ -734,8 +731,8 @@ set_font_path_elements(npaths, paths, bad)
EmptyFontPatternCache(fontPatternCache);
return FSSuccess;
bail:
- *bad = i;
- while (--i >= 0)
+ *bad = validpaths;
+ while (--validpaths >= 0)
FreeFPE(fplist[i]);
fsfree(fplist);
return err;
@@ -745,9 +742,9 @@ bail:
* expects comma seperated string
*/
int
-SetFontCatalogue(str, badpath)
- char *str;
- int *badpath;
+SetFontCatalogue(
+ char *str,
+ int *badpath)
{
int len,
npaths;
@@ -781,10 +778,11 @@ SetFontCatalogue(str, badpath)
return err;
}
-Bool
-do_list_fonts_and_aliases(client, c)
- ClientPtr client;
- LFclosurePtr c;
+#undef cPtr
+#define cPtr ((LFclosurePtr)data)
+
+static Bool
+do_list_fonts_and_aliases(ClientPtr client, pointer data)
{
FontPathElementPtr fpe;
int err = Successful;
@@ -800,19 +798,19 @@ do_list_fonts_and_aliases(client, c)
int aliascount = 0;
if (client->clientGone == CLIENT_GONE) {
- if (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
+ if (cPtr->current.current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current.current_fpe];
(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
}
err = Successful;
goto bail;
}
- if (!c->current.patlen)
+ if (!cPtr->current.patlen)
goto finish;
- while (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
+ while (cPtr->current.current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current.current_fpe];
err = Successful;
if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
@@ -820,14 +818,14 @@ do_list_fonts_and_aliases(client, c)
/* This FPE doesn't support/require list_fonts_and_aliases */
err = (*fpe_functions[fpe->type].list_fonts)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- c->names);
+ ((pointer) cPtr->client, fpe, cPtr->current.pattern,
+ cPtr->current.patlen, cPtr->current.max_names - cPtr->names->nnames,
+ cPtr->names);
if (err == Suspended) {
- if (!c->slept) {
- c->slept = TRUE;
- ClientSleep(client, do_list_fonts_and_aliases, (pointer) c);
+ if (!cPtr->slept) {
+ cPtr->slept = TRUE;
+ ClientSleep(client, do_list_fonts_and_aliases, (pointer) cPtr);
}
return TRUE;
}
@@ -845,32 +843,32 @@ do_list_fonts_and_aliases(client, c)
The code at this level then resolves the alias by polling
the FPEs. */
- if (!c->current.list_started) {
+ if (!cPtr->current.list_started) {
err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- &c->current.private);
+ ((pointer) cPtr->client, fpe, cPtr->current.pattern,
+ cPtr->current.patlen, cPtr->current.max_names - cPtr->names->nnames,
+ &cPtr->current.private);
if (err == Suspended) {
- if (!c->slept) {
+ if (!cPtr->slept) {
ClientSleep(client, do_list_fonts_and_aliases,
- (pointer) c);
- c->slept = TRUE;
+ (pointer) cPtr);
+ cPtr->slept = TRUE;
}
return TRUE;
}
if (err == Successful)
- c->current.list_started = TRUE;
+ cPtr->current.list_started = TRUE;
}
if (err == Successful) {
name = 0;
err = (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &name, &namelen, &resolved,
- &resolvedlen, c->current.private);
+ ((pointer) cPtr->client, fpe, &name, &namelen, &resolved,
+ &resolvedlen, cPtr->current.private);
if (err == Suspended) {
- if (!c->slept) {
+ if (!cPtr->slept) {
ClientSleep(client, do_list_fonts_and_aliases,
- (pointer) c);
- c->slept = TRUE;
+ (pointer) cPtr);
+ cPtr->slept = TRUE;
}
return TRUE;
}
@@ -878,14 +876,14 @@ do_list_fonts_and_aliases(client, c)
if (err == Successful)
{
- if (c->haveSaved)
+ if (cPtr->haveSaved)
{
- if (c->savedName)
- (void)AddFontNamesName(c->names, c->savedName,
- c->savedNameLen);
+ if (cPtr->savedName)
+ (void)AddFontNamesName(cPtr->names, cPtr->savedName,
+ cPtr->savedNameLen);
}
else
- (void)AddFontNamesName(c->names, name, namelen);
+ (void)AddFontNamesName(cPtr->names, name, namelen);
}
/*
@@ -904,15 +902,15 @@ do_list_fonts_and_aliases(client, c)
* is complete.
*/
memmove(tmp_pattern, resolved, resolvedlen);
- if (c->haveSaved)
+ if (cPtr->haveSaved)
{
char *tmpname;
int tmpnamelen;
tmpname = 0;
(void) (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
- &tmpname, &tmpnamelen, c->current.private);
+ ((pointer) cPtr->client, fpe, &tmpname, &tmpnamelen,
+ &tmpname, &tmpnamelen, cPtr->current.private);
if (--aliascount <= 0)
{
err = BadFontName;
@@ -921,21 +919,21 @@ do_list_fonts_and_aliases(client, c)
}
else
{
- c->saved = c->current;
- c->haveSaved = TRUE;
- if (c->savedName)
- fsfree(c->savedName);
- c->savedName = (char *)fsalloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- c->savedNameLen = namelen;
+ cPtr->saved = cPtr->current;
+ cPtr->haveSaved = TRUE;
+ if (cPtr->savedName)
+ fsfree(cPtr->savedName);
+ cPtr->savedName = (char *)fsalloc(namelen + 1);
+ if (cPtr->savedName)
+ memmove(cPtr->savedName, name, namelen + 1);
+ cPtr->savedNameLen = namelen;
aliascount = 20;
}
- memmove(c->current.pattern, tmp_pattern, resolvedlen);
- c->current.patlen = resolvedlen;
- c->current.max_names = c->names->nnames + 1;
- c->current.current_fpe = -1;
- c->current.private = 0;
+ memmove(cPtr->current.pattern, tmp_pattern, resolvedlen);
+ cPtr->current.patlen = resolvedlen;
+ cPtr->current.max_names = cPtr->names->nnames + 1;
+ cPtr->current.current_fpe = -1;
+ cPtr->current.private = 0;
err = BadFontName;
}
}
@@ -946,10 +944,10 @@ do_list_fonts_and_aliases(client, c)
*/
if (err == BadFontName) {
ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
+ cPtr->current.list_started = FALSE;
+ cPtr->current.current_fpe++;
err = Successful;
- if (c->haveSaved)
+ if (cPtr->haveSaved)
{
/* If we're searching for an alias, limit the search to
FPE's of the same type as the one the alias came
@@ -960,20 +958,20 @@ do_list_fonts_and_aliases(client, c)
on a typical system enabling FILE_NAMES_ALIASES, this
is significant. */
- while (c->current.current_fpe < c->num_fpes &&
- c->fpe_list[c->current.current_fpe]->type !=
- c->fpe_list[c->saved.current_fpe]->type)
- c->current.current_fpe++;
+ while (cPtr->current.current_fpe < cPtr->num_fpes &&
+ cPtr->fpe_list[cPtr->current.current_fpe]->type !=
+ cPtr->fpe_list[cPtr->saved.current_fpe]->type)
+ cPtr->current.current_fpe++;
- if (c->names->nnames == c->current.max_names ||
- c->current.current_fpe == c->num_fpes) {
- c->haveSaved = FALSE;
- c->current = c->saved;
+ if (cPtr->names->nnames == cPtr->current.max_names ||
+ cPtr->current.current_fpe == cPtr->num_fpes) {
+ cPtr->haveSaved = FALSE;
+ cPtr->current = cPtr->saved;
/* Give the saved namelist a chance to clean itself up */
continue;
}
}
- if (c->names->nnames == c->current.max_names)
+ if (cPtr->names->nnames == cPtr->current.max_names)
break;
}
}
@@ -988,9 +986,9 @@ do_list_fonts_and_aliases(client, c)
finish:
- names = c->names;
+ names = cPtr->names;
nnames = names->nnames;
- client = c->client;
+ client = cPtr->client;
stringLens = 0;
for (i = 0; i < nnames; i++)
stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
@@ -1028,23 +1026,23 @@ finish:
DEALLOCATE_LOCAL(bufferStart);
bail:
- if (c->slept)
+ if (cPtr->slept)
ClientWakeup(client);
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- fsfree(c->fpe_list);
- if (c->savedName) fsfree(c->savedName);
+ for (i = 0; i < cPtr->num_fpes; i++)
+ FreeFPE(cPtr->fpe_list[i]);
+ fsfree(cPtr->fpe_list);
+ if (cPtr->savedName) fsfree(cPtr->savedName);
FreeFontNames(names);
- fsfree(c);
+ fsfree(cPtr);
return TRUE;
}
int
-ListFonts(client, length, pattern, maxNames)
- ClientPtr client;
- int length;
- unsigned char *pattern;
- int maxNames;
+ListFonts(
+ ClientPtr client,
+ int length,
+ unsigned char *pattern,
+ int maxNames)
{
int i;
LFclosurePtr c;
@@ -1090,7 +1088,7 @@ ListFonts(client, length, pattern, maxNames)
c->haveSaved = FALSE;
c->slept = FALSE;
c->savedName = 0;
- do_list_fonts_and_aliases(client, c);
+ do_list_fonts_and_aliases(client, (pointer) c);
return TRUE;
badAlloc:
SendErrToClient(client, FSBadAlloc, (pointer) 0);
@@ -1100,10 +1098,11 @@ badAlloc:
static int padlength[4] = {0, 3, 2, 1};
static char padding[3];
-Bool
-do_list_fonts_with_info(client, c)
- ClientPtr client;
- LFWXIclosurePtr c;
+#undef cPtr
+#define cPtr ((LFWXIclosurePtr)data)
+
+static Bool
+do_list_fonts_with_info(ClientPtr client, pointer data)
{
FontPathElementPtr fpe;
int err = Successful;
@@ -1120,43 +1119,43 @@ do_list_fonts_with_info(client, c)
int aliascount = 0;
if (client->clientGone == CLIENT_GONE) {
- if (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
+ if (cPtr->current.current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current.current_fpe];
(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
}
err = Successful;
goto bail;
}
- while (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
+ while (cPtr->current.current_fpe < cPtr->num_fpes) {
+ fpe = cPtr->fpe_list[cPtr->current.current_fpe];
err = Successful;
- if (!c->current.list_started) {
+ if (!cPtr->current.list_started) {
err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names,
- &c->current.private);
+ ((pointer) cPtr->client, fpe, cPtr->current.pattern,
+ cPtr->current.patlen, cPtr->current.max_names,
+ &cPtr->current.private);
if (err == Suspended) {
- if (!c->slept) {
+ if (!cPtr->slept) {
ClientSleep(client, do_list_fonts_with_info,
- (pointer) c);
- c->slept = TRUE;
+ (pointer) cPtr);
+ cPtr->slept = TRUE;
}
return TRUE;
}
if (err == Successful)
- c->current.list_started = TRUE;
+ cPtr->current.list_started = TRUE;
}
if (err == Successful) {
name = 0;
pFontInfo = &fontInfo;
err = (*fpe_functions[fpe->type].list_next_font_with_info)
- ((pointer) c->client, fpe, &name, &namelen,
- &pFontInfo, &numFonts, c->current.private);
+ ((pointer) cPtr->client, fpe, &name, &namelen,
+ &pFontInfo, &numFonts, cPtr->current.private);
if (err == Suspended) {
- if (!c->slept) {
+ if (!cPtr->slept) {
ClientSleep(client, do_list_fonts_with_info,
- (pointer) c);
- c->slept = TRUE;
+ (pointer) cPtr);
+ cPtr->slept = TRUE;
}
return TRUE;
}
@@ -1174,7 +1173,7 @@ do_list_fonts_with_info(client, c)
* is BadFontName, indicating the alias resolution
* is complete.
*/
- if (c->haveSaved)
+ if (cPtr->haveSaved)
{
char *tmpname;
int tmpnamelen;
@@ -1184,7 +1183,7 @@ do_list_fonts_with_info(client, c)
tmpFontInfo = &fontInfo;
(void) (*fpe_functions[fpe->type].list_next_font_with_info)
((pointer) client, fpe, &tmpname, &tmpnamelen,
- &tmpFontInfo, &numFonts, c->current.private);
+ &tmpFontInfo, &numFonts, cPtr->current.private);
if (--aliascount <= 0)
{
err = BadFontName;
@@ -1193,18 +1192,18 @@ do_list_fonts_with_info(client, c)
}
else
{
- c->saved = c->current;
- c->haveSaved = TRUE;
- c->savedNumFonts = numFonts;
- c->savedName = (char *) pFontInfo;
+ cPtr->saved = cPtr->current;
+ cPtr->haveSaved = TRUE;
+ cPtr->savedNumFonts = numFonts;
+ cPtr->savedName = (char *) pFontInfo;
aliascount = 20;
}
- memmove(c->current.pattern, name, namelen);
- c->current.patlen = namelen;
- c->current.max_names = 1;
- c->current.current_fpe = 0;
- c->current.private = 0;
- c->current.list_started = FALSE;
+ memmove(cPtr->current.pattern, name, namelen);
+ cPtr->current.patlen = namelen;
+ cPtr->current.max_names = 1;
+ cPtr->current.current_fpe = 0;
+ cPtr->current.private = 0;
+ cPtr->current.list_started = FALSE;
}
/*
* At the end of this FPE, step to the next. If we've finished
@@ -1213,35 +1212,35 @@ do_list_fonts_with_info(client, c)
*/
else if (err == BadFontName) {
ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
+ cPtr->current.list_started = FALSE;
+ cPtr->current.current_fpe++;
err = Successful;
- if (c->haveSaved) {
- if (c->current.max_names == 0 ||
- c->current.current_fpe == c->num_fpes) {
- c->haveSaved = FALSE;
- c->saved.max_names -= (1 - c->current.max_names);
- c->current = c->saved;
+ if (cPtr->haveSaved) {
+ if (cPtr->current.max_names == 0 ||
+ cPtr->current.current_fpe == cPtr->num_fpes) {
+ cPtr->haveSaved = FALSE;
+ cPtr->saved.max_names -= (1 - cPtr->current.max_names);
+ cPtr->current = cPtr->saved;
}
}
- else if (c->current.max_names == 0)
+ else if (cPtr->current.max_names == 0)
break;
} else if (err == Successful) {
/* XXX why is it xFontProp ? */
length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
- reply = c->reply;
- if (c->length < length) {
- reply = (fsListFontsWithXInfoReply *) fsrealloc(c->reply, length);
+ reply = cPtr->reply;
+ if (cPtr->length < length) {
+ reply = (fsListFontsWithXInfoReply *) fsrealloc(cPtr->reply, length);
if (!reply) {
err = AllocError;
break;
}
- c->reply = reply;
- c->length = length;
+ cPtr->reply = reply;
+ cPtr->length = length;
}
- if (c->haveSaved) {
- numFonts = c->savedNumFonts;
- name = c->savedName;
+ if (cPtr->haveSaved) {
+ numFonts = cPtr->savedNumFonts;
+ name = cPtr->savedName;
namelen = strlen(name);
}
fsPack_XFontInfoHeader(pFontInfo, reply, client->major_version);
@@ -1279,8 +1278,8 @@ do_list_fonts_with_info(client, c)
}
fsfree(prop_info);
- --c->current.max_names;
- if (c->current.max_names < 0)
+ --cPtr->current.max_names;
+ if (cPtr->current.max_names < 0)
abort();
}
}
@@ -1291,16 +1290,16 @@ do_list_fonts_with_info(client, c)
if (err == Successful) {
fsGenericReply *final_reply;
- final_reply = (fsGenericReply *)c->reply;
+ final_reply = (fsGenericReply *)cPtr->reply;
if (client->major_version > 1)
length = SIZEOF(fsGenericReply);
else
length = SIZEOF(fsListFontsWithXInfoReply);
- if (c->length < length) {
- final_reply = (fsGenericReply *) fsrealloc(c->reply, length);
+ if (cPtr->length < length) {
+ final_reply = (fsGenericReply *) fsrealloc(cPtr->reply, length);
if (final_reply) {
- c->reply = (fsListFontsWithXInfoReply *)final_reply;
- c->length = length;
+ cPtr->reply = (fsListFontsWithXInfoReply *)final_reply;
+ cPtr->length = length;
} else
err = AllocError;
}
@@ -1315,22 +1314,22 @@ do_list_fonts_with_info(client, c)
if (err != Successful)
SendErrToClient(client, FontToFSError(err), (pointer) 0);
bail:
- if (c->slept)
+ if (cPtr->slept)
ClientWakeup(client);
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- fsfree(c->fpe_list);
- fsfree(c->reply);
- fsfree(c);
+ for (i = 0; i < cPtr->num_fpes; i++)
+ FreeFPE(cPtr->fpe_list[i]);
+ fsfree(cPtr->fpe_list);
+ fsfree(cPtr->reply);
+ fsfree(cPtr);
return TRUE;
}
int
-StartListFontsWithInfo(client, length, pattern, maxNames)
- ClientPtr client;
- int length;
- unsigned char *pattern;
- int maxNames;
+StartListFontsWithInfo(
+ ClientPtr client,
+ int length,
+ unsigned char *pattern,
+ int maxNames)
{
int i;
LFWXIclosurePtr c;
@@ -1371,7 +1370,7 @@ StartListFontsWithInfo(client, length, pattern, maxNames)
c->savedNumFonts = 0;
c->haveSaved = FALSE;
c->slept = FALSE;
- do_list_fonts_with_info(client, c);
+ do_list_fonts_with_info(client, (pointer) c);
return TRUE;
badAlloc:
SendErrToClient(client, FSBadAlloc, (pointer) 0);
@@ -1379,13 +1378,13 @@ badAlloc:
}
int
-LoadGlyphRanges(client, pfont, range_flag, num_ranges, item_size, data)
- ClientPtr client;
- FontPtr pfont;
- Bool range_flag;
- int num_ranges;
- int item_size;
- fsChar2b *data;
+LoadGlyphRanges(
+ ClientPtr client,
+ FontPtr pfont,
+ Bool range_flag,
+ int num_ranges,
+ int item_size,
+ fsChar2b *data)
{
/* either returns Successful, Suspended, or some nasty error */
if (fpe_functions[pfont->fpe->type].load_glyphs)
@@ -1396,27 +1395,24 @@ LoadGlyphRanges(client, pfont, range_flag, num_ranges, item_size, data)
return Successful;
}
+
int
-RegisterFPEFunctions(name_func, init_func, free_func, reset_func,
- open_func, close_func, list_func, start_lfwi_func, next_lfwi_func,
- wakeup_func, client_died, load_glyphs,
- start_list_alias_func, next_list_alias_func,
- set_path_func)
- Bool (*name_func) ();
- int (*init_func) ();
- int (*free_func) ();
- int (*reset_func) ();
- int (*open_func) ();
- int (*close_func) ();
- int (*list_func) ();
- int (*start_lfwi_func) ();
- int (*next_lfwi_func) ();
- int (*wakeup_func) ();
- int (*client_died) ();
- int (*load_glyphs) ();
- int (*start_list_alias_func) ();
- int (*next_list_alias_func) ();
- void (*set_path_func) ();
+RegisterFPEFunctions(
+ Bool (*name_func) (char *name),
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ void (*set_path_func) (void))
{
FPEFunctions *new;
@@ -1452,36 +1448,34 @@ RegisterFPEFunctions(name_func, init_func, free_func, reset_func,
}
void
-FreeFonts()
+FreeFonts(void)
{
}
/* convenience functions for FS interface */
FontPtr
-find_old_font(id)
- FSID id;
+find_old_font(FSID id)
{
return (FontPtr) LookupIDByType(SERVER_CLIENT, id, RT_NONE);
}
Font
-GetNewFontClientID()
+GetNewFontClientID(void)
{
return (Font) FakeClientID(SERVER_CLIENT);
}
int
-StoreFontClientFont(pfont, id)
- FontPtr pfont;
- Font id;
+StoreFontClientFont(
+ FontPtr pfont,
+ Font id)
{
return AddResource(SERVER_CLIENT, id, RT_NONE, (pointer) pfont);
}
void
-DeleteFontClientID(id)
- Font id;
+DeleteFontClientID(Font id)
{
FreeResource(SERVER_CLIENT, id, RT_NONE);
}
@@ -1490,9 +1484,9 @@ static int fs_handlers_installed = 0;
static unsigned int last_server_gen;
int
-init_fs_handlers(fpe, block_handler)
- FontPathElementPtr fpe;
- void (*block_handler) ();
+init_fs_handlers(
+ FontPathElementPtr fpe,
+ BlockHandlerProcPtr block_handler)
{
/* if server has reset, make sure the b&w handlers are reinstalled */
if (last_server_gen < serverGeneration) {
@@ -1515,10 +1509,10 @@ init_fs_handlers(fpe, block_handler)
}
void
-remove_fs_handlers(fpe, block_handler, all)
- FontPathElementPtr fpe;
- void (*block_handler) ();
- Bool all;
+remove_fs_handlers(
+ FontPathElementPtr fpe,
+ BlockHandlerProcPtr block_handler,
+ Bool all)
{
if (all) {
/* remove the handlers if no one else is using them */
@@ -1536,8 +1530,7 @@ remove_fs_handlers(fpe, block_handler, all)
}
void
-DeleteClientFontStuff(client)
- ClientPtr client;
+DeleteClientFontStuff(ClientPtr client)
{
int i;
FontPathElementPtr fpe;
diff --git a/difs/initfonts.c b/difs/initfonts.c
index ea6c95a..9ed7675 100644
--- a/difs/initfonts.c
+++ b/difs/initfonts.c
@@ -47,20 +47,81 @@ in this Software without prior written authorization from The Open Group.
* %W% %E%
*
*/
+/* $XFree86: xc/programs/xfs/difs/initfonts.c,v 1.7 2001/12/14 20:01:34 dawes Exp $ */
#include "font.h"
+#include "difs.h"
+#ifdef FONTCACHE
+#include "misc.h"
+#include <X11/extensions/fontcacheP.h>
+
+#define CACHE_HI_MARK (2048 * 1024)
+#define CACHE_LOW_MARK (((2048 * 1024) / 4) * 3)
+#define CACHE_BALANCE 70
+#endif
FontPatternCachePtr fontPatternCache;
+#ifdef FONTCACHE
+FontCacheSettings cacheSettings = { -1, -1, -1 };
+#endif
void
-InitFonts()
+InitFonts(void)
{
+#ifdef FONTCACHE
+ long himark, lowmark;
+ long balance;
+ FontCacheSettings cs;
+#endif
+
if (fontPatternCache)
FreeFontPatternCache(fontPatternCache);
fontPatternCache = MakeFontPatternCache();
ResetFontPrivateIndex();
+#ifdef FONTCACHE
+ /* check cache control parameters */
+ if (cacheSettings.himark == -1) {
+ himark = CACHE_HI_MARK;
+ if (cacheSettings.lowmark == -1) {
+ lowmark = CACHE_LOW_MARK;
+ } else {
+ lowmark = cacheSettings.lowmark;
+ }
+ } else {
+ himark = cacheSettings.himark;
+ if (cacheSettings.lowmark == -1) {
+ lowmark = (himark / 4) * 3;
+ } else {
+ lowmark = cacheSettings.lowmark;
+ }
+ }
+ if (cacheSettings.balance == -1) {
+ balance = CACHE_BALANCE;
+ } else {
+ balance = cacheSettings.balance;
+ }
+
+ if (himark <= 0 || lowmark <= 0) {
+ FatalError("illegal cache parameter setting\n");
+ }
+ if (himark <= lowmark) {
+ FatalError("illegal cache parameter setting\n");
+ }
+ if (!(10 <= balance && balance <= 90)) {
+ FatalError("illegal cache parameter setting\n");
+ }
+
+ /* set cache control parameters */
+ cs.himark = himark;
+ cs.lowmark = lowmark;
+ cs.balance = balance;
+ if (FontCacheChangeSettings(&cs) == 0) {
+ FatalError("couldn't init renderer font cache\n");
+ }
+#endif
+
#ifdef FONT_PCF
FontFileRegisterFpeFunctions();
#ifdef LOWMEMFTPT
diff --git a/difs/main.c b/difs/main.c
index dc43512..71d2c89 100644
--- a/difs/main.c
+++ b/difs/main.c
@@ -46,16 +46,23 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/main.c,v 3.12 2002/10/15 01:45:02 dawes Exp $ */
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "FS.h"
#include "FSproto.h"
#include "clientstr.h"
-#include "resource.h"
+#include "fsresource.h"
#include "misc.h"
#include "globals.h"
#include "servermd.h"
#include "cache.h"
#include "site.h"
+#include "dispatch.h"
+#include "extentst.h"
+#include "difs.h"
char *ConnectionInfo;
int ConnInfoLen;
@@ -68,26 +75,18 @@ Cache serverCache;
#define SERVER_CACHE_SIZE 10000 /* for random server cacheables */
-extern void InitProcVectors();
-extern void InitFonts();
-extern void InitAtoms();
-extern void InitExtensions();
-extern void ProcessCmdLine();
-static Bool create_connection_block();
+static Bool create_connection_block(void);
-extern ClientPtr currentClient;
char *configfilename;
extern Bool drone_server;
extern OldListenRec *OldListen;
extern int OldListenCount;
-
-main(argc, argv)
- int argc;
- char **argv;
+int
+main(int argc, char *argv[])
{
- int i;
+ int i, oldumask;
argcGlobal = argc;
argvGlobal = argv;
@@ -97,15 +96,22 @@ main(argc, argv)
/* init stuff */
ProcessCmdLine(argc, argv);
InitErrors();
+
/*
- * do this first thing, to get any options that only take effect at
- * startup time. it is erad again each time the server resets
+ * Do this first thing, to get any options that only take effect at
+ * startup time. It is read again each time the server resets.
*/
if (ReadConfigFile(configfilename) != FSSuccess) {
- ErrorF("fatal: couldn't read config file\n");
- exit(1);
+ FatalError("couldn't read config file\n");
}
+ /* make sure at least world write access is disabled */
+ if (((oldumask = umask(022)) & 002) == 002)
+ (void)umask(oldumask);
+
+ SetDaemonState();
+ SetUserId();
+
while (1) {
serverGeneration++;
OsInit();
@@ -169,15 +175,18 @@ main(argc, argv)
exit(0);
}
-void
-NotImplemented()
+int
+NotImplemented(void)
{
NoopDDA(); /* dummy to get difsutils.o to link */
- FatalError("Not implemented\n");
+ /* Getting here can become the next xfs exploit... so don't exit */
+ ErrorF("not implemented\n");
+
+ return (FSBadImplementation);
}
static Bool
-create_connection_block()
+create_connection_block(void)
{
fsConnSetupAccept setup;
char *pBuf;
diff --git a/difs/resource.c b/difs/resource.c
index 037b97f..5eaedb7 100644
--- a/difs/resource.c
+++ b/difs/resource.c
@@ -47,6 +47,7 @@ in this Software without prior written authorization from The Open Group.
* %W% %G%
*
*/
+/* $XFree86: xc/programs/xfs/difs/resource.c,v 3.8 2002/10/15 01:45:02 dawes Exp $ */
/*
* a resource is a 32 bit quantity. the upper 12 bits are client id.
* client provides a 19 bit resource id. this is "hashed" by me by
@@ -67,11 +68,12 @@ in this Software without prior written authorization from The Open Group.
#include "FS.h"
#include "misc.h"
#include "os.h"
-#include "resource.h"
+#include "fsresource.h"
#include "clientstr.h"
+#include "dispatch.h"
#include "globals.h"
-static void rebuild_table();
+static void rebuild_table(int client);
#define INITBUCKETS 64
#define INITHASHSIZE 6
@@ -100,14 +102,15 @@ static RESTYPE lastResourceType;
static RESTYPE lastResourceClass;
static RESTYPE TypeMask;
-typedef int (*DeleteType) ();
+typedef int (*DeleteType) (void *, FSID);
+
+extern int CloseClientFont(ClientPtr, FSID);
static DeleteType *DeleteFuncs = (DeleteType *) NULL;
#ifdef NOTYET
RESTYPE
-CreateNewResourceType(deleteFunc)
- DeleteType deleteFunc;
+CreateNewResourceType(DeleteType deleteFunc)
{
RESTYPE next = lastResourceType + 1;
DeleteType *funcs;
@@ -125,7 +128,7 @@ CreateNewResourceType(deleteFunc)
}
RESTYPE
-CreateNewResourceClass()
+CreateNewResourceClass(void)
{
RESTYPE next = lastResourceClass >> 1;
@@ -147,21 +150,18 @@ ClientResourceRec clientTable[MAXCLIENTS];
*****************/
int
-NoneDeleteFunc ()
+NoneDeleteFunc (void *ptr, FSID id)
{
+ return FSSuccess;
}
Bool
-InitClientResources(client)
- ClientPtr client;
+InitClientResources(ClientPtr client)
{
register int i,
j;
if (client == serverClient) {
- extern int CloseClientFont();
- extern int DeleteAuthCont ();
-
lastResourceType = RT_LASTPREDEF;
lastResourceClass = RC_LASTPREDEF;
TypeMask = RC_LASTPREDEF - 1;
@@ -172,8 +172,8 @@ InitClientResources(client)
if (!DeleteFuncs)
return FALSE;
DeleteFuncs[RT_NONE & TypeMask] = NoneDeleteFunc;
- DeleteFuncs[RT_FONT & TypeMask] = CloseClientFont;
- DeleteFuncs[RT_AUTHCONT & TypeMask] = DeleteAuthCont;
+ DeleteFuncs[RT_FONT & TypeMask] = (DeleteType)CloseClientFont;
+ DeleteFuncs[RT_AUTHCONT & TypeMask] = (DeleteType)DeleteAuthCont;
}
clientTable[i = client->index].resources =
(ResourcePtr *) fsalloc(INITBUCKETS * sizeof(ResourcePtr));
@@ -191,9 +191,7 @@ InitClientResources(client)
}
static int
-hash(client, id)
- int client;
- register FSID id;
+hash(int client, FSID id)
{
id &= RESOURCE_ID_MASK;
switch (clientTable[client].hashsize) {
@@ -215,9 +213,11 @@ hash(client, id)
static Font
-AvailableID(client, id, maxid, goodid)
- register int client;
- register FSID id, maxid, goodid;
+AvailableID(
+ register int client,
+ register FSID id,
+ register FSID maxid,
+ register FSID goodid)
{
register ResourcePtr res;
@@ -243,8 +243,7 @@ AvailableID(client, id, maxid, goodid)
*/
FSID
-FakeClientID(client)
- int client;
+FakeClientID(int client)
{
register FSID id, maxid;
register ResourcePtr *resp;
@@ -286,11 +285,11 @@ FakeClientID(client)
}
Bool
-AddResource(cid, id, type, value)
- int cid;
- FSID id;
- RESTYPE type;
- pointer value;
+AddResource(
+ int cid,
+ FSID id,
+ RESTYPE type,
+ pointer value)
{
register ClientResourceRec *rrec;
register ResourcePtr res,
@@ -323,8 +322,7 @@ AddResource(cid, id, type, value)
}
static void
-rebuild_table(client)
- int client;
+rebuild_table(int client)
{
register int j;
register ResourcePtr res,
@@ -372,10 +370,10 @@ rebuild_table(client)
}
void
-FreeResource(cid, id, skipDeleteFuncType)
- int cid;
- FSID id;
- RESTYPE skipDeleteFuncType;
+FreeResource(
+ int cid,
+ FSID id,
+ RESTYPE skipDeleteFuncType)
{
register ResourcePtr res;
register ResourcePtr *prev,
@@ -406,16 +404,16 @@ FreeResource(cid, id, skipDeleteFuncType)
}
}
if (!gotOne)
- FatalError("Freeing resource id=%X which isn't there\n", id);
+ FatalError("freeing resource id=%X which isn't there\n", id);
}
#ifdef NOTYET
void
-FreeResourceByType(cid, id, type, skipFree)
- int cid;
- FSID id;
- RESTYPE type;
- Bool skipFree;
+FreeResourceByType(
+ int cid,
+ FSID id,
+ RESTYPE type,
+ Bool skipFree)
{
register ResourcePtr res;
register ResourcePtr *prev,
@@ -445,11 +443,11 @@ FreeResourceByType(cid, id, type, skipFree)
*/
Bool
-ChangeResourceValue(cid, id, rtype, value)
- int cid;
- FSID id;
- RESTYPE rtype;
- pointer value;
+ChangeResourceValue(
+ int cid,
+ FSID id,
+ RESTYPE rtype,
+ pointer value)
{
register ResourcePtr res;
@@ -468,8 +466,7 @@ ChangeResourceValue(cid, id, rtype, value)
#endif /* NOTYET */
void
-FreeClientResources(client)
- ClientPtr client;
+FreeClientResources(ClientPtr client)
{
register ResourcePtr *resources;
register ResourcePtr this;
@@ -512,7 +509,8 @@ FreeClientResources(client)
clientTable[client->index].buckets = 0;
}
-FreeAllResources()
+void
+FreeAllResources(void)
{
int i;
@@ -526,10 +524,10 @@ FreeAllResources()
* lookup_id_by_type returns the object with the given id and type, else NULL.
*/
pointer
-LookupIDByType(cid, id, rtype)
- int cid;
- FSID id;
- RESTYPE rtype;
+LookupIDByType(
+ int cid,
+ FSID id,
+ RESTYPE rtype)
{
register ResourcePtr res;
@@ -549,9 +547,9 @@ LookupIDByType(cid, id, rtype)
* given classes, else NULL.
*/
pointer
-LookupIDByClass(id, classes)
- FSID id;
- RESTYPE classes;
+LookupIDByClass(
+ FSID id,
+ RESTYPE classes)
{
int cid;
register ResourcePtr res;
diff --git a/difs/swaprep.c b/difs/swaprep.c
index b5ed328..07981aa 100644
--- a/difs/swaprep.c
+++ b/difs/swaprep.c
@@ -46,18 +46,21 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/swaprep.c,v 1.5 2001/12/14 20:01:35 dawes Exp $ */
+
+#include <swaprep.h>
+#include <swapreq.h>
#include "FSproto.h"
#include "clientstr.h"
-#include "misc.h"
-static void SwapConnSetupAccept();
+static void SwapConnSetupAccept(fsConnSetupAccept *pConnSetup, fsConnSetupAccept *pConnSetupT);
void
-Swap32Write(client, size, pbuf)
- ClientPtr client;
- int size;
- long *pbuf;
+Swap32Write(
+ ClientPtr client,
+ int size,
+ long *pbuf)
{
int n,
i;
@@ -70,10 +73,10 @@ Swap32Write(client, size, pbuf)
}
void
-Swap16Write(client, size, pbuf)
- ClientPtr client;
- int size;
- short *pbuf;
+Swap16Write(
+ ClientPtr client,
+ int size,
+ short *pbuf)
{
int n,
i;
@@ -85,10 +88,11 @@ Swap16Write(client, size, pbuf)
(void) WriteToClient(client, size << 1, (char *) pbuf);
}
-CopySwap32Write(client, size, pbuf)
- ClientPtr client;
- int size;
- long *pbuf;
+void
+CopySwap32Write(
+ ClientPtr client,
+ int size,
+ long *pbuf)
{
int bufsize = size;
long *pbufT;
@@ -134,10 +138,10 @@ CopySwap32Write(client, size, pbuf)
}
void
-CopySwap16Write(client, size, pbuf)
- ClientPtr client;
- int size;
- short *pbuf;
+CopySwap16Write(
+ ClientPtr client,
+ int size,
+ short *pbuf)
{
int bufsize = size;
short *pbufT;
@@ -184,33 +188,44 @@ CopySwap16Write(client, size, pbuf)
DEALLOCATE_LOCAL((char *) pbufT);
}
+
+#undef pRep
+#define pRep ((fsGenericReply *)data)
+
void
-SGenericReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsGenericReply *pRep;
+SGenericReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
(void) WriteToClient(client, size, (char *) pRep);
}
+
+#undef pRep
+#define pRep ((fsListExtensionsReply *)data)
+
void
-SListExtensionsReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsListExtensionsReply *pRep;
+SListExtensionsReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsQueryExtensionReply *)data)
+
void
-SQueryExtensionReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsQueryExtensionReply *pRep;
+SQueryExtensionReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -219,11 +234,14 @@ SQueryExtensionReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsListCataloguesReply *)data)
+
void
-SListCataloguesReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsListCataloguesReply *pRep;
+SListCataloguesReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -232,11 +250,14 @@ SListCataloguesReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsCreateACReply *)data)
+
void
-SCreateACReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsCreateACReply *pRep;
+SCreateACReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -244,11 +265,14 @@ SCreateACReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsGetEventMaskReply *)data)
+
void
-SGetEventMaskReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsGetEventMaskReply *pRep;
+SGetEventMaskReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -256,22 +280,28 @@ SGetEventMaskReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsGetResolutionReply *)data)
+
void
-SGetResolutionReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsGetResolutionReply *pRep;
+SGetResolutionReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsListFontsReply *)data)
+
void
-SListFontsReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsListFontsReply *pRep;
+SListFontsReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -300,11 +330,14 @@ SListFontsReply(client, size, pRep)
reply->font_header_font_ascent = lswaps(reply->font_header_font_ascent); \
reply->font_header_font_descent = lswaps(reply->font_header_font_descent)
+#undef pRep
+#define pRep ((fsListFontsWithXInfoReply *)data)
+
void
-SListFontsWithXInfoReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsListFontsWithXInfoReply *pRep;
+SListFontsWithXInfoReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -315,11 +348,14 @@ SListFontsWithXInfoReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsOpenBitmapFontReply *)data)
+
void
-SOpenBitmapFontReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsOpenBitmapFontReply *pRep;
+SOpenBitmapFontReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -328,11 +364,14 @@ SOpenBitmapFontReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsQueryXInfoReply *)data)
+
void
-SQueryXInfoReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsQueryXInfoReply *pRep;
+SQueryXInfoReply(
+ ClientPtr client,
+ int size,
+ void * data)
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -340,11 +379,14 @@ SQueryXInfoReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsQueryXExtents8Reply *)data)
+
void
-SQueryXExtentsReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsQueryXExtents8Reply *pRep; /* QueryXExtents16Reply is the same */
+SQueryXExtentsReply(
+ ClientPtr client,
+ int size,
+ void * data) /* QueryXExtents16Reply is the same */
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -352,11 +394,14 @@ SQueryXExtentsReply(client, size, pRep)
(void) WriteToClient(client, size, (char *) pRep);
}
+#undef pRep
+#define pRep ((fsQueryXBitmaps8Reply *)data)
+
void
-SQueryXBitmapsReply(client, size, pRep)
- ClientPtr client;
- int size;
- fsQueryXBitmaps8Reply *pRep; /* QueryXBitmaps16Reply is the same */
+SQueryXBitmapsReply(
+ ClientPtr client,
+ int size,
+ void * data) /* QueryXBitmaps16Reply is the same */
{
pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
pRep->length = lswapl(pRep->length);
@@ -367,9 +412,7 @@ SQueryXBitmapsReply(client, size, pRep)
}
void
-SErrorEvent(error, perror)
- fsError *error,
- *perror;
+SErrorEvent(fsError *error, fsError *perror)
{
*perror = *error;
perror->sequenceNumber = lswaps(perror->sequenceNumber);
@@ -378,10 +421,10 @@ SErrorEvent(error, perror)
}
void
-WriteSConnectionInfo(client, size, pInfo)
- ClientPtr client;
- unsigned long size;
- char *pInfo;
+WriteSConnectionInfo(
+ ClientPtr client,
+ unsigned long size,
+ char *pInfo)
{
char *pInfoT,
*pInfoTBase;
@@ -405,9 +448,7 @@ WriteSConnectionInfo(client, size, pInfo)
}
static void
-SwapConnSetupAccept(pConnSetup, pConnSetupT)
- fsConnSetupAccept *pConnSetup,
- *pConnSetupT;
+SwapConnSetupAccept(fsConnSetupAccept *pConnSetup, fsConnSetupAccept *pConnSetupT)
{
pConnSetupT->length = lswapl(pConnSetup->length);
pConnSetupT->max_request_len = lswaps(pConnSetup->max_request_len);
@@ -416,9 +457,7 @@ SwapConnSetupAccept(pConnSetup, pConnSetupT)
}
void
-WriteSConnSetup(client, pcsp)
- ClientPtr client;
- fsConnSetup *pcsp;
+WriteSConnSetup(ClientPtr client, fsConnSetup *pcsp)
{
fsConnSetup cspT;
@@ -433,8 +472,7 @@ WriteSConnSetup(client, pcsp)
}
static void
-SwapPropOffset(po)
- char *po;
+SwapPropOffset(char *po)
{
int i, n;
@@ -446,8 +484,7 @@ SwapPropOffset(po)
}
void
-SwapPropInfo(pi)
- fsPropInfo *pi;
+SwapPropInfo(fsPropInfo *pi)
{
int i;
char *po;
@@ -464,9 +501,7 @@ SwapPropInfo(pi)
}
void
-SwapExtents(extents, num)
- fsXCharInfo *extents;
- int num;
+SwapExtents(fsXCharInfo *extents, int num)
{
SwapShorts((short *)extents, num * (SIZEOF(fsXCharInfo) / 2));
}
diff --git a/difs/swapreq.c b/difs/swapreq.c
index 9767bec..433e840 100644
--- a/difs/swapreq.c
+++ b/difs/swapreq.c
@@ -46,18 +46,17 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/swapreq.c,v 1.7 2001/12/14 20:01:35 dawes Exp $ */
+
+#include <swapreq.h>
-#include "misc.h"
#include "FSproto.h"
#include "clientstr.h"
#include "globals.h"
-
-extern int (*ProcVector[NUM_PROC_VECTORS]) ();
+#include "dispatch.h"
void
-SwapLongs(list, count)
- long *list;
- unsigned long count;
+SwapLongs(long *list, unsigned long count)
{
int n;
register char *longs = (char *)list;
@@ -85,9 +84,7 @@ SwapLongs(list, count)
/* Byte swap a list of shorts */
void
-SwapShorts(list, count)
- short *list;
- register unsigned long count;
+SwapShorts(short *list, unsigned long count)
{
register char *shorts = (char *)list;
register int n;
@@ -124,8 +121,7 @@ SwapShorts(list, count)
* used for all requests that have nothing but 'length' swapped
*/
int
-SProcSimpleRequest(client)
- ClientPtr client;
+SProcSimpleRequest(ClientPtr client)
{
REQUEST(fsReq);
stuff->length = lswaps(stuff->length);
@@ -136,8 +132,7 @@ SProcSimpleRequest(client)
* used for all requests that have nothing but 'length' & a resource id swapped
*/
int
-SProcResourceRequest(client)
- ClientPtr client;
+SProcResourceRequest(ClientPtr client)
{
REQUEST(fsResourceReq);
stuff->length = lswaps(stuff->length);
@@ -145,12 +140,10 @@ SProcResourceRequest(client)
return ((*ProcVector[stuff->reqType]) (client));
}
-static void
-swap_auth(data, num)
- pointer data;
- int num;
+static int
+swap_auth(ClientPtr client, pointer data, int num, int length)
{
- pointer p;
+ unsigned char *p;
unsigned char t;
CARD16 namelen,
datalen;
@@ -158,6 +151,12 @@ swap_auth(data, num)
p = data;
for (i = 0; i < num; i++) {
+ if (p - (unsigned char *)data > length - 4) {
+ int lengthword = length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
namelen = *(CARD16 *) p;
t = p[0];
p[0] = p[1];
@@ -171,26 +170,42 @@ swap_auth(data, num)
p += (namelen + 3) & ~3;
p += (datalen + 3) & ~3;
}
+ if (!num)
+ p += 4;
+ if (p - (unsigned char *)data != length) {
+ int lengthword = length;
+
+ SendErrToClient(client, FSBadLength, (pointer)&lengthword);
+ return (FSBadLength);
+ }
+
+ return (FSSuccess);
}
int
-SProcCreateAC(client)
- ClientPtr client;
+SProcCreateAC(ClientPtr client)
{
+ int status;
+
REQUEST(fsCreateACReq);
stuff->length = lswaps(stuff->length);
stuff->acid = lswapl(stuff->acid);
- swap_auth((pointer) &stuff[1], stuff->num_auths);
+ status = swap_auth(client, (pointer) &stuff[1],
+ stuff->num_auths, stuff->length);
+ if (status != FSSuccess)
+ return (status);
return ((*ProcVector[stuff->reqType]) (client));
}
int
-SProcSetResolution(client)
- ClientPtr client;
+SProcSetResolution(ClientPtr client)
{
REQUEST(fsSetResolutionReq);
stuff->length = lswaps(stuff->length);
stuff->num_resolutions = lswaps(stuff->num_resolutions);
+ if ((int)stuff->length - (&stuff[1] - &stuff[0]) !=
+ stuff->num_resolutions * sizeof(fsResolution))
+ return (FSBadLength);
SwapShorts((short *) &stuff[1], stuff->num_resolutions);
return ((*ProcVector[stuff->reqType]) (client));
@@ -198,8 +213,7 @@ SProcSetResolution(client)
int
-SProcQueryExtension(client)
- ClientPtr client;
+SProcQueryExtension(ClientPtr client)
{
REQUEST(fsQueryExtensionReq);
stuff->length = lswaps(stuff->length);
@@ -207,8 +221,7 @@ SProcQueryExtension(client)
}
int
-SProcListCatalogues(client)
- ClientPtr client;
+SProcListCatalogues(ClientPtr client)
{
REQUEST(fsListCataloguesReq);
stuff->length = lswaps(stuff->length);
@@ -218,8 +231,7 @@ SProcListCatalogues(client)
}
int
-SProcListFonts(client)
- ClientPtr client;
+SProcListFonts(ClientPtr client)
{
REQUEST(fsListFontsReq);
stuff->length = lswaps(stuff->length);
@@ -229,8 +241,7 @@ SProcListFonts(client)
}
int
-SProcListFontsWithXInfo(client)
- ClientPtr client;
+SProcListFontsWithXInfo(ClientPtr client)
{
REQUEST(fsListFontsWithXInfoReq);
stuff->length = lswaps(stuff->length);
@@ -240,8 +251,7 @@ SProcListFontsWithXInfo(client)
}
int
-SProcOpenBitmapFont(client)
- ClientPtr client;
+SProcOpenBitmapFont(ClientPtr client)
{
REQUEST(fsOpenBitmapFontReq);
stuff->length = lswaps(stuff->length);
@@ -252,8 +262,7 @@ SProcOpenBitmapFont(client)
}
int
-SProcQueryXExtents(client)
- ClientPtr client;
+SProcQueryXExtents(ClientPtr client)
{
REQUEST(fsQueryXExtents8Req); /* 8 and 16 are the same here */
stuff->length = lswaps(stuff->length);
@@ -264,8 +273,7 @@ SProcQueryXExtents(client)
}
int
-SProcQueryXBitmaps(client)
- ClientPtr client;
+SProcQueryXBitmaps(ClientPtr client)
{
REQUEST(fsQueryXBitmaps8Req); /* 8 and 16 are the same here */
stuff->length = lswaps(stuff->length);
@@ -276,11 +284,14 @@ SProcQueryXBitmaps(client)
return ((*ProcVector[stuff->reqType]) (client));
}
-SwapConnClientPrefix(pCCP)
- fsConnClientPrefix *pCCP;
+int
+SwapConnClientPrefix(ClientPtr client, fsConnClientPrefix *pCCP)
{
+ REQUEST(fsFakeReq);
+
pCCP->major_version = lswaps(pCCP->major_version);
pCCP->minor_version = lswaps(pCCP->minor_version);
pCCP->auth_len = lswaps(pCCP->auth_len);
- swap_auth((pointer) &pCCP[1], pCCP->num_auths);
+ return (swap_auth(client, (pointer) &pCCP[1],
+ pCCP->num_auths, stuff->length));
}
diff --git a/difs/tables.c b/difs/tables.c
index 29ba6b7..069523d 100644
--- a/difs/tables.c
+++ b/difs/tables.c
@@ -46,52 +46,26 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/difs/tables.c,v 1.6 2001/12/14 20:01:35 dawes Exp $ */
-#include "globals.h"
-
-extern int ProcInitialConnection(), ProcEstablishConnection();
-
-extern int ProcSetAuthorization(),
- ProcSetResolution(), ProcGetResolution(), ProcNoop(),
- ProcListExtensions(), ProcQueryExtension(),
- ProcListFonts(), ProcListFontsWithXInfo(),
- ProcOpenBitmapFont(), ProcQueryXInfo(), ProcQueryXExtents(),
- ProcQueryXBitmaps(), ProcCloseFont(),
- ProcListCatalogues(), ProcSetCatalogues(), ProcGetCatalogues(),
- ProcSetEventMask(), ProcGetEventMask(),
- ProcCreateAC(), ProcFreeAC();
-
-extern int SProcSimpleRequest(), SProcResourceRequest(),
- SProcListCatalogues(),
- SProcSetResolution(),
- SProcQueryExtension(),
- SProcListFonts(), SProcListFontsWithXInfo(),
- SProcOpenBitmapFont(), SProcQueryXExtents(),
- SProcQueryXBitmaps(),
- SProcCreateAC();
-
-extern void SErrorEvent();
-
-extern void NotImplemented(), SGenericReply(),
- SListExtensionsReply(),
- SListCataloguesReply(),
- SQueryExtensionReply(),
- SListFontsReply(), SListFontsWithXInfoReply(),
- SOpenBitmapFontReply(),
- SQueryXInfoReply(), SQueryXExtentsReply(),
- SQueryXBitmapsReply(),
- SGetEventMaskReply(), SCreateACReply(), SGetResolutionReply(),
- SOpenBitmapFontReply();
+#include <dispatch.h>
+#include <swaprep.h>
+#include <swapreq.h>
+#include <fsevents.h>
+#include "globals.h"
+#include "client.h"
+#include "extentst.h"
+#include "difs.h"
-int (*InitialVector[3]) () =
+InitialFunc InitialVector[3] =
{
0,
ProcInitialConnection,
ProcEstablishConnection
};
-int (*ProcVector[NUM_PROC_VECTORS]) () =
+ProcFunc ProcVector[NUM_PROC_VECTORS] =
{
ProcNoop, /* 0 */
ProcListExtensions,
@@ -120,7 +94,7 @@ int (*ProcVector[NUM_PROC_VECTORS]) () =
0
};
-int (*SwappedProcVector[NUM_PROC_VECTORS]) () =
+SwappedProcFunc SwappedProcVector[NUM_PROC_VECTORS] =
{
SProcSimpleRequest, /* 0 */
SProcSimpleRequest,
@@ -149,10 +123,10 @@ int (*SwappedProcVector[NUM_PROC_VECTORS]) () =
0
};
-void (*EventSwapVector[NUM_EVENT_VECTORS]) () =
+EventSwapFunc EventSwapVector[NUM_EVENT_VECTORS] =
{
SErrorEvent,
- NotImplemented,
+ (EventSwapFunc)NotImplemented,
0,
0,
0,
@@ -161,20 +135,20 @@ void (*EventSwapVector[NUM_EVENT_VECTORS]) () =
0
};
-void (*ReplySwapVector[NUM_PROC_VECTORS]) () =
+ReplySwapFunc ReplySwapVector[NUM_PROC_VECTORS] =
{
- NotImplemented, /* NoOp */
+ (ReplySwapFunc)NotImplemented, /* NoOp */
SListExtensionsReply,
SQueryExtensionReply, /* SQueryExtensionReply */
SListCataloguesReply,
- NotImplemented, /* SetCatalogues */
+ (ReplySwapFunc)NotImplemented, /* SetCatalogues */
SGenericReply, /* GetCatalogues */
- NotImplemented, /* SetEventMask */
+ (ReplySwapFunc)NotImplemented, /* SetEventMask */
SGetEventMaskReply,
SCreateACReply,
- NotImplemented, /* FreeAC */
- NotImplemented, /* SetAuthorization - 10 */
- NotImplemented, /* SetResolution */
+ (ReplySwapFunc)NotImplemented, /* FreeAC */
+ (ReplySwapFunc)NotImplemented, /* SetAuthorization - 10 */
+ (ReplySwapFunc)NotImplemented, /* SetResolution */
SGetResolutionReply,
SListFontsReply,
SListFontsWithXInfoReply,
@@ -184,7 +158,7 @@ void (*ReplySwapVector[NUM_PROC_VECTORS]) () =
SQueryXExtentsReply,
SQueryXBitmapsReply,
SQueryXBitmapsReply, /* 20 */
- NotImplemented, /* Close */
- NotImplemented,
- NotImplemented
+ (ReplySwapFunc)NotImplemented, /* Close */
+ (ReplySwapFunc)NotImplemented,
+ (ReplySwapFunc)NotImplemented
};
diff --git a/include/access.h b/include/access.h
index 21957c3..4b9efc0 100644
--- a/include/access.h
+++ b/include/access.h
@@ -47,20 +47,26 @@ in this Software without prior written authorization from The Open Group.
* @(#)access.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/access.h,v 1.5 2001/12/14 20:01:36 dawes Exp $ */
#ifndef _ACCESS_H_
#define _ACCESS_H_
typedef struct _hostaddress *HostList;
+#include <os.h>
+#include <client.h>
+
#define HOST_AF_INET 1
#define HOST_AF_DECnet 2
-extern int AddHost();
-extern int RemoveHost();
-extern int ValidHost();
-extern int GetHostAddress();
-extern int CheckClientAuthorization();
-extern void AccessSetConnectionLimit();
+extern int CheckClientAuthorization(
+ ClientPtr client,
+ AuthPtr client_auth,
+ int *accept,
+ int *index,
+ int *size,
+ char **auth_data);
+extern void AccessSetConnectionLimit(int num);
#endif /* _ACCESS_H_ */
diff --git a/include/accstr.h b/include/accstr.h
index 55ce4f3..991a1fa 100644
--- a/include/accstr.h
+++ b/include/accstr.h
@@ -48,11 +48,10 @@ in this Software without prior written authorization from The Open Group.
* @(#)accstr.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/accstr.h,v 1.7 2001/12/14 20:01:36 dawes Exp $ */
#ifndef _ACCSTR_H_
#define _ACCSTR_H_
-#include "misc.h"
-#include "access.h"
typedef struct _hostaddress {
int type;
@@ -61,4 +60,17 @@ typedef struct _hostaddress {
struct _hostaddress *next;
} HostAddress;
+#include <misc.h>
+#include <access.h>
+
+#if 0
+/* difs/difsutils.c */
+extern int AddHost(HostList *list, HostAddress *addr);
+extern int RemoveHost(HostList *list, HostAddress *addr);
+extern int ValidHost(HostList list, HostAddress *addr);
+#endif
+
+/* os/access.c */
+extern int GetHostAddress(HostAddress *addr);
+
#endif /* _ACCSTR_H_ */
diff --git a/include/auth.h b/include/auth.h
index 79fbbfb..06958ce 100644
--- a/include/auth.h
+++ b/include/auth.h
@@ -47,12 +47,11 @@ in this Software without prior written authorization from The Open Group.
* @(#)auth.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/auth.h,v 1.6 2001/12/14 20:01:36 dawes Exp $ */
#ifndef _AUTH_H_
#define _AUTH_H_
typedef struct _authcontext *AuthContextPtr;
-extern AuthContextPtr GetClientAuthorization();
-
#endif /* _AUTH_H_ */
diff --git a/include/cache.h b/include/cache.h
index e752055..4f75abd 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -47,8 +47,11 @@ in this Software without prior written authorization from The Open Group.
* @(#)cache.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/cache.h,v 1.5 2001/12/14 20:01:37 dawes Exp $ */
+
#ifndef _CACHE_H_
#define _CACHE_H_
+
#include "misc.h"
#define CacheWasReset 1
@@ -57,17 +60,16 @@ in this Software without prior written authorization from The Open Group.
typedef unsigned long CacheID;
typedef unsigned long Cache;
-typedef void (*CacheFree) ();
+typedef void (*CacheFree) (CacheID cid, pointer, int flag);
typedef struct _cache *CachePtr;
-extern CacheID CacheStoreMemory();
-extern int CacheFreeMemory();
-extern void CacheSimpleFree();
-extern Cache CacheInit();
-extern void CacheReset();
-extern void CacheResize();
-extern pointer CacheFetchMemory();
-extern void CacheStats();
+extern Cache CacheInit(unsigned long maxsize);
+extern CacheID CacheStoreMemory(Cache cid, pointer data, unsigned long size, CacheFree free_func);
+extern void CacheFreeMemory(CacheID cid, Bool notify);
+extern pointer CacheFetchMemory(CacheID cid, Bool update);
+extern void CacheReset(void);
+extern void CacheResize(Cache cid, unsigned newsize);
+extern void CacheSimpleFree(CacheID cid, pointer data, int reason);
#endif /* _CACHE_H_ */
diff --git a/include/client.h b/include/client.h
index e09f513..5f484ab 100644
--- a/include/client.h
+++ b/include/client.h
@@ -43,11 +43,17 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/client.h,v 1.7 2001/12/14 20:01:37 dawes Exp $ */
#ifndef _CLIENT_H_
#define _CLIENT_H_
+#ifndef _XTYPEDEF_CLIENTPTR
typedef struct _Client *ClientPtr;
+#define _XTYPEDEF_CLIENTPTR
+#endif
+
+#include <misc.h>
extern ClientPtr *clients;
extern ClientPtr serverClient;
@@ -62,8 +68,6 @@ extern ClientPtr serverClient;
#define CLIENT_AGED 2
#define CLIENT_TIMED_OUT 4
-extern int currentMaxClients;
-
#define REQUEST(type) \
type *stuff = (type *)client->requestBuffer
@@ -101,17 +105,11 @@ extern int currentMaxClients;
else (void) WriteToClient(client, (int)(size), (char *)(pbuf));
-extern void SendErrToClient();
+typedef struct _WorkQueue *WorkQueuePtr;
-extern void SwapFontHeader();
-extern void SwapExtents();
-extern void SwapPropInfo();
-extern void SwapCharInfo();
-extern void WriteSConnSetup();
-extern void WriteSConnectionInfo();
-extern void SErrorEvent();
+#include <difsutils.h> /* for ProcessWorkQueue(void) */
-typedef struct _WorkQueue *WorkQueuePtr;
-extern void ProcessWorkQueue();
+extern int (*ProcVector[]) (ClientPtr);
+extern int (*SwappedProcVector[]) (ClientPtr);
#endif /* _CLIENT_H_ */
diff --git a/include/clientstr.h b/include/clientstr.h
index c52c746..100a1ce 100644
--- a/include/clientstr.h
+++ b/include/clientstr.h
@@ -44,6 +44,7 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/clientstr.h,v 1.7 2001/12/14 20:01:37 dawes Exp $ */
#ifndef _CLIENTSTR_H_
#define _CLIENTSTR_H_
@@ -57,13 +58,13 @@ typedef struct _Client {
int index;
pointer osPrivate;
int noClientException;
- int (**requestVector) ();
+ int (**requestVector) (ClientPtr);
pointer requestBuffer;
int clientGone;
int sequence;
Bool swapped;
long last_request_time;
- void (*pSwapReplyFunc) ();
+ void (*pSwapReplyFunc) (ClientPtr, int, short *);
AuthContextPtr auth;
int auth_generation;
AuthContextPtr default_auth;
@@ -78,12 +79,20 @@ typedef struct _Client {
typedef struct _WorkQueue {
struct _WorkQueue *next;
- Bool (*function) ();
+ Bool (*function) (ClientPtr, pointer);
ClientPtr client;
pointer closure;
} WorkQueueRec;
-
-extern void CloseDownClient();
+#ifndef CloseDownClient
+#ifdef DEBUG
+#define CloseDownClient(client) \
+ fprintf(stderr, "CloseDownClient %s %d\n", __FILE__, __LINE__),\
+ DoCloseDownClient(client)
+#else
+#define CloseDownClient DoCloseDownClient
+#endif
+extern void DoCloseDownClient(ClientPtr client);
+#endif
#endif /* _CLIENTSTR_H_ */
diff --git a/include/closestr.h b/include/closestr.h
index 925af84..9d38ff2 100644
--- a/include/closestr.h
+++ b/include/closestr.h
@@ -44,7 +44,7 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $NCDId: @(#)closestr.h,v 4.1 1991/05/02 04:15:46 lemke Exp $
+ * $NCDXorg: @(#)closestr.h,v 4.1 1991/05/02 04:15:46 lemke Exp $
*
*/
diff --git a/include/difsfn.h b/include/difsfn.h
index c795eea..9005ff5 100644
--- a/include/difsfn.h
+++ b/include/difsfn.h
@@ -44,6 +44,7 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/difsfn.h,v 1.5 2001/12/14 20:01:37 dawes Exp $ */
#ifndef _DIFSFONT_H_
#define _DIFSFONT_H_
@@ -52,12 +53,5 @@ in this Software without prior written authorization from The Open Group.
typedef struct _ClientFont *ClientFontPtr;
typedef struct _FontIDList *FontIDListPtr;
-typedef struct _font_name_cache FontNameCachePtr;
-
-#define NullClientFont ((ClientFontPtr)0)
-
-extern FontPtr FindCachedFontName();
-extern int CacheFontName();
-extern void RemoveBlockAndWakeupHandlers();
#endif /* _DIFSFONT_H_ */
diff --git a/include/difsfnst.h b/include/difsfnst.h
index 5141051..301efea 100644
--- a/include/difsfnst.h
+++ b/include/difsfnst.h
@@ -44,6 +44,7 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/difsfnst.h,v 1.5 2001/12/14 20:01:38 dawes Exp $ */
#ifndef _DIFSFONTST_H_
#define _DIFSFONTST_H_
@@ -71,4 +72,5 @@ typedef struct _FontIDList {
int size;
} FontIDListRec;
+
#endif /* _DIFSFONTST_H_ */
diff --git a/include/extentst.h b/include/extentst.h
index 2d0f0ed..56cb17b 100644
--- a/include/extentst.h
+++ b/include/extentst.h
@@ -47,13 +47,14 @@ in this Software without prior written authorization from The Open Group.
* @(#)extentst.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/extentst.h,v 1.6 2001/12/14 20:01:38 dawes Exp $ */
#ifndef _EXTENTST_H_
#define _EXTENTST_H_
typedef struct _ExtensionEntry {
int index;
- void (*CloseDown) ();
+ void (*CloseDown) (struct _ExtensionEntry*);
char *name;
int base;
int eventBase;
@@ -63,11 +64,12 @@ typedef struct _ExtensionEntry {
int num_aliases;
char **aliases;
pointer extPrivate;
- unsigned short (*MinorOpcode) ();
+ unsigned short (*MinorOpcode) (ClientPtr);
} ExtensionEntry;
-extern void (*EventSwapVector[]) ();
+extern void (*EventSwapVector[]) (fsError *, fsError *);
+#if 0
typedef void (*ExtensionLookupProc) ();
typedef struct _ProcEntry {
@@ -75,14 +77,19 @@ typedef struct _ProcEntry {
ExtensionLookupProc proc;
} ProcEntryRec, *ProcEntryPtr;
-extern void InitExtensions();
-extern int ProcQueryExtension();
-extern int ProcListExtensions();
extern ExtensionEntry *AddExtension();
-extern Bool AddExtensionAlias();
extern ExtensionLookupProc LookupProc();
extern Bool RegisterProc();
-extern unsigned short MinorOpcodeOfRequest();
-extern unsigned short StandardMinorOpcode();
+#endif
+
+extern ExtensionEntry * AddExtension ( char *name, int num_events, int num_errors, int (*main_proc) (ClientPtr), int (*smain_proc) (ClientPtr), void (*closedown_proc) (struct _ExtensionEntry *), unsigned short (*minorop_proc) (ClientPtr) );
+
+extern Bool AddExtensionAlias(char *alias, ExtensionEntry *ext);
+extern int ProcListExtensions(ClientPtr client);
+extern int ProcQueryExtension(ClientPtr client);
+extern unsigned short MinorOpcodeOfRequest(ClientPtr client);
+extern unsigned short StandardMinorOpcode(ClientPtr client);
+extern void CloseDownExtensions(void);
+extern void InitExtensions(void);
#endif /* _EXTENTST_H_ */
diff --git a/include/misc.h b/include/misc.h
index b4038aa..a6de816 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -43,31 +43,23 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/misc.h,v 3.9 2001/12/14 20:01:38 dawes Exp $ */
#ifndef _MISC_H_
#define _MISC_H_
#include <X11/Xosdefs.h>
#include <X11/Xfuncs.h>
+#include <X11/Xdefs.h>
#include "assert.h" /* so its everywhere */
#ifndef NULL
-
-#ifndef X_NOT_STDC_ENV
#include <stddef.h>
-#else
-#define NULL 0
-#endif
-
#endif
#define MAXCLIENTS 128
-typedef unsigned char *pointer;
-typedef int Bool;
-typedef unsigned long Atom;
-
#define MILLI_PER_SECOND (1000)
#define MILLI_PER_MINUTE (1000 * 60)
@@ -78,7 +70,6 @@ typedef unsigned long Atom;
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
-#define abs(a) ((a) > 0 ? (a) : -(a))
#include "os.h"
@@ -122,20 +113,14 @@ typedef unsigned long Atom;
((char *) &(dst))[1] = ((char *) &(src))[0];
-extern void SwapLongs();
-extern void SwapShorts();
-
-extern void CopyIsoLatin1Lowered();
-extern void NoopDDA();
-extern char *NameForAtom();
-extern void BitOrderInvert();
-extern void TwoByteInvert();
-extern void FourByteInvert();
-
-extern long GetTimeInMillis();
+#if 0
+extern void NoopDDA(void);
+extern char *NameForAtom(Atom atom);
+#endif
+extern void BitOrderInvert(unsigned char *buf, int nbytes);
-#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#if !defined(UNIXCPP) || defined(ANSICPP)
#define fsCat(x,y) x##_##y
#else
#define fsCat(x,y) x/**/_/**/y
@@ -191,5 +176,7 @@ typedef struct { /* when cloning, need old transport info */
int portnum;
} OldListenRec;
+/* os/connection.c */
+extern void CreateSockets(int old_listen_count, OldListenRec *old_listen);
#endif /* _MISC_H_ */
diff --git a/include/os.h b/include/os.h
index c5ff552..4bd4a4d 100644
--- a/include/os.h
+++ b/include/os.h
@@ -44,53 +44,120 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $NCDId: @(#)os.h,v 4.2 1991/05/10 07:59:16 lemke Exp $
+ * $NCDXorg: @(#)os.h,v 4.2 1991/05/10 07:59:16 lemke Exp $
*
*/
+/* $XFree86: xc/programs/xfs/include/os.h,v 3.14 2002/10/15 01:45:03 dawes Exp $ */
#ifndef _OS_H_
#define _OS_H_
+typedef struct _FontPathRec *FontPathPtr;
+typedef struct _alt_server *AlternateServerPtr;
+typedef struct _auth *AuthPtr;
+
#include "FSproto.h"
+#include "client.h"
#include "misc.h"
+
+typedef pointer FID;
+
#define ALLOCATE_LOCAL_FALLBACK(_size) FSalloc((unsigned long)_size)
#define DEALLOCATE_LOCAL_FALLBACK(_ptr) FSfree((pointer)_ptr)
+
#include "X11/Xalloca.h"
-#define MAX_REQUEST_SIZE 16384
+#define MAX_REQUEST_SIZE 8192
-extern unsigned long *FSalloc();
-extern unsigned long *FSrealloc();
-extern void FSfree();
+#ifdef SIGNALRETURNSINT
+#define SIGVAL int
+#else
+#define SIGVAL void
+#endif
#define fsalloc(size) FSalloc((unsigned long)size)
#define fsrealloc(ptr, size) FSrealloc((pointer)ptr, (unsigned long)size)
#define fsfree(ptr) FSfree((pointer)ptr)
-int ReadRequest();
-
-Bool CloseDownConnection();
-void CreateSockets();
-void CloseSockets();
-void FlushAllOuput();
-long GetTimeInMIllis();
-void Error();
-void InitErrors();
-void CloseErrors();
-void NoticeF();
-void ErrorF();
-void FatalError();
-void SetConfigValues();
-
-typedef pointer FID;
-typedef struct _FontPathRec *FontPathPtr;
-
-FontPathPtr expand_font_name_pattern();
-
-typedef struct _alt_server *AlternateServerPtr;
-typedef struct _auth *AuthPtr;
+extern int ListenPort;
+extern Bool UseSyslog;
+extern Bool CloneSelf;
+extern char ErrorFile[];
+#ifdef FONTCACHE
+#include <X11/extensions/fontcacheP.h>
+extern FontCacheSettings cacheSettings;
+#endif
+
+struct _osComm; /* FIXME: osCommPtr */
+
+/* os/config.c */
+extern int ReadConfigFile(char *filename);
+
+/* os/connection.c */
+extern void AttendClient(ClientPtr client);
+extern void CheckConnections(void);
+extern void CloseDownConnection(ClientPtr client);
+extern void IgnoreClient(ClientPtr client);
+extern void MakeNewConnections(void);
+extern void ReapAnyOldClients(void);
+extern void ResetSockets(void);
+extern void CloseSockets(void);
+extern void StopListening(void);
+
+/* os/daemon.c */
+extern void BecomeOrphan(void);
+extern void BecomeDaemon(void);
+
+/* os/error.c */
+extern void Error(char *str);
+extern void InitErrors(void);
+extern void CloseErrors(void);
+extern void NoticeF(char *f, ...);
+extern void ErrorF(char * f, ...);
+extern void FatalError(char* f, ...);
+
+/* os/io.c */
+extern Bool InsertFakeRequest(ClientPtr client, char *data, int count);
+extern int FlushClient(ClientPtr client, struct _osComm *oc, char *extraBuf, int extraCount, int padsize);
+extern int ReadRequest(ClientPtr client);
+extern void FlushAllOutput(void);
+extern void FreeOsBuffers(struct _osComm *oc);
+extern void ResetCurrentRequest(ClientPtr client);
+extern void ResetOsBuffers(void);
+extern void WriteToClient(ClientPtr client, int count, char *buf);
+extern void WriteToClientUnpadded(ClientPtr client, int count, char *buf);
+
+/* os/osglue.c */
+extern int ListCatalogues(char *pattern, int patlen, int maxnames, char **catalogues, int *len);
+extern int ValidateCatalogues(int *num, char *cats);
+extern int SetAlternateServers(char *list);
+extern int ListAlternateServers(AlternateServerPtr *svrs);
+extern int CloneMyself(void);
+
+/* os/osinit.c */
+extern void OsInit(void);
+
+/* os/utils.c */
+extern SIGVAL AutoResetServer (int n);
+extern SIGVAL CleanupChild (int n);
+extern SIGVAL GiveUp (int n);
+extern SIGVAL ServerCacheFlush (int n);
+extern SIGVAL ServerReconfig (int n);
+extern long GetTimeInMillis (void);
+extern pointer FSalloc(unsigned long);
+extern pointer FScalloc (unsigned long amount);
+extern pointer FSrealloc(pointer, unsigned long);
+extern void FSfree(pointer);
+extern void OsInitAllocator (void);
+extern void ProcessCmdLine (int argc, char **argv);
+extern void ProcessLSoption (char *str);
+extern void SetUserId(void);
+extern void SetDaemonState(void);
+
+/* os/waitfor.c */
+extern int WaitForSomething(int *pClientsReady);
+
+extern void SetConfigValues(void);
-extern int ListCatalogues();
-extern int ListAlternateServers();
#endif /* _OS_H_ */
diff --git a/include/osstruct.h b/include/osstruct.h
index cea8603..be758b3 100644
--- a/include/osstruct.h
+++ b/include/osstruct.h
@@ -47,22 +47,23 @@ in this Software without prior written authorization from The Open Group.
* @(#)osstruct.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/include/osstruct.h,v 1.4 2001/12/14 20:01:38 dawes Exp $ */
#ifndef _OSSTRUCT_H_
#define _OSSTRUCT_H_
#include "os.h"
typedef struct _alt_server {
- char subset;
- short namelen;
- char *name;
+ char subset;
+ unsigned short namelen;
+ char *name;
} AlternateServerRec;
typedef struct _auth {
- short namelen;
- short datalen;
- char *name;
- char *data;
+ unsigned short namelen;
+ unsigned short datalen;
+ char *name;
+ char *data;
} AuthRec;
#endif /* _OSSTRUCT_H_ */
diff --git a/include/servermd.h b/include/servermd.h
index 7233bd9..a2b8cf9 100644
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -44,6 +44,8 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/include/servermd.h,v 1.5 2001/12/19 21:37:35 dawes Exp $ */
+
#ifndef _SERVERMD_H_
#define _SERVERMD_H_
@@ -52,7 +54,7 @@ in this Software without prior written authorization from The Open Group.
#endif
#ifndef VENDOR_STRING
-#define VENDOR_STRING "The X.Org Group"
+#define VENDOR_STRING "The XFree86 Project (experimental version)"
#endif
#ifndef DEFAULT_FS_PORT
diff --git a/os/access.c b/os/access.c
index 43c035b..72488fd 100644
--- a/os/access.c
+++ b/os/access.c
@@ -43,10 +43,15 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/os/access.c,v 3.7 2001/12/14 20:01:40 dawes Exp $ */
#include <X11/Xos.h>
+#ifndef Lynx
#include <sys/param.h>
#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
#include <netdb.h>
#include <netinet/in.h>
#include "clientstr.h"
@@ -55,12 +60,12 @@ in this Software without prior written authorization from The Open Group.
#include "accstr.h"
#include "osdep.h"
#include "osstruct.h"
+#include "accstr.h"
long MaxClients = DEFAULT_CLIENT_LIMIT;
void
-AccessSetConnectionLimit(num)
- int num;
+AccessSetConnectionLimit(int num)
{
num++; /* take serverClient into account */
if (num > MAXSOCKS) {
@@ -77,8 +82,7 @@ AccessSetConnectionLimit(num)
* needs massive amounts of OS-dependent work (big surprise)
*/
int
-GetHostAddress(addr)
- HostAddress *addr;
+GetHostAddress(HostAddress *addr)
{
char hname[64];
struct hostent *hp;
@@ -101,13 +105,13 @@ GetHostAddress(addr)
/* ARGSUSED */
int
-CheckClientAuthorization(client, client_auth, accept, index, size, auth_data)
- ClientPtr client;
- AuthPtr client_auth;
- int *accept;
- int *index;
- int *size;
- char **auth_data;
+CheckClientAuthorization(
+ ClientPtr client,
+ AuthPtr client_auth,
+ int *accept,
+ int *index,
+ int *size,
+ char **auth_data)
{
OsCommPtr oc;
int i;
@@ -125,10 +129,10 @@ CheckClientAuthorization(client, client_auth, accept, index, size, auth_data)
#define AUTH1_NAME "hp-hostname-1"
#define AUTH2_NAME "hp-printername-1"
for (i = 0; i < *index; i++)
- if (client_auth[i].namelen == sizeof(AUTH1_NAME) &&
- !strcmp(client_auth[i].name, AUTH1_NAME) ||
- client_auth[i].namelen == sizeof(AUTH2_NAME) &&
- !strcmp(client_auth[i].name, AUTH2_NAME)) break;
+ if ((client_auth[i].namelen == sizeof(AUTH1_NAME) &&
+ !strcmp(client_auth[i].name, AUTH1_NAME)) ||
+ (client_auth[i].namelen == sizeof(AUTH2_NAME) &&
+ !strcmp(client_auth[i].name, AUTH2_NAME))) break;
if (i == *index)
i = 0;
else
diff --git a/os/config.c b/os/config.c
index 5648e5b..64f8992 100644
--- a/os/config.c
+++ b/os/config.c
@@ -44,35 +44,53 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $NCDId: @(#)config.c,v 4.6 1991/07/09 14:08:09 lemke Exp $
+ * $NCDXorg: @(#)config.c,v 4.6 1991/07/09 14:08:09 lemke Exp $
*
*/
+/* $XFree86: xc/programs/xfs/os/config.c,v 3.16 2002/10/15 01:45:03 dawes Exp $ */
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
+#include <X11/Xtrans.h>
#include <X11/Xos.h>
#include "misc.h"
#include "configstr.h"
#include "osdep.h"
#include "globals.h"
#include "access.h"
+#include "difsutils.h"
+#ifdef FONTCACHE
+#include <X11/extensions/fontcacheP.h>
+#endif
+#include "fontutil.h"
+#include "difs.h"
+#include "snfstr.h"
+
+extern int portFromCmdline;
static char *font_catalogue = NULL;
-static char *config_set_int(),
- *config_set_bool(),
- *config_set_catalogue(),
- *config_set_glyph_caching_mode(),
- *config_set_list(),
- *config_set_file(),
- *config_set_resolutions(),
- *config_set_snf_format();
+static char *config_set_int(ConfigOptionPtr parm, char *val);
+static char *config_set_bool(ConfigOptionPtr parm, char *val);
+static char *config_set_catalogue(ConfigOptionPtr parm, char *val);
+static char *config_set_glyph_caching_mode(ConfigOptionPtr parm, char *val);
+static char *config_set_list(ConfigOptionPtr parm, char *val);
+static char *config_set_file(ConfigOptionPtr parm, char *val);
+static char *config_set_resolutions(ConfigOptionPtr parm, char *val);
+static char *config_set_ignored_transports(ConfigOptionPtr parm, char *val);
+static char *config_set_snf_format(ConfigOptionPtr parm, char *val);
/* these need to be in lower case and alphabetical order so a
* binary search lookup can be used
*/
static ConfigOptionRec config_options[] = {
{"alternate-servers", config_set_list},
+#ifdef FONTCACHE
+ {"cache-balance", config_set_int},
+ {"cache-hi-mark", config_set_int},
+ {"cache-low-mark", config_set_int},
+#endif
{"catalogue", config_set_catalogue},
{"client-limit", config_set_int},
{"clone-self", config_set_bool},
@@ -80,6 +98,7 @@ static ConfigOptionRec config_options[] = {
{"default-resolutions", config_set_resolutions},
{"deferglyphs", config_set_glyph_caching_mode},
{"error-file", config_set_file},
+ {"no-listen", config_set_ignored_transports},
{"port", config_set_int},
{"server-number", config_set_int},
{"snf-format", config_set_snf_format},
@@ -112,8 +131,7 @@ char *ConfigErrors[] = {
*(c)++= ' ';
static char *
-next_assign(c)
- char *c;
+next_assign(char *c)
{
int nesting = 0;
@@ -130,8 +148,7 @@ next_assign(c)
}
static void
-strip_comments(data)
- char *data;
+strip_comments(char *data)
{
char *c;
@@ -145,9 +162,8 @@ strip_comments(data)
}
}
-static ConfigOptionPtr
-match_param_name(name)
- char *name;
+static ConfigOptionPtr
+match_param_name(char *name)
{
int pos,
rc,
@@ -173,11 +189,10 @@ match_param_name(name)
}
static int
-parse_config(data)
- char *data;
+parse_config(char *data)
{
char *c,
- *val,
+ *val = NULL,
*next_eq,
*consumed,
*p;
@@ -266,14 +281,14 @@ parse_config(data)
* handles anything that should be set once the file is parsed
*/
void
-SetConfigValues()
+SetConfigValues(void)
{
int err,
num;
err = SetFontCatalogue(font_catalogue, &num);
if (err != FSSuccess) {
- FatalError("Element #%d (starting at 0) of font path is bad or has a bad font:\n\"%s\"\n",
+ FatalError("element #%d (starting at 0) of font path is bad or has a bad font:\n\"%s\"\n",
num, font_catalogue);
}
InitErrors();
@@ -281,9 +296,28 @@ SetConfigValues()
font_catalogue = NULL;
}
+#ifdef __UNIXOS2__
+char *__XFSRedirRoot(char *fname)
+{
+ static char redirname[300]; /* enough for long filenames */
+ char *root;
+
+ /* if name does not start with /, assume it is not root-based */
+ if (fname==0 || !(fname[0]=='/' || fname[0]=='\\'))
+ return fname;
+
+ root = (char*)getenv("X11ROOT");
+ if (root==0 ||
+ (fname[1]==':' && isalpha(fname[0])) ||
+ ((strlen(fname)+strlen(root)+2) > 300))
+ return fname;
+ sprintf(redirname,"%s%s",root,fname);
+ return redirname;
+}
+#endif
+
int
-ReadConfigFile(filename)
- char *filename;
+ReadConfigFile(char *filename)
{
FILE *fp;
int ret;
@@ -295,6 +329,9 @@ ReadConfigFile(filename)
ErrorF(ConfigErrors[CONFIG_ERR_MEMORY], filename);
return FSBadAlloc;
}
+#ifdef __UNIXOS2__
+ filename = __XFSRedirRoot(filename);
+#endif
if ((fp = fopen(filename, "r")) == NULL) {
fsfree(data);
ErrorF(ConfigErrors[CONFIG_ERR_OPEN], filename);
@@ -327,11 +364,11 @@ struct nameVal {
};
static char *
-config_parse_nameVal (c, ret, pval, name_val)
- char *c;
- int *ret;
- int *pval;
- struct nameVal *name_val;
+config_parse_nameVal (
+ char *c,
+ int *ret,
+ int *pval,
+ struct nameVal *name_val)
{
char *start,
t;
@@ -359,30 +396,30 @@ config_parse_nameVal (c, ret, pval, name_val)
}
static char *
-config_parse_bool (c, ret, pval)
- char *c;
- int *ret;
- Bool *pval;
+config_parse_bool (
+ char *c,
+ int *ret,
+ Bool *pval)
{
static struct nameVal bool_val[] = {
- "yes", TRUE,
- "on", TRUE,
- "1", TRUE,
- "true", TRUE,
- "no", FALSE,
- "off", FALSE,
- "0", FALSE,
- "false", FALSE,
- (char *) 0, 0,
+ { "yes", TRUE },
+ { "on", TRUE },
+ { "1", TRUE },
+ { "true", TRUE },
+ { "no", FALSE },
+ { "off", FALSE },
+ { "0", FALSE },
+ { "false", FALSE },
+ { (char *) 0, 0 },
};
return config_parse_nameVal (c, ret, pval, bool_val);
}
static char *
-config_parse_int(c, ret, pval)
- char *c;
- int *ret;
- int *pval;
+config_parse_int(
+ char *c,
+ int *ret,
+ int *pval)
{
char *start,
t;
@@ -412,41 +449,45 @@ config_parse_int(c, ret, pval)
/* config option sets */
/* these have to know how to do the real work and tweak the proper things */
static char *
-config_set_int(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_int(
+ ConfigOptionPtr parm,
+ char *val)
{
int ival,
ret;
- extern int ListenPort;
- extern void SetDefaultPointSize();
val = config_parse_int(val, &ret, &ival);
if (ret == -1)
return val;
/* now do individual attribute checks */
- if (!strcmp(parm->parm_name, "port")) {
+ if (!strcmp(parm->parm_name, "port") && !portFromCmdline) {
ListenPort = ival;
} else if (!strcmp(parm->parm_name, "client-limit")) {
AccessSetConnectionLimit(ival);
} else if (!strcmp(parm->parm_name, "default-point-size")) {
SetDefaultPointSize(ival);
}
+#ifdef FONTCACHE
+ else if (!strcmp(parm->parm_name, "cache-balance")) {
+ cacheSettings.balance = ival;
+ } else if (!strcmp(parm->parm_name, "cache-hi-mark")) {
+ cacheSettings.himark = ival * 1024;
+ } else if (!strcmp(parm->parm_name, "cache-low-mark")) {
+ cacheSettings.lowmark = ival * 1024;
+ }
+#endif
return val;
}
static char *
-config_set_bool(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_bool(
+ ConfigOptionPtr parm,
+ char *val)
{
int
ret;
Bool bval;
- extern int ClientLimit;
- extern Bool UseSyslog,
- CloneSelf;
val = config_parse_bool(val, &ret, &bval);
if (ret == -1)
@@ -462,11 +503,10 @@ config_set_bool(parm, val)
}
static char *
-config_set_file(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_file(
+ ConfigOptionPtr parm,
+ char *val)
{
- extern char ErrorFile[];
char *start = val,
t;
@@ -474,16 +514,20 @@ config_set_file(parm, val)
t = *val;
*val = '\0';
if (!strcmp(parm->parm_name, "error-file")) {
+#ifndef __UNIXOS2__
memmove( ErrorFile, start, val - start + 1);
+#else
+ strcpy( ErrorFile, __XFSRedirRoot(start));
+#endif
}
*val = t;
return val;
}
static char *
-config_set_catalogue(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_catalogue(
+ ConfigOptionPtr parm,
+ char *val)
{
char *b;
@@ -492,7 +536,7 @@ config_set_catalogue(parm, val)
fsfree((char *) font_catalogue); /* dump any previous one */
b = font_catalogue = (char *) fsalloc(strlen(val) + 1);
if (!font_catalogue)
- FatalError("Insufficent memory for font catalogue\n");
+ FatalError("insufficent memory for font catalogue\n");
while (*val) { /* remove all the gunk */
if (!isspace(*val)) {
*b++ = *val;
@@ -505,9 +549,9 @@ config_set_catalogue(parm, val)
}
static char *
-config_set_list(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_list(
+ ConfigOptionPtr parm,
+ char *val)
{
char *start = val,
t;
@@ -523,9 +567,25 @@ config_set_list(parm, val)
}
static char *
-config_set_glyph_caching_mode(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_ignored_transports(
+ ConfigOptionPtr parm,
+ char *val)
+{
+ char *start = val,
+ t;
+
+ skip_list_val(val);
+ t = *val;
+ *val = '\0';
+ _FontTransNoListen(start);
+ *val = t;
+ return val;
+}
+
+static char *
+config_set_glyph_caching_mode(
+ ConfigOptionPtr parm,
+ char *val)
{
char *start = val,
t;
@@ -541,9 +601,9 @@ config_set_glyph_caching_mode(parm, val)
}
static char *
-config_set_resolutions(parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_resolutions(
+ ConfigOptionPtr parm,
+ char *val)
{
char *start = val,
t;
@@ -555,7 +615,7 @@ config_set_resolutions(parm, val)
if (!strcmp(parm->parm_name, "default-resolutions")) {
err = SetDefaultResolutions(start);
if (err != FSSuccess) {
- FatalError("Bogus resolution list \"%s\"\n", start);
+ FatalError("bogus resolution list \"%s\"\n", start);
}
}
*val = t;
@@ -564,28 +624,28 @@ config_set_resolutions(parm, val)
static char *
-config_parse_endian(c, ret, pval)
- char *c;
- int *ret;
- int *pval;
+config_parse_endian(
+ char *c,
+ int *ret,
+ int *pval)
{
static struct nameVal endian_val[] = {
- "lsb", LSBFirst,
- "little", LSBFirst,
- "lsbfirst", LSBFirst,
- "msb", MSBFirst,
- "big", MSBFirst,
- "msbfirst", MSBFirst,
- (char *) 0, 0,
+ { "lsb", LSBFirst },
+ { "little", LSBFirst },
+ { "lsbfirst", LSBFirst },
+ { "msb", MSBFirst },
+ { "big", MSBFirst },
+ { "msbfirst", MSBFirst },
+ { (char *) 0, 0 },
};
return config_parse_nameVal (c, ret, pval, endian_val);
}
/* ARGSUSED */
static char *
-config_set_snf_format (parm, val)
- ConfigOptionPtr parm;
- char *val;
+config_set_snf_format (
+ ConfigOptionPtr parm,
+ char *val)
{
int bit, byte, glyph, scan;
int ret;
diff --git a/os/configstr.h b/os/configstr.h
index 1c8184f..9000acc 100644
--- a/os/configstr.h
+++ b/os/configstr.h
@@ -47,13 +47,16 @@ in this Software without prior written authorization from The Open Group.
* @(#)configstr.h 4.1 91/05/02
*
*/
+/* $XFree86: xc/programs/xfs/os/configstr.h,v 1.5 2001/12/14 20:01:41 dawes Exp $ */
#ifndef _CONFIGSTR_H_
#define _CONFIGSTR_H_
#include "config.h"
-typedef struct _config_options {
+typedef struct _config_options ConfigOptionRec, *ConfigOptionPtr;
+
+struct _config_options {
char *parm_name;
- char *(*set_func) ();
-} ConfigOptionRec, *ConfigOptionPtr;
+ char *(*set_func) (ConfigOptionPtr, char *);
+};
#endif /* _CONFIGSTR_H_ */
diff --git a/os/connection.c b/os/connection.c
index 0e3af59..c980b11 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -67,14 +67,24 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/os/connection.c,v 3.25 2002/10/15 01:45:03 dawes Exp $ */
#include <X11/Xtrans.h>
+#include <stdlib.h>
#include "misc.h"
#include <stdio.h>
#include <errno.h>
+#include <X11/Xos.h>
+#ifndef Lynx
#include <sys/param.h>
#include <sys/socket.h>
+#ifndef __UNIXOS2__
#include <sys/uio.h>
+#endif
+#else
+#include <socket.h>
+#include <uio.h>
+#endif
#include <signal.h>
#include "FS.h"
@@ -85,9 +95,12 @@ in this Software without prior written authorization from The Open Group.
#include "globals.h"
#include "osstruct.h"
#include "servermd.h"
+#include "dispatch.h"
+#include "fsevents.h"
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+#ifdef __UNIXOS2__
+#define _NFILE OPEN_MAX
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
#endif
@@ -101,7 +114,6 @@ fd_set LastSelectMask;
fd_set ClientsWithInput;
fd_set ClientsWriteBlocked;
fd_set OutputPending;
-extern long MaxClients;
long OutputBufferSize = BUFSIZE;
Bool NewOutputPending;
@@ -113,31 +125,13 @@ XtransConnInfo *ListenTransConns = NULL;
int *ListenTransFds = NULL;
int ListenTransCount;
-extern ClientPtr NextAvailableClient();
-
-#ifdef SIGNALRETURNSINT
-#define SIGVAL int
-#else
-#define SIGVAL void
-#endif
-
-extern SIGVAL AutoResetServer();
-extern SIGVAL GiveUp();
-extern SIGVAL ServerReconfig();
-extern SIGVAL ServerCacheFlush();
-extern SIGVAL CleanupChild();
-extern void FreeOsBuffers();
-
-static void error_conn_max();
-static void close_fd();
+static void error_conn_max(XtransConnInfo trans_conn);
+static void close_fd(OsCommPtr oc);
static XtransConnInfo
-lookup_trans_conn (fd)
-
-int fd;
-
+lookup_trans_conn (int fd)
{
if (ListenTransFds)
{
@@ -150,7 +144,8 @@ int fd;
return (NULL);
}
-StopListening()
+void
+StopListening(void)
{
int i;
@@ -173,14 +168,9 @@ StopListening()
* only called when server first started
*/
void
-CreateSockets(old_listen_count, old_listen)
-
-int old_listen_count;
-OldListenRec *old_listen;
-
+CreateSockets(int old_listen_count, OldListenRec *old_listen)
{
- int request,
- i;
+ int i;
FD_ZERO(&AllSockets);
FD_ZERO(&AllClients);
@@ -197,11 +187,11 @@ OldListenRec *old_listen;
#ifdef _SC_OPEN_MAX
lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
#else
-#ifdef hpux
+#if defined(hpux) || defined(__UNIXOS2__)
lastfdesc = _NFILE - 1;
#else
lastfdesc = getdtablesize() - 1;
-#endif
+#endif /* hpux */
#endif
if (lastfdesc > MAXSOCKS) {
@@ -238,7 +228,7 @@ OldListenRec *old_listen;
ListenTransFds[ListenTransCount] = old_listen[i].fd;
FD_SET (old_listen[i].fd, &WellKnownConnections);
- NoticeF("Reusing existing file descriptor %d\n",
+ NoticeF("reusing existing file descriptor %d\n",
old_listen[i].fd);
ListenTransCount++;
@@ -267,8 +257,7 @@ OldListenRec *old_listen;
}
if (! XFD_ANYSET(&WellKnownConnections))
- FatalError("Cannot establish any listening sockets\n");
-
+ FatalError("cannot establish any listening sockets\n");
/* set up all the signal handlers */
signal(SIGPIPE, SIG_IGN);
@@ -285,7 +274,8 @@ OldListenRec *old_listen;
/*
* called when server cycles
*/
-ResetSockets()
+void
+ResetSockets(void)
{
}
@@ -302,7 +292,7 @@ CloseSockets(void)
* accepts new connections
*/
void
-MakeNewConnections()
+MakeNewConnections(void)
{
fd_mask readyconnections;
int curconn;
@@ -323,10 +313,10 @@ MakeNewConnections()
for (i = MINCLIENT; i < currentMaxClients; i++) {
if ((client = clients[i]) != NullClient) {
oc = (OsCommPtr) client->osPrivate;
- if (oc && (oc->conn_time != 0) &&
- (connect_time - oc->conn_time) >= TimeOutValue ||
- client->noClientException != FSSuccess &&
- client->clientGone != CLIENT_GONE)
+ if ((oc && (oc->conn_time != 0) &&
+ (connect_time - oc->conn_time) >= TimeOutValue) ||
+ ((client->noClientException != FSSuccess) &&
+ (client->clientGone != CLIENT_GONE)))
CloseDownClient(client);
}
}
@@ -373,13 +363,10 @@ MakeNewConnections()
}
}
-#define NOROOM "Maximum number of clients reached"
+#define NOROOM "maximum number of clients reached"
static void
-error_conn_max(trans_conn)
-
-XtransConnInfo trans_conn;
-
+error_conn_max(XtransConnInfo trans_conn)
{
int fd = _FontTransGetConnectionNumber (trans_conn);
fsConnSetup conn;
@@ -443,8 +430,7 @@ XtransConnInfo trans_conn;
}
static void
-close_fd(oc)
- OsCommPtr oc;
+close_fd(OsCommPtr oc)
{
int fd = oc->fd;
@@ -461,7 +447,8 @@ close_fd(oc)
fsfree(oc);
}
-CheckConnections()
+void
+CheckConnections(void)
{
fd_set mask;
fd_set tmask;
@@ -487,8 +474,8 @@ CheckConnections()
}
}
-CloseDownConnection(client)
- ClientPtr client;
+void
+CloseDownConnection(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
@@ -508,8 +495,8 @@ CloseDownConnection(client)
static fd_set IgnoredClientsWithInput;
-IgnoreClient(client)
- ClientPtr client;
+void
+IgnoreClient(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
@@ -530,8 +517,8 @@ IgnoreClient(client)
* Adds one client back into the input masks.
****************/
-AttendClient(client)
- ClientPtr client;
+void
+AttendClient(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
int connection = oc->fd;
@@ -546,15 +533,15 @@ AttendClient(client)
/*
* figure out which clients need to be toasted
*/
-ReapAnyOldClients()
+void
+ReapAnyOldClients(void)
{
int i;
long cur_time = GetTimeInMillis();
ClientPtr client;
- extern void SendKeepAliveEvent();
#ifdef DEBUG
- fprintf(stderr, "Looking for clients to reap\n");
+ fprintf(stderr, "looking for clients to reap\n");
#endif
for (i = MINCLIENT; i < currentMaxClients; i++) {
diff --git a/os/error.c b/os/error.c
index e1b02e7..c6adcaf 100644
--- a/os/error.c
+++ b/os/error.c
@@ -44,9 +44,13 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/os/error.c,v 1.11 2002/10/15 01:45:03 dawes Exp $ */
#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
#include <X11/Xos.h>
+
#ifndef X_NOT_POSIX
#ifdef _POSIX_SOURCE
#include <limits.h>
@@ -71,15 +75,20 @@ in this Software without prior written authorization from The Open Group.
#include <syslog.h>
#endif
+#include <errno.h>
+
#include "misc.h"
extern char *progname;
Bool UseSyslog;
+#ifdef USE_SYSLOG
+Bool log_open = FALSE;
+#endif
char ErrorFile[PATH_MAX];
static void
-abort_server()
+abort_server(void)
{
fflush(stderr);
@@ -91,13 +100,13 @@ abort_server()
}
void
-InitErrors()
+InitErrors(void)
{
int i;
#ifdef USE_SYSLOG
if (UseSyslog && !log_open) {
- openlog("Font Server", LOG_PID, LOG_LOCAL0);
+ openlog("xfs", LOG_PID, LOG_DAEMON);
log_open = TRUE;
return;
}
@@ -109,13 +118,13 @@ InitErrors()
dup2(i, 2);
close(i);
} else {
- ErrorF("Can't open error file \"%s\"\n", ErrorFile);
+ ErrorF("can't open error file \"%s\"\n", ErrorFile);
}
}
}
void
-CloseErrors()
+CloseErrors(void)
{
#ifdef USE_SYSLOG
if (UseSyslog) {
@@ -127,91 +136,73 @@ CloseErrors()
}
void
-Error(str)
- char *str;
+Error(char *str)
{
- /* XXX this should also go to syslog() */
+#ifdef USE_SYSLOG
+ if (UseSyslog) {
+ syslog(LOG_ERR, "%s: %s", str, strerror(errno));
+ return;
+ }
+#endif
perror(str);
}
/*
* used for informational messages
*/
-/* VARARGS1 */
void
-NoticeF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of 10 args */
- char *f;
- char *s0,
- *s1,
- *s2,
- *s3,
- *s4,
- *s5,
- *s6,
- *s7,
- *s8,
- *s9;
+NoticeF(char *f, ...)
{
-
+ /* XXX should Notices just be ignored if not using syslog? */
+ va_list args;
+ va_start(args, f);
#ifdef USE_SYSLOG
if (UseSyslog) {
- syslog(LOG_NOTICE, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+ vsyslog(LOG_NOTICE, f, args);
return;
}
-#endif
-
- /* XXX should Notices just be ignored if not using syslog? */
+#else
fprintf(stderr, "%s notice: ", progname);
- fprintf(stderr, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+ vfprintf(stderr, f, args);
+#endif /* USE_SYSLOG */
+ va_end(args);
}
/*
* used for non-fatal error messages
*/
-/* VARARGS1 */
void
-ErrorF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of 10 args */
- char *f;
- char *s0,
- *s1,
- *s2,
- *s3,
- *s4,
- *s5,
- *s6,
- *s7,
- *s8,
- *s9;
+ErrorF(char * f, ...)
{
-
+ va_list args;
+ va_start(args, f);
#ifdef USE_SYSLOG
if (UseSyslog) {
- syslog(LOG_ERR, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+ vsyslog(LOG_WARNING, f, args);
return;
}
-#endif
-
+#else
fprintf(stderr, "%s error: ", progname);
- fprintf(stderr, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+ vfprintf(stderr, f, args);
+#endif
+ va_end(args);
}
-/* VARARGS1 */
void
-FatalError(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of 10 args */
- char *f;
- char *s0,
- *s1,
- *s2,
- *s3,
- *s4,
- *s5,
- *s6,
- *s7,
- *s8,
- *s9;
+FatalError(char * f, ...)
{
- ErrorF("Fatal font server error:\n");
- ErrorF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+ va_list args;
+ va_start(args, f);
+#ifdef USE_SYSLOG
+ if (UseSyslog) {
+ vsyslog(LOG_ERR, f, args);
+ return;
+ }
+#else
+ fprintf(stderr, "%s fatal error: ", progname);
+ vfprintf(stderr, f, args);
+#endif
+ va_end(args);
abort_server();
/* NOTREACHED */
}
diff --git a/os/io.c b/os/io.c
index abf4b4d..4345907 100644
--- a/os/io.c
+++ b/os/io.c
@@ -46,23 +46,27 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/os/io.c,v 3.19 2002/05/31 18:46:12 dawes Exp $ */
#include <X11/Xtrans.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
+#ifndef Lynx
#include <sys/param.h>
+#ifndef __UNIXOS2__
#include <sys/uio.h>
+#endif
+#else
+#include <uio.h>
+#endif
#include "FSproto.h"
#include "clientstr.h"
#include "X11/Xpoll.h"
#include "osdep.h"
#include "globals.h"
-
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
+#include "dispatch.h"
/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
@@ -98,8 +102,8 @@ static ConnectionInputPtr FreeInputs = (ConnectionInputPtr) NULL;
static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr) NULL;
static OsCommPtr AvailableInput = (OsCommPtr) NULL;
-static ConnectionInputPtr AllocateInputBuffer();
-static ConnectionOutputPtr AllocateOutputBuffer();
+static ConnectionInputPtr AllocateInputBuffer(void);
+static ConnectionOutputPtr AllocateOutputBuffer(void);
#define MAX_TIMES_PER 10
@@ -119,17 +123,26 @@ static ConnectionOutputPtr AllocateOutputBuffer();
((int)((client)->swapped ? lswaps((req)->length) : (req)->length) << 2)
int
-ReadRequest(client)
- ClientPtr client;
+ReadRequest(ClientPtr client)
{
- OsCommPtr oc = (OsCommPtr) client->osPrivate;
- ConnectionInputPtr oci = oc->input;
+ OsCommPtr oc;
+ ConnectionInputPtr oci;
fsReq *request;
- int fd = oc->fd;
- int result,
+ int fd,
+ result,
gotnow,
needed = 0;
+ if (client == NULL)
+ return -1;
+ oc = (OsCommPtr) client->osPrivate;
+ if (oc == NULL)
+ return -1;
+ oci = oc->input;
+ fd = oc->fd;
+ if (oci != NULL && fd < 0)
+ return -1;
+
if (AvailableInput) {
if (AvailableInput != oc) {
ConnectionInputPtr aci = AvailableInput->input;
@@ -202,13 +215,21 @@ ReadRequest(client)
oci->bufcnt = gotnow;
}
/* fill 'er up */
+ if (oc->trans_conn == NULL) {
+ yield_control_death();
+ return -1;
+ }
result = _FontTransRead(oc->trans_conn, oci->buffer + oci->bufcnt,
oci->size - oci->bufcnt);
if (result <= 0) {
+#if !(defined(SVR4) && defined(i386) && !defined(sun))
if ((result < 0) && ETEST(errno)) {
yield_control_no_input();
return 0;
- } else {
+ } else
+#endif
+ {
+
yield_control_death();
return -1;
}
@@ -221,7 +242,7 @@ ReadRequest(client)
(oci->bufcnt < BUFSIZE) && (needed < BUFSIZE)) {
char *ibuf;
- ibuf = (char *) fsrealloc(oci, BUFSIZE);
+ ibuf = (char *) fsrealloc(oci->buffer, BUFSIZE);
if (ibuf) {
oci->size = BUFSIZE;
oci->buffer = ibuf;
@@ -264,10 +285,7 @@ ReadRequest(client)
}
Bool
-InsertFakeRequest(client, data, count)
- ClientPtr client;
- char *data;
- int count;
+InsertFakeRequest(ClientPtr client, char *data, int count)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
ConnectionInputPtr oci = oc->input;
@@ -331,8 +349,8 @@ InsertFakeRequest(client, data, count)
return TRUE;
}
-ResetCurrentRequest(client)
- ClientPtr client;
+void
+ResetCurrentRequest(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
ConnectionInputPtr oci = oc->input;
@@ -355,12 +373,12 @@ ResetCurrentRequest(client)
}
int
-FlushClient(client, oc, extraBuf, extraCount, padsize)
- ClientPtr client;
- OsCommPtr oc;
- char *extraBuf;
- int extraCount;
- int padsize;
+FlushClient(
+ ClientPtr client,
+ OsCommPtr oc,
+ char *extraBuf,
+ int extraCount,
+ int padsize)
{
ConnectionOutputPtr oco = oc->output;
int fd = oc->fd;
@@ -450,7 +468,8 @@ FlushClient(client, oc, extraBuf, extraCount, padsize)
obuf = (unsigned char *) fsrealloc(oco->buf,
notWritten + OutputBufferSize);
if (!obuf) {
- _FontTransClose(oc->trans_conn);
+ if (oc->trans_conn)
+ _FontTransClose(oc->trans_conn);
oc->trans_conn = NULL;
MarkClientException(client);
oco->count = 0;
@@ -505,7 +524,7 @@ FlushClient(client, oc, extraBuf, extraCount, padsize)
}
void
-FlushAllOutput()
+FlushAllOutput(void)
{
int index, base;
fd_mask mask;
@@ -543,11 +562,7 @@ FlushAllOutput()
* returns number of bytes written
*/
static int
-write_to_client_internal(client, count, buf, padBytes)
- ClientPtr client;
- int count;
- char *buf;
- int padBytes;
+write_to_client_internal(ClientPtr client, int count, char *buf, int padBytes)
{
OsCommPtr oc = (OsCommPtr) client->osPrivate;
ConnectionOutputPtr oco = oc->output;
@@ -579,26 +594,29 @@ write_to_client_internal(client, count, buf, padBytes)
return count;
}
-WriteToClientUnpadded(client, count, buf)
- ClientPtr client;
- int count;
- char *buf;
+void
+WriteToClientUnpadded(ClientPtr client, int count, char *buf)
{
write_to_client_internal(client, count, buf, 0);
}
static int padlength[4] = {0, 3, 2, 1};
-WriteToClient(client, count, buf)
- ClientPtr client;
- int count;
- char *buf;
+void
+WriteToClient(ClientPtr client, int count, char *buf)
{
+ int flag = 0;
+ if (NULL == buf) {
+ flag = -1;
+ buf = (char *)fsalloc(count); memset(buf, 0, count);
+ }
write_to_client_internal(client, count, buf, padlength[count & 3]);
+ if (flag)
+ fsfree(buf);
}
-static ConnectionInputPtr
-AllocateInputBuffer()
+static ConnectionInputPtr
+AllocateInputBuffer(void)
{
register ConnectionInputPtr oci;
@@ -617,8 +635,9 @@ AllocateInputBuffer()
oci->lenLastReq = 0;
return oci;
}
-static ConnectionOutputPtr
-AllocateOutputBuffer()
+
+static ConnectionOutputPtr
+AllocateOutputBuffer(void)
{
register ConnectionOutputPtr oco;
@@ -637,8 +656,7 @@ AllocateOutputBuffer()
void
-FreeOsBuffers(oc)
- OsCommPtr oc;
+FreeOsBuffers(OsCommPtr oc)
{
register ConnectionInputPtr oci;
register ConnectionOutputPtr oco;
@@ -670,7 +688,7 @@ FreeOsBuffers(oc)
}
void
-ResetOsBuffers()
+ResetOsBuffers(void)
{
register ConnectionInputPtr oci;
register ConnectionOutputPtr oco;
diff --git a/os/osdep.h b/os/osdep.h
index c588edb..ae3798b 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -47,6 +47,7 @@ in this Software without prior written authorization from The Open Group.
* @(#)osdep.h 4.1 5/2/91
*
*/
+/* $XFree86: xc/programs/xfs/os/osdep.h,v 3.12 2002/05/31 18:46:12 dawes Exp $ */
#ifndef _OSDEP_H_
#define _OSDEP_H_
@@ -54,7 +55,7 @@ in this Software without prior written authorization from The Open Group.
#define BOTIMEOUT 200 /* in milliseconds */
#define BUFSIZE 4096
#define BUFWATERMARK 8192
-#define MAXBUFSIZE (1 << 18)
+#define MAXBUFSIZE (1 << 15)
#ifndef sgi /* SGI defines OPEN_MAX in a useless way */
#ifndef X_NOT_POSIX
@@ -69,10 +70,20 @@ in this Software without prior written authorization from The Open Group.
#endif
#ifndef OPEN_MAX
+#if defined(__UNIXOS2__) || defined(__QNX__)
+#define OPEN_MAX 256
+#else
#ifdef SVR4
+#ifdef SCO324
+#define OPEN_MAX sysconf(_SC_OPEN_MAX)
+#else
#define OPEN_MAX 128
+#endif
#else
#include <sys/param.h>
+#ifdef __GNU__
+#define OPEN_MAX (sysconf(_SC_OPEN_MAX))
+#endif /*__GNU__*/
#ifndef OPEN_MAX
#if defined(NOFILE) && !defined(NOFILES_MAX)
#define OPEN_MAX NOFILE
@@ -82,16 +93,19 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif
#endif
+#endif
+#ifdef __GNU__
+#define MAXSOCKS 128
+#else /*__GNU__*/
#if OPEN_MAX <= 128 /* 128 is value of MAXCLIENTS */
#define MAXSOCKS (OPEN_MAX - 1)
#else
#define MAXSOCKS 128
#endif
+#endif /*__GNU__*/
-#ifndef NULL
-#define NULL 0
-#endif
+#include <stddef.h>
typedef struct _connectionInput {
struct _connectionInput *next;
@@ -117,7 +131,4 @@ typedef struct _osComm {
struct _XtransConnInfo *trans_conn; /* transport connection object */
} OsCommRec, *OsCommPtr;
-extern Bool CloneSelf;
-extern Bool UseSyslog;
-
#endif /* _OSDEP_H_ */
diff --git a/os/osglue.c b/os/osglue.c
index d0dd8cc..67f784c 100644
--- a/os/osglue.c
+++ b/os/osglue.c
@@ -44,9 +44,10 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $NCDId: @(#)osglue.c,v 4.6 1991/07/09 14:07:30 lemke Exp $
+ * $NCDXorg: @(#)osglue.c,v 4.6 1991/07/09 14:07:30 lemke Exp $
*
*/
+/* $XFree86: xc/programs/xfs/os/osglue.c,v 3.19 2002/10/19 20:04:20 herrb Exp $ */
/*
* this is miscellaneous OS specific stuff.
@@ -57,11 +58,14 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xtrans.h>
#include "osstruct.h"
#include <stdio.h>
+#include <stdlib.h>
#define XK_LATIN1
#include <X11/keysymdef.h>
+#ifdef __UNIXOS2__
+#define _NFILE 256
+#endif
Bool drone_server = FALSE;
-extern Bool CloneSelf;
extern char *progname;
extern char *configfilename;
@@ -85,10 +89,7 @@ extern int ListenTransCount;
static char *catalogue_name = "all";
static Bool /* stolen from R4 Match() */
-pattern_match(pat, plen, string)
- char *pat;
- int plen;
- char *string;
+pattern_match(char *pat, int plen, char *string)
{
register int i,
l;
@@ -148,7 +149,7 @@ pattern_match(pat, plen, string)
if (m < j)
return 0;
l = (l + m) - j;
- while (cp = pat[i]) {
+ while ((cp = pat[i])) {
if ((cp != string[l]) && (cp != XK_question))
return 0;
l++;
@@ -158,12 +159,8 @@ pattern_match(pat, plen, string)
}
int
-ListCatalogues(pattern, patlen, maxnames, catalogues, len)
- char *pattern;
- int patlen;
- int maxnames;
- char **catalogues;
- int *len;
+ListCatalogues(char *pattern, int patlen, int maxnames,
+ char **catalogues, int *len)
{
int count = 0;
char *catlist = NULL;
@@ -192,9 +189,7 @@ bail:
*/
int
-ValidateCatalogues(num, cats)
- int *num;
- char *cats;
+ValidateCatalogues(int *num, char *cats)
{
char *c = cats;
int i,
@@ -212,8 +207,7 @@ ValidateCatalogues(num, cats)
}
int
-SetAlternateServers(list)
- char *list;
+SetAlternateServers(char *list)
{
char *t,
*st;
@@ -272,8 +266,7 @@ SetAlternateServers(list)
}
int
-ListAlternateServers(svrs)
- AlternateServerPtr *svrs;
+ListAlternateServers(AlternateServerPtr *svrs)
{
*svrs = alt_servers;
return num_alts;
@@ -285,8 +278,9 @@ ListAlternateServers(svrs)
* socket open, and sends it to itself. the child stops listening,
* and becomes a drone, hanging out till it loses all its clients.
*/
+
int
-CloneMyself()
+CloneMyself(void)
{
int child;
char old_listen_arg[256];
@@ -294,13 +288,17 @@ CloneMyself()
int i, j;
int lastfdesc;
char portnum[20];
- extern int ListenPort;
assert(!drone_server); /* a drone shouldn't hit this */
if (!CloneSelf)
return -1;
+#ifdef __UNIXOS2__
+ NoticeF("cloning of font server not supported under OS/2!\n");
+ return(-1);
+#endif
+
old_listen_arg[0] = '\0';
#ifdef XNO_SYSCONF /* should only be on FreeBSD 1.x and NetBSD 0.x */
@@ -309,18 +307,19 @@ CloneMyself()
#ifdef _SC_OPEN_MAX
lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
#else
-#ifdef hpux
+#if defined(hpux) || defined(__UNIXOS2__)
lastfdesc = _NFILE - 1;
#else
lastfdesc = getdtablesize() - 1;
-#endif
+#endif /* hpux */
#endif
NoticeF("attempting clone...\n");
+ chdir("/");
child = fork();
if (child == -1) {
/* failed to fork */
- ErrorF("Clone failed to fork()\n");
+ ErrorF("clone failed to fork()\n");
return -1;
}
/*
@@ -330,11 +329,11 @@ CloneMyself()
*/
if (child == 0) {
StopListening();
- NoticeF("Clone: child becoming drone\n");
+ NoticeF("clone: child becoming drone\n");
drone_server = TRUE;
return 1;
} else { /* parent */
- NoticeF("Clone: parent revitalizing as %s\n", progname);
+ NoticeF("clone: parent revitalizing as %s\n", progname);
CloseErrors();
/* XXX should we close stdio as well? */
for (i = 3; i < lastfdesc; i++)
@@ -373,12 +372,13 @@ CloneMyself()
"-ls", old_listen_arg,
"-cf", configfilename,
"-port", portnum,
- NULL);
+ (void *)NULL);
InitErrors(); /* reopen errors, since we don't want to lose
* this */
- Error("Clone failed");
- FatalError("Failed to clone self\n");
+ Error("clone failed");
+ FatalError("failed to clone self\n");
}
/* NOTREACHED */
+ return 0;
}
diff --git a/os/osinit.c b/os/osinit.c
index 995bf8c..7d0a068 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -50,12 +50,14 @@ in this Software without prior written authorization from The Open Group.
* @(#)osinit.c 4.3 5/7/91
*
*/
+/* $XFree86: xc/programs/xfs/os/osinit.c,v 1.5 2001/12/14 20:01:41 dawes Exp $ */
#include "os.h"
extern long LastReapTime;
-OsInit()
+void
+OsInit(void)
{
LastReapTime = GetTimeInMillis();
OsInitAllocator ();
diff --git a/os/utils.c b/os/utils.c
index 30c9f4f..4dc46a1 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -46,15 +46,25 @@ in this Software without prior written authorization from The Open Group.
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/programs/xfs/os/utils.c,v 3.20 2002/10/15 01:45:03 dawes Exp $ */
#include <stdio.h>
#include <X11/Xos.h>
+#include <stdlib.h>
#include "misc.h"
#include "globals.h"
#include <signal.h>
#ifdef MEMBUG
#include <util/memleak/memleak.h>
#endif
+#include <sys/wait.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <grp.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <string.h>
#ifndef X_NOT_POSIX
#ifdef _POSIX_SOURCE
@@ -76,32 +86,46 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif /* PATH_MAX */
-#ifdef SIGNALRETURNSINT
-#define SIGVAL int
-#else
-#define SIGVAL void
-#endif
-
#if defined(X_NOT_POSIX) && (defined(SYSV) || defined(SVR4))
#define SIGNALS_RESET_WHEN_CAUGHT
#endif
+#include <stdlib.h>
+
extern char *configfilename;
+static Bool dropPriv = FALSE; /* whether or not to drop root privileges */
+#ifdef DEFAULT_DAEMON
+static Bool becomeDaemon = TRUE; /* whether to become a daemon or not */
+#else
+static Bool becomeDaemon = FALSE; /* whether to become a daemon or not */
+#endif
+static const char *userId = NULL;
char *progname;
Bool CloneSelf;
-extern int ListenPort;
+Bool portFromCmdline = FALSE;
OldListenRec *OldListen = NULL;
int OldListenCount = 0;
+#ifdef STDERR_FILENO
+# define WRITES write(STDERR_FILENO, s, strlen(s))
+#else
+# define WRITES write(fileno(stderr), s, strlen(s))
+#endif
+
+static char *pidFile = XFSPIDDIR "/xfs.pid";
+static int pidFd;
+static FILE *pidFilePtr;
+static int StorePid (void);
+
/* ARGSUSED */
SIGVAL
-AutoResetServer(n)
- int n;
+AutoResetServer(int n)
{
+ int olderrno = errno;
#ifdef DEBUG
- fprintf(stderr, "got a reset signal\n");
+ WRITES("got a reset signal\n");
#endif
dispatchException |= DE_RESET;
@@ -110,28 +134,31 @@ AutoResetServer(n)
#ifdef SIGNALS_RESET_WHEN_CAUGHT
signal(SIGHUP, AutoResetServer);
#endif
+ errno = olderrno;
}
+/* ARGSUSED */
SIGVAL
-GiveUp()
+GiveUp(int n)
{
-
+ int olderrno = errno;
#ifdef DEBUG
- fprintf(stderr, "got a TERM signal\n");
+ WRITES("got a TERM signal\n");
#endif
dispatchException |= DE_TERMINATE;
isItTimeToYield = TRUE;
+ errno = olderrno;
}
/* ARGSUSED */
SIGVAL
-ServerReconfig(n)
- int n;
+ServerReconfig(int n)
{
+ int olderrno = errno;
#ifdef DEBUG
- fprintf(stderr, "got a re-config signal\n");
+ WRITES("got a re-config signal\n");
#endif
dispatchException |= DE_RECONFIG;
@@ -140,16 +167,17 @@ ServerReconfig(n)
#ifdef SIGNALS_RESET_WHEN_CAUGHT
signal(SIGUSR1, ServerReconfig);
#endif
+ errno = olderrno;
}
/* ARGSUSED */
SIGVAL
-ServerCacheFlush(n)
- int n;
+ServerCacheFlush(int n)
{
+ int olderrno = errno;
#ifdef DEBUG
- fprintf(stderr, "got a flush signal\n");
+ WRITES("got a flush signal\n");
#endif
dispatchException |= DE_FLUSH;
@@ -158,16 +186,17 @@ ServerCacheFlush(n)
#ifdef SIGNALS_RESET_WHEN_CAUGHT
signal(SIGUSR2, ServerCacheFlush);
#endif
+ errno = olderrno;
}
/* ARGSUSED */
SIGVAL
-CleanupChild(n)
- int n;
+CleanupChild(int n)
{
+ int olderrno = errno;
#ifdef DEBUG
- fprintf(stderr, "got a child signal\n");
+ WRITES("got a child signal\n");
#endif
wait(NULL);
@@ -175,10 +204,11 @@ CleanupChild(n)
#ifdef SIGNALS_RESET_WHEN_CAUGHT
signal(SIGCHLD, CleanupChild);
#endif
+ errno = olderrno;
}
long
-GetTimeInMillis()
+GetTimeInMillis(void)
{
struct timeval tp;
@@ -187,14 +217,15 @@ GetTimeInMillis()
}
static void
-usage()
+usage(void)
{
- fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port]\n",
+ fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port] [-droppriv] [-daemon] [-nodaemon] [-user user_name] [-ls listen_socket]\n",
progname);
exit(1);
}
-OsInitAllocator ()
+void
+OsInitAllocator (void)
{
#ifdef MEMBUG
CheckMemory ();
@@ -211,19 +242,14 @@ OsInitAllocator ()
*
* [] denotes optional and ... denotes repitition.
*
- * The string must be _exactly_ in the above format. Since this is
- * an internal option used by the font server, it's ok to be strict
- * about the format of the string.
+ * The string must be _exactly_ in the above format.
*/
void
-ProcessLSoption (str)
-
-char *str;
-
+ProcessLSoption (char *str)
{
char *ptr = str;
- char *slash, *next;
+ char *slash;
char number[20];
int count = 0;
int len, i;
@@ -238,12 +264,18 @@ char *str;
OldListenCount = count + 1;
OldListen = (OldListenRec *) malloc (
OldListenCount * sizeof (OldListenRec));
-
+ if (OldListen == NULL) {
+ fprintf(stderr, "ProcessLSoption: malloc error\n");
+ exit(1);
+ }
ptr = str;
for (i = 0; i < OldListenCount; i++)
{
slash = (char *) strchr (ptr, '/');
+ if (slash == NULL) {
+ usage();
+ }
len = slash - ptr;
strncpy (number, ptr, len);
number[len] = '\0';
@@ -252,6 +284,9 @@ char *str;
ptr = slash + 1;
slash = (char *) strchr (ptr, '/');
+ if (slash == NULL) {
+ usage();
+ }
len = slash - ptr;
strncpy (number, ptr, len);
number[len] = '\0';
@@ -264,7 +299,9 @@ char *str;
else
{
char *comma = (char *) strchr (ptr, ',');
-
+ if (comma == NULL) {
+ usage();
+ }
len = comma - ptr;
strncpy (number, ptr, len);
number[len] = '\0';
@@ -279,24 +316,34 @@ char *str;
/* ARGSUSED */
void
-ProcessCmdLine(argc, argv)
- int argc;
- char **argv;
+ProcessCmdLine(int argc, char **argv)
{
int i;
progname = argv[0];
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-port")) {
- if (argv[i + 1])
+ if (argv[i + 1]) {
ListenPort = atoi(argv[++i]);
- else
+ portFromCmdline = TRUE;
+ } else
usage();
} else if (!strcmp(argv[i], "-ls")) {
if (argv[i + 1])
ProcessLSoption (argv[++i]);
else
usage();
+ } else if (!strcmp(argv[i], "-droppriv")) {
+ dropPriv = TRUE;
+ } else if (!strcmp(argv[i], "-daemon")) {
+ becomeDaemon = TRUE;
+ } else if (!strcmp(argv[i], "-nodaemon")) {
+ becomeDaemon = FALSE;
+ } else if (!strcmp(argv[i], "-user")) {
+ if (argv[i + 1])
+ userId = argv[++i];
+ else
+ usage();
} else if (!strcmp(argv[i], "-cf") || !strcmp(argv[i], "-config")) {
if (argv[i + 1])
configfilename = argv[++i];
@@ -341,14 +388,13 @@ unsigned long MemoryFail;
* expectations of malloc, but this makes lint happier.
*/
-unsigned long *
-FSalloc (amount)
- unsigned long amount;
+pointer
+FSalloc (unsigned long amount)
{
register pointer ptr;
if ((long)amount < 0)
- return (unsigned long *)NULL;
+ return 0;
if (amount == 0)
amount++;
/* aligned extra on long word boundary */
@@ -356,27 +402,26 @@ FSalloc (amount)
#ifdef MEMBUG
if (!Must_have_memory && MemoryFail &&
((random() % MEM_FAIL_SCALE) < MemoryFail))
- return (unsigned long *)NULL;
+ return 0;
if (ptr = (pointer)fmalloc(amount))
- return (unsigned long *) ptr;
+ return ptr;
#else
- if (ptr = (pointer)malloc(amount))
- return (unsigned long *)ptr;
+ if ((ptr = (pointer)malloc(amount)) != 0)
+ return ptr;
#endif
if (Must_have_memory)
- FatalError("Out of memory\n");
- return (unsigned long *)NULL;
+ FatalError("out of memory\n");
+ return 0;
}
/*****************
* FScalloc
*****************/
-unsigned long *
-FScalloc (amount)
- unsigned long amount;
+pointer
+FScalloc (unsigned long amount)
{
- unsigned long *ret;
+ pointer ret;
ret = FSalloc (amount);
if (ret)
@@ -388,26 +433,22 @@ FScalloc (amount)
* FSrealloc
*****************/
-unsigned long *
-FSrealloc (ptr, amount)
- register pointer ptr;
- unsigned long amount;
+pointer
+FSrealloc (pointer ptr, unsigned long amount)
{
- char *realloc();
-
#ifdef MEMBUG
if (!Must_have_memory && MemoryFail &&
((random() % MEM_FAIL_SCALE) < MemoryFail))
- return (unsigned long *)NULL;
+ return 0;
ptr = (pointer)frealloc((char *) ptr, amount);
if (ptr)
- return (unsigned long *) ptr;
+ return ptr;
#else
if ((long)amount <= 0)
{
if (ptr && !amount)
free(ptr);
- return (unsigned long *)NULL;
+ return 0;
}
amount = (amount + 3) & ~3;
if (ptr)
@@ -415,11 +456,11 @@ FSrealloc (ptr, amount)
else
ptr = (pointer)malloc(amount);
if (ptr)
- return (unsigned long *)ptr;
+ return ptr;
#endif
if (Must_have_memory)
- FatalError("Out of memory\n");
- return (unsigned long *)NULL;
+ FatalError("out of memory\n");
+ return 0;
}
/*****************
@@ -428,8 +469,7 @@ FSrealloc (ptr, amount)
*****************/
void
-FSfree(ptr)
- register pointer ptr;
+FSfree(pointer ptr)
{
#ifdef MEMBUG
if (ptr)
@@ -441,3 +481,96 @@ FSfree(ptr)
}
#endif /* SPECIAL_MALLOC */
+
+
+void
+SetUserId(void)
+{
+ /* become xfs user (or other specified on command line) if possible */
+ if ((geteuid() == 0) && (dropPriv || userId)) {
+ const char *user;
+ struct passwd *pwent;
+
+ if (!userId)
+ user = "xfs";
+ else
+ user = userId;
+ pwent = getpwnam(user);
+ if (pwent) {
+ if (setgid(pwent->pw_gid)) {
+ FatalError("fatal: couldn't set groupid to xfs user's group\n");
+ }
+#ifndef QNX4
+#ifndef __CYGWIN__
+ if (setgroups(0, NULL)) {
+ FatalError("fatal: couldn't drop supplementary groups\n");
+ }
+#endif
+ if (initgroups(user, pwent->pw_gid)) {
+ FatalError("fatal: couldn't init supplementary groups\n");
+ }
+#endif /* QNX4 */
+ if (setuid(pwent->pw_uid)) {
+ FatalError("fatal: couldn't set userid to %s user\n", user);
+ }
+ }
+ } else if (dropPriv || userId) {
+ FatalError("fatal: -droppriv or -user flag specified, but xfs not run as root\n");
+ }
+}
+
+
+void
+SetDaemonState(void)
+{
+ int oldpid;
+
+ if (becomeDaemon) {
+ BecomeOrphan();
+ BecomeDaemon();
+ if ((oldpid = StorePid ())) {
+ if (oldpid == -1)
+ ErrorF ("error opening process-id file %s\n", pidFile);
+ else
+ ErrorF ("process-id file %s indicates another xfs is "
+ "running (pid %d); exiting\n", pidFile, oldpid);
+ exit(1);
+ }
+ }
+}
+
+
+static int
+StorePid (void)
+{
+ int oldpid;
+
+ if (pidFile[0] != '\0') {
+ pidFd = open (pidFile, O_RDWR);
+ if (pidFd == -1 && errno == ENOENT)
+ pidFd = open (pidFile, O_RDWR|O_CREAT, 0666);
+ if (pidFd == -1 || !(pidFilePtr = fdopen (pidFd, "r+")))
+ {
+ ErrorF ("cannot open process-id file %s: %s\n", pidFile,
+ strerror (errno));
+ return -1;
+ }
+ if (fscanf (pidFilePtr, "%d\n", &oldpid) != 1)
+ oldpid = -1;
+ if (fseek (pidFilePtr, 0L, SEEK_SET) == -1)
+ {
+ ErrorF ("cannot seek process-id file %s: %s\n", pidFile,
+ strerror (errno));
+ return -1;
+ }
+ if (fprintf (pidFilePtr, "%5ld\n", (long) getpid ()) != 6)
+ {
+ ErrorF ("cannot write to process-id file %s: %s\n", pidFile,
+ strerror (errno));
+ return -1;
+ }
+ (void) fflush (pidFilePtr);
+ (void) fclose (pidFilePtr);
+ }
+ return 0;
+}
diff --git a/os/waitfor.c b/os/waitfor.c
index 9b69621..8394e78 100644
--- a/os/waitfor.c
+++ b/os/waitfor.c
@@ -47,30 +47,31 @@ in this Software without prior written authorization from The Open Group.
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $NCDId: @(#)waitfor.c,v 4.5 1991/06/24 11:59:20 lemke Exp $
+ * $NCDXorg: @(#)waitfor.c,v 4.5 1991/06/24 11:59:20 lemke Exp $
*
*/
+/* $XFree86: xc/programs/xfs/os/waitfor.c,v 3.16 2002/05/31 18:46:12 dawes Exp $ */
#include <X11/Xos.h> /* strings, time, etc */
#include <stdio.h>
#include <errno.h>
+#if !defined(Lynx)
#include <sys/param.h>
+#endif
#include "clientstr.h"
#include "globals.h"
#include "X11/Xpoll.h"
#include "osdep.h"
+#include "os.h"
-extern WorkQueuePtr workQueue;
-
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
#endif
+extern WorkQueuePtr workQueue;
-extern void MakeNewConnections();
-extern void FlushAllOutput();
extern fd_set WellKnownConnections;
extern fd_set LastSelectMask;
@@ -97,8 +98,8 @@ long LastReapTime;
* - room to write data to clients
*/
-WaitForSomething(pClientsReady)
- int *pClientsReady;
+int
+WaitForSomething(int *pClientsReady)
{
struct timeval *wt,
waittime;
@@ -140,7 +141,7 @@ WaitForSomething(pClientsReady)
XFD_COPYSET(&AllSockets, &LastSelectMask);
- BlockHandler((pointer) &wt, (pointer) &LastSelectMask);
+ BlockHandler(&wt, (pointer) &LastSelectMask);
if (NewOutputPending)
FlushAllOutput();
@@ -152,7 +153,7 @@ WaitForSomething(pClientsReady)
}
selecterr = errno;
- WakeupHandler(i, (pointer) &LastSelectMask);
+ WakeupHandler(i, (unsigned long *) &LastSelectMask);
if (i <= 0) { /* error or timeout */
FD_ZERO(&clientsWriteable);
if (i < 0) {
@@ -199,7 +200,7 @@ WaitForSomething(pClientsReady)
while (clientsReadable.fds_bits[i]) {
curclient = ffs(clientsReadable.fds_bits[i]) - 1;
conn = ConnectionTranslation[curclient + (i << 5)];
- FD_CLR (curclient, &clientsReadable);
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
client = clients[conn];
if (!client)
continue;
@@ -216,8 +217,8 @@ WaitForSomething(pClientsReady)
/*
* This is not always a macro
*/
-ANYSET(src)
- long *src;
+int
+ANYSET(long *src)
{
int i;
diff --git a/xfs.man b/xfs.man
index 62737c5..f1d15c0 100644
--- a/xfs.man
+++ b/xfs.man
@@ -1,3 +1,5 @@
+.\" $XFree86: xc/programs/xfs/xfs.man,v 3.16 2001/12/14 20:01:32 dawes Exp $
+.\"
.\" Copyright 1991, 1998 The Open Group
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
@@ -35,13 +37,18 @@
.\" suitability of this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\" $Xorg: xfs.man,v 1.4 2001/02/09 02:05:42 xorgcvs Exp $
-.TH XFS 1 "Release 6.4" "X Version 11"
+.TH XFS 1 __xorgversion__
.SH NAME
xfs \- X font server
.SH SYNOPSIS
.B "xfs"
[\-config \fIconfiguration_file\fP]
+[\-daemon]
+[\-droppriv]
+[\-ls \fIlisten_socket\fP]
+[\-nodaemon]
[\-port \fItcp_port\fP]
+[\-user \fIusername\fP]
.SH DESCRIPTION
.PP
.I Xfs
@@ -54,9 +61,11 @@ private font servers for specific sets of fonts.
.SH "OPTIONS"
.TP 8
.B \-config configuration_file
-Specifies the configuration file the font server will use.
+Specifies the configuration file the font server will use. If this
+parameter is not specified, the default file, \fI/usr/X11R6/lib/X11/fs/config\fR
+will be used.
.TP 8
-.B \-ls listen-socket
+.B \-ls listen_socket
Specifies a file descriptor which is already set up to be used as the
listen socket. This option is only intended to be used by the font server
itself when automatically spawning another copy of itself to handle
@@ -65,6 +74,31 @@ additional connections.
.B \-port tcp_port
Specifies the TCP port number on which the server will listen for connections.
The default port number is 7100.
+.TP 8
+.B \-daemon
+Instructs xfs to fork and go into the background automatically at
+startup If this option is not specified, xfs will run as a regular
+process (unless xfs was built to daemonize by default).
+.TP 8
+.B \-droppriv
+If specified, xfs will attempt to run as user and group \fIxfs\fR (unless
+the
+.B \-user
+option is used). This
+has been implemented for security reasons, as xfs may have undiscovered
+buffer overflows or other paths for possible exploit, both local and
+remote. With this option, you may also wish to specify
+"no-listen = tcp"
+in the config file, which ensures that xfs will not to use a TCP port at all.
+.TP 8
+.B \-nodaemon
+When xfs is built to daemonize (run in the background) by default,
+this prevents that and starts xfs up as a regular process.
+.TP 8
+.B \-user username
+This is equivalent to
+.B \-droppriv
+except that xfs will run as user \fIusername\fR.
.SH "SIGNALS"
.TP 8
.I SIGTERM
@@ -116,6 +150,9 @@ Multiple resolutions are separated by commas.
.IP "error-file (string)"
Filename of the error file. All warnings and errors
will be logged here.
+.IP "no-listen (trans-type)"
+Disable a transport type. For example, TCP/IP connections can
+be disabled with no-listen tcp
.IP "port (cardinal)"
TCP port on which the server will listen for connections.
.IP "use-syslog (boolean)"
@@ -132,31 +169,31 @@ enabled for all fonts, and "16", meaning it is enabled only for
.\" list means the server will talk to any client.
.SH "EXAMPLE"
.nf
-#
-# sample font server configuration file
-#
+XCOMM
+XCOMM sample font server configuration file
+XCOMM
-# allow a max of 10 clients to connect to this font server
+XCOMM allow a max of 10 clients to connect to this font server
client-limit = 10
-# when a font server reaches its limit, start up a new one
+XCOMM when a font server reaches its limit, start up a new one
clone-self = on
-# alternate font servers for clients to use
+XCOMM alternate font servers for clients to use
alternate-servers = hansen:7101,hansen:7102
-# where to look for fonts
-# the first is a set of Speedo outlines, the second is a set of
-# misc bitmaps and the last is a set of 100dpi bitmaps
-#
+XCOMM where to look for fonts
+XCOMM the first is a set of Speedo outlines, the second is a set of
+XCOMM misc bitmaps and the last is a set of 100dpi bitmaps
+XCOMM
catalogue = /usr/X11R6/lib/X11/fonts/speedo,
/usr/X11R6/lib/X11/fonts/misc,
/usr/X11R6/lib/X11/fonts/100dpi/
-# in 12 points, decipoints
+XCOMM in 12 points, decipoints
default-point-size = 120
-# 100 x 100 and 75 x 75
+XCOMM 100 x 100 and 75 x 75
default-resolutions = 100,100,75,75
use-syslog = off
.fi
@@ -194,7 +231,7 @@ with '+' as a separator.
.PP
Examples: \fIDECnet/SRVNOD::FONT$DEFAULT\fP, \fIdecnet/44.70::font$special/symbols\fP.
.SH "SEE ALSO"
-X(1), \fIThe X Font Service Protocol\fP,
+X(__miscmansuffix__), \fIThe X Font Service Protocol\fP,
.br
\fIFont server implementation overview\fP
.SH BUGS