[465] in Zephyr_Bugs
[Steve Smoot: Re: [daemon@ATHENA.MIT.EDU : zwgc for Sun 3?] ]
daemon@ATHENA.MIT.EDU (John T Kohl)
Fri Apr 9 15:12:55 1993
Date: Fri, 9 Apr 1993 15:12:23 -0400
From: John T Kohl <jtkohl@zk3.dec.com>
To: zephyr-bugs@MIT.EDU, marc@MIT.EDU
Here are some patches we found necessary when compiling on the
sun3/sun4. They should be relative to the "unofficial" package on
athena-dist.
------- Forwarded Message
To: John T Kohl <jtkohl@Athena.MIT.EDU>
Reply-To: smoot@cs.berkeley.edu (Steve Smoot)
Subject: Re: [daemon@ATHENA.MIT.EDU : zwgc for Sun 3?]
In-Reply-To: Your message of "Tue, 23 Mar 93 23:25:54 PST."
<9303240425.AA11927@vongole>
Date: Mon, 29 Mar 93 18:12:19 PST
From: Steve Smoot <smoot@gumby.cs.Berkeley.EDU>
Here is zwgc/RCS
-s
#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Imakefile,v
# X_gram.c,v
# main.c,v
# zephyr.vars,v
# zwgc.desc,v
# This archive created: Mon Mar 29 18:12:21 1993
export PATH; PATH=/bin:$PATH
if test -f 'Imakefile,v'
then
echo shar: over-writing existing file "'Imakefile,v'"
fi
cat << \SHAR_EOF > 'Imakefile,v'
head 1.14;
access;
symbols;
locks; strict;
comment @# @;
1.14
date 92.09.15.16.59.06; author jtkohl; state Exp;
branches;
next 1.13;
1.13
date 92.09.08.23.52.20; author jtkohl; state Exp;
branches;
next 1.12;
1.12
date 92.03.03.20.20.42; author lwvanels; state Exp;
branches;
next ;
desc
@Imakefile
@
1.14
log
@fix install pathname for zephyr.vars
@
text
@/**/# Copyright 1988 Massachusetts Institute of Technology.
/**/#
/**/# For copying and distribution information, see the file
/**/# "mit-copyright.h".
/**/#
/**/# $Source: /usr/sww/share/src/Zephyr/src/zwgc/RCS/Imakefile,v $
/**/# $Author: jtkohl $
/**/# $Id: Imakefile,v 1.13 1992/09/08 23:52:20 jtkohl Exp jtkohl $
/**/#
SUBDIRS= Memory String Dictionary
#ifdef macII
LIBS2= -lc -lPW
#endif
LIBS = $(X11_LIB) $(ZEPHYR_LIB) $(KRB_LIB) $(DES_LIB) $(COMERR_LIB) -ltermcap \
$(LIBS2)
LINTLIBS = $(X11_LINTLIB) $(ZEPHYR_LINTLIB) $(KRB_LINTLIB) $(DES_LINTLIB) \
$(COMERR_LINTLIB) -ltermcap
SRCS = parser.y lexer.c node.c exec.c buffer.c main.c zephyr.c X_driver.c\
substitute.c port.c xshow.c \
mux.c eval.c subscriptions.c notice.c xcut.c regexp.c\
character_class.c text_operations.c file.c error.c variables.c\
formatter.c X_fonts.c X_gram.c tty_filter.c standard_ports.c\
xselect.c xmark.c xrevstack.c xerror.c
OBJS = parser.o lexer.o node.o exec.o buffer.o main.o zephyr.o X_driver.o\
substitute.o port_dictionary.o port.o xshow.o pointer_dictionary.o\
mux.o eval.o subscriptions.o notice.o xcut.o regexp.o\
character_class.o text_operations.o file.o error.o variables.o\
formatter.o X_fonts.o X_gram.o tty_filter.o standard_ports.o\
xselect.o xmark.o xrevstack.o xerror.o ulong_dictionary.o
HDRS = exec.h node.h zwgc.h parser.h port.h\
xshow.h pointer.h substitute.h eval.h zephyr.h lexer.h\
subscriptions.h notice.h regexp.h character_class.h\
text_operations.h file.h error.h mux.h variables.h\
formatter.h main.h\
X_driver.h X_fonts.h X_gram.h xselect.h \
buffer.h xmark.h xrevstack.h xerror.h ulong.h
LINCLUDES = -IMemory -IString -IDictionary
GENERATORS= ./generate_stack_instance stack.h
SRCDIR= ${SRCTOP}/zwgc
CONFIG_FILES= zwgc.desc zephyr.vars zwgc_resources
CODE= ${GENERATORS} ${HDRS} ${SRCS} ${CONFIG_FILES} Imakefile
LIB=.
LIBRARIES = $(LIB)/String/new_string.o $(LIB)/Dictionary/string_dictionary.o\
$(LIB)/Dictionary/string_dictionary_aux.o\
$(LIB)/Dictionary/int_dictionary.o\
$(LIB)/Memory/new_memory.o
GENERATED= port_dictionary.c port_dictionary.h \
pointer_dictionary.c pointer_dictionary.h \
ulong_dictionary.c ulong_dictionary.h \
char_stack.h \
string_stack.h \
xmode_stack.h
# y.tab.h y.tab.c
DEPENDSRCS= ${CODE} ${GENERATED}
/*
* The pathnames for the installed default description file & applications
* default file.
*/
ZWGCDESC=$(DESCDIR)/zwgc.desc
APPDEF=$(DESCDIR)/zwgc_resources
DEFINES=-DREVSTACK -DDEFDESC=\"$(ZWGCDESC)\" -DAPPDEFDATABASE=\"$(APPDEF)\" \
-DZWGCPATH=\"$(CLIENTDIR)/zwgc\"
normal_obj_rule()
OUTPUT=zwgc
do_subdirs($(SUBDIRS)) /* gotta do the subdirs first! */
program($(OUTPUT),$(OBJS),,$(LIBRARIES) $(LIBS),$(CLIENTDIR))
#ifdef ATHENA_COMPAT
/* On Athena, zwgc has been in /usr/etc on VAXes and RTs and some people
run in with a full pathname. For compatbility, make a link. */
install::
$(RM) $(DESTDIR)/usr/etc/zwgc
ln $(DESTDIR)$(CLIENTDIR)/zwgc $(DESTDIR)/usr/etc/zwgc || ln -s $(CLIENTDIR)/zwgc $(DESTDIR)/usr/etc/zwgc
#endif
depend:: ${DEPENDSRCS}
install::
-mkdir $(DESTDIR)$(DESCDIR)
$(INSTALLFILE) zwgc.desc $(DESTDIR)$(DESCDIR)/zwgc.desc
$(INSTALLFILE) zephyr.vars $(DESTDIR)$(DESCDIR)/zephyr.vars
$(INSTALLFILE) zwgc_resources $(DESTDIR)$(DESCDIR)/zwgc_resources
YFLAGS=-d
y.tab.h: parser.o
# use implicit yacc rule for the following:
parser.o: parser.y
#
# /* How to generate a port dictionary: */
#
port_dictionary.c port_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h
Dictionary/generate_dictionary_instance ${SRCDIR}/Dictionary port port.h
#
# /* How to generate a pointer dictionary: */
#
pointer_dictionary.c pointer_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h
Dictionary/generate_dictionary_instance ${SRCDIR}/Dictionary pointer pointer.h
#
# /* How to generate a ulong dictionary: */
#
ulong_dictionary.c ulong_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h
Dictionary/generate_dictionary_instance ${SRCDIR}/Dictionary ulong ulong.h
#
# /* How to generate a char stack: */
#
char_stack.h: stack.h
./generate_stack_instance ${SRCDIR} char
#
# /* How to generate a string stack: */
#
string_stack.h: stack.h
./generate_stack_instance ${SRCDIR} string
#
# /* How to generate a xmode stack: */
#
xmode_stack.h: stack.h
./generate_stack_instance ${SRCDIR} xmode
@
1.13
log
@fix DESCDIR
fix dependencies for yacc gunk
@
text
@d6 3
a8 3
/**/# $Source: /private/jtkohl/src/zephyr/src/zwgc/RCS/Imakefile,v $
/**/# $Author: lwvanels $
/**/# $Id: Imakefile,v 1.12 1992/03/03 20:20:42 lwvanels Exp jtkohl $
d92 4
a95 8
-mkdir $(DESTDIR)$(ACLDIR)
$(RM) $(DESTDIR)$(ACLDIR)/zwgc.desc
$(CP) zwgc.desc $(DESTDIR)$(ACLDIR)/zwgc.desc
$(CHMOD) 644 $(DESTDIR)$(ACLDIR)/zwgc.desc
$(RM) $(DESTDIR)$(ETCATHDIR)/zephyr.vars
$(CP) zephyr.vars $(DESTDIR)$(ETCATHDIR)/zephyr.vars
$(RM) $(DESTDIR)$(ACLDIR)/zwgc_resources
$(CP) zwgc_resources $(DESTDIR)$(ACLDIR)/zwgc_resources
@
1.12
log
@checked in with -k by jtkohl at 1992/08/17 21:19:50
@
text
@d6 1
a6 1
/**/# $Source: /mit/zephyr/src/zwgc/RCS/Imakefile,v $
d8 1
a8 1
/**/# $Id: Imakefile,v 1.12 1992/03/03 20:20:42 lwvanels Exp $
d57 2
a58 2
xmode_stack.h \
y.tab.h y.tab.c
d67 2
a68 2
ZWGCDESC=$(ACLDIR)/zwgc.desc
APPDEF=$(ACLDIR)/zwgc_resources
@
SHAR_EOF
if test -f 'X_gram.c,v'
then
echo shar: over-writing existing file "'X_gram.c,v'"
fi
cat << \SHAR_EOF > 'X_gram.c,v'
head 1.17;
access;
symbols;
locks; strict;
comment @ * @;
1.17
date 92.05.07.22.37.55; author marc; state Exp;
branches
1.17.1.1;
next ;
1.17.1.1
date 92.10.08.18.25.20; author jtkohl; state Exp;
branches;
next ;
desc
@X_gram.c
@
1.17
log
@checked in with -k by jtkohl at 1992/10/08 18:24:17
@
text
@/* This file is part of the Project Athena Zephyr Notification System.
* It is one of the source files comprising zwgc, the Zephyr WindowGram
* client.
*
* Created by: Marc Horowitz <marc@@athena.mit.edu>
*
* $Source: /afs/athena.mit.edu/astaff/project/zephyr/src/zwgc/RCS/X_gram.c,v $
* $Author: marc $
*
* Copyright (c) 1989 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#if (!defined(lint) && !defined(SABER))
static char rcsid_X_gram_c[] = "$Id: X_gram.c,v 1.17 1992/05/07 22:37:55 marc Exp $";
#endif
#include <zephyr/mit-copyright.h>
#include "X_gram.h"
#include "xmark.h"
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include "zwgc.h"
#include "X_driver.h"
#include "X_fonts.h"
#include "error.h"
#include "new_string.h"
#include "xrevstack.h"
#include "xerror.h"
#include "xselect.h"
extern XContext desc_context;
extern char *app_instance;
extern unsigned long x_string_to_color();
extern char *getenv();
/*
*
*/
int internal_border_width = 2;
unsigned long default_fgcolor;
unsigned long default_bgcolor;
unsigned long default_bordercolor;
long ttl = 0;
static int reset_saver;
static int border_width = 1;
static int cursor_code = XC_sailboat;
static int set_transient;
static int enable_delete;
static char *title_name,*icon_name;
static Cursor cursor;
static Window group_leader; /* In order to have transient windows,
* I need a top-level window to always exist
*/
static XClassHint classhint;
static XSetWindowAttributes xattributes;
static unsigned long xattributes_mask;
/* ICCCM note:
*
* the following properties must be set on all top-level windows:
*
* WM_NAME XStoreName(dpy,w,name);
* WM_ICON_NAME XSetIconName(dpy,w,name);
* WM_NORMAL_HINTS XSetNormalHints(dpy,w,sizehints);
* WM_HINTS XSetWMHints(dpy,w,wmhints);
* WM_CLASS XSetClassHint(dpy,w,classhint);
*
* and for individual zgrams:
*
* WM_TRANSIENT_FOR XSetTransientForHint(dpy,w,main_window);
* WM_PROTOCOLS XSetWMProtocols(dpy,w,protocols,cnt);
*/
/* set all properties defined in ICCCM. If main_window == 0,
* per-zgram initialization is not done.
*/
/*ARGSUSED*/
void x_set_icccm_hints(dpy,w,name,icon_name,psizehints,pwmhints,main_window)
Display *dpy;
Window w;
char *name;
char *icon_name;
XSizeHints *psizehints;
XWMHints *pwmhints;
Window main_window;
{
XStoreName(dpy,w,name);
XSetIconName(dpy,w,icon_name);
XSetNormalHints(dpy,w,psizehints);
XSetWMHints(dpy,w,pwmhints);
XSetClassHint(dpy,w,&classhint);
/* in order for some wm's to iconify, the window shouldn't be transient.
e.g. Motif wm */
if (main_window != None) {
if (set_transient)
XSetTransientForHint(dpy,w,main_window);
if (enable_delete)
XSetWMProtocols(dpy,w,&XA_WM_DELETE_WINDOW,1);
}
}
void x_gram_init(dpy)
Display *dpy;
{
char *temp;
XSizeHints sizehints;
XWMHints wmhints;
unsigned long rv,tc;
default_fgcolor = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
default_bgcolor = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
rv = get_bool_resource("reverseVideo", "ReverseVideo", 0);
if (rv) {
tc = default_fgcolor;
default_fgcolor = default_bgcolor;
default_bgcolor = tc;
}
if (temp = get_string_resource("foreground","Foreground"))
default_fgcolor = x_string_to_color(temp,default_fgcolor);
if (temp = get_string_resource("background","Background"))
default_bgcolor = x_string_to_color(temp,default_bgcolor);
default_bordercolor = default_fgcolor;
if (temp = get_string_resource("borderColor","BorderColor"))
default_bordercolor = x_string_to_color(temp,default_bordercolor);
temp = get_string_resource("minTimeToLive","MinTimeToLive");
if (temp && atoi(temp)>=0)
ttl = atoi(temp);
reverse_stack = get_bool_resource("reverseStack", "ReverseStack", 0);
reset_saver = get_bool_resource("resetSaver", "ResetSaver", 1);
/* The default here should be 1, but mwm sucks */
set_transient = get_bool_resource("transient", "Transient", 0);
/* This should go away, or become default 1, after a release cycle */
enable_delete = get_bool_resource("enableDelete", "EnableDelete", 0);
temp = get_string_resource("borderWidth", "BorderWidth");
/* <<<>>> */
if (temp && atoi(temp)>=0)
border_width = atoi(temp);
temp = get_string_resource("internalBorder", "InternalBorder");
/* <<<>>> */
if (temp && atoi(temp)>=0)
internal_border_width = atoi(temp);
temp = get_string_resource("cursorCode", "CursorCode");
/* <<<>>> */
if (temp && atoi(temp))
cursor_code = atoi(temp);
cursor = XCreateFontCursor(dpy, cursor_code);
if (!cursor)
cursor = XCreateFontCursor(dpy, XC_sailboat);
temp = get_string_resource("pointerColor", "Foreground");
if (temp) {
char *temp2;
XColor cursor_fore, cursor_back;
/* XXX need to do our own parsing here, since the RecolorCursor
routine requires an XColor, not an unsigned long (pixel) */
if (!(temp2 = get_string_resource("background","Background"))) {
if (default_bgcolor == WhitePixelOfScreen(DefaultScreenOfDisplay(dpy)))
temp2 = "white";
else
temp2 = "black";
}
if (XParseColor(dpy,
DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
temp, &cursor_fore) &&
XParseColor(dpy,
DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
temp2, &cursor_back)) {
XRecolorCursor(dpy, cursor, &cursor_fore, &cursor_back);
}
}
if (!(title_name=get_string_resource("title","Title")))
if (!(title_name=get_string_resource("name","Name")))
title_name=app_instance;
if (!(icon_name=get_string_resource("iconName","IconName")))
if (!(icon_name=get_string_resource("name","Name")))
icon_name=app_instance;
if (!(temp=get_string_resource("name","Name")))
if (!(temp=(char *) getenv("RESOURCE_NAME")))
temp=app_instance;
classhint.res_name=string_Copy(temp);
classhint.res_class="Zwgc";
if (set_transient) {
group_leader=XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,100,100,
0,default_bordercolor,default_bgcolor);
sizehints.x = 0;
sizehints.y = 0;
sizehints.width = 100;
sizehints.height = 100;
sizehints.flags = PPosition | PSize;
wmhints.input = False;
wmhints.initial_state = DontCareState;
wmhints.flags = InputHint | StateHint;
x_set_icccm_hints(dpy,group_leader,"ZwgcGroup","ZwgcGroup",&sizehints,
&wmhints,0);
}
xattributes.border_pixel = default_bordercolor;
xattributes.cursor = cursor;
xattributes.event_mask = (ExposureMask|ButtonReleaseMask|ButtonPressMask
|LeaveWindowMask|Button1MotionMask
|Button3MotionMask|StructureNotifyMask);
xattributes_mask = (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor);
temp = get_string_resource ("backingStore", "BackingStore");
if (!temp)
return;
xattributes_mask |= CWBackingStore;
if (!strcasecmp (temp, "notuseful"))
xattributes.backing_store = NotUseful;
else if (!strcasecmp (temp, "whenmapped"))
xattributes.backing_store = WhenMapped;
else if (!strcasecmp (temp, "always"))
xattributes.backing_store = Always;
else if (!strcasecmp (temp, "default"))
xattributes_mask &= ~CWBackingStore;
else {
switch (get_bool_resource ("backingStore", "BackingStore", -1)) {
case 0:
xattributes.backing_store = NotUseful;
break;
case 1:
xattributes.backing_store = WhenMapped;
break;
case -1:
fprintf (stderr,
"zwgc: Cannot interpret backing-store resource value `%s'.\n",
temp);
xattributes_mask &= ~CWBackingStore;
break;
}
}
}
void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
beepcount)
Display *dpy;
x_gram *gram;
int xalign, yalign;
int xpos, ypos;
int xsize, ysize;
int beepcount;
{
Window w;
XSizeHints sizehints;
XWMHints wmhints;
XSetWindowAttributes attributes;
extern void x_get_input();
/*
* Adjust xpos, ypos based on the alignments xalign, yalign and the sizes:
*/
if (xalign<0)
xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xpos - xsize
- 2*border_width;
else if (xalign == 0)
xpos = (WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
- 2*border_width)>>1 + xpos;
if (yalign<0)
ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ypos - ysize
- 2*border_width;
else if (yalign == 0)
ypos = (HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
- 2*border_width)>>1 + ypos;
/*
* Create the window:
*/
attributes = xattributes;
attributes.background_pixel = gram->bgcolor;
gram->w = w = XCreateWindow (dpy, DefaultRootWindow (dpy), xpos, ypos,
xsize, ysize, border_width, 0,
CopyFromParent, CopyFromParent,
xattributes_mask, &attributes);
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = xsize;
sizehints.height = ysize;
sizehints.flags = USPosition|USSize;
wmhints.input = True;
wmhints.initial_state = NormalState;
if (set_transient) {
wmhints.window_group = group_leader;
wmhints.flags = InputHint | StateHint | WindowGroupHint;
x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,
group_leader);
} else {
wmhints.flags = InputHint | StateHint;
x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,0);
}
XSaveContext(dpy, w, desc_context, (caddr_t)gram);
gram->can_die.tv_sec = 0;
XMapWindow(dpy, w);
if (beepcount)
XBell(dpy, 0);
xerror_happened = 0;
if (reverse_stack && bottom_gram) {
XWindowChanges winchanges;
winchanges.sibling=bottom_gram->w;
winchanges.stack_mode=Below;
begin_xerror_trap (dpy);
XReconfigureWMWindow (dpy, w, DefaultScreen (dpy),
CWSibling|CWStackMode, &winchanges);
end_xerror_trap (dpy);
if (xerror_happened) {
/* The event didn't go. Print an error message, and continue. */
ERROR ("Error configuring window to the bottom of the stack.\n");
}
}
/* we always need to keep a linked list of windows */
add_to_bottom(gram);
if (xerror_happened)
pull_to_top(gram);
if (reset_saver)
XResetScreenSaver(dpy);
XFlush(dpy);
/* Because the flushing/syncing/etc with the error trapping can cause
events to be read into the Xlib queue, we need to go through the queue
here before exiting so that any pending events get processed.
*/
x_get_input(dpy);
}
void x_gram_draw(dpy, w, gram, region)
Display *dpy;
Window w;
x_gram *gram;
Region region;
{
int i;
GC gc;
XGCValues gcvals;
xblock *xb;
XTextItem text;
int startblock,endblock,startpixel,endpixel;
#define SetFG(fg) \
gcvals.foreground=fg; \
XChangeGC(dpy,gc,GCForeground,&gcvals)
gc = XCreateGC(dpy, w, 0, &gcvals);
XSetRegion(dpy,gc,region);
if ((markgram == gram) && (STARTBLOCK != -1) && (ENDBLOCK != -1)) {
if (xmarkSecond() == XMARK_END_BOUND) {
startblock=STARTBLOCK;
endblock=ENDBLOCK;
startpixel=STARTPIXEL;
endpixel=ENDPIXEL;
} else {
startblock=ENDBLOCK;
endblock=STARTBLOCK;
startpixel=ENDPIXEL;
endpixel=STARTPIXEL;
}
} else {
startblock = -1;
endblock = -1;
}
for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
if (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
xb->y2-xb->y1) != RectangleOut) {
if (i==startblock) {
if (i==endblock) {
SetFG(gram->bgcolor);
XFillRectangle(dpy,w,gc,xb->x1,xb->y1,startpixel,
(xb->y2-xb->y1));
SetFG(xb->fgcolor);
XFillRectangle(dpy,w,gc,xb->x1+startpixel,xb->y1,
(endpixel-startpixel),(xb->y2-xb->y1));
SetFG(gram->bgcolor);
XFillRectangle(dpy,w,gc,xb->x1+endpixel,xb->y1,
(xb->x2-xb->x1-endpixel),(xb->y2-xb->y1));
} else {
SetFG(gram->bgcolor);
XFillRectangle(dpy,w,gc,xb->x1,xb->y1,startpixel,
(xb->y2-xb->y1));
SetFG(xb->fgcolor);
XFillRectangle(dpy,w,gc,xb->x1+startpixel,xb->y1,
(xb->x2-xb->x1-startpixel),(xb->y2-xb->y1));
}
} else if (i==endblock) {
SetFG(xb->fgcolor);
XFillRectangle(dpy,w,gc,xb->x1,xb->y1,endpixel,
(xb->y2-xb->y1));
SetFG(gram->bgcolor);
XFillRectangle(dpy,w,gc,xb->x1+endpixel,xb->y1,
(xb->x2-xb->x1-endpixel),(xb->y2-xb->y1));
} else {
if ((startblock < i) && (i < endblock)) {
SetFG(xb->fgcolor);
} else {
SetFG(gram->bgcolor);
}
XFillRectangle(dpy,w,gc,xb->x1,xb->y1,(xb->x2-xb->x1),
(xb->y2-xb->y1));
}
}
}
gcvals.function=GXxor;
XChangeGC(dpy,gc,GCFunction,&gcvals);
for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
if (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
xb->y2-xb->y1) != RectangleOut) {
SetFG(gram->bgcolor^xb->fgcolor);
text.chars=gram->text+xb->strindex;
text.nchars=xb->strlen;
text.delta=0;
text.font=xb->fid;
XDrawText(dpy,w,gc,xb->x,xb->y,&text,1);
}
}
XFreeGC(dpy,gc);
}
void x_gram_expose(dpy,w,gram,event)
Display *dpy;
Window w;
x_gram *gram;
XExposeEvent *event;
{
static Region region;
static int partregion;
XRectangle rect;
rect.x = (short) event->x;
rect.y = (short) event->y;
rect.width = (unsigned short) event->width;
rect.height = (unsigned short) event->height;
#ifdef MARK_DEBUG
printf("----- xeventExpose:\nx=%d y=%d w=%d h=%d\n-----",
event->x,event->y,event->width,event->height);
#endif
if (! partregion) {
region=XCreateRegion();
partregion = 1;
}
if (rect.width && rect.height) XUnionRectWithRegion(&rect,region,region);
if (event->count == 0) {
x_gram_draw(dpy,w,gram,region);
partregion = 0;
XDestroyRegion(region);
}
}
@
1.17.1.1
log
@<dglo>'s mods for tvtwm. Still ought to test vs. other wm's
@
text
@d7 1
a7 1
* $Source: /usr/sww/share/src/Zephyr/src/zwgc/RCS/X_gram.c,v $
d16 1
a16 1
static char rcsid_X_gram_c[] = "$Id: X_gram.c,v 1.17 1992/05/07 22:37:55 marc Exp jtkohl $";
d296 1
a296 1
sizehints.flags = PPosition|PSize;
@
SHAR_EOF
if test -f 'main.c,v'
then
echo shar: over-writing existing file "'main.c,v'"
fi
cat << \SHAR_EOF > 'main.c,v'
head 1.23;
access;
symbols
BASE:1.23;
locks; strict;
comment @ * @;
1.23
date 92.04.16.19.11.03; author marc; state Exp;
branches
1.23.1.1;
next ;
1.23.1.1
date 92.09.14.22.33.41; author jtkohl; state Exp;
branches;
next ;
desc
@main.c
@
1.23
log
@checked in with -k by jtkohl at 1992/09/14 22:30:28
@
text
@/* This file is part of the Project Athena Zephyr Notification System.
* It is one of the source files comprising zwgc, the Zephyr WindowGram
* client.
*
* Created by: Marc Horowitz <marc@@athena.mit.edu>
*
* $Source: /mit/zephyr/src.rw/zwgc/RCS/main.c,v $
* $Author: marc $
*
* Copyright (c) 1989 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#if (!defined(lint) && !defined(SABER))
static char rcsid_main_c[] = "$Id: main.c,v 1.23 1992/04/16 19:11:03 marc Exp $";
#endif
#include <zephyr/mit-copyright.h>
#include <stdio.h>
#include <signal.h>
#include <zephyr/zephyr.h>
#include "new_memory.h"
#include "zwgc.h"
#include "parser.h"
#include "node.h"
#include "exec.h"
#include "zephyr.h"
#include "notice.h"
#include "subscriptions.h"
#include "file.h"
#include "mux.h"
#include "port.h"
#include "variables.h"
#include "main.h"
extern void notice_handler();
static void setup_signals(), detach();
/*
* Global zwgc-wide variables:
*/
#ifdef DEBUG
int zwgc_debug = 0;
#endif
static char *zwgc_version_string = "0.4.5";
/*
* description_filename_override - <<<>>>
*/
static char *description_filename_override = NULL;
/*
* subscriptions_filename_override - <<<>>> export!
*/
char *subscriptions_filename_override = NULL;
/****************************************************************************/
/* */
/* Code to deal with reading in the description file: */
/* */
/****************************************************************************/
/*
* program - this holds a pointer to the node representation of the
* description file once it has been read in.
*/
static struct _Node *program = NULL;
/*
* <<<>>>
*/
static void fake_startup_packet()
{
ZNotice_t notice;
struct timezone tz;
char msgbuf[BUFSIZ];
var_set_variable("version", zwgc_version_string);
bzero(¬ice, sizeof(notice));
notice.z_version = "";
notice.z_class = "WG_CTL_CLASS";
notice.z_class_inst = "WG_CTL_USER<<<>>>";
notice.z_opcode = "WG_STARTUP";
notice.z_default_format = "Zwgc mark II version $version now running...\n";
notice.z_recipient = "";
notice.z_sender = "ZWGC";
gettimeofday(¬ice.z_time,&tz);
notice.z_port = 0;
notice.z_kind = ACKED;
notice.z_auth = ZAUTH_YES;
sprintf(msgbuf,"Zwgc mark II version %s now running...",
zwgc_version_string);
notice.z_message = msgbuf;
notice.z_message_len = strlen(notice.z_message)+1;
notice_handler(¬ice);
}
static void read_in_description_file()
{
FILE *input_file;
/* var_clear_all_variables(); <<<>>> */
input_file = locate_file(description_filename_override, USRDESC, DEFDESC);
if (input_file)
program = parse_file(input_file);
else
program = NULL;
fake_startup_packet();
}
/****************************************************************************/
/* */
/* Code to deal with argument parsing & overall control: */
/* */
/****************************************************************************/
/*
* void usage()
* Effects: Prints out an usage message on stderr then exits the
* program with error code 1.
*/
void usage()
{
#ifdef DEBUG
fprintf(stderr, "\
zwgc: usage: zwgc [-debug] [-f <filename>] [-subfile <filename>]\n\
[-ttymode] [-nofork] [-reenter]\n\
[-default <driver>] {-disable <driver>}*\n\
[output driver options]\n");
#else
fprintf(stderr, "\
zwgc: usage: zwgc [-f <filename>] [-subfile <filename>]\n\
[-ttymode] [-nofork] [-reenter]\n\
[-default <driver>] {-disable <driver>}*\n\
[output driver options]\n");
#endif
exit(1);
}
/*
* <<<>>>
*/
static void run_initprogs()
{
/*
* This code stolen from old zwgc: yuck. Clean up & fix. <<<>>>
* Should this fork instead of just systeming?
*/
int status;
char *progname = ZGetVariable("initprogs");
if (!progname)
return;
status = system(progname);
if (status == 127) {
perror("zwgc initprog exec");
fprintf(stderr,"zwgc initprog of <%s> failed: no shell.\n",
progname);
} else if (status!=-1 && status>>8) {
perror("zwgc initprog exec");
fprintf(stderr,"zwgc initprog of <%s> failed with status [%d].\n",
progname, status>>8);
}
}
/*
* main -- the program entry point. Does parsing & top level control.
*/
int main(argc, argv)
int argc;
char **argv;
{
char **new;
register char **current;
int dofork = 1;
/*
* Process "-f <filename>", "-subfile <filename>", "-nofork",
* "-reenter" (which is ignored) and (if DEBUG) "-debug"
* arguments, removing then from argc, argv:
*/
for (new=current=argv+1; *current; current++) {
if (string_Eq(*current, "-debug")) {
argc--;
#ifdef DEBUG
zwgc_debug = 1;
#endif
} else if (string_Eq(*current, "-f")) {
argc -= 2; current++;
if (!*current)
usage();
description_filename_override = *current;
} else if (string_Eq(*current, "-subfile")) {
argc -= 2; current++;
if (!*current)
usage();
subscriptions_filename_override = *current;
} else if (string_Eq(*current, "-nofork")) {
argc--;
dofork = 0;
} else if (string_Eq(*current, "-reenter")) {
argc--; /* just throw it away */
} else
*(new)++ = *current;
}
*new = *current;
/*
* Initialize various subsystems in proper order:
*/
dprintf("Initializing subsystems...\n"); /*<<<>>>*/
mux_init();
var_clear_all_variables(); /* <<<>>> */
init_ports(); /* <<<>>> */
dprintf("Initializing standard ports...\n");
init_standard_ports(&argc, argv);
if (argc>1)
usage();
dprintf("Initializing zephyr...\n");
setup_signals(dofork);
zephyr_init(notice_handler);
if (dofork)
detach();
/*
* Run the initprogs program(s) now that we are all set to deal:
*/
dprintf("Running initprogs program...\n");
run_initprogs();
dprintf("Test Zwgc parser.\n\n");
read_in_description_file();
dprintf("Entering main loop\n");
mux_loop();
dprintf("Returning from main loop\n");
finalize_zephyr();
return(0);
}
/****************************************************************************/
/* */
/* : */
/* */
/****************************************************************************/
#define USER_SUPPRESS "SUPPRESS"
#define USER_UNSUPPRESS "UNSUPPRESS"
void notice_handler(notice)
ZNotice_t *notice;
{
char *control_opcode;
dprintf("Got a message\n");
if (control_opcode = decode_notice(notice)) {
#ifdef DEBUG
printf("got control opcode <%s>.\n", control_opcode);
#endif
if (!strcasecmp(control_opcode, USER_REREAD)) {
read_in_description_file();
} else if (!strcasecmp(control_opcode, USER_SHUTDOWN))
zwgc_shutdown();
else if (!strcasecmp(control_opcode, USER_STARTUP)) {
#ifdef DEBUG_MEMORY
report_memory_usage(); /* <<<>>> */
#endif
zwgc_startup();
} else if (!strcasecmp(control_opcode, USER_SUPPRESS)) {
string class = get_field(notice->z_message,
notice->z_message_len, 1);
string instance = get_field(notice->z_message,
notice->z_message_len, 2);
string recipient = get_field(notice->z_message,
notice->z_message_len, 3);
punt(class, instance, recipient);
free(class);
free(instance);
free(recipient);
} else if (!strcasecmp(control_opcode, USER_UNSUPPRESS)) {
string class = get_field(notice->z_message,
notice->z_message_len, 1);
string instance = get_field(notice->z_message,
notice->z_message_len, 2);
string recipient = get_field(notice->z_message,
notice->z_message_len, 3);
unpunt(class, instance, recipient);
free(class);
free(instance);
free(recipient);
} else
printf("zwgc: unknown control opcode %s.\n", control_opcode);
return;
}
if (!zwgc_active) {
#ifdef DEBUG
if (zwgc_debug)
printf("NON-ACTIVE: PUNTED <%s>!!!!\n", notice->z_class_inst);
#endif
return;
}
if (puntable_address_p(notice->z_class,
notice->z_class_inst,
notice->z_recipient)) {
#ifdef DEBUG
if (zwgc_debug)
printf("PUNTED <%s>!!!!\n", notice->z_class_inst);
#endif
return;
}
exec_process_packet(program, notice);
}
/***************************************************************************/
/*
*
*/
static void signal_exit()
{
mux_end_loop_p = 1;
}
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
/* clean up ALL the waiting children, in case we get hit with
multiple SIGCHLD's at once, and don't process in time. */
static void signal_child()
{
#if defined(NO_UNION_WAIT) || defined(_POSIX_SOURCE)
int status;
#else
union wait status;
#endif
extern int errno;
int pid, old_errno = errno;
do {
pid = wait3(&status, WNOHANG, (struct rusage *)0);
} while (pid != 0 && pid != -1);
errno = old_errno;
}
static void setup_signals(dofork)
int dofork;
{
if (dofork) {
/* Ignore keyboard signals if forking. Bad things will happen. */
signal(SIGINT, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
} else {
/* clean up on SIGINT. exiting on logout is the user's problem, now. */
signal(SIGINT, signal_exit);
}
/* behavior never changes */
signal(SIGTERM, signal_exit);
signal(SIGHUP, signal_exit);
signal(SIGCHLD, signal_child);
signal(SIGPIPE, SIG_IGN); /* so that Xlib gets an error */
}
/* detach() taken from old zwgc, with lots of stuff ripped out */
static void detach()
{
/* detach from terminal and fork. */
register int i;
/* to try to get SIGHUP on user logout */
#ifdef _AIX
(void) setpgid(0, getpgrp(getppid()));
#else
(void) setpgrp(0, getpgrp(getppid()));
#endif
/* fork off and let parent exit... */
if (i = fork()) {
if (i < 0) {
perror("zwgc: cannot fork, aborting:");
exit(1);
}
exit(0);
}
}
@
1.23.1.1
log
@add fallback to hardwired port numbers
@
text
@d7 1
a7 1
* $Source: /usr/sww/share/src/Zephyr/src/zwgc/RCS/main.c,v $
d16 1
a16 1
static char rcsid_main_c[] = "$Id: main.c,v 1.23 1992/04/16 19:11:03 marc Exp jtkohl $";
a23 1
#include <netdb.h>
a225 4
if (!getservbyname(HM_SVCNAME,"udp")) {
fprintf(stderr,"Warning: service '%s' not in /etc/services or equivalent.\n\tAsk your sysadmin to add the Zephyr entries to the services file.\n",
HM_SVCNAME);
}
@
SHAR_EOF
if test -f 'zephyr.vars,v'
then
echo shar: over-writing existing file "'zephyr.vars,v'"
fi
cat << \SHAR_EOF > 'zephyr.vars,v'
head 1.2;
access;
symbols;
locks; strict;
comment @# @;
1.2
date 92.09.15.17.20.23; author jtkohl; state Exp;
branches;
next 1.1;
1.1
date 92.09.15.00.16.48; author jtkohl; state Exp;
branches;
next ;
desc
@zephyr.vars
@
1.2
log
@don't use initprogs here at UCB
@
text
@# Copyright 1988 Massachusetts Institute of Technology
#
# For copying and distribution information, see the file
# "mit-copyright.h".
#
# $Source: /usr/sww/share/src/Zephyr/src/zwgc/RCS/zephyr.vars,v $
# $Author: jtkohl $
# $Id: zephyr.vars,v 1.1 1992/09/15 00:16:48 jtkohl Exp jtkohl $
#
# Zephyr default variables file
#
# Format is:
#
# var = value
#
# Exposure setting defaults to realm-visible.
exposure = realm-visible
# Initialization programs. not currently used at UCB
# initprogs = /etc/athena/zinit
@
1.1
log
@Initial revision
@
text
@d6 1
a6 1
# $Source: /afs/athena.mit.edu/astaff/project/zephyr/src/zwgc/RCS/zephyr.vars,v $
d8 1
a8 1
# $Id: zephyr.vars,v 1.3 89/11/15 21:46:43 jtkohl Exp $
d21 1
a21 1
# Initialization programs.
d23 1
a23 1
initprogs = /etc/athena/zinit
@
SHAR_EOF
if test -f 'zwgc.desc,v'
then
echo shar: over-writing existing file "'zwgc.desc,v'"
fi
cat << \SHAR_EOF > 'zwgc.desc,v'
head 1.11;
access;
symbols;
locks; strict;
comment @# @;
1.11
date 92.09.15.00.19.32; author jtkohl; state Exp;
branches;
next 1.10;
1.10
date 91.07.01.01.47.26; author lwvanels; state Exp;
branches;
next ;
desc
@zwgc.desc
@
1.11
log
@sww changs
@
text
@# Copyright 1989, 1990 Massachusetts Institute of Technology
#
# For copying and distribution information, see the file
# "mit-copyright.h".
#
# $Source: /usr/sww/share/src/Zephyr/src/zwgc/RCS/zwgc.desc,v $
# $Author: lwvanels $
# $Id: zwgc.desc,v 1.10 1991/07/01 01:47:26 lwvanels Exp jtkohl $
#
#
# Default WindowGram description file
#
# Opcode "ping" is used by sender programs to see if the message would
# really get sent, or if the recipient has logged out. No useful
# information is normally contained in these messages, so we discard them.
if (upcase($opcode) == "PING") then exit endif
#
# AUTHENTICATION information
#
# $auth can be either Yes, No, or Forged
#
# "Yes" means that the sender field present in the notice was verified by
# Kerberos authentication
#
# "No" means that either the sender did not include any authentication
# information, or the authentication information was not verified by the
# Zephyr Server before the notice was sent to you.
#
# "Forged" means that the Server claims that the sender of the notice
# was verified by Kerberos authentication, but your WindowGram client
# could not verify this. This stage of verification is done by a cryptographic
# checksum. The most probable cause of the failure of the checksum
# provided by the Server to match the checksum generated by your
# WindowGram client is that you changed Kerberos tickets, and the Server
# was using an old value to compute the cryptographic checksum. You can
# update the Server's value by typing 'zctl load' to your prompt.
#
# By default, notices which appear forged are labeled as 'UNAUTHENTIC'
# to avoid confusion as to what 'Forged' really means.
# To change this display, change the last word in the line following
# 'match "forged" to something other than "UNAUTHENTIC".
case $auth
match "yes"
set aval = "Authentic"
match "no","forged"
set aval = "@@b(@@large(UNAUTHENTIC))"
endcase
case $class
match "WG_CTL_CLASS"
exit
#
# MAIL NOTIFICATION
#
# To receive mail notifications, you need to do several things:
# 1) subscribe to MAIL,POP messages. You do this by typing:
# zctl add mail pop
# to your prompt. By doing this, you will get a simple notice every
# time you are logged in and more mail arrives for you at your post office.
#
# 2) If you wish to be notified of the sender, recipient and subject of the
# new mail, remove the pound-signs from the beginning of the 10 lines below
# between 'match "MAIL"' and 'exit', inclusive, and type the command
# zctl add mail popret
# to your prompt.
#
# Note: The use of the following lines is NOT necessary to receive
# notifications of new mail. The only effect of uncommenting these
# lines is to display on your screen the sender, recipient and subject
# of the mail (In addition, uncommenting these lines will add extra load
# to the post office servers, making them run slower.).
# If you do not wish this information to be displayed where other users
# might possibly read it, or you wish to avoid loading down the post
# office servers, you need not uncomment these lines. Just follow step
# 1 above.
#
#match "MAIL"
# case $instance
# match "pop"
# exec "/usr/sww/bin/zmailnotify"
# exit
# endcase
# print "(Authentication: @@bold("+$aval+"))\n"
# print substitute($default)
# put
# exit
match "message"
case $instance
match "PERSONAL"
set type = "Personal"
match "URGENT"
set type = "Urgent"
default
set type = "Instance "+$instance
endcase
fields signature body
if ($body == "") then
set body = $signature
set signature = ""
endif
if ($signature =~ "^[Ff]rom: .*") then
set dummy = lany($signature,"From: ")
endif
if ($signature =~ "\n$") then
set dummy = rany($signature,"\n")
endif
if ($signature == "") then
set ftext = "From: @@bold("+protect($sender)+")"
else
set ftext = "From: @@bold("+protect($signature)+" <"+
protect($sender)+">)"
endif
print "@@center(@@bold("+$aval+") "+$type+" message at "+$time+
" on "+$date+"\n"+$ftext+" on "+$fromhost+"\nTo: "+
$recipient+")\n\n"
print $body
case $auth
match "yes"
put
match "no","forged"
set X_geometry="-0-80"
put
set X_geometry=""
endcase
exit
match "login"
case $opcode
match "USER_LOGIN"
set log = "logged in"
match "USER_LOGOUT"
set log = "logged out"
default
set log = "unknown opcode"
endcase
fields host when tty
print "@@center(@@bold("+$sender+") "+$log+")\n"
print "@@center(on @@bold("+$host+") on "+$tty+")\n"
print "@@center(at "+$when+")"
put
exit
default
print "(Authentication: @@bold("+$aval+") from host: "+$fromhost+")\n"
print substitute($default)
put
exit
endcase
@
1.10
log
@checked in with -k by jtkohl at 1992/09/15 00:19:16
@
text
@d6 1
a6 1
# $Source: /afs/athena.mit.edu/astaff/project/zephyr/src/zwgc/RCS/zwgc.desc,v $
d8 1
a8 1
# $Id: zwgc.desc,v 1.10 91/07/01 01:47:26 lwvanels Exp $
d82 1
a82 1
# exec "/usr/athena/bin/zmailnotify"
@
SHAR_EOF
# End of shell archive
exit 0
------- End Forwarded Message