/* $Id: glob.h,v 1.2 90/11/30 16:22:14 spanachi Exp $ */

/*
 * Copyright (C) 1990 by Digital Equipment Corporation.
 * 
 * Author: Michael P. Altenhofen, CEC Karlsruhe e-mail:
 * Altenhofen@kampus.enet.dec.com
 * 
 * This file ist part of Shared X
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation without fee is hereby granted, but only for non-profit  use
 * and distribution,  and provided  that the copyright notice and this notice
 * is preserved on all copies.
 * 
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#ifndef _GLOB_H_
#define _GLOB_H_

#include <stdio.h>
#include <setjmp.h>
#include <signal.h>

#include "misc.h"

PUBLIC jmp_buf jmpenv;
/* -- some flags reporting critical process states -- */

PUBLIC Bool AnyClientsWriteBlocked;
PUBLIC Bool NewOutputPending;
PUBLIC Bool isItTimeToYield;
PUBLIC Bool clientsDoomed;

/* -- debugging flags -- */

PUBLIC Bool _debug_requests;
PUBLIC Bool _debug_events;
PUBLIC Bool _debug_io;
PUBLIC Bool _debug_resources;
PUBLIC Bool _debug_alloc;

/* -- global strings -- */

PUBLIC char *defaultServer;	/* name of server XmuX is connected to;
				 * default "0:=0" */
PUBLIC char *display_name;	/* display name that is used by clients to
				 * connect to XmuX; default ":2" */
PUBLIC char *ConnectionInfo;	/* display information send to
				 * clients during connection setup */

PUBLIC FILE *logfile;		/* the logfile */

/* -- global error handling variables -- */

PUBLIC int clientErrorValue;	/* the error value (e.g. BadValue) send by
				 * the server */
PUBLIC int clientErrorRequest;	/* the request code (e.g. X_OpenFont) which
				 * caused the error */

PUBLIC int delay;		/* delay between "pixmap updates" in the
				 * pixmap viewer window */

/* -- global bookkeeping variables -- */

PUBLIC int currentMaxClients;

PUBLIC long MaxClients;
PUBLIC long OutputBufferSize;
PUBLIC long WellKnownConnections;

#ifdef _USE_MASKS_

#include "defs.h"

/* -- global flags (size OS dependent !) -- */

PUBLIC fd_set AllClients;
PUBLIC fd_set AllServers;
PUBLIC fd_set ReadyServers;
PUBLIC fd_set AllSockets;
PUBLIC fd_set ClientsWithInput;
PUBLIC fd_set ClientsWriteBlocked;

PUBLIC fd_set LastSelectMask;

PUBLIC fd_set OutputPending;

#endif

#ifdef _USE_STRUCTS_

#include "PSstruct.h"

/* -- array of "input" (i.e. request) buffers (one per client) -- */

PUBLIC ConnectionInput inputBuffers[MAXSOCKS];

PUBLIC ClientPtr *clients;
PUBLIC ClientPtr requestingClient;
PUBLIC ClientPtr muxClient;

/*
 * Global translation table: maps connection numbers (in fact file
 * descriptors) to corresponding  MUXClient or MUXServer data structures
 */

PUBLIC ClientPtr Connections[MAXSOCKS];

/*
 * Global array (one entry per server): used to compute event serial numbers
 * send to clients from event serial numbers received by real X servers.
 * There are two main reasons for this:
 * 
 * a) simply bypassing serials can cause clients (in fact Xlib) to complain
 * about "lost sequences".
 * 
 * b) we must rely on correct serials during internal updates concerning event
 * masks (that's one price we have to pay for X asynchronous behaviour; see
 * comments in events.c).
 */

PUBLIC unsigned long ServerAhead[MAXSOCKS];

#endif

#ifdef _USE_PROTO_

#include <X11/Xproto.h>

PUBLIC xConnSetupPrefix connSetupPrefix;

#endif

#endif				/* -- #ifndef _GLOB_H_ -- */
