summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
commit44c57155607fba22f35981377381b49969368318 (patch)
treeb6efc8fc68f3f31706b6741c01ca2a62883a8325
parent6bcb25d990a285e0e913044cffc3919d0091c263 (diff)
-rw-r--r--design2
-rw-r--r--di/atomcache.c28
-rw-r--r--di/cache.c3
-rw-r--r--di/cmap.c6
-rw-r--r--di/cmaputil.c10
-rw-r--r--di/dispatch.c3
-rw-r--r--di/gfx.c8
-rw-r--r--di/init.c2
-rw-r--r--di/lbxfuncs.c18
-rw-r--r--di/lbxutil.c22
-rw-r--r--di/main.c5
-rw-r--r--di/options.c9
-rw-r--r--di/pm.c15
-rw-r--r--di/props.c4
-rw-r--r--di/resource.c6
-rw-r--r--di/utils.c110
-rw-r--r--di/wire.c60
-rw-r--r--include/cache.h1
-rw-r--r--include/colormap.h117
-rw-r--r--include/lbx.h2
-rw-r--r--include/misc.h12
-rw-r--r--include/os.h14
-rw-r--r--include/swap.h30
-rw-r--r--include/util.h8
-rw-r--r--include/wire.h30
-rw-r--r--lbxproxy.man5
-rw-r--r--os/WaitFor.c36
-rw-r--r--os/connection.c122
-rw-r--r--os/io.c14
-rw-r--r--os/osdep.h37
30 files changed, 465 insertions, 274 deletions
diff --git a/design b/design
index 674e572..c76a7da 100644
--- a/design
+++ b/design
@@ -262,5 +262,5 @@ Data Flow
--------
-$NCDId: @(#)design,v 1.4 1994/04/11 18:17:03 lemke Exp $
+$NCDXorg: @(#)design,v 1.4 1994/04/11 18:17:03 lemke Exp $
$Xorg: design,v 1.3 2000/08/17 19:53:53 cpqbld Exp $
diff --git a/di/atomcache.c b/di/atomcache.c
index dbff6ab..43e2466 100644
--- a/di/atomcache.c
+++ b/di/atomcache.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/atomcache.c,v 1.7 2002/10/15 02:16:26 dawes Exp $ */
/*
* atom cache for LBX
@@ -133,22 +134,35 @@ ResizeHashTable(server)
}
static Bool
-ResizeReverseMap(server)
+ResizeReverseMap(server, atom)
XServerPtr server;
+ Atom atom;
{
- if (server->reverseMapSize == 0)
+ int oldMapSize = 0;
+
+ /* has the map already been initialized? */
+ if (server->reverseMapSize <= 0)
server->reverseMapSize = 1000;
else
+ /* keep track of the map size before we resize it */
+ oldMapSize = server->reverseMapSize;
+
+ /* grow the map until it is big enough */
+ while (server->reverseMapSize < atom)
server->reverseMapSize *= 2;
- server->reverseMap = (AtomListPtr *) xrealloc(server->reverseMap,
+ /* resize the map */
+ server->reverseMap = (AtomListPtr *) xrealloc(server->reverseMap,
server->reverseMapSize * sizeof(AtomListPtr));
- bzero((char *)server->reverseMap,
- (server->reverseMapSize * sizeof(AtomListPtr)));
if (!server->reverseMap)
+ /* memory allocation problem */
return FALSE;
+ /* zero out the new portion of the map */
+ bzero((char *) (server->reverseMap + oldMapSize),
+ ((server->reverseMapSize - oldMapSize) * sizeof(AtomListPtr)));
+
return TRUE;
}
@@ -162,7 +176,7 @@ LbxMakeAtom(server, string, len, atom, makeit)
{
AtomListPtr a;
int hash;
- int h;
+ int h = 0;
int r;
hash = Hash(string, len);
@@ -223,7 +237,7 @@ LbxMakeAtom(server, string, len, atom, makeit)
}
}
if (server->reverseMapSize <= a->atom)
- ResizeReverseMap(server);
+ ResizeReverseMap(server, a->atom);
server->reverseMap[a->atom] = a;
return a->atom;
}
diff --git a/di/cache.c b/di/cache.c
index 9cbf7d8..6f354d4 100644
--- a/di/cache.c
+++ b/di/cache.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/cache.c,v 1.6 2001/12/14 20:00:50 dawes Exp $ */
#include "misc.h"
#include "util.h"
#include "cache.h"
@@ -225,7 +226,7 @@ flush_cache(cache, needed)
CachePtr cache;
unsigned long needed;
{
- CacheEntryPtr cp, *prev, oldest, *oldprev;
+ CacheEntryPtr cp, *prev, oldest, *oldprev = NULL;
int i;
while ((cache->cursize + needed) > cache->maxsize) {
diff --git a/di/cmap.c b/di/cmap.c
index e717c52..9f987b2 100644
--- a/di/cmap.c
+++ b/di/cmap.c
@@ -48,6 +48,7 @@ from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/cmap.c,v 1.6 2001/12/14 20:00:50 dawes Exp $ */
#include <stdio.h>
#include "assert.h"
@@ -225,8 +226,9 @@ typedef struct _bignum {
BigNumLower lower;
} BigNumRec, *BigNumPtr;
-#define BigNumGreater(x,y) ((x)->upper > (y)->upper ||\
- (x)->upper == (y)->upper && (x)->lower > (y)->lower)
+#define BigNumGreater(x,y) (((x)->upper > (y)->upper) ||\
+ (((x)->upper == (y)->upper) &&\
+ ((x)->lower > (y)->lower)))
#define UnsignedToBigNum(u,r) (((r)->upper = UPPERPART(u)), \
((r)->lower = LOWERPART(u)))
diff --git a/di/cmaputil.c b/di/cmaputil.c
index ddec241..4f988ac 100644
--- a/di/cmaputil.c
+++ b/di/cmaputil.c
@@ -48,6 +48,7 @@ from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/cmaputil.c,v 1.11 2002/05/31 18:46:07 dawes Exp $ */
#include <stdio.h>
#include "misc.h"
@@ -134,7 +135,7 @@ GetVisual(vid)
* beware of too-small buffers
*/
-void
+static void
CopyISOLatin1Lowered(dest, source, length)
register unsigned char *dest, *source;
int length;
@@ -191,7 +192,7 @@ lookup(name, len, create)
Bool create;
{
unsigned int h = 0, g;
- dbEntryPtr entry, *prev;
+ dbEntryPtr entry, *prev = NULL;
char *str = name;
if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
@@ -243,6 +244,9 @@ InitColors()
return TRUE;
if (!have_rgb_db)
{
+#ifdef __UNIXOS2__
+ rgbPath = (char*)__XOS2RedirRoot(rgbPath);
+#endif
path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
strcpy(path, rgbPath);
strcat(path, ".txt");
@@ -430,8 +434,6 @@ DestroyColormap(client, value, id)
XID id;
{
ColormapPtr pmap = (ColormapPtr)value;
- xfree(pmap->blue);
- xfree(pmap->green);
xfree(pmap);
return Success;
}
diff --git a/di/dispatch.c b/di/dispatch.c
index b7907e5..39be1b7 100644
--- a/di/dispatch.c
+++ b/di/dispatch.c
@@ -21,6 +21,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/dispatch.c,v 1.6 2001/10/28 03:34:22 tsi Exp $ */
#include <stdio.h>
#include "assert.h"
@@ -68,7 +69,7 @@ int
Dispatch ()
{
register int *clientReady; /* array of request ready clients */
- register int result;
+ register int result = 0;
register ClientPtr client;
register int nready;
diff --git a/di/gfx.c b/di/gfx.c
index 885fe5c..a3a6794 100644
--- a/di/gfx.c
+++ b/di/gfx.c
@@ -46,6 +46,8 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/gfx.c,v 1.6 2001/12/14 20:00:51 dawes Exp $ */
+
/*
* graphics acceleration
*/
@@ -880,15 +882,15 @@ ProcLBXPutImage(client)
char *out;
int len,
reqlen,
- method,
+ method = 0,
compBytes,
status;
#ifdef LBX_STATS
float percentCompression;
char *methodName;
#endif
- LbxBitmapCompMethod *bcompMethod;
- LbxPixmapCompMethod *pcompMethod;
+ LbxBitmapCompMethod *bcompMethod = NULL;
+ LbxPixmapCompMethod *pcompMethod = NULL;
GFX_CACHE_DECLARE;
status = LBX_IMAGE_COMPRESS_SUCCESS;
diff --git a/di/init.c b/di/init.c
index 25ab189..fb4879a 100644
--- a/di/init.c
+++ b/di/init.c
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/init.c,v 1.6 2001/12/14 20:00:51 dawes Exp $ */
/*
* This file is used for anything that needs to dip into Xlib structures
@@ -60,6 +61,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <stdio.h>
+#include "XLbx.h"
/* Hook up to an X server and set up a multiplexing LBX encoded connection */
struct _XDisplay*
diff --git a/di/lbxfuncs.c b/di/lbxfuncs.c
index 402ab60..918ec6e 100644
--- a/di/lbxfuncs.c
+++ b/di/lbxfuncs.c
@@ -22,6 +22,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/lbxfuncs.c,v 1.6 2002/09/18 17:11:50 tsi Exp $ */
/*
* top level LBX request & reply handling
@@ -140,14 +141,14 @@ send_setup_reply(client, success, majorVer, minorVer, cs, cs_len)
ClientPtr client;
Bool success;
int majorVer, minorVer;
- char *cs;
+ void *cs;
int cs_len;
{
xConnSetupPrefix reply;
reply.success = success;
if (!success) {
- reply.lengthReason = strlen(cs);
+ reply.lengthReason = strlen((char *)cs);
cs_len = reply.lengthReason + 3;
}
reply.majorVersion = majorVer;
@@ -243,7 +244,8 @@ get_setup_reply(client, data, len)
td = TagGetTag(client->server, client->server->global_cache,
rep->tag);
if (!td) {
- fprintf(stderr, "no data for setup tag 0x%x\n", rep->tag);
+ fprintf(stderr, "no data for setup tag 0x%lx\n",
+ (long)rep->tag);
send_setup_reply(client, FALSE, 0, 0, "bad tag data from server", 0);
if (client->swapped)
DEALLOCATE_LOCAL(data);
@@ -330,6 +332,8 @@ ProcLBXInternAtom(client)
return ProcStandardRequest(client);
}
+
+ return 0; /* ?!?!? */
}
static Bool
@@ -566,7 +570,7 @@ get_mod_map_reply(client, nr, data)
tag_data = TagGetData(client->server, client->server->global_cache,
tag);
if (!tag_data) {
- fprintf(stderr, "no data for mod map tag 0x%x\n", tag);
+ fprintf(stderr, "no data for mod map tag 0x%lx\n", (long)tag);
WriteError(client, X_GetModifierMapping, 0, 0, BadAlloc);
return TRUE;
}
@@ -666,7 +670,7 @@ get_key_map_reply(client, nr, data)
tag_data = TagGetData(client->server,
client->server->global_cache, tag);
if (!tag_data) {
- fprintf(stderr, "no data for key map tag 0x%x\n", tag);
+ fprintf(stderr, "no data for key map tag 0x%lx\n", (long)tag);
WriteError(client, X_GetKeyboardMapping, 0, 0, BadAlloc);
return TRUE;
}
@@ -892,7 +896,7 @@ get_queryfont_reply(client, nr, data)
} else {
td = TagGetTag(client->server, client->server->global_cache, tag);
if (!td) {
- fprintf(stderr, "no data for font tag 0x%x\n", tag);
+ fprintf(stderr, "no data for font tag 0x%lx\n", (long)tag);
WriteError(client, X_QueryFont, 0, 0, BadAlloc);
return TRUE;
}
@@ -1089,7 +1093,7 @@ int
ProcLBXGetGeometry(client)
ClientPtr client;
{
- REQUEST(xResourceReq);
+ /* REQUEST(xResourceReq); */
xGetGeometryReply reply;
ReplyStuffPtr nr;
char n;
diff --git a/di/lbxutil.c b/di/lbxutil.c
index 6612201..9bd16c1 100644
--- a/di/lbxutil.c
+++ b/di/lbxutil.c
@@ -21,6 +21,8 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/lbxutil.c,v 1.5 2001/10/28 03:34:22 tsi Exp $ */
+
/*
* utility routines for LBX requests
*/
@@ -285,8 +287,8 @@ LbxFreeTag(server, tag, tagtype)
break;
default:
fprintf(stderr,
- "unknown type in InvalidateTag request: tag 0x%x type %d\n",
- tag, tagtype);
+ "unknown type in InvalidateTag request: tag 0x%lx type %d\n",
+ (long)tag, tagtype);
return;
}
TagFreeData(server, tag_cache, tag, TRUE);
@@ -309,8 +311,8 @@ LbxSendTagData(client, tag, tagtype)
tdata = ptdp->data;
len = ptdp->length;
} else {
- fprintf(stderr, "invalid SendTagData request: tag 0x%x type %d\n",
- tag, tagtype);
+ fprintf(stderr, "invalid SendTagData request: tag 0x%lx type %d\n",
+ (long)tag, tagtype);
len = 0;
tdata = NULL;
}
@@ -330,22 +332,22 @@ void
DumpCompressionStats()
{
if (raw_stream_out && stream_out_plain) {
- fprintf(stderr, "Requests: normal = %d, reencoded = %d",
- raw_stream_out, stream_out_plain);
+ fprintf(stderr, "Requests: normal = %ld, reencoded = %ld",
+ (long)raw_stream_out, (long)stream_out_plain);
stream_out_compressed += stream_out_uncompressed;
if (stream_out_compressed)
- fprintf(stderr, ", compressed = %d", stream_out_compressed);
+ fprintf(stderr, ", compressed = %ld", (long)stream_out_compressed);
else
stream_out_compressed = stream_out_plain;
fprintf(stderr, "\n %.2f:1 overall reduction ratio\n",
(float)raw_stream_out / (float)stream_out_compressed);
}
if (raw_stream_in && stream_in_plain) {
- fprintf(stderr, "Responses: normal = %d, reencoded = %d",
- raw_stream_in, stream_in_plain);
+ fprintf(stderr, "Responses: normal = %ld, reencoded = %ld",
+ (long)raw_stream_in, (long)stream_in_plain);
stream_in_compressed += stream_in_uncompressed;
if (stream_in_compressed)
- fprintf(stderr, ", compressed = %d", stream_in_compressed);
+ fprintf(stderr, ", compressed = %ld", (long)stream_in_compressed);
else
stream_in_compressed = stream_in_plain;
fprintf(stderr, "\n %.2f:1 overall reduction ratio\n",
diff --git a/di/main.c b/di/main.c
index acba869..bdfdac5 100644
--- a/di/main.c
+++ b/di/main.c
@@ -45,7 +45,9 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/main.c,v 1.9 2001/12/14 20:00:51 dawes Exp $ */
+#include <stdlib.h>
#include "lbx.h"
#include "wire.h"
#include "atomcache.h"
@@ -82,6 +84,8 @@ main (argc, argv)
ProcessCommandLine (argc, argv);
+ InitConnectionLimits();
+
AdjustProcVector();
InitializeGlobals ();
@@ -128,6 +132,7 @@ main (argc, argv)
FreeColors();
FreeTags();
}
+ CloseServerSockets();
exit (0);
}
diff --git a/di/options.c b/di/options.c
index 5d9cd6c..1fafa94 100644
--- a/di/options.c
+++ b/di/options.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/options.c,v 1.7 2001/12/14 20:00:51 dawes Exp $ */
#include <stdio.h>
#include "X.h"
@@ -483,8 +484,9 @@ OptZlibReply(server, preply, replylen)
unsigned char *preply;
int replylen;
{
- server->lbxNegOpt.streamOpts.streamCompInit = ZlibInit;
- server->lbxNegOpt.streamOpts.streamCompArg = (pointer) zlevel;
+ server->lbxNegOpt.streamOpts.streamCompInit =
+ (LbxStreamCompHandle (*)(int, pointer))ZlibInit;
+ server->lbxNegOpt.streamOpts.streamCompArg = (pointer)(long) zlevel;
server->lbxNegOpt.streamOpts.streamCompStuffInput = ZlibStuffInput;
server->lbxNegOpt.streamOpts.streamCompInputAvail = ZlibInputAvail;
server->lbxNegOpt.streamOpts.streamCompFlush = ZlibFlush;
@@ -492,7 +494,8 @@ OptZlibReply(server, preply, replylen)
server->lbxNegOpt.streamOpts.streamCompWriteV = ZlibWriteV;
server->lbxNegOpt.streamOpts.streamCompOn = ZlibCompressOn;
server->lbxNegOpt.streamOpts.streamCompOff = ZlibCompressOff;
- server->lbxNegOpt.streamOpts.streamCompFreeHandle = ZlibFree;
+ server->lbxNegOpt.streamOpts.streamCompFreeHandle =
+ (void (*)(LbxStreamCompHandle))ZlibFree;
return 0;
}
diff --git a/di/pm.c b/di/pm.c
index c6e145f..e96322d 100644
--- a/di/pm.c
+++ b/di/pm.c
@@ -25,7 +25,9 @@ not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/lbxproxy/di/pm.c,v 1.9 2002/09/16 18:06:20 eich Exp $ */
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -33,6 +35,7 @@ from The Open Group.
#include <netinet/in.h>
#include <netdb.h>
#include <X11/Xmd.h>
+#include <X11/Xlib.h>
#include <X11/ICE/ICElib.h>
#include <X11/ICE/ICEmsg.h>
#include <X11/ICE/ICEproto.h>
@@ -187,7 +190,7 @@ _ConnectToProxyManager (pmAddr, errorString)
if ((PM_iceConn = IceOpenConnection (
pmAddr, NULL, 0, 0, sizeof(iceError), iceError)) == NULL)
{
- sprintf (errorString,
+ snprintf (errorString, sizeof(errorString),
"Could not open ICE connection to proxy manager: %s", iceError);
return 0;
}
@@ -200,7 +203,7 @@ _ConnectToProxyManager (pmAddr, errorString)
if (setupstat != IceProtocolSetupSuccess)
{
IceCloseConnection (PM_iceConn);
- sprintf (errorString,
+ snprintf (errorString,sizeof(errorString),
"Could not initialize proxy management protocol: %s",
iceError);
return 0;
@@ -407,12 +410,8 @@ PMprocessMessages (iceConn, clientData, opcode, length,
* Connect to this server and send a GetProxyAddrReply msg.
*/
if (!ConnectToServer (display_name)) {
- char msg [100];
-
- (void) sprintf (msg,
- "could not connect to '%s'",
- display_name);
- FatalError(msg);
+ FatalError ("could not connect to '%s'",
+ display_name);
}
}
else
diff --git a/di/props.c b/di/props.c
index 84dfc9d..988a1e1 100644
--- a/di/props.c
+++ b/di/props.c
@@ -46,6 +46,8 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/props.c,v 1.6 2001/12/14 20:00:52 dawes Exp $ */
+
/*
* property handling
*/
@@ -332,7 +334,7 @@ GetLbxGetPropertyReply(client, nr, data)
client->server->prop_cache, tag);
if (!ptdp) {
- fprintf(stderr, "no data for property tag 0x%x\n", tag);
+ fprintf(stderr, "no data for property tag 0x%lx\n", (long)tag);
WriteError(client, X_GetProperty, 0, 0, BadAlloc);
return TRUE;
}
diff --git a/di/resource.c b/di/resource.c
index b928230..2b7811e 100644
--- a/di/resource.c
+++ b/di/resource.c
@@ -3,7 +3,11 @@
Copyright 1987, 1998 The Open Group
-All Rights Reserved.
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
diff --git a/di/utils.c b/di/utils.c
index 3846d3d..28516fc 100644
--- a/di/utils.c
+++ b/di/utils.c
@@ -45,6 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
+/* $XFree86: xc/programs/lbxproxy/di/utils.c,v 1.15 2002/12/09 04:10:58 tsi Exp $ */
#include "lbx.h"
#include <stdio.h>
@@ -62,18 +63,13 @@ SOFTWARE.
#undef _POSIX_SOURCE
#endif
#endif
-#ifndef SYSV
+#if !defined(SYSV) && !defined(Lynx) && !defined(QNX4)
#include <sys/resource.h>
#endif
-/* lifted from Xt/VarargsI.h */
-#if NeedVarargsPrototypes
#include <stdarg.h>
-#endif
-#if NeedVarargsPrototypes
-static void VErrorF(char*, va_list);
-#endif
+static void VErrorF(const char*, va_list);
#ifdef SIGNALRETURNSINT
#define SIGVAL int
@@ -86,6 +82,8 @@ static void VErrorF(char*, va_list);
#include "atomcache.h"
#include "proxyopts.h"
+#include <stdlib.h>
+
/*
* External declarations not in header files
*/
@@ -194,7 +192,7 @@ AutoResetServer (sig)
isItTimeToYield = TRUE;
#ifdef GPROF
chdir ("/tmp");
- exit (0);
+ _exit (0);
#endif
#ifdef SYSV
signal (SIGHUP, AutoResetServer);
@@ -275,7 +273,7 @@ void UseMsg()
void
ShowHelpAndExit (status)
-
+ int status;
{
UseMsg ();
exit (status);
@@ -638,27 +636,13 @@ OsInitAllocator ()
#endif
}
-/*VARARGS1*/
void
-AuditF(
-#if NeedVarargsPrototypes
- char * f, ...)
-#else
- f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of ten args */
- char *f;
- char *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
-#endif
+AuditF(const char * f, ...)
{
#ifdef notyet /* ever ? */
-#ifdef X_NOT_STDC_ENV
- long tm;
-#else
time_t tm;
-#endif
char *autime, *s;
-#if NeedVarargsPrototypes
va_list args;
-#endif
if (*f != ' ')
{
@@ -672,72 +656,38 @@ AuditF(
s = argvGlobal[0];
ErrorF("AUDIT: %s: %d %s: ", autime, getpid(), s);
}
-#if NeedVarargsPrototypes
va_start(args, f);
VErrorF(f, args);
va_end(args);
-#else
- ErrorF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
-#endif
#endif
}
-/*VARARGS1*/
void
-FatalError(
-#if NeedVarargsPrototypes
- char *f, ...)
-#else
-f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of ten args */
- char *f;
- char *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
-#endif
+FatalError(const char *f, ...)
{
-#if NeedVarargsPrototypes
va_list args;
-#endif
ErrorF("\nFatal lbxproxy error: ");
-#if NeedVarargsPrototypes
va_start(args, f);
VErrorF(f, args);
va_end(args);
-#else
- ErrorF(f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
-#endif
ErrorF("\n");
AbortServer();
/*NOTREACHED*/
}
-#if NeedVarargsPrototypes
static void
-VErrorF(f, args)
- char *f;
- va_list args;
+VErrorF(const char *f, va_list args)
{
vfprintf(stderr, f, args);
}
-#endif
-/*VARARGS1*/
void
-ErrorF(
-#if NeedVarargsPrototypes
- char * f, ...)
-#else
- f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) /* limit of ten args */
- char *f;
- char *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
-#endif
+ErrorF(const char * f, ...)
{
-#if NeedVarargsPrototypes
va_list args;
va_start(args, f);
VErrorF(f, args);
va_end(args);
-#else
- fprintf( stderr, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
-#endif
}
char *
@@ -918,6 +868,41 @@ ClientIsAsleep (client)
return FALSE;
}
+#ifdef __UNIXOS2__
+/* This code is duplicated from XLibInt.c, because the same problems with
+ * the drive letter as in clients also exist in the server
+ * Unfortunately the standalone servers don't link against libX11
+ */
+
+char *__XOS2RedirRoot(char *fname)
+{
+ /* This adds a further redirection by allowing the ProjectRoot
+ * to be prepended by the content of the envvar X11ROOT.
+ * This is for the purpose to move the whole X11 stuff to a different
+ * disk drive.
+ * The feature was added despite various environment variables
+ * because not all file opens respect them.
+ */
+ 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
+
+
+
+
void
LBXReadAtomsFile (server)
@@ -936,6 +921,9 @@ LBXReadAtomsFile (server)
server->atom_control = NULL;
min_keep_prop_size = DEF_KEEP_PROP_SIZE;
+#ifdef __UNIXOS2__
+ atomsFile = (char*)__XOS2RedirRoot(atomsFile);
+#endif
if (!(f = fopen (atomsFile, "r"))) {
ErrorF ("Could not load atom control file: %s\n", atomsFile);
return;
diff --git a/di/wire.c b/di/wire.c
index 41bc3a3..fa0510a 100644
--- a/di/wire.c
+++ b/di/wire.c
@@ -45,12 +45,20 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/di/wire.c,v 1.14 2002/09/19 13:22:03 tsi Exp $ */
#include "lbx.h"
#include <stdio.h>
+#include <stdlib.h>
#include "wire.h"
+#include "tags.h"
+#include "colormap.h"
#include "init.h"
+#ifndef Lynx
#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
#include <errno.h>
#include "proxyopts.h"
#include "swap.h"
@@ -72,7 +80,7 @@ in this Software without prior written authorization from The Open Group.
/*
* The following include for utsname.h is from lib/xtrans
*/
-#if (defined(_POSIX_SOURCE) && !defined(AIXV3)) || defined(hpux) || defined(USG) || defined(SVR4)
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4)
#define NEED_UTSNAME
#include <sys/utsname.h> /* uname() */
#else
@@ -134,16 +142,16 @@ WriteReqToServer(client, len, buf, checkLargeRequest)
delta_out_attempts++;
#endif
- if ((diffs = LBXDeltaMinDiffs(&server->outdeltas, buf, len,
- min(MAXBYTESDIFF, (len - sz_xLbxDeltaReq) >> 1),
+ if ((diffs = LBXDeltaMinDiffs(&server->outdeltas, (unsigned char *)buf,
+ len, min(MAXBYTESDIFF, (len - sz_xLbxDeltaReq) >> 1),
&cindex)) >= 0) {
#ifdef LBX_STATS
delta_out_hits++;
#endif
- LBXEncodeDelta(&server->outdeltas, buf, diffs, cindex,
- &server->tempdeltabuf[sz_xLbxDeltaReq]);
+ LBXEncodeDelta(&server->outdeltas, (unsigned char *)buf, diffs,
+ cindex, &server->tempdeltabuf[sz_xLbxDeltaReq]);
p->reqType = server->lbxReq;
p->lbxReqType = X_LbxDelta;
p->diffs = diffs;
@@ -154,7 +162,7 @@ WriteReqToServer(client, len, buf, checkLargeRequest)
WriteToServer(client, newlen, (char *) p, TRUE, checkLargeRequest);
written = TRUE;
}
- LBXAddDeltaOut(&server->outdeltas, buf, len);
+ LBXAddDeltaOut(&server->outdeltas, (unsigned char *)buf, len);
}
if (!written) {
#ifdef BIGREQS
@@ -407,10 +415,21 @@ SendIncrementPixel(client, cmap, pixel)
}
void
+#ifdef NeedFunctionPrototypes
+SendAllocColor(
+ ClientPtr client,
+ XID cmap,
+ CARD32 pixel,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue)
+#else
SendAllocColor(client, cmap, pixel, red, green, blue)
ClientPtr client;
XID cmap;
+ CARD32 pixel;
CARD16 red, green, blue;
+#endif
{
xLbxAllocColorReq req;
@@ -859,8 +878,10 @@ ServerProcStandardEvent(sc)
#endif
/* Note that LBXDecodeDelta decodes and adds current msg to the cache */
- len = LBXDecodeDelta(&server->indeltas, ((char *) rep) + sz_xLbxDeltaReq,
- delta->diffs, delta->cindex, &rep);
+ len = LBXDecodeDelta(&server->indeltas,
+ (xLbxDiffItem *)((char *) rep + sz_xLbxDeltaReq),
+ delta->diffs, delta->cindex,
+ (unsigned char **)&rep);
/* Make local copy in case someone writes to the request buffer */
memcpy(server->tempdeltabuf, (char *) rep, len);
@@ -876,7 +897,7 @@ ServerProcStandardEvent(sc)
delta_in_attempts++;
#endif
- LBXAddDeltaIn(&server->indeltas, (char *) rep, len);
+ LBXAddDeltaIn(&server->indeltas, (unsigned char *) rep, len);
}
if (rep->generic.type == server->lbxEvent &&
rep->generic.data1 != LbxMotionDeltaEvent) {
@@ -950,7 +971,7 @@ ServerProcStandardEvent(sc)
start, end);
#endif
if (pmap && pmap->grab_status == CMAP_GRABBED)
- GotServerFreeCellsEvent (pmap, start, end, 1);
+ GotServerFreeCellsEvent (pmap, start, end);
break;
}
}
@@ -1328,7 +1349,7 @@ StartProxyReply(server, rep)
server->lbxNegOpt.serverDeltaMaxLen);
LBXInitDeltaCache(&server->outdeltas, server->lbxNegOpt.proxyDeltaN,
server->lbxNegOpt.proxyDeltaMaxLen);
- QueueWorkProc(ProxyWorkProc, NULL, (pointer) server->index);
+ QueueWorkProc(ProxyWorkProc, NULL, (pointer)(long) server->index);
#ifdef OPTDEBUG
fprintf(stderr, "squishing = %d\n", server->lbxNegOpt.squish);
@@ -1511,9 +1532,10 @@ ConnectToServer(dpy_name)
return FALSE;
}
bzero(server, sizeof(XServerRec));
+
if (!InitServer (dpy_name, i, server, &sequence)) {
if (proxyMngr) {
- (void) sprintf (proxy_address,
+ (void) snprintf (proxy_address, sizeof(proxy_address),
"could not connect to server '%s'",
dpy_name);
SendGetProxyAddrReply( PM_iceConn, PM_Failure, NULL, proxy_address);
@@ -1539,13 +1561,19 @@ ConnectToServer(dpy_name)
#ifdef NEED_UTSNAME
uname (&name);
- (void) strcpy (my_host, name.nodename);
+ (void) snprintf(my_host,sizeof(my_host),"%s",name.nodename);
#else
- (void) gethostname (my_host, 250);
+ (void) gethostname (my_host,sizeof(my_host));
#endif
}
- (void) sprintf (proxy_address, "%s:%s", my_host, display);
-
+ if (snprintf (proxy_address, sizeof(proxy_address) ,"%s:%s", my_host,
+ display) >= sizeof(proxy_address)) {
+ (void) snprintf (proxy_address, sizeof(proxy_address),
+ "display name too long");
+ SendGetProxyAddrReply( PM_iceConn, PM_Failure, NULL, proxy_address);
+ return FALSE;
+ }
+
servers[i] = server;
sc = AllocNewConnection(server->fd, -1, TRUE, NULL);
diff --git a/include/cache.h b/include/cache.h
index 3637a09..b1abd4f 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -1,6 +1,5 @@
/* $Xorg: cache.h,v 1.4 2001/02/09 02:05:32 xorgcvs Exp $ */
/*
-
Copyright 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
diff --git a/include/colormap.h b/include/colormap.h
index 39fdf3a..b4a7d87 100644
--- a/include/colormap.h
+++ b/include/colormap.h
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/include/colormap.h,v 1.6 2001/12/14 20:00:55 dawes Exp $ */
#ifndef COLORMAP_H_
#define COLORMAP_H_
@@ -181,6 +182,47 @@ extern Entry * FindBestPixel(
#endif
);
+extern void ReleaseCmap(
+#if NeedFunctionPrototypes
+ ClientPtr /* client */,
+ ColormapPtr /* pmap */
+#endif
+);
+
+extern int CreateColormap(
+#if NeedFunctionPrototypes
+ ClientPtr /*client*/,
+ Colormap /*cmap*/,
+ VisualID /*visual*/
+#endif
+);
+
+extern int FreeColormap(
+#if NeedFunctionPrototypes
+ ClientPtr /*client*/,
+ Colormap /*cmap*/
+#endif
+);
+
+extern int CreateVisual(
+#if NeedFunctionPrototypes
+ int /*depth*/,
+ xVisualType * /*vis*/
+#endif
+);
+
+extern LbxVisualPtr GetVisual(
+#if NeedFunctionPrototypes
+ VisualID /*vid*/
+#endif
+);
+
+extern Bool InitColors(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
extern RGBEntryPtr FindColorName(
#if NeedFunctionPrototypes
XServerPtr /*server*/,
@@ -199,16 +241,17 @@ extern Bool AddColorName(
#endif
);
-extern int CreateVisual(
+extern void FreeColors(
#if NeedFunctionPrototypes
- int /*depth*/,
- xVisualType * /*vis*/
+ void
#endif
);
-extern LbxVisualPtr GetVisual(
+extern int DestroyColormap(
#if NeedFunctionPrototypes
- VisualID /*vid*/
+ ClientPtr /*client*/,
+ pointer /*pmap*/,
+ XID /*id*/
#endif
);
@@ -223,26 +266,6 @@ extern int FindPixel(
#endif
);
-extern int StorePixel(
-#if NeedFunctionPrototypes
- ClientPtr /*client*/,
- ColormapPtr /*pmap*/,
- CARD32 /*red*/,
- CARD32 /*green*/,
- CARD32 /*blue*/,
- Pixel /*pixel*/,
- Bool /*from_server*/
-#endif
-);
-
-extern int FreeClientPixels(
-#if NeedFunctionPrototypes
- ClientPtr /*client*/,
- pointer /*pcr*/,
- XID /*id*/
-#endif
-);
-
extern int IncrementPixel(
#if NeedFunctionPrototypes
ClientPtr /*pclient*/,
@@ -260,50 +283,48 @@ extern int AllocCell(
#endif
);
-extern int FreePixels(
+extern int StorePixel(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
ColormapPtr /*pmap*/,
- int /*num*/,
- Pixel * /*pixels*/,
- Pixel /*mask*/
+ CARD32 /*red*/,
+ CARD32 /*green*/,
+ CARD32 /*blue*/,
+ Pixel /*pixel*/,
+ Bool /*from_server*/
#endif
);
-extern int CreateColormap(
+extern void GotServerFreeCellsEvent(
#if NeedFunctionPrototypes
- ClientPtr /*client*/,
- Colormap /*cmap*/,
- VisualID /*visual*/
+ ColormapPtr /* pmap */,
+ Pixel /* pixel_start */,
+ Pixel /* pixel_end */
#endif
);
-extern int DestroyColormap(
+extern void FreeAllClientPixels(
#if NeedFunctionPrototypes
- ClientPtr /*client*/,
- pointer /*pmap*/,
- XID /*id*/
+ ColormapPtr /* pmap */,
+ int /* client */
#endif
);
-extern int FreeColormap(
+extern int FreeClientPixels(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
- Colormap /*cmap*/
+ pointer /*pcr*/,
+ XID /*id*/
#endif
);
-extern int CopyAndFreeColormap(
+extern int FreePixels(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
- Colormap /*new*/,
- Colormap /*old*/
-#endif
-);
-
-extern void FreeColors(
-#if NeedFunctionPrototypes
- void
+ ColormapPtr /*pmap*/,
+ int /*num*/,
+ Pixel * /*pixels*/,
+ Pixel /*mask*/
#endif
);
diff --git a/include/lbx.h b/include/lbx.h
index 04e46af..da6ce39 100644
--- a/include/lbx.h
+++ b/include/lbx.h
@@ -45,13 +45,13 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/include/lbx.h,v 1.6 2001/12/14 20:00:55 dawes Exp $ */
#ifndef _LBX_H_
#define _LBX_H_
#include "misc.h"
#include "os.h"
#include "util.h"
-#define _XLBX_SERVER_
#include "lbxstr.h"
/* we keep the ifdefs in the code as a guide to what's going on */
diff --git a/include/misc.h b/include/misc.h
index 8d2d8a0..526372a 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -27,13 +27,13 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/lbxproxy/include/misc.h,v 1.7 2001/12/14 20:00:55 dawes Exp $ */
#ifndef MISC_H
#define MISC_H 1
#define NEED_EVENTS
#define NEED_REPLIES
-#define _XLBX_SERVER_
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xmd.h>
@@ -43,21 +43,15 @@ from The Open Group.
#include "Xalloca.h"
#include "Xfuncs.h"
#include "Xfuncproto.h"
+#include "lbxstr.h"
-typedef void *pointer;
-#ifndef _BOOL_ALREADY_DEFINED_
-typedef int Bool;
-#endif
#ifndef TRUE
#define FALSE 0
#define TRUE 1
#endif
-typedef struct _Client *ClientPtr;
typedef struct _XServer *XServerPtr;
-#ifndef NULL
-#define NULL 0
-#endif
+#include <stddef.h>
#define DE_RESET 1
#define DE_TERMINATE 2
#define MILLI_PER_SECOND (1000)
diff --git a/include/os.h b/include/os.h
index 0ad6c0b..20bca9e 100644
--- a/include/os.h
+++ b/include/os.h
@@ -27,6 +27,8 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/lbxproxy/include/os.h,v 1.7 2001/12/14 20:00:55 dawes Exp $ */
+
#ifndef OS_H
#define OS_H
@@ -55,12 +57,24 @@ extern Bool NewOutputPending;
extern Bool AnyClientsWriteBlocked;
extern int GrabInProgress;
+extern void InitConnectionLimits(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
extern void CreateServerSockets(
#if NeedFunctionPrototypes
int * /*listen_fds[]*/
#endif
);
+extern void CloseServerSockets(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
extern void CreateWellKnownSockets(
#if NeedFunctionPrototypes
void
diff --git a/include/swap.h b/include/swap.h
index d94d29d..bbfa877 100644
--- a/include/swap.h
+++ b/include/swap.h
@@ -22,6 +22,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/include/swap.h,v 1.2 2001/08/01 00:45:01 tsi Exp $ */
#ifndef _SWAP_H_
#define _SWAP_H_
@@ -47,9 +48,10 @@ extern void SwapVisual(
#endif
);
-extern void SwapConnectionInfo(
+extern void WriteSConnSetupPrefix(
#if NeedFunctionPrototypes
- xConnSetup * /*pConnSetup*/
+ ClientPtr /* pClient */,
+ xConnSetupPrefix * /* pcsp */
#endif
);
@@ -209,15 +211,15 @@ extern void SwapGetProperty(
#endif
);
-extern void SwapPutImage(
+extern void SwapGetImage(
#if NeedFunctionPrototypes
- xLbxPutImageReq * /*r*/
+ xLbxGetImageReq * /*r*/
#endif
);
-extern void SwapGetImage(
+extern void SwapInternAtoms(
#if NeedFunctionPrototypes
- xLbxGetImageReq * /*r*/
+ xLbxInternAtomsReq * /* r */
#endif
);
@@ -245,9 +247,21 @@ extern void SwapLbxConnSetupPrefix(
#endif
);
-extern void SwapConnSetupPrefix(
+extern void SwapAllocColor(
+#if NeedFunctionPrototypes
+ xLbxAllocColorReq * /* r */
+#endif
+);
+
+extern void SwapGrabCmap(
+#if NeedFunctionPrototypes
+ xLbxGrabCmapReq * /* r */
+#endif
+);
+
+extern void SwapReleaseCmap(
#if NeedFunctionPrototypes
- xConnSetupPrefix * /*csp*/
+ xLbxReleaseCmapReq * /* r */
#endif
);
diff --git a/include/util.h b/include/util.h
index a4ad597..a6e757e 100644
--- a/include/util.h
+++ b/include/util.h
@@ -46,6 +46,8 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/include/util.h,v 1.7 2001/12/14 20:00:56 dawes Exp $ */
+
#ifndef _UTIL_H_
#define _UTIL_H_
@@ -150,21 +152,21 @@ extern void OsInitAllocator(
extern void AuditF(
#if NeedVarargsPrototypes
- char * /*f*/,
+ const char * /*f*/,
...
#endif
);
extern void FatalError(
#if NeedVarargsPrototypes
- char * /*f*/,
+ const char * /*f*/,
...
#endif
);
extern void ErrorF(
#if NeedVarargsPrototypes
- char * /*f*/,
+ const char * /*f*/,
...
#endif
);
diff --git a/include/wire.h b/include/wire.h
index 14e9761..077f325 100644
--- a/include/wire.h
+++ b/include/wire.h
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/lbxproxy/include/wire.h,v 1.7 2001/12/14 20:00:56 dawes Exp $ */
#ifdef DEBUG /* Need this here because lbx.h undef's DEBUG */
extern int lbxDebug;
@@ -263,24 +264,24 @@ extern void WriteReqToServer(
#endif
);
-extern void WriteToServer(
+extern void _write_to_server(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
+ Bool /*compressed*/,
int /*len*/,
- char * /*buf*/,
- Bool /*startOfRequest*/,
- Bool /*checkLargeRequest*/
+ char* /*buf*/,
+ Bool /*checkLarge*/,
+ Bool /*startOfRequest*/
#endif
);
-extern void _write_to_server(
+extern void WriteToServer(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
- Bool /*compressed*/,
int /*len*/,
- char* /*buf*/,
- Bool /*checkLarge*/,
- Bool /*startOfRequest*/
+ char * /*buf*/,
+ Bool /*startOfRequest*/,
+ Bool /*checkLargeRequest*/
#endif
);
@@ -328,6 +329,17 @@ extern void SendIncrementPixel(
#endif
);
+extern void SendAllocColor(
+#if NeedFunctionPrototypes
+ ClientPtr /* pClient */,
+ XID /* cmap */,
+ CARD32 /* pixel */,
+ CARD16 /* red */,
+ CARD16 /* green */,
+ CARD16 /* blue */
+#endif
+);
+
extern void SendGetModifierMapping(
#if NeedFunctionPrototypes
ClientPtr /*client*/
diff --git a/lbxproxy.man b/lbxproxy.man
index 52c51af..7b406b5 100644
--- a/lbxproxy.man
+++ b/lbxproxy.man
@@ -23,7 +23,10 @@
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
-.TH LBXPROXY 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/lbxproxy/lbxproxy.man,v 1.8 2001/12/14 20:00:49 dawes Exp $
+.\"
+.TH LBXPROXY 1 __xorgversion__
.SH NAME
lbxproxy - Low BandWidth X proxy
.SH SYNOPSIS
diff --git a/os/WaitFor.c b/os/WaitFor.c
index cc42939..3bccd66 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -45,6 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
+/* $XFree86: xc/programs/lbxproxy/os/WaitFor.c,v 1.9 2001/12/14 20:00:57 dawes Exp $ */
/*****************************************************************
* OS Dependent input routines:
@@ -57,10 +58,6 @@ SOFTWARE.
#include "Xos.h" /* for strings, fcntl, time */
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
-
#include <stdio.h>
#include "misc.h"
#include "util.h"
@@ -71,9 +68,21 @@ extern int errno;
#include "os.h"
#include "pm.h"
-extern int ConnectionTranslation[];
+int
+mffs(fd_mask mask)
+{
+ int i;
-extern WorkQueuePtr workQueue;
+ if (!mask) return 0;
+
+ i = 1;
+ while (!(mask & 1))
+ {
+ i++;
+ mask >>= 1;
+ }
+ return i;
+}
/*****************
* WaitForSomething:
@@ -127,10 +136,10 @@ WaitForSomething(pClientsReady, poll)
else if (AnyClientsWriteBlocked)
{
XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
- i = Select (MAXSOCKS, &LastSelectMask, &clientsWritable, NULL, wt);
+ i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
}
else
- i = Select (MAXSOCKS, &LastSelectMask, NULL, NULL, wt);
+ i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
selecterr = errno;
if (poll && i == 0)
@@ -141,7 +150,7 @@ WaitForSomething(pClientsReady, poll)
if (dispatchException)
return 0;
FD_ZERO(&clientsWritable);
- if (i < 0)
+ if (i < 0) {
if (selecterr == EBADF) /* Some client disconnected */
{
CheckConnections ();
@@ -151,9 +160,11 @@ WaitForSomething(pClientsReady, poll)
else if (selecterr != EINTR)
ErrorF("WaitForSomething(): select: errno=%d\n",
selecterr);
+ }
}
else
{
+ fd_set tmp_set;
if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
{
NewOutputPending = TRUE;
@@ -164,7 +175,8 @@ WaitForSomething(pClientsReady, poll)
}
XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
- if (LastSelectMask.fds_bits[0] & WellKnownConnections.fds_bits[0])
+ XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
+ if (XFD_ANYSET(&tmp_set))
QueueWorkProc(EstablishNewConnections, NULL,
(pointer)&LastSelectMask);
if (proxy_manager_fd >= 0 &&
@@ -186,11 +198,11 @@ WaitForSomething(pClientsReady, poll)
int client_index;
curclient = ffs (clientsReadable.fds_bits[i]) - 1;
- client_index = ConnectionTranslation[curclient + (i << 5)];
+ client_index = ConnectionTranslation[curclient + (i * (sizeof(fd_mask)*8))];
{
pClientsReady[nready++] = client_index;
}
- clientsReadable.fds_bits[i] &= ~(((fd_mask)1) << curclient);
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
}
}
}
diff --git a/os/connection.c b/os/connection.c
index 1335e01..420af0f 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -44,7 +44,7 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
-/*****************************************************************
+ *****************************************************************
* Stuff to create connections --- OS dependent
*
* EstablishNewConnections, CreateWellKnownSockets,
@@ -60,6 +60,7 @@ SOFTWARE.
* socket ids aren't small nums (0 - 2^8)
*
*****************************************************************/
+/* $XFree86: xc/programs/lbxproxy/os/connection.c,v 1.18 2002/07/06 09:59:17 alanh Exp $ */
#include "misc.h"
#include <X11/Xtrans.h>
@@ -67,10 +68,6 @@ SOFTWARE.
#include <stdio.h>
#include <stdlib.h> /* atoi */
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
-
#include <signal.h>
#include <setjmp.h>
@@ -85,9 +82,13 @@ extern int errno;
#include <sys/ioctl.h>
#endif
+#ifdef QNX4
+#include <sys/stat.h>
+#endif
+
#if defined (TCPCONN) || defined(STREAMSCONN)
# include <netinet/in.h>
-# ifndef hpux
+# if !defined(hpux)
# ifdef apollo
# ifndef NO_TCP_H
# include <netinet/tcp.h>
@@ -126,7 +127,7 @@ fd_set LastSelectMask; /* mask returned from last select call */
fd_set ClientsWithInput; /* clients with FULL requests in buffer */
fd_set ClientsWriteBlocked; /* clients who cannot receive output */
fd_set OutputPending; /* clients with reply/event data ready to go */
-int MaxClients = MAXSOCKS;
+int MaxClients = 0;
Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
@@ -145,8 +146,8 @@ static fd_set SavedClientsWithInput;
static int auditTrailLevel = 1;
int GrabInProgress = 0;
-int ConnectionTranslation[MAXSOCKS];
-int ConnectionOutputTranslation[MAXSOCKS];
+int *ConnectionTranslation = NULL;
+int *ConnectionOutputTranslation = NULL;
static XtransConnInfo *ListenTransConns = NULL;
static int *ListenTransFds = NULL;
@@ -194,6 +195,54 @@ lookup_trans_conn (fd)
}
+/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+
+void
+InitConnectionLimits()
+{
+ lastfdesc = -1;
+
+#ifndef __UNIXOS2__
+
+#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX)
+ lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
+#ifdef HAS_GETDTABLESIZE
+ if (lastfdesc < 0)
+ lastfdesc = getdtablesize() - 1;
+#endif
+
+#ifdef _NFILE
+ if (lastfdesc < 0)
+ lastfdesc = _NFILE - 1;
+#endif
+
+#else /* __UNIXOS2__ */
+ lastfdesc = 255;
+#endif
+
+ /* This is the fallback */
+ if (lastfdesc < 0)
+ lastfdesc = MAXSOCKS;
+
+ if (lastfdesc > MAXSELECT)
+ lastfdesc = MAXSELECT;
+
+ if (lastfdesc > 2 * MAXCLIENTS)
+ {
+ lastfdesc = 2 * MAXCLIENTS;
+ if (debug_conns)
+ ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ }
+ MaxClients = lastfdesc;
+
+ ConnectionTranslation = (int *)xalloc((lastfdesc + 1) * sizeof(int));
+ ConnectionOutputTranslation = (int *)xalloc((lastfdesc + 1) * sizeof(int));
+ if (ConnectionTranslation == NULL || ConnectionOutputTranslation == NULL)
+ FatalError("failed to allocate ConnectionTranslation\n");
+}
+
/*
* Create the socket(s) that clients will used for one server.
*/
@@ -295,6 +344,15 @@ CreateServerSockets(fds)
(void) fprintf (stderr, "Using port number '%s'\n", display);
}
+void
+CloseServerSockets()
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ _LBXPROXYTransClose (ListenTransConns[i]);
+}
+
/*****************
* CreateWellKnownSockets
* Initialize the global connection file descriptor arrays
@@ -311,27 +369,8 @@ CreateWellKnownSockets()
FD_ZERO(&LastSelectMask);
FD_ZERO(&ClientsWithInput);
- for (i=0; i<MAXSOCKS; i++) ConnectionTranslation[i] = 0;
- for (i=0; i<MAXSOCKS; i++) ConnectionOutputTranslation[i] = 0;
-#ifdef XNO_SYSCONF
-#undef _SC_OPEN_MAX
-#endif
-#ifdef _SC_OPEN_MAX
- lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
-#else
-#ifdef hpux
- lastfdesc = _NFILE - 1;
-#else
- lastfdesc = getdtablesize() - 1;
-#endif
-#endif
-
- if (lastfdesc > MAXSOCKS)
- {
- lastfdesc = MAXSOCKS;
- if (debug_conns)
- ErrorF( "GOT TO END OF SOCKETS %d\n", MAXSOCKS);
- }
+ for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+ for (i=0; i<MaxClients; i++) ConnectionOutputTranslation[i] = 0;
FD_ZERO(&WellKnownConnections);
@@ -533,24 +572,28 @@ EstablishNewConnections(clientUnused, closure)
ClientPtr clientUnused;
pointer closure;
{
- fd_mask readyconnections; /* mask of listeners that are ready */
+ fd_set readyconnections; /* set of listeners that are ready */
int curconn; /* fd of listener that's ready */
register int newconn; /* fd of new client */
register ClientPtr client;
fd_set tmask;
+ int i;
- XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
- readyconnections = tmask.fds_bits[0];
- if (!readyconnections)
+ XFD_ANDSET(&tmask, (fd_set*)closure, &WellKnownConnections);
+ XFD_COPYSET(&tmask, &readyconnections);
+ if (!XFD_ANYSET(&readyconnections))
return TRUE;
- while (readyconnections)
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
{
+ while (readyconnections.fds_bits[i])
+ {
XtransConnInfo trans_conn, new_trans_conn;
int status;
- curconn = ffs (readyconnections) - 1;
- readyconnections &= ~(1 << curconn);
+ curconn = ffs (readyconnections.fds_bits[i]) - 1;
+ readyconnections.fds_bits[i] &= ~(1L << curconn);
+ curconn += (i * (sizeof(fd_mask)*8));
if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
continue;
@@ -569,6 +612,7 @@ EstablishNewConnections(clientUnused, closure)
_LBXPROXYTransClose(new_trans_conn);
return FALSE;
}
+ }
}
return TRUE;
@@ -692,13 +736,13 @@ CheckConnections()
while (mask)
{
curoff = ffs (mask) - 1;
- curclient = curoff + (i << 5);
+ curclient = curoff + (i * (sizeof(fd_mask)*8));
FD_ZERO(&tmask);
FD_SET(curclient, &tmask);
r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
if (r < 0)
CloseDownClient(clients[ConnectionTranslation[curclient]]);
- mask &= ~(1 << curoff);
+ mask &= ~(1L << curoff);
}
}
}
diff --git a/os/io.c b/os/io.c
index e87b32f..c92cc0b 100644
--- a/os/io.c
+++ b/os/io.c
@@ -45,6 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
+/* $XFree86: xc/programs/lbxproxy/os/io.c,v 1.10 2001/12/14 20:00:58 dawes Exp $ */
/*****************************************************************
* i/o functions
*
@@ -56,9 +57,6 @@ SOFTWARE.
#include <stdio.h>
#include <X11/Xtrans.h>
#include "Xos.h"
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
#include "misc.h"
#include <errno.h>
#include <sys/param.h>
@@ -86,9 +84,6 @@ extern int errno;
#endif
extern void MarkClientException();
-extern int ConnectionTranslation[];
-extern int ConnectionOutputTranslation[];
-
static int timesThisConnection = 0;
static ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL;
static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL;
@@ -887,7 +882,7 @@ LbxFlushClient(who, oc, extraBuf, extraCount)
}
if (oc->output) {
if (extraCount) {
- int len = obuf->count + (extraCount + 3) & ~3;
+ int len = (obuf->count + extraCount + 3) & ~3;
if (ExpandOutputBuffer(obuf, len) < 0) {
if (oc->trans_conn) {
_LBXPROXYTransDisconnect(oc->trans_conn);
@@ -933,7 +928,8 @@ LbxFlushClient(who, oc, extraBuf, extraCount)
void
FlushAllOutput()
{
- register int index, base, mask;
+ register int index, base;
+ register fd_mask mask;
OsCommPtr oc;
register ClientPtr client;
@@ -955,7 +951,7 @@ FlushAllOutput()
{
index = ffs(mask) - 1;
mask &= ~lowbit(mask);
- if ((index = ConnectionOutputTranslation[(base << 5) + index]) == 0)
+ if ((index = ConnectionOutputTranslation[(base * (sizeof(fd_mask)*8)) + index]) == 0)
continue;
client = clients[index];
if (client->clientGone)
diff --git a/os/osdep.h b/os/osdep.h
index 71b3712..8daa5b5 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -45,6 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
+/* $XFree86: xc/programs/lbxproxy/os/osdep.h,v 1.11 2002/05/31 18:46:08 dawes Exp $ */
#define BOTIMEOUT 200 /* in milliseconds */
#define BUFSIZE 4096
@@ -65,6 +66,10 @@ SOFTWARE.
#endif
#endif
+#if defined(__UNIXOS2__) || defined(__QNX__)
+#define OPEN_MAX 256
+#endif
+
#ifndef OPEN_MAX
#ifdef SVR4
#define OPEN_MAX 128
@@ -80,16 +85,28 @@ SOFTWARE.
#endif
#endif
+#include <X11/Xpoll.h>
+
+/*
+ * MAXSOCKS is used only for initialising MaxClients when no other method
+ * like sysconf(_SC_OPEN_MAX) is not supported.
+ */
+
#if OPEN_MAX <= 128
#define MAXSOCKS (OPEN_MAX - 1)
#else
#define MAXSOCKS 128
#endif
-#ifndef NULL
-#define NULL 0
+/* MAXSELECT is the number of fds that select() can handle */
+#define MAXSELECT (sizeof(fd_set) * NBBY)
+
+#if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
+#define HAS_GETDTABLESIZE
#endif
+#include <stddef.h>
+
typedef struct _connectionInput {
struct _connectionInput *next;
char *buffer; /* contains current client input */
@@ -126,26 +143,30 @@ typedef struct _osComm {
(*((OsCommPtr)((who)->osPrivate))->flushClient)(who, oc, extraBuf, extraCount)
extern void FreeOsBuffers(
-#if NeedFunctionPrototypes
OsCommPtr /*oc*/
-#endif
);
extern int StandardFlushClient(
-#if NeedFunctionPrototypes
ClientPtr /*who*/,
OsCommPtr /*oc*/,
char * /*extraBuf*/,
int /*extraCount*/
-#endif
);
extern int LbxFlushClient(
-#if NeedFunctionPrototypes
ClientPtr /*who*/,
OsCommPtr /*oc*/,
char * /*extraBuf*/,
int /*extraCount*/
-#endif
);
+#include "util.h"
+
+extern int *ConnectionTranslation;
+extern int *ConnectionOutputTranslation;
+
+extern WorkQueuePtr workQueue;
+
+#define ffs mffs
+extern int mffs(fd_mask);
+