summaryrefslogtreecommitdiff
path: root/zwgc
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@mit.edu>2007-07-20 04:26:48 +0000
committerGravatar Karl Ramm <kcr@mit.edu>2007-07-20 04:26:48 +0000
commit82ea504def6eb144c2b13b315890b297e29345c5 (patch)
treeb4623148e6feddde431fcb3b564342c5b0d64523 /zwgc
parent0feeeb3f9ce439f7bca5b691c7c681319a107a8e (diff)
parente6df42eaf361b9878e79ab8964aa26e1ddb95cef (diff)
unpack of new upstream
Diffstat (limited to 'zwgc')
-rw-r--r--zwgc/ChangeLog5
-rw-r--r--zwgc/Makefile.in36
-rw-r--r--zwgc/X_gram.c58
-rw-r--r--zwgc/file.h1
-rw-r--r--zwgc/main.c11
-rw-r--r--zwgc/notice.c16
-rw-r--r--zwgc/parser.y1
-rw-r--r--zwgc/subscriptions.c126
-rw-r--r--zwgc/tty_filter.c12
-rw-r--r--zwgc/xcut.c5
-rw-r--r--zwgc/xmark.c61
-rw-r--r--zwgc/xshow.c71
-rw-r--r--zwgc/zephyr.c84
-rw-r--r--zwgc/zephyr.h1
-rw-r--r--zwgc/zutils.c500
-rw-r--r--zwgc/zutils.h28
-rw-r--r--zwgc/zwgc.152
-rw-r--r--zwgc/zwgc.desc7
18 files changed, 252 insertions, 823 deletions
diff --git a/zwgc/ChangeLog b/zwgc/ChangeLog
deleted file mode 100644
index b2f9647..0000000
--- a/zwgc/ChangeLog
+++ /dev/null
@@ -1,5 +0,0 @@
-2001-03-26 Ken Raeburn <raeburn@mit.edu>
-
- * tty_filter.c [__linux__]: Include termcap.h instead of declaring
- ospeed.
-
diff --git a/zwgc/Makefile.in b/zwgc/Makefile.in
index 1ae13cc..dca3f72 100644
--- a/zwgc/Makefile.in
+++ b/zwgc/Makefile.in
@@ -8,29 +8,30 @@ sbindir=@sbindir@
lsbindir=@lsbindir@
includedir=${prefix}/include
-mandir=@mandir@
+mandir=${prefix}/man
libdir=${exec_prefix}/lib
bindir=${exec_prefix}/bin
+top_builddir=..
srcdir=@srcdir@
top_srcdir=@top_srcdir@
-top_builddir=..
BUILDTOP=..
VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
CC=@CC@
YACC=@YACC@
INSTALL=@INSTALL@
INSTANTIATE=${srcdir}/instantiate
-LIBTOOL=@LIBTOOL@
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
CPPFLAGS=@CPPFLAGS@
CFLAGS=@CFLAGS@
ALL_CFLAGS=${CFLAGS} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \
-I${BUILDTOP}/h -I${srcdir} -I. @X_CFLAGS@ ${CPPFLAGS}
YFLAGS=-d
-LDFLAGS=-L${BUILDTOP}/lib @X_LIBS@ @LDFLAGS@
-LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err @X_PRE_LIBS@ @ZWGC_LIBX11@ \
- @X_EXTRA_LIBS@ @TLIB@ @REGEX_LIBS@ @ARES_LIBS@
+LDFLAGS=@X_LIBS@ @LDFLAGS@
+LIBS=${LIBZEPHYR} @LIBS@ -lcom_err @X_PRE_LIBS@ @ZWGC_LIBX11@ @X_EXTRA_LIBS@ \
+ @TLIB@ @REGEX_LIBS@ @ARES_LIBS@
OBJS= port_dictionary.o pointer_dictionary.o unsigned_long_dictionary.o \
string_dictionary.o int_dictionary.o string_dictionary_aux.o \
@@ -39,12 +40,12 @@ OBJS= port_dictionary.o pointer_dictionary.o unsigned_long_dictionary.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 \
- new_string.o new_memory.o zutils.o
+ new_string.o new_memory.o
all: zwgc
-zwgc: ${OBJS} ${BUILDTOP}/lib/libzephyr.la
- ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+zwgc: ${OBJS} ${LIBZEPHYR}
+ ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
port_dictionary.c port_dictionary.h: dictionary.c dictionary.h
${INSTANTIATE} ${srcdir} dictionary port port.h
@@ -85,16 +86,17 @@ y.tab.c y.tab.h: parser.y
check:
install: zwgc
- ${LIBTOOL} ${INSTALL} -m 755 -s zwgc ${DESTDIR}${bindir}
- ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zwgc.1 ${DESTDIR}${mandir}/man1
- ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zwgc.desc ${DESTDIR}${datadir}/zephyr
- ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zwgc_resources ${DESTDIR}${datadir}/zephyr
+ ${LIBTOOL} --mode=install ${INSTALL} -m 755 zwgc ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zwgc.1 ${DESTDIR}${mandir}/man1
+ ${INSTALL} -m 644 ${srcdir}/zwgc.desc ${DESTDIR}${datadir}/zephyr
+ ${INSTALL} -m 644 ${srcdir}/zwgc_resources ${DESTDIR}${datadir}/zephyr
clean:
- ${LIBTOOL} rm -f ${OBJS} zwgc port_dictionary.[ch] pointer_dictionary.[ch]
- ${LIBTOOL} rm -f unsigned_long_dictionary.[ch] string_dictionary.[ch]
- ${LIBTOOL} rm -f int_dictionary.[ch] char_stack.h string_stack.h xmode_stack.h
- ${LIBTOOL} rm -f y.tab.[ch]
+ ${LIBTOOL} --mode=clean rm -f zwgc
+ rm -f ${OBJS} port_dictionary.[ch] pointer_dictionary.[ch]
+ rm -f unsigned_long_dictionary.[ch] string_dictionary.[ch]
+ rm -f int_dictionary.[ch] char_stack.h string_stack.h xmode_stack.h
+ rm -f y.tab.[ch]
${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
zephyr.o: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c
index 0597135..d5879b3 100644
--- a/zwgc/X_gram.c
+++ b/zwgc/X_gram.c
@@ -25,6 +25,7 @@ static const char rcsid_X_gram_c[] = "$Id$";
#include "xmark.h"
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
+#include <X11/Xatom.h>
#include "zwgc.h"
#include "X_driver.h"
#include "X_fonts.h"
@@ -48,7 +49,7 @@ int internal_border_width = 2;
unsigned long default_fgcolor;
unsigned long default_bgcolor;
unsigned long default_bordercolor;
-long ttl = 0;
+long ttl = 500;
static int reset_saver;
static int border_width = 1;
static int cursor_code = XC_sailboat;
@@ -62,6 +63,10 @@ static Window group_leader; /* In order to have transient windows,
static XClassHint classhint;
static XSetWindowAttributes xattributes;
static unsigned long xattributes_mask;
+static int set_all_desktops = True;
+static Atom net_wm_desktop = None;
+static Atom net_wm_window_type = None;
+static Atom net_wm_window_type_utility = None;
/* ICCCM note:
*
@@ -95,7 +100,7 @@ void x_set_icccm_hints(dpy,w,name,icon_name,psizehints,pwmhints,main_window)
{
XStoreName(dpy,w,name);
XSetIconName(dpy,w,icon_name);
- XSetNormalHints(dpy,w,psizehints);
+ XSetWMNormalHints(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.
@@ -218,6 +223,14 @@ void x_gram_init(dpy)
|LeaveWindowMask|Button1MotionMask
|Button3MotionMask|StructureNotifyMask);
xattributes_mask = (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor);
+
+ set_all_desktops = get_bool_resource("allDesktops", "AllDesktops", True);
+ net_wm_desktop = XInternAtom(dpy, "_NET_WM_DESKTOP", False);
+ net_wm_window_type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
+ net_wm_window_type_utility = XInternAtom(dpy,
+ "_NET_WM_WINDOW_TYPE_UTILITY",
+ False);
+
temp = get_string_resource ("backingStore", "BackingStore");
if (!temp)
return;
@@ -248,6 +261,24 @@ void x_gram_init(dpy)
}
}
+int x_calc_gravity(xalign, yalign)
+ int xalign, yalign;
+{
+ if (yalign > 0) { /* North */
+ return (xalign > 0) ? NorthWestGravity
+ : (xalign == 0) ? NorthGravity
+ : NorthEastGravity;
+ } else if (yalign == 0) { /* Center */
+ return (xalign > 0) ? WestGravity
+ : (xalign == 0) ? CenterGravity
+ : EastGravity;
+ } else { /* South */
+ return (xalign > 0) ? SouthWestGravity
+ : (xalign == 0) ? SouthGravity
+ : SouthEastGravity;
+ }
+}
+
void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
beepcount)
Display *dpy;
@@ -261,6 +292,7 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
XSizeHints sizehints;
XWMHints wmhints;
XSetWindowAttributes attributes;
+ unsigned long all_desktops = 0xFFFFFFFF;
extern void x_get_input();
/*
@@ -295,9 +327,10 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
sizehints.y = ypos;
sizehints.width = xsize;
sizehints.height = ysize;
- sizehints.flags = USPosition|USSize;
+ sizehints.win_gravity = x_calc_gravity(xalign, yalign);
+ sizehints.flags = USPosition|USSize|PWinGravity;
- wmhints.input = True;
+ wmhints.input = False;
wmhints.initial_state = NormalState;
if (set_transient) {
wmhints.window_group = group_leader;
@@ -311,6 +344,13 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,0);
}
+ if (net_wm_window_type != None && net_wm_window_type_utility != None)
+ XChangeProperty(dpy, w, net_wm_window_type, XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *) &net_wm_window_type_utility, 1);
+ if (set_all_desktops && net_wm_desktop != None)
+ XChangeProperty(dpy, w, net_wm_desktop, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *) &all_desktops, 1);
XSaveContext(dpy, w, desc_context, (caddr_t)gram);
@@ -327,6 +367,11 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
winchanges.sibling=bottom_gram->w;
winchanges.stack_mode=Below;
+ /* Metacity may use border_width even if it's not specified in
+ * the value mask, so we must initialize it. See:
+ * http://bugzilla.gnome.org/show_bug.cgi?id=305257 */
+ winchanges.border_width=border_width;
+
begin_xerror_trap (dpy);
XReconfigureWMWindow (dpy, w, DefaultScreen (dpy),
CWSibling|CWStackMode, &winchanges);
@@ -434,9 +479,8 @@ void x_gram_draw(dpy, w, gram, region)
XChangeGC(dpy,gc,GCFunction,&gcvals);
for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
- if ((xb->strlen > 0) &&
- (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
- xb->y2-xb->y1) != RectangleOut)) {
+ 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;
diff --git a/zwgc/file.h b/zwgc/file.h
index d222873..b0aff1f 100644
--- a/zwgc/file.h
+++ b/zwgc/file.h
@@ -19,7 +19,6 @@
#include <stdio.h>
-extern char *get_home_directory();
extern FILE *locate_file();
#endif
diff --git a/zwgc/main.c b/zwgc/main.c
index 151647e..52b9e7a 100644
--- a/zwgc/main.c
+++ b/zwgc/main.c
@@ -126,7 +126,6 @@ static void fake_startup_packet()
notice.z_port = 0;
notice.z_kind = ACKED;
notice.z_auth = ZAUTH_YES;
- notice.z_dest_galaxy = ZGetDefaultGalaxy();
sprintf(msgbuf,"Zwgc mark II version %s now running...",
zwgc_version_string);
notice.z_message = msgbuf;
@@ -462,6 +461,12 @@ static RETSIGTYPE signal_child()
errno = old_errno;
}
+/* rewrite the wgfile in case it has gone away */
+static RETSIGTYPE signal_usr1()
+{
+ write_wgfile();
+}
+
static void setup_signals(dofork)
int dofork;
{
@@ -494,6 +499,9 @@ static void setup_signals(dofork)
sa.sa_handler = signal_child;
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
+ sa.sa_handler = signal_usr1;
+ sigaction(SIGUSR1, &sa, (struct sigaction *)0);
+
#else /* !POSIX */
if (dofork) {
/* Ignore keyboard signals if forking. Bad things will happen. */
@@ -511,6 +519,7 @@ static void setup_signals(dofork)
signal(SIGHUP, signal_exit);
signal(SIGCHLD, signal_child);
signal(SIGPIPE, SIG_IGN); /* so that Xlib gets an error */
+ signal(SIGUSR1, signal_usr1);
#endif
}
diff --git a/zwgc/notice.c b/zwgc/notice.c
index 5168562..e3d4cdb 100644
--- a/zwgc/notice.c
+++ b/zwgc/notice.c
@@ -253,7 +253,7 @@ char *decode_notice(notice, hostname)
ZNotice_t *notice;
char *hostname;
{
- char *notice_rhs, *galaxy_rhs;
+ char *temp;
string time, notyear, year, date_string, time_string;
/*
@@ -269,22 +269,18 @@ char *decode_notice(notice, hostname)
var_set_variable("recipient",
(notice->z_recipient[0] ? notice->z_recipient : "*"));
var_set_variable("fullsender", notice->z_sender);
- var_set_variable("destgalaxy", notice->z_dest_galaxy);
var_set_variable_to_number("port", (int)notice->z_port);
var_set_variable_then_free_value("kind", z_kind_to_ascii(notice->z_kind));
var_set_variable_then_free_value("auth", z_auth_to_ascii(notice->z_auth));
/*
- * Set $sender to the name of the notice sender except first strip
- * off the rhs if it is the rhs of the zephyr server which
- * delivered the message. */
- if ((notice_rhs = strchr(notice->z_sender,'@')) &&
- (galaxy_rhs = ZGetRhs(notice->z_dest_galaxy)) &&
- string_Eq(notice_rhs+1, galaxy_rhs))
+ * Set $sender to the name of the notice sender except first strip off the
+ * realm name if it is the local realm:
+ */
+ if ( (temp=strchr(notice->z_sender,'@')) && string_Eq(temp+1, ZGetRealm()) )
var_set_variable_then_free_value("sender",
string_CreateFromData(notice->z_sender,
- (notice_rhs-
- notice->z_sender)));
+ temp-notice->z_sender));
else
var_set_variable("sender", notice->z_sender);
diff --git a/zwgc/parser.y b/zwgc/parser.y
index ebafa88..6f53985 100644
--- a/zwgc/parser.y
+++ b/zwgc/parser.y
@@ -230,6 +230,7 @@ elseparts : elseifparts
reverse_list_of_nodes($3));
$$->next = $1;
$$ = reverse_list_of_nodes($$); }
+ ;
/* elseifparts needs to be reversed before using... */
elseifparts : /* empty */
diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c
index 0bdac84..e72963e 100644
--- a/zwgc/subscriptions.c
+++ b/zwgc/subscriptions.c
@@ -32,7 +32,6 @@ static char rcsid_subscriptions_c[] = "$Id$";
#include "error.h"
#include "file.h"
#include "main.h"
-#include "zutils.h"
/****************************************************************************/
/* */
@@ -129,8 +128,6 @@ void unpunt(class, instance, recipient)
int_dictionary_Delete(puntable_addresses_dict, binding);
}
-#if 0
-
/****************************************************************************/
/* */
/* Code to implement batching [un]subscription requests: */
@@ -164,7 +161,7 @@ static void free_subscription_list(list, number_of_elements)
static void flush_subscriptions()
{
- TRAP(ZSubscribeTo(NULL, subscription_list,subscription_list_size, 0),
+ TRAP(ZSubscribeTo(subscription_list,subscription_list_size, 0),
"while subscribing");
free_subscription_list(subscription_list, subscription_list_size);
@@ -174,8 +171,7 @@ static void flush_subscriptions()
static void flush_unsubscriptions()
{
if (unsubscription_list_size)
- TRAP(ZUnsubscribeTo(NULL, unsubscription_list,
- unsubscription_list_size, 0),
+ TRAP(ZUnsubscribeTo(unsubscription_list, unsubscription_list_size, 0),
"while unsubscribing");
free_subscription_list(unsubscription_list, unsubscription_list_size);
@@ -236,7 +232,7 @@ static void inithosts()
strncpy(ourhostcanon, ourhost, sizeof(ourhostcanon)-1);
return;
}
- (void) strncpy(ourhostcanon,hent->h_name, sizeof(ourhostcanon)-1);
+ strncpy(ourhostcanon, hent->h_name, sizeof(ourhostcanon)-1);
return;
}
@@ -321,28 +317,19 @@ static void load_subscriptions_from_file(file)
fclose(file);
}
-#endif /* 0 */
-
#define DEFSUBS "/dev/null"
static void load_subscriptions()
{
- char subsname[MAXPATHLEN];
- int i, cnt;
- char *home, *galaxy;
-
- if (subscriptions_filename_override) {
- strcpy(subsname, subscriptions_filename_override);
- } else if (home = get_home_directory()) {
- strcpy(subsname, home?home:"");
- strcat(subsname, "/");
- strcat(subsname, USRSUBS);
- } else {
- strcpy(subsname, "");
- }
-
- FATAL_TRAP(load_all_sub_files(SUB, *subsname?subsname:NULL),
- "while loading subscription files");
+ FILE *subscriptions_file;
+
+ /* no system default sub file on client--they live on the server */
+ /* BUT...we need to use something to call load_subscriptions_from_file,
+ so we use /dev/null */
+ subscriptions_file = locate_file(subscriptions_filename_override,
+ USRSUBS, DEFSUBS);
+ if (subscriptions_file)
+ load_subscriptions_from_file(subscriptions_file);
}
/****************************************************************************/
@@ -353,94 +340,45 @@ static void load_subscriptions()
int zwgc_active = 0;
-static ZSubscription_t **saved_subscriptions = NULL;
-static int *number_of_saved_subscriptions;
+static ZSubscription_t *saved_subscriptions = NULL;
+static int number_of_saved_subscriptions;
void zwgc_shutdown()
{
- int cnt, i;
- char *galaxy;
-
if (!zwgc_active)
return;
- TRAP(ZGetGalaxyCount(&cnt), "while getting galaxy count");
+ TRAP(ZRetrieveSubscriptions(0, &number_of_saved_subscriptions),
+ "while retrieving zephyr subscription list");
if (error_code)
- return;
-
- if ((saved_subscriptions =
- (ZSubscription_t **) malloc(sizeof(ZSubscription_t *)*cnt)) == NULL) {
- fprintf(stderr, "out of memory allocating list of subscription lists");
- return;
- }
- if ((number_of_saved_subscriptions =
- (int *) malloc(sizeof(int)*cnt)) == NULL) {
- fprintf(stderr,
- "out of memory allocating number of subscription lists");
- return;
- }
-
- for (i=0; i<cnt; i++) {
- TRAP(ZGetGalaxyName(i, &galaxy), "while getting galaxy name")
- if (error_code)
- continue;
-
- TRAP(ZRetrieveSubscriptions(galaxy, 0,
- &number_of_saved_subscriptions[i]),
- "while retrieving zephyr subscription list");
- if (error_code)
- return;
-
- saved_subscriptions[i] = (ZSubscription_t *)
- malloc(number_of_saved_subscriptions[i]*sizeof(ZSubscription_t));
-
- if (number_of_saved_subscriptions[i])
- TRAP(ZGetSubscriptions(saved_subscriptions[i],
- &number_of_saved_subscriptions[i]),
- "while getting subscriptions");
- if (error_code) {
- free(saved_subscriptions[i]);
- saved_subscriptions[i] = NULL;
- }
- TRAP(ZCancelSubscriptions(galaxy, 0), "while canceling subscriptions");
+ return;
+ saved_subscriptions = (ZSubscription_t *)
+ malloc(number_of_saved_subscriptions*sizeof(ZSubscription_t));
+ if (number_of_saved_subscriptions)
+ TRAP(ZGetSubscriptions(saved_subscriptions,
+ &number_of_saved_subscriptions),
+ "while getting subscriptions");
+ if (error_code) {
+ free(saved_subscriptions);
+ saved_subscriptions = NULL;
}
+ TRAP(ZCancelSubscriptions(0), "while canceling subscriptions") ;
zwgc_active = 0;
}
void zwgc_startup()
{
- int cnt, i;
- char *galaxy;
-
if (zwgc_active)
return;
if (saved_subscriptions) {
- TRAP(ZGetGalaxyCount(&cnt), "while getting galaxy count");
- if (error_code)
- return;
-
- for (i=0; i<cnt; i++) {
- TRAP(ZGetGalaxyName(i, &galaxy), "while getting galaxy name");
- if (error_code)
- continue;
-
- if (saved_subscriptions[i]) {
- TRAP(ZSubscribeToSansDefaults(galaxy, saved_subscriptions[i],
- number_of_saved_subscriptions[i],
- 0),
- "while resubscribing to zephyr messages");
- free(saved_subscriptions[i]);
- saved_subscriptions[i] = NULL;
- }
- }
-
+ TRAP(ZSubscribeToSansDefaults(saved_subscriptions,number_of_saved_subscriptions,0),
+ "while resubscribing to zephyr messages");
+ free(saved_subscriptions);
saved_subscriptions = NULL;
- } else {
- load_subscriptions();
- }
-
+ } else
+ load_subscriptions();
zwgc_active = 1;
}
diff --git a/zwgc/tty_filter.c b/zwgc/tty_filter.c
index c0646c6..72a6747 100644
--- a/zwgc/tty_filter.c
+++ b/zwgc/tty_filter.c
@@ -36,10 +36,12 @@ static const char rcsid_tty_filter_c[] = "$Id$";
extern int tgetent();
extern char *tgetstr(),*getenv();
-#if 0
-short ospeed;
-char PC;
+#ifdef linux
+extern speed_t ospeed;
+#else
+extern short ospeed;
#endif
+char PC;
/* Dictionary naming convention:
@@ -93,7 +95,6 @@ char **argv;
int ex;
string_dictionary_binding *b;
int isrealtty = string_Eq(drivername, "tty");
-#if 0
#ifdef HAVE_TERMIOS_H
struct termios tbuf;
@@ -103,7 +104,6 @@ char **argv;
ospeed = (ioctl(0, TIOCGETP, &sgttyb) == 0) ? sgttyb.sg_ospeed : 2400;
#endif
-#endif
if (termcap_dict == (string_dictionary) NULL)
termcap_dict = string_dictionary_Create(7);
@@ -133,10 +133,8 @@ char **argv;
/* We cheat here, and ignore the padding (if any) specified for
the mode-change strings (it's a real pain to do "right") */
-#if 0
tmp = tgetstr("pc", &p);
PC = (tmp) ? *tmp : 0;
-#endif
if (tmp = tgetstr("md",&p)) { /* bold ? */
EXPAND("B.bold");
tmp = tgetstr("me",&p);
diff --git a/zwgc/xcut.c b/zwgc/xcut.c
index 7c45cc4..cadfc3d 100644
--- a/zwgc/xcut.c
+++ b/zwgc/xcut.c
@@ -242,6 +242,11 @@ void xcut(dpy,event,desc_context)
case ButtonPress:
if (current_pressop != PRESSOP_NONE) {
current_pressop = PRESSOP_STOP;
+ } else if ((event->xbutton.button==Button4 ||
+ event->xbutton.button==Button5) &&
+ !get_bool_resource("scrollDelete","ScrollDelete",0)) {
+ /* Ignore scroll wheel movement. */
+ break;
} else if ( (event->xbutton.state)&ShiftMask ) {
if (event->xbutton.button==Button1) {
if (selecting_in)
diff --git a/zwgc/xmark.c b/zwgc/xmark.c
index ba3c26f..1c796f3 100644
--- a/zwgc/xmark.c
+++ b/zwgc/xmark.c
@@ -48,7 +48,7 @@ void xmarkSetBound(gram,x,y,which)
int x,y;
int which;
{
- int i,j,xofs,yofs;
+ int i,xofs,yofs;
XFontStruct *font;
xblock *xb;
unsigned char *s;
@@ -104,34 +104,26 @@ void xmarkSetBound(gram,x,y,which)
}
for (yofs=xb->y1;(i<gram->numblocks) && (xb->y1 == yofs);i++,xb++) {
+
if (x <= xb->x2) {
markblock[which]=i;
xofs=xb->x1;
-
if ((x < xofs) || (y < xb->y1)) {
markchar[which]=0;
- markpixel[which]=0;
- RETURN;
- }
-
- if (xb->strlen == -1) {
- markchar[which]=0;
- markpixel[which]=0;
RETURN;
}
-
font=get_fontst_from_fid(xb->fid);
- for (j=0,s=(unsigned char *)((gram->text)+(xb->strindex));
- xofs<x && j<xb->strlen;
- j++,s++) {
- /* if font->per_char is NULL, then we should use min_bounds */
- short usewidth = font->per_char ? font->per_char[*s - font->min_char_or_byte2].width : font->min_bounds.width;
- if (x <= (xofs+=usewidth)) {
- markchar[which]=j;
- markpixel[which]=xofs - xb->x1 - usewidth;
- RETURN;
- }
+ for (i=0,s=(unsigned char *)((gram->text)+(xb->strindex));
+ xofs<x && i<xb->strlen;
+ i++,s++) {
+ /* if font->per_char is NULL, then we should use min_bounds */
+ short usewidth = font->per_char ? font->per_char[*s - font->min_char_or_byte2].width : font->min_bounds.width;
+ if (x <= (xofs+=usewidth)) {
+ markchar[which]=i;
+ markpixel[which]=xofs - xb->x1 - usewidth;
+ RETURN;
+ }
}
}
}
@@ -372,24 +364,21 @@ char *xmarkGetText()
}
for (i=startblock; i<=endblock; i++) {
+ if (last_y != -1 && last_y != markgram->blocks[i].y)
+ text_so_far = string_Concat2(text_so_far, "\n");
index = markgram->blocks[i].strindex;
len = markgram->blocks[i].strlen;
- if ((len == -1) && (i != endblock)) {
- text_so_far = string_Concat2(text_so_far, "\n");
- } else {
- if (startblock == endblock)
- temp = string_CreateFromData(text+index+startchar,
- endchar-startchar);
- else if (i==startblock)
- temp = string_CreateFromData(text+index+startchar,
- len-startchar);
- else if (i==endblock)
- temp = string_CreateFromData(text+index, endchar);
- else
- temp = string_CreateFromData(text+index, len);
- text_so_far = string_Concat2(text_so_far, temp);
- free(temp);
- }
+ if (startblock == endblock)
+ temp = string_CreateFromData(text+index+startchar,
+ endchar-startchar);
+ else if (i==startblock)
+ temp = string_CreateFromData(text+index+startchar,len-startchar);
+ else if (i==endblock)
+ temp = string_CreateFromData(text+index,endchar);
+ else
+ temp = string_CreateFromData(text+index,len);
+ text_so_far = string_Concat2(text_so_far, temp);
+ free(temp);
last_y = markgram->blocks[i].y;
}
}
diff --git a/zwgc/xshow.c b/zwgc/xshow.c
index 4cc3f16..d970ccc 100644
--- a/zwgc/xshow.c
+++ b/zwgc/xshow.c
@@ -134,7 +134,7 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
x_gram *gram;
int strindex = 0;
- int line, block;
+ int line, block=0;
int maxwidth=0, chars=0, maxascent, maxdescent;
int ssize, lsize,csize, rsize, width;
int i, ascent, descent;
@@ -156,8 +156,7 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
/* add up sizes for each block, get max ascent and descent */
- for (i=0, block=lines[line].startblock; i<lines[line].numblock;
- i++,block++) {
+ for (i=0; i<lines[line].numblock; i++,block++) {
chars += auxblocks[block].len;
ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str,
auxblocks[block].len);
@@ -165,19 +164,19 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
ascent = auxblocks[block].font->ascent;
descent = auxblocks[block].font->descent;
if (ascent>maxascent)
- maxascent = ascent;
+ maxascent = ascent;
if (descent>maxdescent)
- maxdescent = descent;
+ maxdescent = descent;
switch (auxblocks[block].align) {
- case LEFTALIGN:
+ case LEFTALIGN:
lsize += ssize;
break;
-
- case CENTERALIGN:
+
+ case CENTERALIGN:
csize += ssize;
break;
-
- case RIGHTALIGN:
+
+ case RIGHTALIGN:
rsize += ssize;
break;
}
@@ -247,6 +246,7 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
/* set x1,y1,x2,y2 of each block also. */
gram->text = (char *)malloc(chars);
+ block = 0;
for (line=0; line<numlines; line++) {
lofs = internal_border_width;
@@ -257,8 +257,7 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
yend = yofs+lines[line].descent+1; /* +1 because lines look scrunched
without it. */
- for (i=0, block=lines[line].startblock; i<lines[line].numblock;
- i++,block++) {
+ for (i=0; i<lines[line].numblock; i++,block++) {
blocks[block].fid = auxblocks[block].font->fid;
switch (auxblocks[block].align) {
case LEFTALIGN:
@@ -292,20 +291,8 @@ void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
strindex += blocks[block].strlen;
}
- blocks[block].fid = block?blocks[block-1].fid:auxblocks[0].font->fid;
- blocks[block].x = maxwidth + internal_border_width;
- blocks[block].x1 = (lines[line].rsize?rofs:
- (lines[line].csize?cofs:
- lofs));
- blocks[block].x2 = maxwidth + internal_border_width*2;
- blocks[block].y = yofs;
- blocks[block].y1 = ystart;
- blocks[block].y2 = yend;
- blocks[block].strindex = 0;
- blocks[block].strlen = -1; /* magic value indicates newline */
- block++;
-
yofs = yend;
+
}
if ((geometry = var_get_variable("X_geometry")),(geometry[0]=='\0'))
@@ -387,8 +374,8 @@ void xshow(dpy, desc, numstr, numnl)
lines = (xlinedesc *)malloc(sizeof(xlinedesc)*(numnl+1));
- blocks = (xblock *)malloc(sizeof(xblock)*(numstr+numnl+1));
- auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*(numstr+numnl+1));
+ blocks = (xblock *)malloc(sizeof(xblock)*numstr);
+ auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*numstr);
curmode.bold = 0;
curmode.italic = 0;
@@ -517,24 +504,12 @@ void xshow(dpy, desc, numstr, numnl)
break;
case DT_NL:
- font = MODE_TO_FONT(dpy,style,&curmode);
-
- auxblocks[nextblock].len = -1;
- auxblocks[nextblock].font = font;
- if (curmode.expcolor)
- blocks[nextblock].fgcolor = curmode.color;
- else
- blocks[nextblock].fgcolor =
- x_string_to_color(mode_to_colorname(dpy,style,&curmode),
- default_fgcolor);
- nextblock++;
-
lines[line].startblock = linestart;
- lines[line].numblock = (nextblock-linestart)-1;
+ lines[line].numblock = nextblock-linestart;
+ font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = font->ascent;
lines[line].descent = font->descent;
line++;
-
linestart = nextblock;
break;
}
@@ -543,19 +518,9 @@ void xshow(dpy, desc, numstr, numnl)
/* case DT_EOF: will drop through to here. */
if (linestart != nextblock) {
- font = MODE_TO_FONT(dpy,style,&curmode);
- auxblocks[nextblock].len = -1;
- auxblocks[nextblock].font = font;
- if (curmode.expcolor)
- blocks[nextblock].fgcolor = curmode.color;
- else
- blocks[nextblock].fgcolor =
- x_string_to_color(mode_to_colorname(dpy,style,&curmode),
- default_fgcolor);
- nextblock++;
-
lines[line].startblock = linestart;
- lines[line].numblock = (nextblock-linestart)-1;
+ lines[line].numblock = nextblock-linestart;
+ font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = 0;
lines[line].descent = 0;
line++;
diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c
index 6eaee64..9ad8dbe 100644
--- a/zwgc/zephyr.c
+++ b/zwgc/zephyr.c
@@ -43,6 +43,9 @@ static const char rcsid_zephyr_c[] = "$Id$";
extern int zwgc_debug;
#endif /* DEBUG */
+static int zephyr_inited = 0;
+static unsigned short zephyr_port = 0;
+
/*
* Internal Routine:
*
@@ -70,6 +73,25 @@ static string get_zwgc_port_number_filename()
}
/*
+ * Write out the port number to the wg file.
+ */
+
+void write_wgfile()
+{
+ char *name = get_zwgc_port_number_filename();
+ FILE *port_file;
+
+ port_file = fopen(name, "w");
+ if (port_file) {
+ fprintf(port_file, "%d\n", zephyr_port);
+ fclose(port_file);
+ } else {
+ fprintf(stderr, "zwgc: error while opening %s for writing: ", name);
+ perror("");
+ }
+}
+
+/*
*
*/
@@ -98,8 +120,6 @@ static void handle_zephyr_input(notice_handler)
}
}
-static int zephyr_inited = 0;
-
/*
*
*/
@@ -107,7 +127,6 @@ static int zephyr_inited = 0;
void zephyr_init(notice_handler)
void (*notice_handler)();
{
- unsigned short port = 0; /* Use any old port */
char *temp;
char *exposure;
char *tty = NULL;
@@ -117,14 +136,13 @@ void zephyr_init(notice_handler)
* Initialize zephyr. If error, print error message & exit.
*/
FATAL_TRAP( ZInitialize(), "while initializing Zephyr" );
- FATAL_TRAP( ZOpenPort(&port), "while opening Zephyr port" );
+ FATAL_TRAP( ZOpenPort(&zephyr_port), "while opening Zephyr port" );
/*
* Save away our port number in a special place so that zctl and
* other clients can send us control messages: <<<>>>
*/
temp = get_zwgc_port_number_filename();
- errno = 0;
port_file = fopen(temp, "r");
if (port_file) {
fprintf(stderr, "zwgc: windowgram file already exists. If you are\n");
@@ -132,6 +150,7 @@ void zephyr_init(notice_handler)
fprintf(stderr, "zwgc: and try again.\n");
exit(1);
}
+ write_wgfile();
/* Set hostname and tty for locations. If we support X, use the
* display string for the default tty name. */
@@ -151,22 +170,28 @@ void zephyr_init(notice_handler)
* not one of the allowed ones, print an error and treat it as
* EXPOSE_NONE.
*/
-
- error_code = set_exposure("*", exposure = ZGetVariable("exposure"));
- if (error_code)
+ if (temp = ZGetVariable("exposure")) {
+ if (!(exposure = ZParseExposureLevel(temp))) {
+ ERROR2("invalid exposure level %s, using exposure level none instead.\n", temp);
+ exposure = EXPOSE_NONE;
+ }
+ } else
+ exposure = EXPOSE_OPSTAFF;
+ error_code = ZSetLocation(exposure); /* <<<>>> */
+ if (error_code != ZERR_LOGINFAIL)
TRAP( error_code, "while setting location" );
/*
- * If the exposure level isn't EXPOSE_NONE, turn on receiving notices.
+ * If the exposure level isn't EXPOSE_NONE, turn on recieving notices.
* (this involves reading in the subscription file, etc.)
*/
if (string_Neq(exposure, EXPOSE_NONE))
zwgc_startup();
/*
- * Set $galaxy to our galaxy and $user to our zephyr username:
+ * Set $realm to our realm and $user to our zephyr username:
*/
- var_set_variable("galaxy", ZGetDefaultGalaxy());
+ var_set_variable("realm", ZGetRealm());
var_set_variable("user", ZGetSender());
/*
@@ -175,16 +200,6 @@ void zephyr_init(notice_handler)
mux_add_input_source(ZGetFD(), (void (*)())handle_zephyr_input,
notice_handler);
zephyr_inited = 1;
-
- port_file = fopen(temp, "w");
- if (port_file) {
- fprintf(port_file, "%d\n", port);
- fclose(port_file);
- } else {
- fprintf(stderr, "zwgc: error while opening %s for writing: ", temp);
- perror("");
- }
-
return;
}
@@ -195,8 +210,6 @@ void zephyr_init(notice_handler)
void finalize_zephyr() /* <<<>>> */
{
string temp;
- int i, cnt;
- char *galaxy;
if (zephyr_inited) {
/*
@@ -214,28 +227,17 @@ void finalize_zephyr() /* <<<>>> */
* Cancel our subscriptions, unset our location, and close our zephyr
* connection:
*/
-
- TRAP(ZGetGalaxyCount(&cnt), "while getting galaxy count");
- if (error_code)
- return;
-
- for (i=0; i<cnt; i++) {
- TRAP(ZGetGalaxyName(i, &galaxy), "while getting galaxy name");
- if (error_code)
- continue;
#ifdef DEBUG
- if (zwgc_debug) {
- TRAP( ZCancelSubscriptions(galaxy, 0),
- "while canceling subscriptions" );
- TRAP( ZUnsetLocation(galaxy), "while unsetting location" );
- } else {
+ if (zwgc_debug) {
+ TRAP( ZUnsetLocation(), "while unsetting location" );
+ TRAP( ZCancelSubscriptions(0), "while canceling subscriptions" );
+ } else {
#endif /* DEBUG */
- (void) ZCancelSubscriptions(galaxy, 0);
- (void) ZUnsetLocation(galaxy);
+ (void) ZUnsetLocation();
+ (void) ZCancelSubscriptions(0);
#ifdef DEBUG
- }
-#endif /* DEBUG */
}
+#endif /* DEBUG */
ZClosePort();
}
return;
diff --git a/zwgc/zephyr.h b/zwgc/zephyr.h
index d2e3735..98265df 100644
--- a/zwgc/zephyr.h
+++ b/zwgc/zephyr.h
@@ -19,5 +19,6 @@
extern void zephyr_init();
extern void finalize_zephyr();
+extern void write_wgfile();
#endif
diff --git a/zwgc/zutils.c b/zwgc/zutils.c
deleted file mode 100644
index 87d54b8..0000000
--- a/zwgc/zutils.c
+++ /dev/null
@@ -1,500 +0,0 @@
-/* XXX this file is duplicated in clients/zctl and clients/zwgc, until
- zctl is changed to message zwgc to perform these tasks */
-
-#include <stdio.h>
-#include <string.h>
-#include <netdb.h>
-#include <errno.h>
-
-#include <sys/param.h>
-
-#include <zephyr/zephyr.h>
-#ifdef HAVE_KRB4
-#include <krb_err.h>
-#endif
-
-#include "zutils.h"
-
-#ifdef ZWGC
-#include "subscriptions.h"
-#define ZGetWGPort() (ZGetPort())
-#endif
-
-#ifdef ZCTL
-Code_t send_wgc_control(opcode, msg, len)
- char *opcode;
- char *msg;
- int len;
-{
- int retval;
- short newport;
- struct sockaddr_in oldsin, newsin;
- ZNotice_t notice;
-
- oldsin = ZGetDestAddr();
-
- if ((newport = ZGetWGPort()) == -1) {
- return(errno);
- }
-
- newsin = oldsin;
- newsin.sin_port = (u_short) newport;
- if ((retval = ZSetDestAddr(&newsin)) != ZERR_NONE) {
- return(retval);
- }
-
- (void) memset((char *)&notice, 0, sizeof(notice));
- notice.z_kind = UNSAFE;
- notice.z_port = 0;
- notice.z_class = WG_CTL_CLASS;
- notice.z_class_inst = WG_CTL_USER;
- notice.z_opcode = opcode;
- notice.z_sender = 0;
- notice.z_recipient = "";
- notice.z_default_format = "";
- notice.z_dest_galaxy = "";
- notice.z_message = msg;
- notice.z_message_len = len;
-
- if ((retval = ZSendNotice(&notice,ZNOAUTH)) != ZERR_NONE)
- return(retval);
-
- if ((retval = ZSetDestAddr(&oldsin)) != ZERR_NONE) {
- return(retval);
- }
-
-#if 0
- /* XXX why was this here? */
- if ((retval = ZInitialize()) != ZERR_NONE)
- return(retval);
-#endif
-}
-#endif
-
-void fix_macros(subs,subs2,num)
- ZSubscription_t *subs,*subs2;
- int num;
-{
- int i;
-
- for (i=0;i<num;i++) {
- subs2[i] = subs[i];
- fix_macros2(subs[i].zsub_class,&subs2[i].zsub_class);
- fix_macros2(subs[i].zsub_classinst,&subs2[i].zsub_classinst);
- fix_macros2(subs[i].zsub_recipient,&subs2[i].zsub_recipient);
- }
-}
-
-void fix_macros2(src,dest)
- char *src;
- char **dest;
-{
- static char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN];
- struct hostent *hent;
-
- if (!*ourhost) {
-#ifdef HAVE_SYS_UTSNAME
- uname(&name);
- strcpy(ourhost, name.nodename);
-#else
- if (gethostname(ourhost,MAXHOSTNAMELEN) == -1) {
- /* XXX */
- com_err("",errno,"while getting host name");
- return;
- }
-#endif
- }
-
- if (!*ourhostcanon) {
- if (!(hent = gethostbyname(ourhost))) {
- fprintf(stderr,"Can't get canonical name for host %s",
- ourhost);
- return;
- }
-
- (void) strcpy(ourhostcanon,hent->h_name);
- }
-
- if (!strcmp(src,TOKEN_HOSTNAME)) {
- *dest = ourhost;
- } else if (!strcmp(src,TOKEN_CANONNAME)) {
- *dest = ourhostcanon;
- } else if (!strcmp(src,TOKEN_ME)) {
- *dest = ZGetSender();
- }
-}
-
-Code_t set_exposure(zgalaxy, exposure)
- char *zgalaxy;
- char *exposure;
-{
- char *exp_level, *galaxy_exp_level, zvar[1024];
- Code_t code, retval;
- int cnt, i;
-
- exp_level = ZParseExposureLevel(exposure);
-
- if (zgalaxy && strcmp(zgalaxy, "*") == 0) {
- if (retval = ZGetGalaxyCount(&cnt))
- return(retval);
-
- for (i=0; i<cnt; i++) {
- if (retval = ZGetGalaxyName(i, &zgalaxy))
- return(retval);
-
- sprintf(zvar, "exposure-%s", zgalaxy);
-
- if (galaxy_exp_level = ZGetVariable(zvar)) {
- if (strcmp(galaxy_exp_level, EXPOSE_NETVIS) == 0)
- galaxy_exp_level = EXPOSE_REALMVIS;
- else
- galaxy_exp_level = ZParseExposureLevel(galaxy_exp_level);
- } else if (galaxy_exp_level = exp_level) {
- if (strcmp(galaxy_exp_level, EXPOSE_NETVIS) == 0)
- galaxy_exp_level = EXPOSE_REALMVIS;
-
- if (i > 0) {
- if (strcmp(galaxy_exp_level, EXPOSE_REALMVIS) == 0)
- galaxy_exp_level = EXPOSE_OPSTAFF;
- else if (strcmp(galaxy_exp_level, EXPOSE_REALMANN) == 0)
- galaxy_exp_level = EXPOSE_OPSTAFF;
- } else {
- galaxy_exp_level = ZParseExposureLevel(galaxy_exp_level);
- }
- } else {
- galaxy_exp_level = EXPOSE_NONE;
- }
-
- if (strcmp(galaxy_exp_level, EXPOSE_NONE) == 0)
- continue;
-
- if ((code = ZSetLocation(zgalaxy, exp_level)) != ZERR_NONE) {
- retval = code;
- continue;
- }
-#ifdef ZCTL
- if (strcmp(exp_level,EXPOSE_NONE) == 0) {
- if (code = send_wgc_control(USER_SHUTDOWN, NULL, 0)) {
- retval = code;
- continue;
- }
- } else {
- if (code = send_wgc_control(USER_STARTUP, NULL, 0)) {
- retval = code;
- continue;
- }
- }
-#endif
- }
-#ifdef HAVE_KRB4
- if (retval == KRBET_AD_NOTGT)
- retval = ZERR_NONE;
-#endif
- return(retval);
- } else {
- if ((retval = ZSetLocation(zgalaxy, exp_level)) != ZERR_NONE)
- return(retval);
-#ifdef ZCTL
- if (strcmp(exp_level,EXPOSE_NONE) == 0) {
- if (retval = send_wgc_control(USER_SHUTDOWN, NULL, 0))
- return(retval);
- } else {
- if (retval = send_wgc_control(USER_STARTUP, NULL, 0))
- return(retval);
- }
-#endif
- }
-}
-
-#ifdef ZCTL
-Code_t xpunt(zclass, zinst, zrecip, type)
- char *zclass;
- char *zinst;
- char *zrecip;
- int type;
-{
- char *msg;
-
- msg = (char *) malloc(strlen(zclass) + strlen(zinst) + strlen(zrecip) + 3);
-
- sprintf(msg, "%s%c%s%c%s", zclass, '\0', zinst, '\0', zrecip);
-
- return(send_wgc_control((type == PUNT)?"SUPPRESS":"UNSUPPRESS",
- msg,
- strlen(zclass) + strlen(zinst) +
- strlen(zrecip) + 3));
-}
-
-#elif defined(ZWGC)
-
-Code_t xpunt(zclass, zinst, zrecip, type)
- char *zclass;
- char *zinst;
- char *zrecip;
- int type;
-{
- if (type == PUNT)
- punt(zclass, zinst, zrecip);
- else
- unpunt(zclass, zinst, zrecip);
-
- return(ZERR_NONE);
-}
-
-#endif
-
-Code_t load_sub_file(type, file, galaxy)
- int type;
- char *file;
- char *galaxy;
-{
- ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE],
- punts[1];
- FILE *fp;
- int ind,unind,puntind,lineno,i,retval;
- short wgport;
- char *comma,*comma2,subline[BUFSIZ];
-
- if (type != LIST)
- if ((wgport = ZGetWGPort()) == -1) {
- return(errno);
- }
-
- if (file) {
- fp = fopen(file,"r");
-
- if ((fp == NULL) && (errno != ENOENT))
- return(errno);
- } else {
- fp = NULL;
- }
-
- ind = unind = puntind = 0;
- lineno = 1;
-
- /* this will fall through to subbing an empty list, giving the default
- subs only */
-
- if (fp) {
- for (;;lineno++) {
- if (!fgets(subline,sizeof subline,fp))
- break;
- if (*subline == '#' || !*subline)
- continue;
- subline[strlen(subline)-1] = '\0'; /* nuke newline */
- comma = strchr(subline,',');
- if (comma)
- comma2 = strchr(comma+1,',');
- else
- comma2 = 0;
- if (!comma || !comma2) {
- fprintf(stderr,
- "Malformed subscription at line %d of %s:\n%s\n",
- lineno,file,subline);
- continue;
- }
- *comma = '\0';
- *comma2 = '\0';
- if (type == LIST) {
- if (*subline == '!')
- printf("(Un-subscription) Class %s instance %s recipient %s\n",
- subline+1, comma+1, comma2+1);
- else if (*subline = '-')
- printf("(Suppression) Class %s instance %s recipient %s\n",
- subline+1, comma+1, comma2+1);
- else
- printf("Class %s instance %s recipient %s\n",
- subline, comma+1, comma2+1);
- continue;
- }
- if (*subline == '!') { /* an un-subscription */
- /* if we are explicitly un-subscribing to
- the contents of a subscription file, ignore
- any un-subscriptions in that file */
- if (type == UNSUB)
- continue;
- unsubs[unind].zsub_class =
- (char *)malloc((unsigned)(strlen(subline)));
- /* XXX check malloc return */
- /* skip the leading '!' */
- (void) strcpy(unsubs[unind].zsub_class,subline+1);
- unsubs[unind].zsub_classinst =
- (char *)malloc((unsigned)(strlen(comma+1)+1));
- /* XXX check malloc return */
- (void) strcpy(unsubs[unind].zsub_classinst,comma+1);
- unsubs[unind].zsub_recipient =
- (char *)malloc((unsigned)(strlen(comma2+1)+1));
- /* XXX check malloc return */
- (void) strcpy(unsubs[unind].zsub_recipient,comma2+1);
- unind++;
- } else if (*subline == '-') { /* an suppression */
- punts[puntind].zsub_class =
- (char *)malloc((unsigned)(strlen(subline)));
- /* XXX check malloc return */
- /* skip the leading '-' */
- (void) strcpy(punts[puntind].zsub_class,subline+1);
- punts[puntind].zsub_classinst =
- (char *)malloc((unsigned)(strlen(comma+1)+1));
- /* XXX check malloc return */
- (void) strcpy(punts[puntind].zsub_classinst,comma+1);
- punts[puntind].zsub_recipient =
- (char *)malloc((unsigned)(strlen(comma2+1)+1));
- /* XXX check malloc return */
- (void) strcpy(punts[puntind].zsub_recipient,comma2+1);
- puntind++;
- } else {
- subs[ind].zsub_class =
- (char *)malloc((unsigned)(strlen(subline)+1));
- /* XXX check malloc return */
- (void) strcpy(subs[ind].zsub_class,subline);
- subs[ind].zsub_classinst =
- (char *)malloc((unsigned)(strlen(comma+1)+1));
- /* XXX check malloc return */
- (void) strcpy(subs[ind].zsub_classinst,comma+1);
- subs[ind].zsub_recipient =
- (char *)malloc((unsigned)(strlen(comma2+1)+1));
- /* XXX check malloc return */
- (void) strcpy(subs[ind].zsub_recipient,comma2+1);
- ind++;
- }
- if (ind == SUBSATONCE) {
- fix_macros(subs,subs2,ind);
- if ((retval = (type == SUB)?
- ZSubscribeTo(galaxy, subs2,ind,(u_short)wgport):
- ZUnsubscribeTo(galaxy, subs2,ind,(u_short)wgport)) !=
- ZERR_NONE) {
- goto cleanup;
- }
- for (i=0;i<ind;i++) {
- free(subs[i].zsub_class);
- free(subs[i].zsub_classinst);
- free(subs[i].zsub_recipient);
- }
- ind = 0;
- }
- if (unind == SUBSATONCE) {
- fix_macros(unsubs,subs2,unind);
- if ((retval = ZUnsubscribeTo(galaxy, subs2,unind,(u_short)wgport)) != ZERR_NONE) {
- goto cleanup;
- }
- for (i=0;i<unind;i++) {
- free(unsubs[i].zsub_class);
- free(unsubs[i].zsub_classinst);
- free(unsubs[i].zsub_recipient);
- }
- unind = 0;
- }
- if (puntind) {
- fix_macros(punts,subs2,puntind);
-
- if (retval = xpunt(punts[0].zsub_class,
- punts[0].zsub_classinst,
- punts[0].zsub_recipient,
- (type == SUB)?PUNT:UNPUNT))
- goto cleanup;
-
- free(punts[0].zsub_class);
- free(punts[0].zsub_classinst);
- free(punts[0].zsub_recipient);
-
- puntind = 0;
- }
- }
- }
-
- if (type != LIST) {
- /* even if we have no subscriptions, be sure to send
- an empty packet to trigger the default subscriptions */
- fix_macros(subs,subs2,ind);
- if ((retval = (type == SUB)?ZSubscribeTo(galaxy, subs2,ind,(u_short)wgport):
- ZUnsubscribeTo(galaxy, subs2,ind,(u_short)wgport)) != ZERR_NONE) {
- goto cleanup;
- }
- if (unind) {
- fix_macros(unsubs,subs2,unind);
- if ((retval =
- ZUnsubscribeTo(galaxy, subs2,unind,(u_short)wgport)) != ZERR_NONE) {
- goto cleanup;
- }
- }
- }
-
- retval = 0;
-
-cleanup:
- for (i=0;i<ind;i++) {
- free(subs[i].zsub_class);
- free(subs[i].zsub_classinst);
- free(subs[i].zsub_recipient);
- }
- for (i=0;i<unind;i++) {
- free(unsubs[i].zsub_class);
- free(unsubs[i].zsub_classinst);
- free(unsubs[i].zsub_recipient);
- }
- for (i=0;i<puntind;i++) {
- free(unsubs[i].zsub_class);
- free(unsubs[i].zsub_classinst);
- free(unsubs[i].zsub_recipient);
- }
-
- if (fp)
- (void) fclose(fp); /* ignore errs--file is read-only */
- return(retval);
-}
-
-Code_t load_all_sub_files(type, basefile)
- int type;
- char *basefile;
-{
- Code_t retval, code;
- int i, cnt;
- char *galaxy, *exp;
- char fn[MAXPATHLEN];
-
- if (retval = ZGetGalaxyCount(&cnt))
- return(retval);
-
- for (i=0; i<cnt; i++) {
- if (retval = ZGetGalaxyName(i, &galaxy))
- return(retval);
-
- strcpy(fn, "exposure-");
- strcat(fn, galaxy);
-
- if ((((exp = ZGetVariable(fn)) == NULL) &&
- ((exp = ZGetVariable("exposure")) == NULL)) ||
- (strcasecmp(exp, EXPOSE_NONE) == 0))
- /* skip this galaxy */
- continue;
-
- if (basefile) {
- strcpy(fn, basefile);
- strcat(fn, "-");
- strcat(fn, galaxy);
- }
-
- if (type == LIST)
- printf("For galaxy %s:\n", galaxy);
-
- if ((i == 0) && basefile) {
- code = load_sub_file(type, basefile, galaxy);
- if ((code != ZERR_NONE) &&
- (code != ENOENT))
- retval = code;
- }
-
- code = load_sub_file(type, basefile?fn:NULL, galaxy);
- if ((code != ZERR_NONE) &&
- (code != ENOENT))
- retval = code;
-
- if (type == LIST)
- printf("\n");
- }
-#ifdef HAVE_KRB4
- if (retval == KRBET_AD_NOTGT)
- retval = ZERR_NONE;
-#endif
- return(retval);
-}
diff --git a/zwgc/zutils.h b/zwgc/zutils.h
deleted file mode 100644
index 483e808..0000000
--- a/zwgc/zutils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* XXX this file is duplicated in clients/zctl and clients/zwgc, until
- zctl is changed to message zwgc to perform these tasks */
-
-#define ZWGC
-
-#include <zephyr/zephyr.h>
-
-#define TOKEN_HOSTNAME "%host%"
-#define TOKEN_CANONNAME "%canon%"
-#define TOKEN_ME "%me%"
-#define TOKEN_WILD "*"
-
-#define SUBSATONCE 7
-
-#define SUB 0
-#define UNSUB 1
-#define PUNT 2
-#define UNPUNT 3
-#define LIST 4
-#define ALL 5
-
-Code_t send_wgc_control (char *, char *, int);
-void fix_macros (ZSubscription_t *, ZSubscription_t *, int);
-void fix_macros2 (char *src, char **dest);
-Code_t set_exposure (char *, char *);
-Code_t load_sub_file (int, char *, char *);
-Code_t load_all_sub_files (int, char *);
-Code_t xpunt (char *, char *, char *, int);
diff --git a/zwgc/zwgc.1 b/zwgc/zwgc.1
index 7c7126a..dc60d4b 100644
--- a/zwgc/zwgc.1
+++ b/zwgc/zwgc.1
@@ -177,7 +177,7 @@ as the information used to determine this hostname is not guaranteed to
be correct (even for authentic messages).
.TP
.B fullsender
-The notice sender's name, including the kerberos realm name.
+The notice sender's name, including the zephyr realm name.
.TP
.B instance
The instance of the current notice.
@@ -209,8 +209,8 @@ The recipient for the current notice. If the notice is a multicast
(sent to several people), the recipient is set to ``*''.
.TP
.B sender
-Usually a shortened version of fullsender. If the kerberos realm of
-the sender is equal to the kerberos realm of the zephyr servers,
+Usually a shortened version of fullsender. If the realm of the sender
+is equal to the realm of the recipient,
.I sender
omits the realm name.
.TP
@@ -380,7 +380,6 @@ created, its mode is set to read-write, owner only (no access for others).
.TP
.B break
Exits the innermost if, case, or while block.
-.\" .if n .ll +2in
.TP
\fBcase \fIexpr1\fR [ ((\fBmatch \fIexpr\fR [,\fIexpr ...\fR]) | \fBdefault\fR)\fI commands \fR] ... \fBendcase\fR
Evaluates \fIexpr1\fR. Then, each of the match expressions is
@@ -427,7 +426,6 @@ of the process.
Completes processing of the current notice. The remainder of the
description file is ignored after execution of this command.
.\" hack because the following line otherwise breaks because it is too long.
-.\" .if n .ll +2in
.TP
\fBif \fIexpr1 \fBthen \fIcommands1\fR [\fBelseif \fIexpr2 \fBthen \fIcommands2\fR] ... [\fBelse \fIcommandsn\fR] \fBendif\fR
If \fIexpr1\fR evaluates to true, execute \fIcommands1\fI, etc. [A conditional
@@ -535,10 +533,7 @@ the TERMCAP entry (see
for the terminal named by the TERM environment variable.
Supported @ commands are:
.RS 10
-.\" .TQ 15
-.\" @em
-.\" Emphasis. Use underline if available, else reverse video.
-.TP
+.TP 15
@roman
Roman (plain) letters (turns off all special modes).
.TP
@@ -551,15 +546,6 @@ Italic letters (underlining, if available).
@beep
"bl" termcap entry, else "^G" (beep the terminal); limited to once per
message.
-.\" .TQ
-.\" @blink
-.\" "mb"/"me" termcap entry, else nothing.
-.\" .TQ
-.\" @rv
-.\" "so"/"se" termcap entry.
-.\" .TQ
-.\" @u
-.\" "us"/"ue" termcap entry.
.TP
@l or @left
left aligned
@@ -825,6 +811,27 @@ entirely.
Transient
Secondary transient determining value [default False]
.TP
+allDesktops
+(logical) Primary value which determines if zephyrgram windows should
+appear on all desktops, for those window managers which support multiple
+desktops (sometimes referred to as workspaces). When this resource is
+true (the default),
+.I zwgc
+sets the \fB_NET_WM_DESKTOP\fR property to 0xFFFFFFFF for each zephyrgram
+window, indicating that it should appear on all desktops.
+.TP
+AllDesktops
+Secondary value determining whether zephyrgram windows should appear
+on all desktops.
+.TP
+scrollDelete
+(logical) If true, scrolling over a zgram will cause it
+to be deleted
+.TP
+ScrollDelete
+Secondary value to enable deletion of a zgram by scrolling over it
+[default False]
+.TP
enableDelete
(logical) If true, zwgc creates a WM_PROTOCOLS property on all zgrams, with
WM_DELETE_WINDOW as contents.
@@ -969,7 +976,12 @@ SIGINT, SIGQUIT, and SIGTSTP are ignored because they can be sent
inadvertently, and bizarre side-effects can result. If you want them
to be acted on, then run
.I zwgc -nofork &
-
+.PP
+If
+.I zwgc
+receives a SIGUSR1, it will rewrite the file used to store the
+WindowGram port number ($WGFILE or /tmp/wg.\fIuid\fR), in the event
+that the file has been lost.
.SH CONTROL MESSAGES
In order to allow some special user controls over the behavior of
.IR zwgc ,
@@ -1028,7 +1040,7 @@ System-wide description file
/usr/athena/share/zephyr/zwgc_resources
Default X application resources.
.TP
-$HOME/.zephyr.vars
+$ZEPHYR_VARS or $HOME/.zephyr.vars
File containing variable definitions
.TP
$HOME/.zephyr.subs
diff --git a/zwgc/zwgc.desc b/zwgc/zwgc.desc
index 90a5666..48c7fe3 100644
--- a/zwgc/zwgc.desc
+++ b/zwgc/zwgc.desc
@@ -63,10 +63,11 @@ match "message"
set type = "Instance "+$instance
endif
- fields signature body
- if ($body == "") then
- set body = $signature
+ if ($number_of_fields == "1") then
+ fields body
set signature = ""
+ else
+ fields signature body
endif
if ($signature =~ "^[Ff]rom: .*") then
set dummy = lany($signature,"From: ")