v05i055: Xrooms -- A Rooms implementation for X, Part05/14
Kent Landfield
kent at ssbell.IMD.Sterling.COM
Mon Jan 15 17:08:25 AEST 1990
Submitted-by: wsl.dec.com!mikey (Mike Yang)
Posting-number: Volume 5, Issue 55
Archive-name: xrooms/part05
#! /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 5 (of 14)."
# Contents: ./utils/list.c ./utils/regex.c ./utils/strtbl.c
# ./xrooms/Makefile ./xrooms/xrDebug.c ./xrooms/xrXawRoom.c
# Wrapped by kent at ssbell on Sun Jan 14 21:57:47 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f './utils/list.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./utils/list.c'\"
else
echo shar: Extracting \"'./utils/list.c'\" \(8941 characters\)
sed "s/^X//" >'./utils/list.c' <<'END_OF_FILE'
X
X /*\
X * $Header: list.c,v 5.0 90/01/10 06:50:54 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#define DEBUG_VAR listDebug
X#include "utils.h"
X#include "liststr.h"
X
X
X#define _lCompare(pL,k1,k2) ((pL)->pSort?(*(pL)->pSort)(k1,k2):\
X _genCompareKey((pL)->keyType,k1,k2))
X
X/***====================================================================***/
X
XListPtr
XlCreate(size, sortFunc, keyType, dataType)
Xunsigned size;
XCompareKeyFunc sortFunc;
XGenKeyDescPtr keyType;
XGenDataDescPtr dataType;
X{
XListPtr pList;
X
X uENTRY4("lCreate(%d,0x%x,0x%x,0x%x)\n",size,sortFunc,keyType,dataType);
X if (size<1) {
X uRETURN(NullList);
X }
X if (keyType==NullGenKeyDesc) keyType= genDefaultKeyType;
X if (dataType==NullGenDataDesc) dataType= genDefaultDataType;
X pList= uTypedAlloc(ListRec);
X if (pList!=NullList) {
X pList->pCells= uTypedCalloc(size,ListCellRec);
X if (pList->pCells!=NullListCell) {
X pList->nStored= 0;
X pList->nCells= size;
X pList->pSort= sortFunc;
X pList->keyType= keyType;
X pList->dataType= dataType;
X }
X else {
X uFree((Opaque)pList);
X uRETURN(NullList);
X }
X }
X uRETURN(pList);
X}
X
X/***====================================================================***/
X
Xvoid
XlDestroy(pList)
XListPtr pList;
X{
Xint i;
X uENTRY1("lDestroy(0x%x)\n",pList);
X if (pList!=NullList) {
X if (pList->pCells!=NullListCell) {
X for (i=0;i<pList->nStored;i++) {
X _genRemoveKey(pList->keyType,pList->pCells[i].key);
X _genRemoveData(pList->dataType,pList->pCells[i].data);
X }
X uFree((Opaque)pList->pCells);
X pList->pCells=0;
X }
X pList->nStored= pList->nCells= 0;
X pList->pSort= NullListSortFunc;
X pList->keyType= NullGenKeyDesc;
X pList->dataType= NullGenDataDesc;
X uFree((Opaque)pList);
X }
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xint
XlNItems(pList)
XListPtr pList;
X{
X uENTRY1("lNItems(0x%x)\n",pList);
X if (pList!=NullList) {
X uRETURN(pList->nStored);
X }
X uRETURN(0);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_lGrowCells(pList)
XListPtr pList;
X{
X uENTRY1("_lGrowCells(0x%x)\n",pList);
X if ((pList!=NullList)&&(pList->nCells>0)) {
X pList->nCells*= 2;
X pList->pCells= (ListCellPtr)uRealloc((Opaque)pList->pCells,
X (unsigned)pList->nCells*sizeof(ListCellRec));
X if (pList->pCells!=NullListCell) {
X uRETURN(True);
X }
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_lDeleteCell(pList,where)
XListPtr pList;
Xunsigned where;
X{
Xunsigned i;
X
X uENTRY2("_lDeleteCell(0x%x,%d)\n",pList,where);
X if ((pList!=NullList)&&(where<pList->nStored)) {
X _genRemoveKey(pList->keyType,pList->pCells[where].key);
X _genRemoveData(pList->dataType,pList->pCells[where].data);
X for (i=where;i<pList->nStored;i++) {
X pList->pCells[i]= pList->pCells[i+1];
X }
X pList->nStored--;
X uRETURN(True);
X }
X uRETURN(False);;
X}
X
X/***====================================================================***/
X
Xstatic Boolean
X_lInsertCell(pList,where,key,data)
XListPtr pList;
Xunsigned where;
XGenKey key;
XGenData data;
X{
Xunsigned i;
X
X uENTRY4("_lInsertCell(0x%x,%d,0x%x,0x%x)\n",pList,where,key,data);
X if ((pList!=NullList)&&(where<=pList->nStored)) {
X if ((pList->nStored==pList->nCells)&&(!_lGrowCells(pList))) {
X uInternalError("REALLOC FAILED List 0x%x may be corrupted\n",
X pList);
X uAction("restart ASAP!!\n");
X uRETURN(False);
X }
X
X for (i=pList->nStored;i>where;i--) {
X pList->pCells[i]= pList->pCells[i-1];
X }
X pList->pCells[where].key= key;
X pList->pCells[where].data= data;
X pList->nStored++;
X uRETURN(True);
X }
X uRETURN(False);;
X}
X
X/***====================================================================***/
X
Xstatic Comparison
X_lFindSortedSpot(pList,key,pIndex)
XListPtr pList;
XGenKey key;
Xunsigned *pIndex;
X{
Xint i;
XComparison compare= Greater;
X
X uENTRY3("_lFindSortedSpot(0x%x,0x%x,0x%x)\n",pList,key,pIndex);
X if (pList!=NullList) {
X for (i=0;i<pList->nStored;i++) {
X compare= _lCompare(pList,pList->pCells[i].key,key);
X if (compare!=Less) {
X *pIndex= i;
X uRETURN(compare);
X }
X }
X *pIndex= i;
X uRETURN(Greater);
X }
X uRETURN(CannotCompare);
X}
X
X/***====================================================================***/
X
XBoolean
XlStore(pList, key, data)
XListPtr pList;
XGenKey key;
XGenData data;
X{
Xunsigned index;
XComparison compare;
X
X uENTRY3("lStore(0x%x,0x%x,0x%x)\n",pList,key,data);
X if (pList!=NullList) {
X compare= _lFindSortedSpot(pList,key,&index);
X if (compare==Greater) {
X _lInsertCell(pList,index,key,data);
X uRETURN(True);
X }
X else if (compare==Equal) {
X pList->pCells[index].data= _genReplaceData(pList->dataType,data,
X &pList->pCells[index].data);
X uRETURN(True);
X }
X }
X uInternalError("storing 0x%x into name list 0x%x\n",data,pList);
X uRETURN(False);
X}
X
X/***====================================================================***/
X
XBoolean
XlRemove(pList, key)
XListPtr pList;
XGenKey key;
X{
Xunsigned index;
XComparison compare;
X
X uENTRY2("lRemove(0x%x,0x%x)\n",pList,key);
X if (pList!=NullList) {
X compare= _lFindSortedSpot(pList,key,&index);
X if (compare==Equal) {
X _lDeleteCell(pList,index);
X uRETURN(True);
X }
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
XBoolean
XlRemoveAll(pList)
XListPtr pList;
X{
Xunsigned i;
X
X uENTRY1("lRemoveAll(0x%x)\n",pList);
X if (pList!=NullList) {
X for (i=0;i<pList->nStored;i++) {
X _genRemoveKey(pList->keyType,pList->pCells[i].key);
X _genRemoveData(pList->dataType,pList->pCells[i].data);
X }
X pList->nStored= 0;
X uRETURN(True);
X }
X uRETURN(False);
X}
X/***====================================================================***/
X
XBoolean
XlLookup(pList, key, pData)
XListPtr pList;
XGenKey key;
XGenData *pData;
X{
Xunsigned index;
XComparison compare;
X
X uENTRY2("lLookup(0x%x,0x%x)\n",pList,key);
X if (pList!=NullList) {
X compare= _lFindSortedSpot(pList,key,&index);
X if (compare==Equal) {
X if (pData!=(GenData *)NULL)
X *pData= pList->pCells[index].data;
X uRETURN(True);
X }
X else if (pData!=(GenData *)NULL)
X *pData= _genNullData(pList->dataType);
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
Xvoid
XlIterate(pList, pFunc, arg)
XListPtr pList;
XGenIterFunc pFunc;
XOpaque arg;
X{
Xint i;
X
X uENTRY3("lIterate(0x%x,0x%x,0x%x)\n",pList,pFunc,arg);
X if ((pList!=NullList)&&(pFunc!=(GenIterFunc)NULL)) {
X for (i=0;i<pList->nStored;i++) {
X if (!(*pFunc)(pList->pCells[i].key,pList->pCells[i].data,arg))
X break;
X }
X }
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
XBoolean
X_lInitIter(pList, pState)
XListPtr pList;
XOpaque *pState;
X{
X uENTRY2("_lInitIter(0x%x,0x%x)\n",pList,pState);
X *pState= (Opaque)0;
X if ((pList!=NullList)&&(pList->nStored>0)) {
X uRETURN(True);
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
XBoolean
X_lIterNext(pList, pState, pKey, pData)
XListPtr pList;
XOpaque *pState;
XGenKey *pKey;
XGenData *pData;
X{
Xunsigned index= (unsigned)*pState;
X
X uENTRY4("_lIterNext(0x%x,0x%x,0x%x,0x%x)\n",pList,pState,pKey,pData);
X if ((pList!=NullList)&&(index<pList->nStored)) {
X *pKey= pList->pCells[index].key;
X *pData= pList->pCells[index].data;
X index++;
X *pState= (Opaque)index;
X uRETURN(True);
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
Xvoid
XlEndIterator(pList, state)
XListPtr pList;
XOpaque state;
X{
X uENTRY2("lEndIterator(0x%x,%d)\n",pList,state);
X uVOIDRETURN;
X}
END_OF_FILE
if test 8941 -ne `wc -c <'./utils/list.c'`; then
echo shar: \"'./utils/list.c'\" unpacked with wrong size!
fi
# end of './utils/list.c'
fi
if test -f './utils/regex.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./utils/regex.c'\"
else
echo shar: Extracting \"'./utils/regex.c'\" \(8259 characters\)
sed "s/^X//" >'./utils/regex.c' <<'END_OF_FILE'
X
X /*\
X * $Header: regex.c,v 5.0 90/01/10 06:51:07 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#define DEBUG_VAR regexDebug
X
X#include "utils.h"
X#include "regex.h"
X
Xextern Boolean rxMatch();
X
X/***====================================================================***/
X
Xstatic Boolean
XrxStarMatch(ptrn,ptrnLength,str,indices,matchFunc,arg)
Xchar *ptrn;
Xint ptrnLength;
Xchar *str;
Xchar **indices;
XBoolean (*matchFunc)();
XOpaque arg;
X{
Xint i;
X
X uENTRY5("rxStarMatch(%s,%d,%s,0x%x,0x%x)\n",ptrn,ptrnLength,str,indices,
X matchFunc);
X if (((*str)!=NUL)&&(*matchFunc)(ptrn,str,arg)&&
X (rxStarMatch(ptrn,ptrnLength,str+1,indices,matchFunc,arg))) {
X for (i=0;i<ptrnLength;i++) {
X indices[i]= str;
X }
X uRETURN(True);
X }
X else {
X for (i=0;i<ptrnLength;i++) {
X indices[i]= NULL;
X }
X uRETURN(rxMatch(ptrn+ptrnLength,str,indices+ptrnLength));
X }
X}
X
X/***====================================================================***/
X
Xstatic Boolean
XrxQuestionMatch(ptrn,ptrnLength,str,indices,matchFunc,arg)
Xchar *ptrn;
Xint ptrnLength;
Xchar *str;
Xchar **indices;
XBoolean (*matchFunc)();
XOpaque arg;
X{
Xint i;
X
X uENTRY5("rxQuestionMatch(%s,%d,%s,0x%x,0x%x)\n",ptrn,ptrnLength,str,indices,
X matchFunc);
X if ((*matchFunc)(ptrn,str,arg)&&
X (rxMatch(ptrn+ptrnLength,str+1,indices+ptrnLength))) {
X for (i=0;i<ptrnLength;i++) {
X indices[i]= str;
X }
X uRETURN(True);
X }
X else {
X for (i=0;i<ptrnLength;i++) {
X indices[i]= NULL;
X }
X uRETURN(rxMatch(ptrn+ptrnLength,str,indices+ptrnLength));
X }
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xstatic Boolean
XrxExactMatch(ptrn,str,arg)
Xchar *ptrn;
Xchar *str;
XOpaque arg;
X{
X uENTRY3("rxExactMatch(%s,%s,0x%x)\n",ptrn,str,arg);
X if (ptrn[0]==str[0])
X uRETURN(True);
X uRETURN(False);
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xstatic Boolean
XrxDotMatch(ptrn,str,arg)
Xchar *ptrn;
Xchar *str;
XOpaque arg;
X{
X uENTRY3("rxDotMatch(%s,%s,0x%x)\n",ptrn,str,arg);
X if ((ptrn[0]=='.')&&(str[0]!=NUL))
X uRETURN(True);
X uRETURN(False);
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xstatic Boolean
XrxSlashMatch(ptrn,str,arg)
Xchar *ptrn;
Xchar *str;
XOpaque arg;
X{
X uENTRY3("rxSlashMatch(%s,%s,0x%x)\n",ptrn,str,arg);
X if ((ptrn[0]=='\\')&&(ptrn[1]==str[0]))
X uRETURN(True);
X uRETURN(False);
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xstatic Boolean
XrxBracketMatchOnce(ptrn,str,bracketChars)
Xchar *ptrn;
Xchar *str;
Xchar bracketChars[256];
X{
X uENTRY3("rxBracketMatchOnce(%s,%s,0x%x)\n",ptrn,str,bracketChars);
X uRETURN(bracketChars[*str]!=False);
X}
X
X/***====================================================================***/
X
Xstatic Boolean
XrxBracketMatch(ptrn,str,indices)
Xchar *ptrn;
Xchar *str;
Xchar **indices;
X{
Xchar matchChars[256],*ptrnStart;
XBoolean defaultMatch= False;
Xint i;
X
X uENTRY3("rxBracketMatch(%s,%s,0x%x)\n",ptrn,str,indices);
X if (*ptrn!='[') uRETURN(False);
X ptrnStart= ptrn++;
X
X if (*ptrn=='^') { defaultMatch= True; ptrn++; }
X
X matchChars[0]= False;
X for (i=1;i<256;i++) {
X matchChars[i]= defaultMatch;
X }
X while ((*ptrn)&&(*ptrn!=']')) {
X if (*ptrn=='\\') {
X ptrn++;
X if (*ptrn==NUL) break;
X }
X matchChars[*ptrn]= !defaultMatch;
X ptrn++;
X }
X if (*ptrn!=']') uRETURN(False);
X ptrn++;
X if (*ptrn=='*') {
X ptrn++;
X uRETURN(rxStarMatch(ptrnStart,ptrn-ptrnStart,str,indices,
X rxBracketMatchOnce,(Opaque)matchChars));
X }
X else if (*ptrn=='?') {
X ptrn++;
X uRETURN(rxQuestionMatch(ptrnStart,ptrn-ptrnStart,str,indices,
X rxBracketMatchOnce,(Opaque)matchChars));
X }
X if (matchChars[*str]) {
X int i;
X for (i=ptrn-ptrnStart;i>0;i--) {
X *indices++= str;
X }
X uRETURN(rxMatch(ptrn,str+1,indices));
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
XBoolean
XrxMatch(ptrn,str,indices)
Xchar *ptrn;
Xchar *str;
Xchar **indices;
X{
X
X uENTRY3("rxMatch(%s,%s,0x%x)\n",ptrn,str,indices);
X if (ptrn[0]==NUL) {
X uRETURN((Boolean)str[0]==NUL);
X }
X
X if (ptrn[0]=='[')
X uRETURN(rxBracketMatch(ptrn,str,indices));
X if (ptrn[0]=='.') {
X if (ptrn[1]=='*') {
X uRETURN(rxStarMatch(ptrn,2,str,indices,rxDotMatch,NULL));
X }
X else if (ptrn[1]=='?') {
X uRETURN(rxQuestionMatch(ptrn,2,str,indices,rxDotMatch,NULL));
X }
X else if (str[0]!=NUL) {
X indices[0]= str;
X uRETURN(rxMatch(ptrn+1,str+1,indices+1));
X }
X else uRETURN(False);
X }
X if (ptrn[0]=='\\') {
X indices[0]= str;
X if ((ptrn[1]=='(')||(ptrn[1]==')')) {
X indices[1]= str;
X uRETURN(rxMatch(ptrn+2,str,indices+2));
X }
X if (ptrn[1]==NUL) {
X uRETURN(str[0]==NUL);
X }
X if (ptrn[2]=='*') {
X uRETURN(rxStarMatch(ptrn,3,str,indices,rxSlashMatch,NULL));
X }
X else if (ptrn[2]=='?') {
X uRETURN(rxQuestionMatch(ptrn,3,str,indices,rxSlashMatch,NULL));
X }
X if (ptrn[1]==str[0]) {
X indices[1]= str;
X uRETURN(rxMatch(ptrn+2,str+1,indices+2));
X }
X }
X if (ptrn[1]=='*')
X uRETURN(rxStarMatch(ptrn,2,str,indices,rxExactMatch,NULL));
X if (ptrn[1]=='?')
X uRETURN(rxQuestionMatch(ptrn,2,str,indices,rxExactMatch,NULL));
X if (ptrn[0]==str[0]) {
X indices[0]= str;
X uRETURN(rxMatch(ptrn+1,str+1,indices+1));
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
Xstatic void
XrxFindMatches(wholePtrn,indices,pM)
Xchar *wholePtrn;
Xchar **indices;
XRXMatchesPtr pM;
X{
Xchar *ptrn;
Xint nMatches,openSave;
X
X uENTRY3("rxFindMatches(%s,0x%x,0x%x)\n",wholePtrn,indices,pM);
X nMatches= 0;
X ptrn= wholePtrn;
X while (*ptrn!=NUL) {
X if ((*ptrn=='\\')&&(*(ptrn+1)=='(')) { nMatches++; ptrn++; }
X ptrn++;
X }
X pM->nMatches= 0;
X if (nMatches<1)
X uVOIDRETURN;
X if (nMatches>REGEX_MAX_MATCHES)
X nMatches= REGEX_MAX_MATCHES;
X
X ptrn= wholePtrn;
X openSave= False;
X while ((*ptrn!=NUL)&&(pM->nMatches<nMatches)) {
X if ((*ptrn=='\\')&&(*(ptrn+1)=='(')) {
X if (openSave)
X goto BAILOUT;
X openSave= True;
X pM->matchStrings[pM->nMatches]= indices[ptrn-wholePtrn];
X }
X if ((*ptrn=='\\')&&(*(ptrn+1)==')')) {
X if (!openSave)
X goto BAILOUT;
X openSave= False;
X pM->matchLengths[pM->nMatches]= indices[ptrn-wholePtrn]-
X pM->matchStrings[pM->nMatches];
X pM->nMatches++;
X }
X ptrn++;
X }
X uVOIDRETURN;
XBAILOUT:
X pM->nMatches= 0;
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
XBoolean
XregexMatch(wholePtrn,wholeStr,pMatches)
Xchar *wholePtrn;
Xchar *wholeStr;
XRXMatchesPtr pMatches;
X{
Xchar **matchIndices;
X
X uENTRY3("regexMatch(%s,%s,0x%x)\n",wholePtrn,wholeStr,pMatches);
X matchIndices= (char **)uTmpAlloc(strlen(wholePtrn)*sizeof(char *));
X if (matchIndices==NULL)
X uRETURN(False);
X if (!rxMatch(wholePtrn,wholeStr,matchIndices)) {
X uTmpFree(matchIndices);
X uRETURN(False);
X }
X
X if (pMatches!=NULL) {
X rxFindMatches(wholePtrn,matchIndices,pMatches);
X }
X uTmpFree(matchIndices);
X uRETURN(True);
X}
END_OF_FILE
if test 8259 -ne `wc -c <'./utils/regex.c'`; then
echo shar: \"'./utils/regex.c'\" unpacked with wrong size!
fi
# end of './utils/regex.c'
fi
if test -f './utils/strtbl.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./utils/strtbl.c'\"
else
echo shar: Extracting \"'./utils/strtbl.c'\" \(8655 characters\)
sed "s/^X//" >'./utils/strtbl.c' <<'END_OF_FILE'
X
X /*\
X * $Header: strtbl.c,v 5.0 90/01/10 06:51:23 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#define DEBUG_VAR strtblDebug
X#include "utils.h"
X#include "storagestr.h"
X#include "strtblstr.h"
X#include "hash.h"
X
X/***====================================================================***/
X
Xstatic Boolean stInitialized;
X
Xstatic Boolean stHavePrivate;
Xstatic Opaque *stPrivate;
Xstatic Opaque stPrivDefault;
X
Xstatic int stNextFree;
Xstatic int stSize;
X
Xstatic StringTableEntry *stringTable;
Xstatic HashTablePtr stringLookup;
X
Xstatic GenKeyDescRec stStringKeyTypeRec= {
X (HashFunc)genHashString,
X (CompareKeyFunc)genCompareStringKey,
X (StoreKeyFunc)NULL,
X (RemoveKeyFunc)NULL,
X (GenKey)NULL
X};
X
Xstatic GenDataDescRec stTokenDataTypeRec= {
X (StoreDataFunc)NULL,
X (ReplaceDataFunc)NULL,
X (RemoveDataFunc)NULL,
X (GenData)NullStringToken
X};
X
X/***====================================================================***/
X
Xchar *
XstText(token)
XStringToken token;
X{
X if ((!stInitialized)||(token==NullStringToken)||
X (stTokenIndex(token)>stSize)) {
X return("<NullStringToken>");
X }
X return(stringTable[stTokenIndex(token)].string);
X}
X
X/***====================================================================***/
X
XBoolean
XstInit(nStr, avgSize, needPriv, privDflt)
Xunsigned nStr;
Xunsigned avgSize;
XBoolean needPriv;
XOpaque privDflt;
X{
Xregister int i;
X
X uENTRY2("stInit(%d,%d)\n",nStr,avgSize);
X /* doesn't use avgSize yet */
X if (stInitialized)
X uRETURN(False);
X stSize= nStr;
X stringTable= uTypedCalloc(nStr,StringTableEntry);
X if (stringTable==NULL)
X uRETURN(False);
X stringLookup= htCreate((unsigned)(nStr*11)/10,&stStringKeyTypeRec,
X &stTokenDataTypeRec);
X if (stringLookup==NULL) {
X uFree((Opaque)stringTable);
X uRETURN(False);
X }
X
X if (needPriv) {
X stPrivate= (Opaque *)uTypedCalloc(nStr,Opaque);
X if (stPrivate==NULL) {
X uFree((Opaque)stringTable);
X htDestroy(stringLookup);
X uRETURN(False);
X }
X stHavePrivate= True;
X stPrivDefault= privDflt;
X stPrivate[0]= privDflt;
X }
X else {
X stHavePrivate= False;
X }
X
X stringTable[0].string= NULL;
X stNextFree= 1;
X for (i=1;i<nStr;i++) {
X stringTable[i].next= i+1;
X }
X stringTable[nStr-1].next= (unsigned)NullStringToken;
X stInitialized= True;
X uRETURN(True);
X}
X
X/***====================================================================***/
X
Xvoid
XstClose()
X{
X uENTRY("stClose()\n");
X if (!stInitialized)
X uVOIDRETURN;
X uFree((Opaque)stringTable);
X htDestroy(stringLookup);
X if (stHavePrivate) {
X uFree((Opaque)stPrivate);
X }
X stSize= 0;
X stringTable= NULL;
X stringLookup= NULL;
X stNextFree= (int)NullStringToken;
X stHavePrivate= False;
X stPrivDefault= 0;
X stInitialized= False;
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
XStringToken
XstAddString(str)
Xchar *str;
X{
XStringToken token,old;
X
X uENTRY1("stAddString(%s)\n",str);
X if ((str==NULL)||(str[0]=='\0')) {
X uRETURN(NullStringToken);
X }
X
X if (stNextFree==(int)NullStringToken) {
X register int i;
X stNextFree= stSize;
X stSize*= 2;
X stringTable= (StringTableEntry *)uRealloc((Opaque)stringTable,
X (unsigned)stSize*sizeof(StringTableEntry));
X if (!stringTable) {
X uFatalError("catastrophic failure! stringTable lost!\n");
X /* NOTREACHED */
X }
X if (!htResize(stringLookup,(stSize*11)/10)) {
X uFatalError("catastrophic failure! stringLookup lost!\n");
X /* NOTREACHED */
X }
X if (stHavePrivate) {
X stPrivate= (Opaque *)uRealloc((Opaque)stPrivate,
X (unsigned)stSize*sizeof(Opaque));
X if (stPrivate==NULL) {
X uFatalError("catastrophic failure! stPrivate lost!\n");
X /* NOTREACHED */
X }
X }
X for (i=stNextFree;i<stSize;i++) {
X stringTable[i].next= i+1;
X }
X stringTable[stSize-1].next= (int)NullStringToken;
X }
X token= stCreateToken(str[0],stNextFree);
X stNextFree= stringTable[stNextFree].next;
X str= uStringDup(str);
X stringTable[stTokenIndex(token)].string= str;
X if (stHavePrivate) {
X stPrivate[stTokenIndex(token)]= stPrivDefault;
X }
X old= (StringToken)htAdd(stringLookup,(GenKey)str,(GenData)token);
X if (old!=NullStringToken)
X uWarning("string \"%s\" stored twice!\n",str);
X uRETURN(token);
X}
X
X/***====================================================================***/
X
XStringToken
XstGetToken(str)
Xchar *str;
X{
XStringToken token;
X
X uENTRY1("stGetToken(%s)\n",str);
X if (stInitialized) {
X token= (StringToken)htLookup(stringLookup,(GenKey)str);
X if (token==NullStringToken) {
X token= stAddString(str);
X }
X }
X uRETURN(token);
X}
X
X/***====================================================================***/
X
XBoolean
XstGetTokenIfExists(str, pToken)
Xchar *str;
XStringToken *pToken;
X{
XStringToken token= NullStringToken;
X
X uENTRY2("stGetTokenIfExists(%s,0x%x)\n",str,pToken);
X if (stInitialized) {
X token= (StringToken)htLookup(stringLookup,(GenKey)str);
X }
X if (pToken)
X *pToken= token;
X if (token==NullStringToken)
X uRETURN(False);
X uRETURN(True);
X}
X
X/***====================================================================***/
X
Xchar *
XstGetString(token)
XStringToken token;
X{
X uENTRY1("stGetString(0x%x)\n",token);
X if ((!stInitialized)||(token==NullStringToken)||
X (stTokenIndex(token)>stSize)) {
X uRETURN(NULL);
X }
X /* some kind of consistency check here? */
X uRETURN(stringTable[stTokenIndex(token)].string);
X}
X
X/***====================================================================***/
X
XBoolean
XstRemove(token)
XStringToken token;
X{
XStringToken htToken= NullStringToken;
X
X uENTRY1("stRemove(0x%x)\n",token);
X if (stInitialized) {
X htToken= (StringToken)htRemove(stringLookup,
X (GenData)stringTable[stTokenIndex(token)].string);
X if (htToken==token) {
X uFree((Opaque)stringTable[stTokenIndex(token)].string);
X stringTable[stTokenIndex(token)].next= stNextFree;
X stNextFree= (int)token;
X uRETURN(True);
X }
X else if (htToken!=NullStringToken)
X uWarning(" htRemove returned 0x%x, expected 0x%x\n",
X htToken,token);
X }
X uRETURN(False);
X}
X
X/***====================================================================***/
X
XBoolean
XstSetPrivate(token,value)
XStringToken token;
XOpaque value;
X{
X uENTRY2("stSetPrivate(0x%x,0x%x)\n",token,value);
X if ((!stInitialized)||(!stHavePrivate)) {
X uRETURN(False);
X }
X stPrivate[stTokenIndex(token)]= value;
X uRETURN(True);
X}
X
X/***====================================================================***/
X
XOpaque
XstGetPrivate(token)
XStringToken token;
X{
X uENTRY1("stGetPrivate(0x%x)\n",token);
X if ((!stInitialized)||(!stHavePrivate)) {
X uRETURN(stPrivDefault);
X }
X uRETURN(stPrivate[stTokenIndex(token)]);
X}
X
X/***====================================================================***/
X
XComparison
X_stCompare(token1,token2)
XStringToken token1,token2;
X{
X uENTRY2("_stCompare(0x%x,0x%x)\n",token1,token2);
X if (!stInitialized)
X uRETURN(Equal);
X
X if (token1==NullStringToken) {
X if (token2==NullStringToken) { uRETURN(Equal); }
X else { uRETURN(Less); }
X }
X else if (token2==NullStringToken) { uRETURN(Greater); }
X
X if ((stTokenIndex(token1)>stSize)||(stTokenIndex(token2)>stSize)) {
X uRETURN(Equal);
X }
X /* some kind of consistency check here? */
X uRETURN(uStringCompare(stringTable[stTokenIndex(token1)].string,
X stringTable[stTokenIndex(token2)].string));
X}
X
X/***====================================================================***/
END_OF_FILE
if test 8655 -ne `wc -c <'./utils/strtbl.c'`; then
echo shar: \"'./utils/strtbl.c'\" unpacked with wrong size!
fi
# end of './utils/strtbl.c'
fi
if test -f './xrooms/Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./xrooms/Makefile'\"
else
echo shar: Extracting \"'./xrooms/Makefile'\" \(8128 characters\)
sed "s/^X//" >'./xrooms/Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file. Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def. If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit Mips.macros to change
X
X# platform: $XConsortium: Vax.macros,v 1.49 88/10/23 11:01:02 jim Exp $
X
XBOOTSTRAPCFLAGS =
X AS = as
X CC = cc
X CPP = /lib/cpp
X LD = ld
X LINT = lint
X INSTALL = install
X TAGS = ctags
X RM = rm -f
X MV = mv
X LN = ln -s
X RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X AR = ar clq
X LS = ls
X LINTOPTS = -axz
X LINTLIBFLAG = -C
X MAKE = make
XSTD_CPP_DEFINES =
X STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site: $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
XSYSLAST_LIBRARIES = -ldnet
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X SHELL = /bin/sh
X
X DESTDIR =
X USRLIBDIR = $(DESTDIR)/usr/lib
X BINDIR = $(DESTDIR)/usr/bin/X11
X INCDIR = $(DESTDIR)/usr/include/X11
X ADMDIR = $(DESTDIR)/usr/adm
X LIBDIR = $(USRLIBDIR)/X11
X LINTLIBDIR = $(USRLIBDIR)/lint
X FONTDIR = $(LIBDIR)/fonts
X XINITDIR = $(LIBDIR)/xinit
X XDMDIR = $(LIBDIR)/xdm
X UWMDIR = $(LIBDIR)/uwm
X AWMDIR = $(LIBDIR)/awm
X TWMDIR = $(LIBDIR)/twm
X MANPATH = $(DESTDIR)/usr/local/man
X MANSOURCEPATH = $(MANPATH)/man
X MANDIR = $(MANSOURCEPATH)1
X LIBMANDIR = $(MANSOURCEPATH)3
X XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X INSTBINFLAGS = -m 0755
X INSTUIDFLAGS = -m 4755
X INSTLIBFLAGS = -m 0664
X INSTINCFLAGS = -m 0444
X INSTMANFLAGS = -m 0444
X INSTAPPFLAGS = -m 0444
X INSTKMEMFLAGS = -m 0755
X FCFLAGS = -t
X CDEBUGFLAGS = -O
X
X PATHSEP = /
X DEPEND = $(DEPENDSRC)/makedepend
X IMAKE = $(IMAKESRC)/imake
X RGB = $(RGBSRC)/rgb
X FC = $(BDFTOSNFSRC)/bdftosnf
X MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
X
X CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X TOP = /usr/src/X11
X CLIENTSRC = $(TOP)/clients
X DEMOSRC = $(TOP)/demos
X LIBSRC = $(TOP)/lib
X FONTSRC = $(TOP)/fonts
X INCLUDESRC = $(TOP)/X11 -I$(TOP)
X SERVERSRC = $(TOP)/server
X UTILSRC = $(TOP)/util
X SCRIPTSSRC = $(UTILSRC)/scripts
X EXAMPLESRC = $(TOP)/examples
X CONTRIBSRC = $(TOP)/contrib
X DOCSRC = $(TOP)/doc
X RGBSRC = $(TOP)/rgb
X DEPENDSRC = $(UTILSRC)/makedepend
X IMAKESRC = $(UTILSRC)/imake
X IRULESRC = $(UTILSRC)/imake.includes
X XLIBSRC = $(LIBSRC)/X
X XMUSRC = $(LIBSRC)/Xmu
X TOOLKITSRC = $(LIBSRC)/Xt
X AWIDGETSRC = $(LIBSRC)/Xaw
X OLDXLIBSRC = $(LIBSRC)/oldX
X BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X EXTENSIONSRC = $(TOP)/extensions
X EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
X XLIB = $(XLIBSRC)/libX11.a
X XMULIB = $(XMUSRC)/libXmu.a
X OLDXLIB = $(OLDXLIBSRC)/liboldX.a
X XTOOLLIB = $(TOOLKITSRC)/libXt.a
X XAWLIB = $(AWIDGETSRC)/libXaw.a
X LINTXLIB = $(XLIBSRC)/llib-lX11.ln
X LINTXMU = $(XMUSRC)/llib-lXmu.ln
X LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
X LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
X INCLUDES = -I$(TOP)
X MACROFILE = Mips.macros
X ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X IMAKE_DEFINES =
X IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X -s Makefile $(IMAKE_DEFINES)
X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X .emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules: $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X CDEBUGFLAGS = -g
X
X UTIL_DEFINES = -DDEBUG_ON -DENTRY_TRACKING_ON -DASSERTIONS_ON
X
X DEBUGSRC = xrDebug.c
X DEBUGOBJ = xrDebug.o
X LOCAL_LIBRARIES = ../lib/librooms.a ../utils/libutils.a
X# SRCS = xrooms.c xrGen.c xrApp.c ScrollW.c Column.c $(DEBUGSRC)
X# OBJS = xrooms.o xrGen.o xrApp.o ScrollW.o Column.o $(DEBUGOBJ)
X
X UISRCS = xrXawUI.c xrXawRoom.c
X UIOBJS = xrXawUI.o xrXawRoom.o
X UILIBS = -lXaw -lXmu -lXt
X UIDEFS = -DXAW
X
X VERSIONLIBS = -lXext
X VERSIONDEFS = -DX11R4
X
X STAMPDEFS = -DCOMPILE_STAMP="\"`date` (`whoami`)\""
X
X SRCS = xrMain.c xrSetup.c \
X xrGen.c xrApp.c $(UISRCS) xrNames.c xrProfile.c\
X xrProto.c xrProtoArgs.c xrProtoIter.c xrDoProto.c \
X xrActions.c \
X xrXUtils.c $(DEBUGSRC)
X OBJS = xrMain.o xrSetup.o \
X xrGen.o xrApp.o $(UIOBJS) xrNames.o xrProfile.o\
X xrProto.o xrProtoArgs.o xrProtoIter.o xrDoProto.o \
X xrActions.o \
X xrXUtils.o $(DEBUGOBJ)
X PROGRAMS = xrooms
X INCLUDES = -I../utils -I../lib -I. -I$(TOP) -I$(TOP)/X11
XSYSLAST_LIBRARIES = $(UILIBS) -lX11 -lm $(VERSIONLIBS)
X DEFINES = $(UTIL_DEFINES) $(STD_DEFINES) $(UIDEFS) $(VERSIONDEFS)
X
X PROGRAM = xrooms
X
Xall:: xrooms
X
Xxrooms: $(OBJS) $(LOCAL_LIBRARIES)
X $(RM) $@
X $(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X $(RM) $(PROGRAM)
X $(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xrooms
X $(INSTALL) -c $(INSTALLFLAGS) xrooms $(BINDIR)
X
Xinstall.man:: xrooms.man
X $(INSTALL) -c $(INSTMANFLAGS) xrooms.man $(MANDIR)/xrooms.1
X
Xdepend:: $(DEPEND)
X
Xdepend::
X $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X @echo "making $@"; \
X cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X $(RM) $(PROGRAM)
X
XxrMain.o: xrMain.c
X $(RM) $@
X $(CC) -c $(CFLAGS) $(DEFINES) $(STAMPDEFS) $*.c
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X $(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/Imake.rules \
X $(IRULESRC)/site.def \
X $(IRULESRC)/$(MACROFILE)
X - at if [ -f Makefile ]; then \
X echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X else exit 0; fi
X $(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X @echo "making $@"; \
X cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
X
Xtags::
X $(TAGS) -w *.[ch]
X $(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X @echo "install done"
X
Xinstall.man::
X @echo "install.man done"
X
XMakefiles::
X
END_OF_FILE
if test 8128 -ne `wc -c <'./xrooms/Makefile'`; then
echo shar: \"'./xrooms/Makefile'\" unpacked with wrong size!
fi
# end of './xrooms/Makefile'
fi
if test -f './xrooms/xrDebug.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./xrooms/xrDebug.c'\"
else
echo shar: Extracting \"'./xrooms/xrDebug.c'\" \(8564 characters\)
sed "s/^X//" >'./xrooms/xrDebug.c' <<'END_OF_FILE'
X
X /*\
X * $Header: xrDebug.c,v 5.1 90/01/11 14:11: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#include <ctype.h>
X#define DEBUG_VAR xrdebugDebug
X#include "utils.h"
X#include "strtbl.h"
X#include "profile.h"
X#include "rooms.h"
X#include "apps.h"
X#include "names.h"
X#include "nameprof.h"
X
Xextern unsigned listDebug,hashDebug,regexDebug,strtblDebug;
Xextern unsigned appDebug,roomDebug;
Xextern unsigned xroomsDebug,xrgenDebug;
Xextern unsigned parserDebug,scanDebug;
X
Xextern void DebugPrintRooms(/* name */);
Xextern void DebugPrintApps(/* name */);
Xextern void DebugPrintProfiles(/* name */);
X
X/***====================================================================***/
X
Xextern unsigned xrAppDebug,xrdpDebug,xrRoomDebug,xruiDebug;
Xextern unsigned xrgenDebug,xrMainDebug,xrNamesDebug,xrProfileDebug;
Xextern unsigned xrprDebug,xrpaDebug,xrSetupDebug,xruDebug,xrdebugDebug;
X
Xvoid
XxrDumpDebugVars()
X{
X uDebug("hashDebug= 0x%x\n",hashDebug);
X uDebug("listDebug= 0x%x\n",listDebug);
X uDebug("regexDebug= 0x%x\n",regexDebug);
X uDebug("strtblDebug= 0x%x\n",strtblDebug);
X uDebug("asDebug= 0x%x\n",asDebug);
X uDebug("appDebug= 0x%x\n",appDebug);
X uDebug("roomDebug= 0x%x\n",roomDebug);
X uDebug("profileDebug= 0x%x\n",profileDebug);
X uDebug("namesDebug= 0x%x\n",namesDebug);
X uDebug("parserDebug= 0x%x\n",parserDebug);
X uDebug("scanDebug= 0x%x\n",scanDebug);
X uDebug("appsDebug= 0x%x\n",appsDebug);
X uDebug("roomsDebug= 0x%x\n",roomsDebug);
X uDebug("xrAppDebug= 0x%x\n",xrAppDebug);
X uDebug("xrdpDebug= 0x%x\n",xrdpDebug);
X uDebug("xrRoomDebug= 0x%x\n",xrRoomDebug);
X uDebug("xruiDebug= 0x%x\n",xruiDebug);
X uDebug("xrgenDebug= 0x%x\n",xrgenDebug);
X uDebug("xrMainDebug= 0x%x\n",xrMainDebug);
X uDebug("xrNamesDebug= 0x%x\n",xrNamesDebug);
X uDebug("xrProfileDebug= 0x%x\n",xrProfileDebug);
X uDebug("xrprDebug= 0x%x\n",xrprDebug);
X uDebug("xrpaDebug= 0x%x\n",xrpaDebug);
X uDebug("xrSetupDebug= 0x%x\n",xrSetupDebug);
X uDebug("xruDebug= 0x%x\n",xruDebug);
X uDebug("xrdebugDebug= 0x%x\n",xrdebugDebug);
X uDebug("xrgenDebug= 0x%x\n",xrgenDebug);
X return;
X}
X
X/***====================================================================***/
X
Xvoid
XxrDebugSet(lhs,rhs)
Xchar *lhs,*rhs;
X{
XBoolean intValue= False;
Xint value;
X
X uENTRY2("xrDebugSet(%s,%s)\n",uStringText(lhs),uStringText(rhs));
X if (sscanf(rhs,"0x%x",&value)==1) intValue= True;
X else if (sscanf(rhs,"%d",&value)==1) intValue= True;
X
X if (intValue) {
X if (uStringEqual(lhs,"hash")) hashDebug= value;
X else if (uStringEqual(lhs,"list")) listDebug= value;
X else if (uStringEqual(lhs,"regex")) regexDebug= value;
X else if (uStringEqual(lhs,"strtbl")) strtblDebug= value;
X else if (uStringEqual(lhs,"appstate")) asDebug= value;
X else if (uStringEqual(lhs,"app")) appDebug= value;
X else if (uStringEqual(lhs,"room")) roomDebug= value;
X else if (uStringEqual(lhs,"profile")) profileDebug= value;
X else if (uStringEqual(lhs,"names")) namesDebug= value;
X else if (uStringEqual(lhs,"nameprof")) nameprofDebug= value;
X else if (uStringEqual(lhs,"parser")) parserDebug= value;
X else if (uStringEqual(lhs,"scan")) scanDebug= value;
X else if (uStringEqual(lhs,"apps")) appsDebug= value;
X else if (uStringEqual(lhs,"rooms")) roomsDebug= value;
X else if (uStringEqual(lhs,"xrapp")) xrAppDebug= value;
X else if (uStringEqual(lhs,"xrdp")) xrdpDebug= value;
X else if (uStringEqual(lhs,"xrroom")) xrRoomDebug= value;
X else if (uStringEqual(lhs,"xrui")) xruiDebug= value;
X else if (uStringEqual(lhs,"xrgen")) xrgenDebug= value;
X else if (uStringEqual(lhs,"xrmain")) xrMainDebug= value;
X else if (uStringEqual(lhs,"xrnames")) xrNamesDebug= value;
X else if (uStringEqual(lhs,"xrprofile")) xrProfileDebug= value;
X else if (uStringEqual(lhs,"xrpr")) xrprDebug= value;
X else if (uStringEqual(lhs,"xrpa")) xrpaDebug= value;
X else if (uStringEqual(lhs,"xrsetup")) xrSetupDebug= value;
X else if (uStringEqual(lhs,"xru")) xruDebug= value;
X else if (uStringEqual(lhs,"xrdebug")) xrdebugDebug= value;
X else if (uStringEqual(lhs,"xrgen")) xrgenDebug= value;
X else if (uStringEqual(lhs,"utils")) {
X listDebug= hashDebug= regexDebug= strtblDebug= value;
X }
X else if (uStringEqual(lhs,"low")) {
X asDebug= value;
X }
X else if (uStringEqual(lhs,"lib")) {
X appDebug= roomDebug= asDebug= value;
X }
X else if (uStringEqual(lhs,"app")) {
X appsDebug= roomsDebug= profileDebug= value;
X namesDebug= nameprofDebug= value;
X scanDebug= parserDebug= value;
X }
X else if (uStringEqual(lhs,"xrooms")) {
X xrAppDebug= xrdpDebug= xrRoomDebug= value;
X xruiDebug= xrgenDebug= xrMainDebug= value;
X xrNamesDebug= xrProfileDebug= value;
X xrprDebug= xrpaDebug= xrSetupDebug= value;
X xruDebug= xrdebugDebug= value;
X }
X else if (uStringEqual(lhs,"all")) {
X listDebug= hashDebug= regexDebug= value;
X strtblDebug= asDebug= value;
X appDebug= roomDebug= asDebug= value;
X appsDebug= roomsDebug= profileDebug= value;
X namesDebug= nameprofDebug= value;
X scanDebug= parserDebug= value;
X xrAppDebug= xrdpDebug= xrRoomDebug= value;
X xruiDebug= xrgenDebug= xrMainDebug= value;
X xrNamesDebug= xrProfileDebug= value;
X xrprDebug= xrpaDebug= xrSetupDebug= value;
X xruDebug= xrdebugDebug= value;
X }
X }
X else {
X if (rhs[0]==NUL) rhs= NullString;
X if (uStringEqual(lhs,"entry")) uSetEntryFile(rhs);
X else if (uStringEqual(lhs,"error")) uSetErrorFile(rhs);
X else if (uStringEqual(lhs,"debug")) uSetDebugFile(rhs);
X else if (uStringEqual(lhs,"message")) uDebug("%s\n",rhs);
X else if (uStringEqual(lhs,"dump")) {
X if (uStringEqual(rhs,"rooms"))
X DebugPrintRooms(NullString);
X else if (uStringEqual(rhs,"apps"))
X DebugPrintApps(NullString);
X else if (uStringEqual(rhs,"xapps"))
X xraDebugPrint();
X else if (uStringPrefix("room-",rhs))
X DebugPrintRooms(rhs+5);
X else if (uStringPrefix("app-",rhs))
X DebugPrintApps(rhs+4);
X else if (uStringEqual(rhs,"all")) {
X DebugPrintRooms(NullString);
X DebugPrintApps(NullString);
X }
X else {
X uDebug("weird dump command %s\n",rhs);
X }
X }
X }
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xchar *
XxrDebugSetting(str)
Xchar *str;
X{
Xchar lhs[256],rhs[256];
Xint len;
X
X uENTRY1("xrDebugSetting(%s)\n",uStringText(str));
X if (str==NullString) {
X uRETURN(NullString);
X }
X while (((*str)!=NUL)&&isspace(*str)) str++;
X for (len=0;((*str)!=NUL)&&(!isspace(*str))&&(*str!='=')&&(len<255);str++) {
X lhs[len++]= *str;
X }
X lhs[len++]= NUL;
X if (*str!='=') {
X while (((*str)!=NUL)&&(isspace(*str))) {
X str++;
X }
X }
X if (*str!='=') {
X uWarning("xrDebugSetting expected '='\n");
X uRETURN(str);
X }
X else str++;
X while (((*str)!=NUL)&&isspace(*str)) str++;
X for (len=0;((*str)!=NUL)&&(!isspace(*str))&&(*str!=',')&&(len<255);str++) {
X rhs[len++]= *str;
X }
X rhs[len++]= NUL;
X xrDebugSet(lhs,rhs);
X uRETURN(str);
X}
X
X/***====================================================================***/
X
Xvoid
XxrDebugSettings(str)
Xchar *str;
X{
X uENTRY1("xrDebugSettings(%s)\n",uStringText(str));
X while (*str!=NUL) {
X while ((*str!=NUL)&&(isspace(*str))) str++;
X if (*str!=NUL) {
X str= xrDebugSetting(str);
X while ((*str!=NUL)&&isspace(*str)) str++;
X if (*str==',') str++;
X }
X }
X if (DEBUG_VAR&8) {
X xrDumpDebugVars();
X }
X uVOIDRETURN;
X}
X
END_OF_FILE
if test 8564 -ne `wc -c <'./xrooms/xrDebug.c'`; then
echo shar: \"'./xrooms/xrDebug.c'\" unpacked with wrong size!
fi
# end of './xrooms/xrDebug.c'
fi
if test -f './xrooms/xrXawRoom.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'./xrooms/xrXawRoom.c'\"
else
echo shar: Extracting \"'./xrooms/xrXawRoom.c'\" \(8252 characters\)
sed "s/^X//" >'./xrooms/xrXawRoom.c' <<'END_OF_FILE'
X
X /*\
X * $Header: xrXawRoom.c,v 5.2 90/01/11 17:09:51 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 <X11/Xos.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xutil.h>
X#include <X11/StringDefs.h>
X#include <X11/cursorfont.h>
X
X#ifdef X11R4
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Form.h>
X#else
X#include <X11/Command.h>
X#include <X11/Form.h>
X#endif
X
X#define BOOLEAN_DEFINED
X#define OPAQUE_DEFINED
X#define DEBUG_VAR xrRoomDebug
X#include "utils.h"
X#include "hash.h"
X
X#include "rooms.h"
X
X#include "xrDebug.h"
X#include "xrXUtils.h"
X#include "xrRoom.h"
X#include "xrooms.h"
X
X#include "xrUI.h"
X#include "xrGen.h"
X#include "xrProto.h"
X
Xstatic Widget xrrInverted= NULL;
Xunsigned xawButtonWidth;
Xunsigned xawButtonCols;
X
X
X/***====================================================================***/
X
X
Xstatic void
XxrrFlipColors(widget)
XWidget widget;
X{
X static Arg arglist[] = {
X {XtNforeground, NULL},
X {XtNbackground, NULL},
X };
X XtArgVal temp;
X
X uENTRY1("FlipColors(0x%x)\n",widget);
X arglist[0].value = arglist[1].value = NULL;
X XtGetValues(widget, arglist, XtNumber(arglist));
X temp = arglist[0].value;
X arglist[0].value = arglist[1].value;
X arglist[1].value = temp;
X XtSetValues(widget, arglist, XtNumber(arglist));
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
X#define MAX_BUTTONS 100
Xstatic Widget buttons[MAX_BUTTONS];
Xstatic int num_buttons = 0;
Xstatic void
XxrrAdjustButtons()
X{
X Widget lasth = NULL, lastv = NULL;
X int each, count = 0;
X static Arg args[] = {
X {XtNfromHoriz, (XtArgVal) NULL},
X {XtNfromVert, (XtArgVal) NULL},
X {XtNhorizDistance, (XtArgVal) 3},
X {XtNvertDistance, (XtArgVal) 3},
X };
X
X for(each=0; each<num_buttons; each++) {
X if (XtIsManaged(buttons[each])) {
X args[0].value = (XtArgVal) lasth;
X args[1].value = (XtArgVal) lastv;
X XtSetValues(buttons[each], args, XtNumber(args));
X if ((++count % xawButtonCols) == 0) {
X lasth = NULL;
X lastv = buttons[each];
X } else {
X lasth = buttons[each];
X }
X }
X }
X
X if (XtIsRealized(xruiScrollW)) {
X /* For some reason, this causes the layout changes to take effect */
X XtSetMappedWhenManaged(xruiMenu, False);
X XtManageChild(xruiMenu);
X XtUnmanageChild(xruiMenu);
X XtSetMappedWhenManaged(xruiMenu, True);
X }
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrManageRoom(pRoom)
XRoomPtr pRoom;
X{
XXRoomInfoPtr pRoomInfo;
X
X uENTRY1("xrrManageRoom(%s)\n",roomText(pRoom));
X if (pRoom!=NullRoom) {
X pRoomInfo= (XRoomInfoPtr)roomGetPrivate(pRoom);
X XtManageChild(pRoomInfo->widget);
X xrrAdjustButtons();
X }
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrInvertButton(widget)
XWidget widget;
X{
X uENTRY1("InvertButton(0x%x)\n",widget);
X xrrInverted = widget;
X xrrFlipColors(widget);
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrUninvertButton()
X{
X uENTRY("xrrUninvertButton()\n");
X if (xrrInverted) xrrFlipColors(xrrInverted);
X xrrInverted= NULL;
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrDoButtonPress(widget, p, data)
XWidget widget;
XOpaque p, data;
X{
XRoomPtr pRoom= (RoomPtr)p;
X
X uENTRY3("xrrDoButtonPress(0x%x,%s,0x%x)\n",widget,roomText(pRoom),data);
X SwitchToRoom(pRoom);
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrUnmanageRoom(pRoom)
XRoomPtr pRoom;
X{
XXRoomInfoPtr pRoomInfo;
X
X uENTRY1("xrrUnmanageRoom(%s)\n",roomText(pRoom));
X if (pRoom!=NullRoom) {
X pRoomInfo= (XRoomInfoPtr)roomGetPrivate(pRoom);
X if (!(roomGetVisibility(pRoom)&roomVisible)) {
X if (pRoomInfo->widget==xrrInverted) {
X xrrUninvertButton();
X }
X XtUnmanageChild(pRoomInfo->widget);
X xrrAdjustButtons();
X }
X }
X
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xextern void xruiHandlePopup();
X
Xstatic Widget
XxrrAddButtonForRoom(pRoom)
XRoomPtr pRoom;
X{
XWidget result= NULL;
Xchar *name;
XXRoomInfoPtr pRoomInfo;
X
X static Arg args[] = {
X {XtNlabel, (XtArgVal) NULL},
X {XtNwidth, (XtArgVal) 0},
X {XtNresizable, (XtArgVal) TRUE},
X {XtNtop, (XtArgVal) XtChainTop},
X {XtNbottom, (XtArgVal) XtChainTop},
X {XtNleft, (XtArgVal) XtChainLeft},
X {XtNright, (XtArgVal) XtChainLeft},
X };
X
X uENTRY1("xrrAddButtonForRoom(%s)\n",roomText(pRoom));
X if (pRoom!=NullRoom) {
X name= stGetString(roomName(pRoom));
X args[0].value = (XtArgVal)name;
X args[1].value = (XtArgVal)xawButtonWidth;
X result = XtCreateWidget(name, commandWidgetClass, xruiScrollW,
X args, XtNumber(args));
X XtAddEventHandler(result,ButtonPressMask,False,xruiHandlePopup,NULL);
X buttons[num_buttons++] = result;
X XtAddCallback(result, XtNcallback, xrrDoButtonPress, pRoom);
X pRoomInfo= uTypedAlloc(XRoomInfoRec);
X if (pRoomInfo!=NullXRoomInfo) {
X pRoomInfo->widget= result;
X pRoomInfo->nameAtom= XInternAtom(xroomsDpy,name,False);
X }
X roomSetPrivate(pRoom,(Opaque)pRoomInfo);
X }
X uRETURN(result);
X}
X
X/***====================================================================***/
X
Xstatic void
XxrrButtonsRearranged()
X{
X uENTRY("xrrButtonsRearranged()\n");
X/* SaveNeeded();*/
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxrrRoomFeedback(pRoom,what,pApp)
XRoomPtr pRoom;
Xunsigned what;
XAppPtr pApp;
X{
XXRoomInfoPtr pRoomInfo;
X
X uENTRY3("xrrRoomFeedback(%s,%d,%s)\n",roomText(pRoom),what,appText(pApp));
X pRoomInfo= (XRoomInfoPtr)roomGetPrivate(pRoom);
X switch (what) {
X case roomFBCreated:
X if (pRoomInfo==NullXRoomInfo) {
X xrrAddButtonForRoom(pRoom);
X xrpUpdateAllRooms(xroomsDpy,xroomsRealRoot);
X }
X break;
X case roomFBDestroyed:
X if (pRoomInfo!=NullXRoomInfo) {
X xrrUnmanageRoom(pRoom);
X uFree((Opaque)pRoomInfo);
X xrpUpdateAllRooms(xroomsDpy,xroomsRealRoot);
X }
X break;
X case roomFBVisible:
X xrrManageRoom(pRoom);
X xrpUpdateAllRooms(xroomsDpy,xroomsRealRoot);
X break;
X case roomFBHidden:
X if (pRoom==GetCurrentRoom())
X SwitchToRoom(xruiFindDefaultRoom());
X xrrUnmanageRoom(pRoom);
X xrpUpdateAllRooms(xroomsDpy,xroomsRealRoot);
X break;
X case roomFBActivated:
X if (xrrInverted!=NULL) xrrUninvertButton();
X if (pRoomInfo!=NullXRoomInfo) {
X if (roomIsVisible(pRoom)) {
X xrrInvertButton(pRoomInfo->widget);
X }
X xrpSetCurrent(xroomsDpy,xroomsRealRoot,pRoomInfo->nameAtom);
X }
X uDEBUG1(WATCH_EVENTS,"Switching to room %s\n",roomText(pRoom));
X break;
X case roomFBDeactivated:
X if (pRoomInfo!=NullXRoomInfo) {
X if (roomIsVisible(pRoom)) {
X xrrUninvertButton();
X }
X }
X break;
X }
X uVOIDRETURN;
X}
X
X/***====================================================================***/
X
XOpaque
XxrrInit(parent)
XWidget parent;
X{
X uENTRY1("xrrInit(0x%x)\n",parent);
X SetDefaultRoomFeedback(xrrRoomFeedback);
X uRETURN((Opaque)parent);
X}
END_OF_FILE
if test 8252 -ne `wc -c <'./xrooms/xrXawRoom.c'`; then
echo shar: \"'./xrooms/xrXawRoom.c'\" unpacked with wrong size!
fi
# end of './xrooms/xrXawRoom.c'
fi
echo shar: End of archive 5 \(of 14\).
cp /dev/null ark5isdone
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