v05i059: Xrooms -- A Rooms implementation for X, Part09/14

Kent Landfield kent at ssbell.IMD.Sterling.COM
Mon Jan 15 17:17:24 AEST 1990


Submitted-by: wsl.dec.com!mikey (Mike Yang)
Posting-number: Volume 5, Issue 59
Archive-name: xrooms/part09

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 9 (of 14)."
# Contents:  ./lib/app.h ./lib/profparser.y ./xrooms/xrProto.c
# Wrapped by kent at ssbell on Sun Jan 14 21:58:04 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f './lib/app.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./lib/app.h'\"
else
echo shar: Extracting \"'./lib/app.h'\" \(16436 characters\)
sed "s/^X//" >'./lib/app.h' <<'END_OF_FILE'
X#ifndef APP_H
X#define APP_H 1
X
X
X  /*\
X   *  $Header: app.h,v 5.0 90/01/10 06:52:57 erik Exp $
X   *
X   *		              COPYRIGHT 1990
X   *		        DIGITAL EQUIPMENT CORPORATION
X   *		           MAYNARD, MASSACHUSETTS
X   *			    ALL RIGHTS RESERVED.
X   *
X   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
X   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
X   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE 
X   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED 
X   * WARRANTY.
X   *
X   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
X   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
X   * ADDITION TO THAT SET FORTH ABOVE.
X   *
X   * Permission to use, copy, modify, and distribute this software and its
X   * documentation for any purpose and without fee is hereby granted, provided
X   * that the above copyright notice appear in all copies and that both that
X   * copyright notice and this permission notice appear in supporting
X   * documentation, and that the name of Digital Equipment Corporation not be
X   * used in advertising or publicity pertaining to distribution of the 
X   * software without specific, written prior permission.
X  \*/
X
X  /*\
X
X  \*/
X
X	/*\
X	 *  Methods for manipulating an App.  This package was written to
X	 *  support an implementation of rooms under X, but might be useful
X	 *  for other applications that want to keep track of the state of
X	 *  a bunch of windows.  In particular, this package knows nothing
X	 *  about X;  it uses a function pointer supplied by rooms to 
X	 *  request changes to application states.  
X	 *  For the rest of this description: "rooms" is assumed to mean 
X	 *  "whatever program contains this package,"   "application" refers 
X	 *  to any window being tracked or managed by rooms, and "App" refers
X	 *  to an instance of the class implemented by this package that 
X	 *  represents an application.   An "external" change is a change in
X	 *  the state of an application that is not in response to a request
X	 *  made by rooms,  an "internal" change is a change that occurs in
X	 *  response to a request by rooms.   Note the distinction between
X	 *  "application" and "App" -- an App may represent (serially) multiple
X	 *  applications.
X	 *
X	 *  An App represents the real state and a set of possible desired 
X	 *  states of a window.  An App keeps track of its current state 
X	 *  (a <real> state), its default state (a <profile> state), and an 
X	 *  optional set of named room states (each is a <profile> state and 
X	 *  a StringToken name).
X	 *  Each room state describes the state the App window should take 
X	 *  in the room with the associated name.   The App window should
X	 *  use the default state in any room that doesn't have an explicit
X	 *  state.    
X	 *
X	 *  The structures that represent the current, default, and each of 
X	 *  the room states are guaranteed not to change across the life
X	 *  of an App (*not* application) with one exception:  room states 
X	 *  that are explicitly destroyed should not be used again.   If a 
X	 *  room state with the same name is created later, it will *not* use 
X	 *  the same structure.   Rooms or any other code that uses this
X	 *  package should take considerable care to make sure that all 
X	 *  references to destroyed room states are removed.
X	 *
X	 *  Rooms provides an "Update" function for each App.   The 
X	 *  Update function is called when an application's current state 
X	 *  changes internally.   The Update function should (try to) update 
X	 *  the screen to match the internal change.
X	 *
X	 *  The App class provides several fields (and methods to get and 
X	 *  set them) for the convenience of other packages that use App's,
X	 *  but does not directly interpret their contents.  These private
X	 *  values are:
X	 *	name -- The name of the associated program or window.   The
X	 *		App class only stores and reports the name of the
X	 *		application.   It does not use the name.  It is not
X	 *		an error to allow multiple Apps with the same name.
X	 *	active -- An active App has a Current window state that is
X	 *		not "asInactive."   Active Apps should correspond
X	 *		to some window that is realized on the user's screen.
X	 *		Inactive Apps describe the desired states of an 
X	 *		application should it ever be invoked.
X	 *	permanence -- a comment about the expected lifetime of the 
X	 *		App.  The structures describing a permanent App
X	 *		should not be destroyed when the program (or window) 
X	 *		it represents exits or is destroyed.   If a another
X	 *		window or program with the same name is created later, 
X	 *		the *same* App should be used to represent it.  A 
X	 *		transient App should be destroyed when the program (or 
X	 *		window)	it represents exits or is destroyed.  The App
X	 *		Class does *not* automatically destroy inactive
X	 *		transient Apps.
X	 *	output priv -- a place for the packages using Apps to store
X	 *		any per-App information they need.  No implied 
X	 *		semantics.
X	 * 
X	 *  DEBUGGING FUNCTIONS --
X	 *  char *
X	 *  appText(pApp)
X	 *  AppPtr	pApp;
X	 *	Return the name of the application, suitable for debugging.
X	 *	appText is guaranteed to never return NullString.   The
X	 *	return string is stored in a static buffer that must *not*
X	 *	be freed, and may be clobbered by subsequent calls to appText.
X	 *
X	 *  appDebugPrint(pApp)
X	 *  AppPtr	pApp;
X	 *	Prints a bunch of useful debugging information about "pApp"
X	 *	using uDebug (which usually writes to stderr).
X	 *
X	 *  FUNCTIONS TO CREATE AND DESTROY APPS --
X	 *  AppPtr
X	 *  appCreate(name,pRealState,pDfltState)
X	 *  StringToken	name;
X	 *  AppStatePtr	pRealState;
X	 *  AppStatePtr	pDfltState;
X	 *	Creates an application with the specified name, current
X	 *	state and default state.   If pRealState or pDfltState
X	 *	are NullAppState, appCreate uses an appropriate default
X	 *	for each (normally [ inactive ] and [ iconic ]).  Returns
X	 *	a pointer to the newly created App, or False if name is
X	 *	NullStringToken, pRealState is not a legal <real> state,
X	 *	<pDfltState> is not a legal <profile> state, or there is
X	 *	an allocation failure.
X	 *
X	 *  appDestroy(pApp)
X	 *  AppPtr	pApp;
X	 *	Destroys "pApp" and frees all memory associated with it.
X	 *	It's not a good idea to try to use an App after it has been
X	 *	destroyed, so clean up those pointers.
X	 *
X	 *  FUNCTIONS TO CHANGE OR QUERY THE DEFAULT STATE OF AN APP --
X	 *  AppStatePtr
X	 *  appSetDefault(pApp,pNewDflt,isRealState)
X	 *  AppPtr	pApp;
X	 *  AppStatePtr	pNewDflt;
X	 *  Boolean	isRealState.
X	 *	Changes the default state of "pApp" to "pNewDflt."   Copies
X	 *	values from "pNewDflt" into the existing default state, so 
X	 *	previously stored references to the default state of the 
X	 *	App remain valid, and the calling function can free pNewDflt.
X	 *	If "isRealState" is True, "pNewDflt" is assumed to be a 
X	 *	<real> state, and only fields that are already defined in 
X	 *	the default state of the App and are not bolted will be
X	 *	updated.   If "isRealState" is False, "pNewDflt" is assumed
X	 *	to be a <profile> state, the current fields of the default
X	 *	state will be clobbered.   See the descriptions of
X	 *	asCopyRealToProfile and asCopyFully  in appstate.h for a more
X	 *	complete description.   appSetDefault returns a pointer to
X	 *	the default state of the App, or NullAppState if "pApp" is
X	 *	NullApp, or if "isRealState" lies (i.e. "isRealState" is True
X	 *	and "pNewDflt" is not a legal <real> state, or if "isRealState"
X	 *	is False, and "pNewDflt" is not a legal <profile> state.  If
X	 *	pNewDflt is NullAppState, a suitable default (usually [ iconic])
X	 *	will be substituted.
X	 *  
X	 *  AppStatePtr
X	 *  appGetDefault(pApp)
X	 *  AppPtr	pApp;
X	 *	Gets the default state of pApp.  All calls to "appGetDefault"
X	 *	for a specific App are guaranteed to return the same value
X	 *	across the lifetime of the App, so this return value can be
X	 *	cached safely.  Returns NullAppState if pApp is NullApp.
X	 *
X	 *  FUNCTIONS TO CHANGE OR QUERY THE CURRENT STATE OF AN APP --
X	 *  AppStatePtr
X	 *  appSetCurrent(pApp,pNewReal,isRealState)
X	 *  AppPtr	pApp;
X	 *  AppStatePtr	pNewDflt;
X	 *  Boolean	isRealState;
X	 *	Changes the current state of "pApp" to "pNewReal."  Also
X	 *	copies values from pNewReal into the existing current state,
X	 *	so prior references to the current state of the App remain
X	 *	valid.  "isRealState" indicates the type of "pNewReal," much
X	 *	like the "isRealState" argument to appSetDefault.  This time
X	 *	see the documentation for asCopyFully (real -> real) or
X	 *	asCopyProfileToReal (profile->real) in appstate.h for a more
X	 *	complete description of the semantics.   If "pNewReal" is
X	 *	a <real> state, appSetCurrent assumes the change reflects an 
X	 *	external change and does *not* call the update function.  If 
X	 *	"pNewReal" is a <profile> state, appSetCurrent assumes the
X	 *	change is internal and *does* call the update function.
X	 *	Returns a pointer to the current state of "pApp," or 
X	 *	NullAppState if pApp is NullApp, or if "pNewReal" is not
X	 *	legal according to "isRealState."
X	 *	
X	 *  AppStatePtr
X	 *  appGetCurrent(pApp)
X	 *  AppPtr	pApp;
X	 *	Gets the current state of pApp.  All calls to "appGetCurrent"
X	 *	for a specific App are guaranteed to return a pointer to the 
X	 *	same instance across the lifetime of the App, so this return 
X	 *	value can be cached safely.  Returns NullAppState if pApp 
X	 *	is NullApp.
X	 *
X	 *  FUNCTIONS TO MUCK WITH THE LOCAL STATES OF AN APP --
X	 *  unsigned
X	 *  appNLocalStates(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns the number of rooms with explicitly defined states
X	 *	for "pApp."   If pApp is NullApp, returns 0.
X	 *
X	 *  AppStatePtr
X	 *  appSetRoomState(pApp,roomName,pNew,isRealState)
X	 *  AppPtr	pApp;
X	 *  StringToken	roomName;
X	 *  AppStatePtr	pNew;
X	 *  Boolean	isRealState;
X	 *	Changes the state of "pApp" in the room named "roomName" to
X	 *	be "pNew."   If "pApp" already has a state local to "roomName,"
X	 *	pNew is copied into the existing room state.   If "pApp" does
X	 *	not have a state local to "roomName," appSetRoom creates a
X	 *	duplicate of the default state of "pApp" and copies "pNew"
X	 *	into it (so bolts in the default state of an application are
X	 *	effective).  As with appSetDefault and appSetCurrent, 
X	 *	"isRealState" indicates the type of "pNew."  Returns a pointer
X	 *	to the local state of "pApp" in "roomName," which is guaranteed
X	 *	to persist until it is explicitly removed or "pApp" is 
X	 *	destroyed.  Returns NullAppState if "pApp" is NullApp, 
X	 *	"roomName" is NullStringToken, or "pNew" is illegal.
X	 *
X	 *  Boolean
X	 *  appRemoveRoomState(pApp,roomName)
X	 *  AppPtr	pApp;
X	 *  StringToken	roomName;
X	 *	Removes the local state for pApp in the room named "roomName."
X	 *	The previous local state is freed, so outstanding references
X	 *	should be cleaned up.  Returns True if the local state is 
X	 *	removed, False if "pApp" is NullApp, "roomName" is 
X	 *	NullStringToken, or "pApp" does not have a local state for 
X	 *	"roomName."
X	 *
X	 *  AppStatePtr
X	 *  appGetRoomState(pApp,roomName)
X	 *  AppPtr	pApp;
X	 *  StringToken	roomName;
X	 *	Gets the local state of "pApp" in "roomName."  All calls 
X	 *	to "appGetRoomState" for a specific App and roomName are 
X	 *	guaranteed to return a pointer to the same instance until
X	 *	the local state is explicitly removed or the App is destroyed,
X	 *	so the returned value may be cached safely.
X	 *	Returns NullAppState if "pApp" is NullApp, "roomName" is
X	 *	NullStringToken, or "pApp" has no local state for "roomName."
X	 *
X	 *  Boolean
X	 *  appRemoveAllRoomStates(pApp)
X	 *  AppPtr	pApp;
X	 *	Removes the local states for all rooms in pApp.  Frees all 
X	 *	local states, so outstanding references should be cleaned
X	 *	up.  Returns True if successful, False if "pApp" is NullApp.
X	 *
X	 *  FUNCTIONS FOR DEALING WITH THE UPDATE FUNCTION OF AN APP --
X	 *  void
X	 *  appSetUpdateFunc(pApp,pFunc)
X	 *  AppPtr		pApp;
X	 *  AppUpdateFunc	pFunc;
X	 *	Change the update func of "pApp" to "pFunc."   The update
X	 *	function is called whenever an internal change to the
X	 *	current state of an App is requested (intuited, whatever).
X	 *	No return value.
X	 *
X	 *  AppUpdateFunc
X	 *  appGetUpdateFunc(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns a pointer to the update func of "pApp," or NULL
X	 *	if "pApp" is NullApp.
X	 *
X	 *  GET/SET THE VARIOUS PRIVATE FIELDS --
X	 *  StringToken
X	 *  appName(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns the name of "pApp," or NullStringToken if pApp is
X	 *	NullApp.
X	 *
X	 *  Boolean
X	 *  appIsActive(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns True if the window state of the current state of 
X	 *	"pApp" is anything but asInactive; returns False if the 
X	 *	window state is asInactive, or "pApp" is NullApp.
X	 *
X	 *  Boolean
X	 *  appIsPermanent(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns True if "pApp" is permanent, False if "pApp" is
X	 *	transient or NullApp.
X	 *
X	 *  Boolean
X	 *  appSetPermanence(pApp, permanent )
X	 *  AppPtr	pApp;
X	 *  Boolean	permanent;
X	 *	Sets permanence of "pApp" to "permanent."  Returns True for
X	 *	success, False if pApp is NullApp.
X	 *  
X	 *  void
X	 *  appSetOutputPriv(pApp,priv)
X	 *  AppPtr	pApp;
X	 *  Opaque	priv;
X	 *	Sets the output private field of "pApp" to "priv."  No
X	 *	return value.
X	 *
X	 *  Opaque
X	 *  appGetOutputPriv(pApp)
X	 *  AppPtr	pApp;
X	 *	Returns the output private field of "pApp," or NULL if
X	 *	pApp is NullApp.
X	 *
X	 *  OTHER USEFUL FUNCTIONS --
X	 *  void
X	 *  appIterate(pApp,pFunc,arg)
X	 *  AppPtr	pApp;
X	 *  AppIterFunc	pFunc;
X	 *  Opaque	arg;
X	 *	Iterates across all local states of "pApp," calling "*pFunc"
X	 *	on each in turn with "(pApp,roomName,pLocalState,arg)."
X	 *	Stops iterating if pFunc returns False.  No return value.
X	 *
X	 *  appIterator(pApp,roomName,pState,istate)	<Statement>
X	 *	CLU-like (I'll do time in purgatory for that) iterator.
X	 *	Executes <Statement> (which can be a block statement) for
X	 *	each local state of "pApp," setting roomName and pState
X	 *	to the appropriate value for each state in turn.  This iterator
X	 *	keeps its state in a structure pointed to by "istate" --
X	 *	don't muck with it, and don't store anything you care about
X	 *	in it before you use the iterator.  Also, be absolutely
X	 *	certain you call appEndIterator(pApp,istate) after the loop.
X	 *	You can nest iterators.   This is smoke and mirrors, but
X	 *	useful, so be careful.  For example:
X	 *	    appIterator(pApp,rName,pState,ignoreMe) {
X	 *		uInformation("app %s has state %s in room %s\n",
X	 *				appText(pApp),asText(pState),
X	 *				stText(rName));
X	 *	    }
X	 *	    appEndIterator(pApp,ignoreMe);
X	 *	displays all of the local states in pApp.
X	 *	
X	\*/
X
X#include "appstate.h"
X#include "strtbl.h"
X
Xtypedef struct _AppRec 		*AppPtr;
X
Xtypedef	Boolean	(*AppUpdateFunc)(/* pApp, pNewState, pPriv */);
Xtypedef	Boolean	(*AppIterFunc)(/* pApp, roomName, pState, arg */);
X
X#define	NullApp			((AppPtr)NULL)
X
Xextern	unsigned int	appDebug;
X
Xextern	char		*appText();
Xextern	void		 appDebugPrint(/* pApp */);
X
Xextern	AppPtr	 	 appCreate(/*name,pRealState,pDfltState*/);
Xextern	void	 	 appDestroy(/*pApp*/);
X
Xextern	AppStatePtr	 appSetDefault(/* pApp, pNewDflt, isRealState */);
Xextern	AppStatePtr	 appGetDefault(/* pApp */);
X
Xextern	AppStatePtr	 appSetCurrent(/* pApp, pNewReal, isRealState */);
Xextern	AppStatePtr	 appGetCurrent(/* pApp */);
X
Xextern	int		 appNLocalStates(/* pApp */);
Xextern	AppStatePtr	 appSetRoomState(/* pApp, roomName, pNew, isReal */);
Xextern	Boolean		 appRemoveRoomState(/* pApp, roomName */);
Xextern	AppStatePtr	 appGetRoomState(/* pApp, roomName */);
Xextern	Boolean	 	 appRemoveAllRoomStates(/* pApp */);
X
Xextern	void	 	 appSetUpdateFunc(/* pApp, updateFunc */);
Xextern	AppUpdateFunc 	 appGetUpdateFunc(/* pApp */);
X
Xextern	StringToken	 appName(/* pApp */);
Xextern	Boolean		 appIsActive(/* pApp */);
Xextern	Boolean		 appIsPermanent(/* pApp */);
Xextern	Boolean		 appSetPermanence(/* pApp, permanent */);
Xextern	void	 	 appSetOutputPriv(/* pApp, pPriv */);
Xextern	Opaque	 	 appGetOutputPriv(/* pApp */);
X
Xextern	void		 appIterate(/* pApp, pFunc, arg */);
X
Xextern	Boolean		 _appInitIter(/* pApp, ppIState */);
Xextern	Boolean		 _appIterNext(/* pApp, pIState, pRoomName, ppState */);
Xextern	void		 appEndIterator(/* pApp, pIState */);
X
X#define	appIterator(pa,k,d,pi) \
X	if (_appInitIter(pa,&pi)) \
X	    while (_appIterNext(pa,&pi,&k,&d))
X
X#endif /* APP_H */
END_OF_FILE
if test 16436 -ne `wc -c <'./lib/app.h'`; then
    echo shar: \"'./lib/app.h'\" unpacked with wrong size!
fi
# end of './lib/app.h'
fi
if test -f './lib/profparser.y' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./lib/profparser.y'\"
else
echo shar: Extracting \"'./lib/profparser.y'\" \(15032 characters\)
sed "s/^X//" >'./lib/profparser.y' <<'END_OF_FILE'
X%{
X  /*\
X   *  $Header: profparser.y,v 5.0 90/01/10 06:54:03 erik Exp $
X   *
X   *		              COPYRIGHT 1990
X   *		        DIGITAL EQUIPMENT CORPORATION
X   *		           MAYNARD, MASSACHUSETTS
X   *			    ALL RIGHTS RESERVED.
X   *
X   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
X   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
X   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE 
X   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED 
X   * WARRANTY.
X   *
X   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
X   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
X   * ADDITION TO THAT SET FORTH ABOVE.
X   *
X   * Permission to use, copy, modify, and distribute this software and its
X   * documentation for any purpose and without fee is hereby granted, provided
X   * that the above copyright notice appear in all copies and that both that
X   * copyright notice and this permission notice appear in supporting
X   * documentation, and that the name of Digital Equipment Corporation not be
X   * used in advertising or publicity pertaining to distribution of the 
X   * software without specific, written prior permission.
X  \*/
X%}
X%token	APPLICATION	 1
X	ROOM		 2
X	NAMES		 3
X
X	LBRACE		 10
X	RBRACE		 11
X	LBRACKET	 12
X	RBRACKET	 13
X	LPAREN		 14
X	RPAREN		 15
X
X	BOLT		20
X	QUESTION	21
X	EQUALS		22
X	GETS		23
X	PLUS		24
X	SEMI		25
X	COLON		26
X
X	DEFAULT		30
X	ICONIC		31
X	NORMAL		32
X
X	IF		200
X	ELSE		201
X	SWITCH		202
X	CASE		203
X	USE		204
X	CLASS		205
X	IGNORE		206
X
X	VISIBLE		40
X	HIDDEN		41
X	ALWAYS		42
X	WHEN_ACTIVE	43
X	WHEN_NONEMPTY	44
X
X	TRANSIENT	50
X	PERMANENT	51
X
X	PROPERTY	100
X	STRING		101
X	IDENT		102
X	GEOMETRY	103
X	COMMENT		104
X	END_OF_FILE	 0
X%{
X#define	DEBUG_VAR	parserDebug
X#include "utils.h"
X#include "profparser.h"
X#include "nameprof.h"
X%}
X%start	ProfileFile
X%union	{
X	AppStatePtr	 pState;
X	ParserStatePtr	 pNamedState;
X	NPBoolExprPtr	 pBoolExpr;
X	NPStringExprPtr	 pStringExpr;
X	NPCasePtr	 pCase;
X	NPStatementPtr	 pStatement;
X	StringToken	 token;
X	Boolean		 bool;
X	unsigned	 uVal;
X}
X%type <pState>		OptStateSpec StateSpec
X%type <pNamedState>	OptProfileBody ListOfStates State OptWinState OptGeom
X%type <pBoolExpr>	BooleanExpr
X%type <pStringExpr>	StringExpr StringTerminal AssignLHS
X%type <pCase>		ListOfCases Case 
X%type <pStatement>	ListOfNameSpec NameSpec IfStatement SwitchStatement 
X			ClassStatement UseStatement IgnoreStatement 
X			AssignStatement BlockStatement OptDefaultCase
X%type <token>		String OptString
X%type <bool>		Profile NameProfile RoomProfile AppProfile 
X			OptBolt Profiles Permanence
X%type <uVal>		OptBolts OptVisibilities Visibilities 
X%%
XProfileFile		:	Profiles END_OF_FILE	{ return(True); 
X							  /* NOTREACHED */}
X			|	END_OF_FILE
X			;
X
XProfiles		:	Profiles Profile	{ $$= True; }
X			|	Profile			{ $$= True; }
X			;
X
XProfile			:	RoomProfile 
X				{ $$= $1; }
X			|	AppProfile  
X				{ $$= $1; }
X			|	NameProfile 
X				{ $$= $1; }
X			|	COMMENT
X				{ $$= profileAddComment(parserUseString()); } 
X			;
X
XRoomProfile		:	ROOM String OptVisibilities
X				    OptProfileBody
X				{ $$= parserRoomProfile($2,$3,$4); }
X			;
X
XAppProfile		:	Permanence APPLICATION String OptStateSpec 
X				    OptProfileBody
X				{ $$= parserAppProfile($3,$4,$5,$1); }
X			;
X
XPermanence		:	TRANSIENT		{ $$= True; }
X			|	PERMANENT		{ $$= False; }
X			|				{ $$= False; }
X			;
X
XOptVisibilities		:	VISIBLE	Visibilities	{ $$= $2; }
X			|	Visibilities		{ $$= $1; }
X			|	VISIBLE			{ $$=  roomVisible; }
X			|	HIDDEN			{ $$=  0; }
X			|	{ $$= roomDefaultVisibility; }
X			;
X
XVisibilities		:	ALWAYS		{ $$= roomAlways; }
X			|	DEFAULT		{ $$= roomDefaultVisibility; }
X			|	WHEN_ACTIVE
X				{ $$= roomWhenActive; }
X			|	WHEN_NONEMPTY
X				{ $$= roomWhenNonEmpty; }
X			|	WHEN_ACTIVE WHEN_NONEMPTY
X				{ $$= roomWhenActive|roomWhenNonEmpty; }
X			|	WHEN_NONEMPTY WHEN_ACTIVE
X				{ $$= roomWhenActive|roomWhenNonEmpty; }
X			;
X
XOptProfileBody		:	LBRACE
X				    ListOfStates
X				RBRACE
X				{ $$= $2; }
X			|	{ $$= NullParserState; }
X			;
X
XOptStateSpec		:	StateSpec	{ $$= $1; }
X			|			{ $$= NullAppState; }
X			;
X
XListOfStates		:	ListOfStates	State
X				{ $$= parserAppendState($1,$2); }
X			|	State
X				{ $$= $1; }
X			;
X
XState			:	String	StateSpec
X				{ $$= parserCreateNamedState($1,$2); }
X			;
X
XStateSpec		:	LBRACKET OptWinState OptGeom RBRACKET
X				{ $$= parserCreateState( $2, $3 ); }
X			;
X
XNameProfile		:	NAMES OptString BlockStatement
X				{ 
X				    StringToken	name=	($2?$2:nprDefaultName);
X				    if (name!=NullStringToken) {
X					nprAddFunction(name,$3,False);
X					profileForNames(name);
X					$$=True;
X				    }
X				    else $$= False;
X				}
X			;
X
XListOfNameSpec		:	ListOfNameSpec	NameSpec
X				{
X				    npAppendStatement($1,$2);
X				    $$= $1;
X				}
X			|	NameSpec
X				{ $$= $1; }
X			;
X
XNameSpec		:	IfStatement      	 { $$= $1; }
X			|	SwitchStatement	 	 { $$= $1; }
X			|	ClassStatement	 	 { $$= $1; }
X			|	UseStatement	 	 { $$= $1; }
X			|	IgnoreStatement	 	 { $$= $1; }
X			|	AssignStatement		 { $$= $1; }
X			|	BlockStatement	 	 { $$= $1; }
X			|	COMMENT	
X				{ $$= npComment(parserUseString()); }
X			;
X
XIfStatement		:	IF LPAREN BooleanExpr RPAREN NameSpec 
X							ELSE NameSpec
X				{ $$= npIfStatement( $3, $5, $7 ); }
X			|	IF LPAREN BooleanExpr RPAREN NameSpec
X				{ $$= npIfStatement( $3, $5, NullNPStatement);}
X			;
X
XSwitchStatement		:	SWITCH LPAREN StringExpr RPAREN LBRACE
X				     ListOfCases
X				     OptDefaultCase
X				RBRACE
X				{ $$= npSwitchStatement($3, $6, $7); }
X			;
X
X
XListOfCases		:	ListOfCases Case
X				{ 
X				    npAppendCase($1,$2);
X				    $$= $1;
X				}
X			|	Case
X				{ $$= $1; }
X			;
X
XCase			:	CASE StringExpr COLON NameSpec
X				{ $$= npCase( $2, $4 ); }
X			;
X
XOptDefaultCase		:	DEFAULT COLON NameSpec
X				{ $$= $3; }
X			|	{ $$= NullNPStatement; }
X			;
X
XClassStatement		:	CLASS StringExpr
X				{ $$= npClassStatement($2); }
X			;
X
XUseStatement		:	USE StringExpr
X				{ $$= npUseStatement($2); }
X			;
X
XIgnoreStatement		:	IGNORE
X				{ $$= npIgnoreStatement(); }
X			;
X
XAssignStatement		:	AssignLHS GETS StringExpr
X				{ $$= npAssignStatement($1,$3,False); }
X			|	AssignLHS PLUS GETS StringExpr
X				{ $$= npAssignStatement($1,$4,True); }
X			;
X
XAssignLHS		:	PROPERTY
X				{ $$= npStringTerminal(NPPropertyName,
X						   parserUseString()); }
X			|	IDENT
X				{ $$= npStringTerminal(NPIdentifier,
X						   parserUseString()); }
X			;
X
XBlockStatement		:	LBRACE ListOfNameSpec RBRACE
X				{ $$= $2; }
X			;
X
XString			:	STRING
X				{ $$= stGetToken(parserUseString()); }
X			;
X
XOptString		:	String		{ $$= $1; }
X			|			{ $$= NullStringToken; }
X			;
X
XOptWinState		:	ICONIC OptBolt
X				{$$= parserCreateWinState(asIconic,$2);}
X			|	NORMAL OptBolt
X				{$$= parserCreateWinState(asNormal,$2);}
X			|
X			        {$$= NullParserState; }
X			;
X
XOptGeom			:	GEOMETRY OptBolts
X				{$$= parserCreateGeom(parserUseGeom(),$2);}
X			|
X				{$$= parserCreateGeom(NullAppState,asNoValue); }
X			;
X
XOptBolts		:	IDENT BOLT
X				{ $$= parseBolts(parserUseString()); }
X			|	{ $$= asNoValue; }
X			;
X
XOptBolt			:	BOLT	{ $$= True;  }
X			|		{ $$= False; }
X			;
X
XBooleanExpr		:	BOLT StringExpr
X				{ $$= npUnaryExpr(True,$2); }
X			|	StringExpr
X				{ $$= npUnaryExpr(False,$1); }
X			|	StringExpr EQUALS StringExpr
X				{ $$= npEquals($1,$3); }
X			;
X
XStringExpr		:	StringExpr PLUS StringTerminal 
X				{ $$= npStringConcat($1,$3); }
X			|	LPAREN BooleanExpr QUESTION StringExpr 
X						COLON 	 StringExpr RPAREN
X				{ $$= npStringConditional($2,$4,$6); }
X			|	LPAREN BooleanExpr QUESTION StringExpr RPAREN
X				{ $$= npStringConditional($2,$4,
X							NullNPStringExpr); }
X			|	StringTerminal
X				{ $$= $1; }
X			;
X
XStringTerminal		:	STRING
X				{ $$= npStringTerminal(NPStringConstant,
X						   parserUseString()); }
X			|	PROPERTY
X				{ $$= npStringTerminal(NPPropertyName,
X						   parserUseString()); }
X			|	IDENT
X				{ $$= npStringTerminal(NPIdentifier,
X						   parserUseString()); }
X			;
X
X%%
XScannablePtr	pYYLexScan;
X
Xvoid
Xyyerror(s)
Xchar	*s;
X{
X    (void)uError("%s\n",s);
X    uInformation("line %d\n",scanLineNum(pYYLexScan));
X    return;
X}
XBoolean
Xyywrap()
X{
X   return(True);
X}
Xint
Xyylex()
X{
Xint	token;
X
X   if (pYYLexScan==NullScannable)	token=	TOK_END;
X   else					token=	scanToken(pYYLexScan);
X   return(token);
X}
X
Xchar *
XparserUseString()
X{
Xchar	*str= NullString;
X
X    uENTRY("parserUseString()\n");
X    if (pYYLexScan!=NullScannable) {
X	str= scanUseString(pYYLexScan);
X    }
X    uRETURN(str);
X}
X
XAppStatePtr
XparserUseGeom()
X{
XAppStatePtr	 pGeomState= NullAppState;
X
X    uENTRY("parserUseGeom()\n");
X    if (pYYLexScan!=NullScannable) {
X	pGeomState= scanUseState(pYYLexScan);
X    }
X    uRETURN(pGeomState);
X}
X
X/***====================================================================***/
X
Xstatic void
X_applyStateToRoom(pPState,pRoom)
XParserStatePtr	pPState;
XRoomPtr		pRoom;
X{
XAppPtr		pApp;
X
X    uENTRY2("_applyStateToRoom(0x%x,%s)\n",pPState,roomText(pRoom));
X    if (pPState->u.state.name!=NullStringToken) {
X	pApp=	GetApp(pPState->u.state.name,False);
X	if (pApp!=NullApp) {
X	    (void)appSetRoomState(pApp,roomName(pRoom),
X					 pPState->u.state.pState,False);
X	    if (appIsActive(pApp)) {
X		(void)roomCheckAppStates(pRoom,pApp);
X	    }
X	}
X    }
X    else {
X	uWarning("Default state for room %s ignored\n",roomText(pRoom));
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
XBoolean
XparserRoomProfile(name, vis, pStates)
XStringToken	name;
Xunsigned	vis;
XParserStatePtr	pStates;
X{
XParserStatePtr	pNext;
XRoomPtr		pRoom= NullRoom;
X
X    uENTRY3("parserRoomProfile(%s,0x%x,0x%x)\n",stText(name),vis,pStates);
X    if (name!=NullStringToken) {
X	pRoom=	LookupRoom(name);
X	if (pRoom==NullRoom) {
X	    pRoom=	CreateRoom(name);
X	}
X	roomSetVisibility(pRoom,vis,True);
X	while (pStates!=NullParserState) {
X	    pNext=	pStates->pNext;
X	    if (pRoom!=NullRoom) 
X		_applyStateToRoom(pStates,pRoom);
X	    asDestroy(pStates->u.state.pState);
X	    pStates->u.state.pState=	NullAppState;
X	    pStates->pNext=		NullParserState;
X	    (void)uFree((Opaque)pStates);
X	    pStates=	pNext;
X	}
X    }
X    if (pRoom==NullRoom) {
X	uRETURN(False);
X    }
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xstatic void
X_applyStateToApp(pPState,pApp)
XParserStatePtr	pPState;
XAppPtr		pApp;
X{
X    uENTRY2("_applyStateToApp(0x%x,%s)\n",pPState,appText(pApp));
X    if (pPState->u.state.name!=NullStringToken) {
X	(void)appSetRoomState(pApp,pPState->u.state.name,	
X					pPState->u.state.pState,False);
X    }
X    else {
X	(void)appSetDefault(pApp,pPState->u.state.pState,False);
X    }
X    uVOIDRETURN;
X}
X
XBoolean
XparserAppProfile(name, pDfltState, pStates, transient)
XStringToken	name;
XAppStatePtr	pDfltState;
XParserStatePtr	pStates;
XBoolean		transient;
X{
XParserStatePtr	pNext;
XRoomPtr		pRoom;
XAppPtr		pApp;
XOpaque		rstate;
X
X    uENTRY4("parserAppProfile(%s,%s,0x%x,%s)\n",stText(name),asText(pDfltState),
X						pStates,booleanText(transient));
X    
X    if (name!=NullStringToken) {
X	pApp=	GetApp(name,False);
X	appRemoveAllRoomStates(pApp);
X	while (pStates!=NullParserState) {
X	    pNext=	pStates->pNext;
X	    if (pApp!=NullApp) 
X		_applyStateToApp(pStates,pApp);
X	    asDestroy(pStates->u.state.pState);
X	    pStates->u.state.pState=	NullAppState;
X	    pStates->pNext=		NullParserState;
X	    (void)uFree((Opaque)pStates);
X	    pStates=	pNext;
X	}
X	if (pDfltState) {
X	    if (pApp!=NullApp) {
X		(void)appSetDefault(pApp,pDfltState,False);
X	    }
X	    asDestroy(pDfltState);
X	}
X    }
X
X    if (appIsActive(pApp)) {
X	RoomsIterator(pRoom,rstate) {
X	    roomCheckAppStates(pRoom,pApp);
X	}
X	RoomsEndIterator(rstate);
X    }
X
X    if (pApp!=NullApp) {
X	SetAppPermanence(pApp,!transient);
X	uRETURN(True);
X    }
X    uRETURN(False);
X}
X
X/***====================================================================***/
X
XAppStatePtr
XparserCreateState(pPWinState, pPGeom)
XParserStatePtr	pPWinState;
XParserStatePtr	pPGeom;
X{
XAppStatePtr	pState;
X
X    uENTRY2("parserCreateState(0x%x,0x%x)\n",pPWinState,pPGeom);
X    if (pPGeom!=NullParserState) {
X	pState=	pPGeom->u.pGeomState;
X	uFree((Opaque)pPGeom);
X
X	if (pPWinState!=NullParserState) {
X	    asChangeSelected(pState,asWinStateValue,pPWinState->u.ws.winState,
X						0,0,(unsigned)0,(unsigned)0);
X	    if (pPWinState->u.ws.bolted)
X		asBolt(pState,asWinStateValue);
X	    uFree((Opaque)pPWinState);
X	}
X    }
X    uRETURN(pState);
X}
X
X/***====================================================================***/
X
XParserStatePtr
XparserAppendState(pState1, pState2)
XParserStatePtr	pState1,pState2;
X{
XParserStatePtr	pEnd;
X
X    uENTRY2("parserAppendState(0x%x,0x%x)\n",pState1,pState2);
X    if (pState1==NullParserState) {
X	uRETURN(pState2);
X    }
X    if (pState2!=NullParserState) {
X	pEnd=	pState1;
X	while (pEnd->pNext!=NullParserState) {
X	    pEnd= pEnd->pNext;
X	}
X	pEnd->pNext=	pState2;
X    }
X    uRETURN(pState1);
X}
X
X/***====================================================================***/
X
XParserStatePtr
XparserCreateNamedState(name, pState)
XStringToken	name;
XAppStatePtr	pState;
X{
XParserStatePtr	pPState=	NullParserState;
X
X    uENTRY2("parserCreateNamedState(%s,%s)\n",stText(name),asText(pState));
X    pPState=	uTypedAlloc(ParserStateRec);
X    if (pPState!=NullParserState) {
X	bzero(pPState,sizeof(ParserStateRec));
X	pPState->u.state.name=		name;
X	pPState->u.state.pState=	pState;
X    }
X    uRETURN(pPState);
X}
X
X/***====================================================================***/
X
XParserStatePtr
XparserCreateWinState(winState, bolted)
XWinState	winState;
XBoolean		bolted;
X{
XParserStatePtr	pPState=	NullParserState;
X
X    uENTRY2("parserCreateWinState(%s,%s)\n",asWinStateText(winState),
X						booleanText(bolted));
X    pPState=	uTypedAlloc(ParserStateRec);
X    if (pPState!=NullParserState) {
X	bzero(pPState,sizeof(ParserStateRec));
X	pPState->u.ws.winState=	winState;
X	pPState->u.ws.bolted=	bolted;
X    }
X    uRETURN(pPState);
X}
X
X/***====================================================================***/
X
XParserStatePtr
XparserCreateGeom(pState, bolts)
XAppStatePtr	pState;
Xunsigned	bolts;
X{
XParserStatePtr	pPState=	NullParserState;
X
X    uENTRY2("parserCreateGeom(%s,0x%x)\n",asText(pState),bolts);
X    pPState=	uTypedAlloc(ParserStateRec);
X    if (pPState!=NullParserState) {
X	bzero(pPState,sizeof(ParserStateRec));
X	if (pState==NullAppState) {
X	    pState=	asDupFully(asDefaultProfile);
X	}
X	pPState->u.pGeomState=	pState;
X	if (bolts!=asNoValue)
X	    asBolt(pState,bolts&asAllValues&asFlags(pState));
X    }
X    uRETURN(pPState);
X}
X
X/***====================================================================***/
X
Xunsigned
XparseBolts(str)
Xchar	*str;
X{
Xunsigned	bolts=	asNoValue;
X
X    uENTRY1("parseBolts(%s)\n",uStringText(str));
X    if (str!=NullString) {
X	while (*str!=NUL) {
X	    if		(*str=='x')	bolts|=	asXValue;
X	    else if 	(*str=='y')	bolts|= asYValue;
X	    else if	(*str=='w')	bolts|= asWidthValue;
X	    else if	(*str=='h')	bolts|= asHeightValue;
X	    else if	(*str=='s')	bolts|= asWinStateValue;
X	    else {
X		uWarning("unknown character '%c' in bolt specification\n",*str);
X		uAction("ignored.\n");
X	    }
X	    str++;
X	}
X    }
X    uRETURN(bolts);
X}
END_OF_FILE
if test 15032 -ne `wc -c <'./lib/profparser.y'`; then
    echo shar: \"'./lib/profparser.y'\" unpacked with wrong size!
fi
# end of './lib/profparser.y'
fi
if test -f './xrooms/xrProto.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./xrooms/xrProto.c'\"
else
echo shar: Extracting \"'./xrooms/xrProto.c'\" \(16098 characters\)
sed "s/^X//" >'./xrooms/xrProto.c' <<'END_OF_FILE'
X  
X  /*\
X   *  $Header: xrProto.c,v 5.1 90/01/10 17:05:15 erik Exp $
X   *
X   *		              COPYRIGHT 1990
X   *		        DIGITAL EQUIPMENT CORPORATION
X   *		           MAYNARD, MASSACHUSETTS
X   *			    ALL RIGHTS RESERVED.
X   *
X   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
X   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
X   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE 
X   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED 
X   * WARRANTY.
X   *
X   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
X   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
X   * ADDITION TO THAT SET FORTH ABOVE.
X   *
X   * Permission to use, copy, modify, and distribute this software and its
X   * documentation for any purpose and without fee is hereby granted, provided
X   * that the above copyright notice appear in all copies and that both that
X   * copyright notice and this permission notice appear in supporting
X   * documentation, and that the name of Digital Equipment Corporation not be
X   * used in advertising or publicity pertaining to distribution of the 
X   * software without specific, written prior permission.
X  \*/
X
X#include <stdio.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xproto.h>
X#include <X11/Xatom.h>
X#define	OPAQUE_DEFINED
X#define	BOOLEAN_DEFINED
X#define	DEBUG_VAR	xrprDebug
X#include "utils.h"
X#include "appstate.h"
X#include "rooms.h"
X#include "apps.h"
X
X#include "xrooms.h"
X#include "xrProto.h"
X#include "xrRoom.h"
X
X/***====================================================================***/
X
Xunsigned	xrpDfltBoltState;
X
X/***====================================================================***/
X
Xvoid
XxrpSetCurrent(dpy, root, nameAtom)
XDisplay	*dpy;
XWindow	 root;
XAtom	 nameAtom;
X{
X    uENTRY3("xrpSetCurrent(0x%x,0x%x,0x%x)\n",dpy,root,nameAtom);
X    (void)XChangeProperty(dpy,root,ROOMS_CURRENT,XA_ATOM, 32, 
X					PropModeReplace,(char *)&nameAtom,1);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstruct _xrappIterArgRec {
X	int	 nNames;
X	Atom	*pNames;
X};
X
Xstatic Boolean
X_xrpAddRoom(pRoom,pArg)
XRoomPtr			 pRoom;
Xstruct _xrappIterArgRec *pArg;
X{
XXRoomInfoPtr		 pRoomInfo;
X
X    uENTRY2("_xrpAddRoom(%s,0x%x)\n",roomText(pRoom),pArg);
X    if (pRoom!=NullRoom) {
X	pRoomInfo=	(XRoomInfoPtr)roomGetPrivate(pRoom);
X	if ((pRoomInfo!=NullXRoomInfo)&&(roomGetVisibility(pRoom)&roomVisible)){
X	    pArg->pNames[pArg->nNames]=	pRoomInfo->nameAtom;
X	    pArg->nNames++;
X	}
X    }
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xvoid
XxrpUpdateAllRooms(dpy, root)
XDisplay	*dpy;
XWindow	 root;
X{
Xint			 nRooms;
XAtom			*pNames;
Xstruct _xrappIterArgRec	 iarg;
X
X    uENTRY2("xrpUpdateAllRooms(0x%x,0x%x)\n",dpy,root);
X    nRooms=	NumberOfRooms();
X    if (nRooms<=0) {
X	XDeleteProperty(dpy,root,ROOMS_ALL);
X	uVOIDRETURN;
X    }
X    pNames=	uTypedCalloc(nRooms,Atom);
X    if (pNames==(Atom *)NULL) {
X	uVOIDRETURN;
X    }
X    iarg.nNames= 0;
X    iarg.pNames= pNames;
X    RoomsIterate(_xrpAddRoom,(Opaque)&iarg);
X    if (iarg.nNames>0) {
X	XChangeProperty(dpy,root,ROOMS_ALL,XA_ATOM,32,PropModeReplace,
X				(unsigned char *)pNames,iarg.nNames);
X				     
X    }
X    uFree((Opaque)pNames);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxrprReturnString(dpy,win,len,str)
XDisplay	*dpy;
XWindow	 win;
Xint	 len;
Xchar	*str;
X{
X    uENTRY4("xrprReturnString(0x%x,0x%x,%d,0x%x)\n",dpy,win,len,str);
X    if (win!=None) {
X	XChangeProperty(dpy,win,ROOMS_RETURN,XA_STRING,8,PropModeReplace,
X						(unsigned char *)str,len);
X	XFlush(dpy);
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxrprReturnStatus(dpy,win,success)
XDisplay	*dpy;
XWindow	 win;
XBoolean	 success;
X{
Xchar	buf[4];
X
X    uENTRY3("xrprReturnStatus(0x%x,0x%x,%s)\n",dpy,win,booleanText(success));
X    if (win!=None) {
X	buf[0]=	buf[1]= buf[2]= buf[3]= NUL;
X	if (success)	buf[0]=	't';
X	else		buf[0]=	'f';
X	XChangeProperty(dpy,win,ROOMS_RETURN,XA_STRING,8,PropModeReplace,
X								buf,1);
X	XFlush(dpy);
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic int
X_xrprParseVisibility(str,pVis)
Xchar	 *str;
Xunsigned *pVis;
X{
Xunsigned	vis=	0;
XBoolean		ok= True;
X
X    uENTRY2("_xrprParseVisibility(%s,0x%x)\n",uStringText(str),pVis);
X    if (strlen(str)>=4) {
X	if		(str[0]=='A')	vis|=	roomAlways;
X	else if 	(str[0]=='a')	vis&=	(~roomAlways);
X	else				ok=	False;
X
X	if		(str[1]=='N')	vis|=	roomWhenNonEmpty;
X	else if 	(str[1]=='n')	vis&=	(~roomWhenNonEmpty);
X	else				ok=	False;
X
X	if		(str[2]=='A')	vis|=	roomWhenActive;
X	else if 	(str[2]=='a')	vis&=	(~roomWhenActive);
X	else			ok=	False;
X
X	if		(str[3]=='B')	vis|=	roomVisible;
X	else if 	(str[3]=='H')	vis&=	(~roomVisible);
X	else			ok=	False;
X	if (ok&&(pVis!=(unsigned *)NULL)) {
X	    *pVis=	vis;
X	    uRETURN(4);
X	}
X    }
X    uRETURN(0);
X}
X
X/***====================================================================***/
X
Xstatic int
X_xrprParseWhichPart(str,pWhich)
Xchar	 *str;
Xunsigned *pWhich;
X{
Xunsigned	parts=	0;
XBoolean		query=	False;
X
X    uENTRY2("_xrprParseWhichPart(%s,0x%x)\n",uStringText(str),pWhich);
X    if (strlen(str)<5) {
X	uRETURN(0);
X    }
X    switch (str[0]) {
X	case '+':	parts|=	asWinStateValue;	break;
X	case '!':	parts&=	(~asWinStateValue);	break;
X	default:	uRETURN(0);
X    }
X    switch (str[1]) {
X	case '?':	query=	True;				break;
X	case '+':	parts|=	asXValue;			break;
X	case '-':	parts|= asXValue|asXNegative;		break;
X	case '!':	parts&=	(~(asXValue|asXNegative));	break;
X	default:	uRETURN(0);
X    }
X    switch (str[2]) {
X	case '?':	query=	True;				break;
X	case '+':	parts|=	asYValue;			break;
X	case '-':	parts|= asYValue|asYNegative;		break;
X	case '!':	parts&=	(~(asYValue|asYNegative));	break;
X	default:	uRETURN(0);
X    }
X    switch (str[3]) {
X	case '?':	query=	True;			break;
X	case '+':	parts|=	asWidthValue;		break;
X	case '!':	parts&=	(~asWidthValue);	break;
X	default:	uRETURN(0);
X    }
X    switch (str[4]) {
X	case '?':	query=	True;			break;
X	case '+':	parts|=	asHeightValue;		break;
X	case '!':	parts&=	(~asHeightValue);	break;
X	default:	uRETURN(0);
X    }
X    if (query)	*pWhich=	XR_QUERY_PARTS;
X    else	*pWhich=	parts;
X    uRETURN(5);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseWhichState(ch,pWhich)
Xchar	  ch;
Xunsigned *pWhich;
X{
X
X    uENTRY2("_xrprParseWhichState(%c,0x%x)\n",ch,pWhich);
X    switch (ch) {
X	case 'A':	*pWhich=	XR_ALL_STATES;		break;
X	case 'D':	*pWhich=	XR_DFLT_STATE;		break;
X	case 'L':	*pWhich=	XR_LOCAL_STATE;		break;
X	case 'V':	*pWhich=	XR_VISIBLE_STATE;	break;
X	case '?':	*pWhich=	XR_QUERY_STATE;		break;
X	default:	uRETURN(False);
X    }
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseWhichApp(str,pLen,pWhich,ppName)
Xchar	 *str;
Xint	 *pLen;
Xunsigned *pWhich;
Xchar	**ppName;
X{
Xint	len=	1;
X
X    uENTRY4("_xrprParseWhichApp(%s,0x%x,0x%x,0x%x)\n",str,pLen,pWhich,ppName);
X    *pWhich=	XR_QUERY_APP;
X    *ppName=	NullString;
X    switch (str[0]) {
X	case 'A':	*pWhich=	XR_ALL_APPS;	break;
X	case 'V':	*pWhich=	XR_ACTIVE_APPS;	break;
X	case 'L':	*pWhich=	XR_LAST_APP;	break;
X	case '?':	*pWhich=	XR_QUERY_APP;	break;
X	case 'N':	
X	case 'W':	
X			if (str[1]==NUL) {
X			    *pWhich=	XR_QUERY_APP;
X			    len= 2;
X			}
X			else {
X			    if (str[0]=='N')		*pWhich= XR_NAMED_APP;
X			    else if (str[0]=='W')	*pWhich= XR_WINDOW_APP;
X			    *ppName=	&str[1];
X			    len=	1+strlen(*ppName)+1;
X			}
X			break;
X	default:	uRETURN(False);
X    }
X    *pLen=	len;
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseWhichRoom(str,pLen,pWhich,ppName)
Xchar	 *str;
Xint	 *pLen;
Xunsigned *pWhich;
Xchar	**ppName;
X{
Xint	len=	1;
X
X    uENTRY4("_xrprParseWhichRoom(%s,0x%x,0x%x,0x%x)\n",str,pLen,pWhich,ppName);
X    *pWhich=	XR_CURRENT_ROOM;
X    *ppName=	NullString;
X    switch (str[0]) {
X	case 'A':	*pWhich=	XR_ALL_ROOMS;		break;
X	case 'V':	*pWhich=	XR_VISIBLE_ROOMS;	break;
X	case 'C':	*pWhich=	XR_CURRENT_ROOM;	break;
X	case 'L':	*pWhich=	XR_LAST_ROOM;		break;
X	case '?':	*pWhich=	XR_QUERY_ROOM;		break;
X	case 'N':	if (str[1]==NUL) {
X			    *pWhich=	XR_QUERY_ROOM;
X			    len= 2;
X			}
X			else {
X			    *pWhich=	XR_NAMED_ROOM;
X			    *ppName=	&str[1];
X			    len=	1+strlen(*ppName)+1;
X			}
X			break;
X	default:	uRETURN(False);
X    }
X    *pLen=	len;
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseSetStateRequest(str,pArgs)
Xchar			*str;
XxrSetStateArgsPtr	 pArgs;
X{
XBoolean	ok= True;
Xint	roomI;
X
X    uENTRY2("_xrprParseSetStateRequest(%s,0x%x)\n",uStringText(str),pArgs);
X    if ((str!=NullString)&&(strlen(str)>=9)) {
X	if ((str[0]=='S')||(str[0]=='M')||(str[0]=='C'))
X	     pArgs->doWhat=	str[0];
X	else ok=			False;
X	    
X	if ((str[1]=='P')||(str[1]=='B')||(str[1]=='L'))
X	     pArgs->toWhat=		str[1];
X	else ok=			False;
X
X	ok=	ok&&(_xrprParseWhichPart(&str[2],&pArgs->whichPart)>0);
X	ok=	ok&&_xrprParseWhichState(str[7],&pArgs->whichState);
X	ok=	ok&&_xrprParseWhichApp(&str[8],&roomI,&pArgs->whichApp,
X						   &pArgs->appName);
X	roomI+=	8;
X
X	ok=	ok&&_xrprParseWhichRoom(&str[roomI],&roomI,&pArgs->whichRoom,
X						  &pArgs->roomName);
X    }
X    else ok= False;
X
X    if (!ok) {
X	uWarning("Bad SET STATE request (%s)\n",uStringText(str));
X    }
X    uRETURN(ok);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseRememberRequest(str,pArgs)
Xchar			*str;
XxrRememberArgsPtr	 pArgs;
X{
XBoolean	ok= True;
Xint	len;
X
X    uENTRY2("_xrprParseRememberRequest(%s,0x%x)\n",uStringText(str),pArgs);
X    if ((str!=NullString)&&(strlen(str)>=2)) {
X	if	(str[0]=='R')	pArgs->remember=	True;
X	else if (str[0]=='F')	pArgs->remember=	False;
X	else			ok=			False;
X
X	ok=	_xrprParseWhichApp(&str[1],&len,&pArgs->whichApp,
X						 &pArgs->appName)&&ok;
X    }
X    else ok= False;
X
X    if (!ok) {
X	uWarning("Bad REMEMBER request (%s)\n",uStringText(str));
X    }
X    uRETURN(ok);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseVisibilityRequest(str,pArgs)
Xchar			*str;
XxrVisibilityArgsPtr	 pArgs;
X{
XBoolean	ok= True;
Xint	len;
X
X    uENTRY2("_xrprParseVisibilityRequest(%s,0x%x)\n",uStringText(str),pArgs);
X    if ((str!=NullString)&&(strlen(str)>=7)) {
X	len= _xrprParseVisibility(str,&pArgs->visibility);
X	if (len>0) {
X	    if 		(str[len]=='+')	pArgs->checkAuto=	True;
X	    else if	(str[len]=='-')	pArgs->checkAuto=	False;
X	    else			ok=			False;
X	    len++;
X
X	    if 		(str[len]=='C')	pArgs->createRoom=	True;
X	    else if	(str[len]=='c')	pArgs->createRoom=	False;
X	    else			ok=			False;
X	    len++;
X
X	    ok= ok&&_xrprParseWhichRoom(&str[len],&len,&pArgs->whichRoom,
X						  	&pArgs->roomName);
X	}
X    }
X    else ok= False;
X
X    if (!ok) {
X	uWarning("Bad VISIBILITY request (%s)\n",uStringText(str));
X    }
X    uRETURN(ok);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_xrprParseGetAppNameRequest(str,pWhichApp,ppAppName)
Xchar		 *str;
Xunsigned	 *pWhichApp;
Xchar		**ppAppName;
X{
XBoolean	ok= True;
Xint	len;
X
X    uENTRY3("_xrprParseGetAppNameRequest(%s,0x%x,0x%x)\n",uStringText(str),
X							pWhichApp,ppAppName);
X    if (str!=NullString) {
X	ok=	_xrprParseWhichApp(&str[0],&len,pWhichApp,ppAppName);
X    }
X    else ok= False;
X
X    if (!ok) {
X	uWarning("Bad GET APP NAME request (%s)\n",uStringText(str));
X    }
X    uRETURN(ok);
X}
X
X/***====================================================================***/
X
XBoolean
XxrprDispatchRequest(dpy,root,pRequest,pArgStart)
XDisplay		*dpy;
XWindow	 	 root;
XxrRequestPtr	 pRequest;
Xint		*pArgStart;
X{
XAtom	actualType;
Xint	actualFormat,nItems,bytesAfter;
Xchar	*pString= NullString;
XBoolean	ok=	False;
X
X    uENTRY4("xrprDispatchRequest(0x%x,0x%x,0x%x,0x%x)\n",dpy,root,pRequest,
X							 pArgStart);
X    if (pRequest->size>0) {
X	    if (XGetWindowProperty(dpy,pRequest->win,ROOMS_ARGUMENT,
X				*pArgStart,pRequest->size*4,True,XA_STRING,
X				&actualType,&actualFormat,&nItems,&bytesAfter,
X				&pString)==Success) {
X	    if ((actualType==XA_STRING)&&(nItems==(pRequest->size)*4)&&
X		(actualFormat==8)) {
X		if (bytesAfter==0)	*pArgStart=	0;
X		else			*pArgStart+=	pRequest->size;
X		ok=	True;
X	    }
X	    else {
X		uError("bogus _XROOMS_ARGUMENT property (%d!=%d||%d!=%d)\n",
X					actualType,XA_STRING,
X					nItems,pRequest->size*4);
X		uAction("removing properties. requests may be lost\n");
X		XDeleteProperty(dpy,root,ROOMS_REQUEST);
X		XDeleteProperty(dpy,pRequest->win,ROOMS_ARGUMENT);
X	    }
X	}
X    }
X    else {
X	pString=	NullString;
X	ok=		True;
X    }
X
X    if (ok) {
X	uDEBUG1(1,"REQUEST = \"%s\"\n",uStringText(pString));
X	if (pRequest->request==XR_RQ_NOOP) {
X	    uDEBUG1(1,"NOOP = \"%s\"\n",uStringText(pString));
X	}
X	else if (pRequest->request==XR_RQ_DEBUG) {
X	    extern void xrDebugSettings(/*settings*/);
X	    xrDebugSettings(pString);
X	    xrprReturnStatus(dpy,pRequest->win,True);
X	}
X	else if (pRequest->request==XR_RQ_SET_STATE) {
X	    xrSetStateArgsRec	stateArgs;
X	    if (_xrprParseSetStateRequest(pString,&stateArgs)) {
X		switch (stateArgs.toWhat) {
X		    case 'P':
X			ok= xrdpDoSetState(&stateArgs);
X			break;
X		    case 'B':	case 'L':
X			ok= xrdpDoBolt(&stateArgs);
X			break;
X		    default:
X			ok= False;
X			break;
X		}
X	    }
X	    else ok=	False;
X	    xrprReturnStatus(dpy,pRequest->win,ok);
X	}
X	else if (pRequest->request==XR_RQ_REMEMBER) {
X	    xrRememberArgsRec	args;
X	    if (_xrprParseRememberRequest(pString,&args)) {
X		ok= xrdpDoRemember(&args);
X	    }
X	    else ok= False;
X	    xrprReturnStatus(dpy,pRequest->win,ok);
X	}
X	else if (pRequest->request==XR_RQ_SET_VISIBILITY) {
X	    xrVisibilityArgsRec	 args;
X	    if (_xrprParseVisibilityRequest(pString,&args)) {
X		ok= xrdpDoSetVisibility(&args);
X	    }
X	    else ok= False;
X	    xrprReturnStatus(dpy,pRequest->win,ok);
X	}
X	else if (pRequest->request==XR_RQ_LOAD_PROFILE) {
X	    ok=	xrpfLoadString(pString);
X	    xrprReturnStatus(dpy,pRequest->win,ok);
X	}
X	else if (pRequest->request==XR_RQ_APP_NAME) {
X	    unsigned	which;
X	    char	*appName=	NullString;
X	    char	buf[258];
X	    if (_xrprParseGetAppNameRequest(pString,&which,&appName)) {
X		appName= xrdpDoGetAppName(which,appName);
X		if (appName!=NullString) {
X		    sprintf(buf,"t%s",appName);
X		    appName=	buf;
X		}
X	    }
X	    else ok= False;
X	    if ((ok)&&(appName!=NullString))
X		 xrprReturnString(dpy,pRequest->win,strlen(appName),appName);
X	    else xrprReturnStatus(dpy,pRequest->win,False);
X	}
X	else {
X	    xrprReturnStatus(dpy,pRequest->win,False);
X	}
X	if (pString!=NullString)
X	    (void)XFree(pString);
X	uRETURN(bytesAfter==0);
X    }
X    else {
X	xrprReturnStatus(dpy,pRequest->win,False);
X    }
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xvoid
XxrprHandleRequests(dpy,root)
XDisplay	*dpy;
XWindow	 root;
X{
Xlong	reqStart;
XAtom	actualType;
Xint	actualFormat,nItems,bytesAfter;
Xint	argStart= 0;
XBoolean	done=	False;
XxrRequestPtr	pRequest;
X
X    uENTRY2("xrprHandleRequests(0x%x,0x%x)\n",dpy,root);
X    reqStart= 0;
X    while (!done) {
X	if (XGetWindowProperty(dpy,root,ROOMS_REQUEST,reqStart,3,True,
X				XA_INTEGER,&actualType,&actualFormat,&nItems,
X				&bytesAfter,&pRequest)==Success) {
X	    if ((actualType==XA_INTEGER)&&(actualFormat==32)&&(nItems==3)) {
X		reqStart+= 3;
X		switch (pRequest->request) {
X		    default:
X			done= xrprDispatchRequest(dpy,root,pRequest,&argStart);
X			break;
X		}
X		done=	done&&(bytesAfter==0);
X		if (bytesAfter==0)
X		    reqStart=	0;
X		if (pRequest!=NULL) 
X		    (void)XFree(pRequest);
X	    }
X	    else {
X		if (actualType!=None)
X		    uError("bogus _XROOMS_REQUEST property\n");
X		    uAction("removing properties. requests may be lost\n");
X		    XDeleteProperty(dpy,root,ROOMS_REQUEST);
X		    XDeleteProperty(dpy,pRequest->win,ROOMS_ARGUMENT);
X		    done=	True;
X		}
X	}
X	else done= True;
X    }
X    uVOIDRETURN;
X}
END_OF_FILE
if test 16098 -ne `wc -c <'./xrooms/xrProto.c'`; then
    echo shar: \"'./xrooms/xrProto.c'\" unpacked with wrong size!
fi
# end of './xrooms/xrProto.c'
fi
echo shar: End of archive 9 \(of 14\).
cp /dev/null ark9isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0



More information about the Comp.sources.x mailing list