summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorGravatar Greg Hudson <ghudson@mit.edu>1997-09-14 17:50:06 +0000
committerGravatar Greg Hudson <ghudson@mit.edu>1997-09-14 17:50:06 +0000
commitac16f380e349fa39ec7e26bccb5456cb300006a5 (patch)
treec07ca88af97b4f6b77d28a2dc723d2e4621ed302 /clients
parentd33e482744fad80d95cdd89ed380c5b8401e49bf (diff)
Pull in sources from zephyr locker. See /mit/zephyr/repository for
detailed change information.
Diffstat (limited to 'clients')
-rw-r--r--clients/Imakefile20
-rw-r--r--clients/syslogd/Imakefile28
-rw-r--r--clients/syslogd/Makefile.in47
-rw-r--r--clients/syslogd/syslog.3184
-rw-r--r--clients/syslogd/syslog.c206
-rw-r--r--clients/syslogd/syslog.conf20
-rw-r--r--clients/syslogd/syslog.h5
-rw-r--r--clients/syslogd/syslogd.c433
-rw-r--r--clients/xzwrite/GetString.c25
-rw-r--r--clients/xzwrite/Imakefile28
-rw-r--r--clients/xzwrite/Makefile.in57
-rw-r--r--clients/xzwrite/Makefile.old96
-rw-r--r--clients/xzwrite/XZwrite.in (renamed from clients/xzwrite/XZwrite)4
-rw-r--r--clients/xzwrite/bfgets.c2
-rw-r--r--clients/xzwrite/destlist.c23
-rw-r--r--clients/xzwrite/destlist.c.old417
-rw-r--r--clients/xzwrite/gethomedir.c3
-rw-r--r--clients/xzwrite/interface.c23
-rw-r--r--clients/xzwrite/logins.c15
-rw-r--r--clients/xzwrite/util.c25
-rw-r--r--clients/xzwrite/xzwrite-proto.h123
-rw-r--r--clients/xzwrite/xzwrite.c15
-rw-r--r--clients/xzwrite/xzwrite.h2
-rw-r--r--clients/xzwrite/zephyr.c34
-rw-r--r--clients/xzwrite/zephyr.c.old269
-rw-r--r--clients/zaway/Imakefile15
-rw-r--r--clients/zaway/Makefile.in47
-rw-r--r--clients/zaway/zaway.c29
-rw-r--r--clients/zctl/Imakefile16
-rw-r--r--clients/zctl/Makefile.in61
-rw-r--r--clients/zctl/zctl.19
-rw-r--r--clients/zctl/zctl.c51
-rw-r--r--clients/zctl/zctl_cmds.ct3
-rw-r--r--clients/zleave/Imakefile15
-rw-r--r--clients/zleave/Makefile.in47
-rw-r--r--clients/zleave/zleave.c25
-rw-r--r--clients/zlocate/Imakefile15
-rw-r--r--clients/zlocate/Makefile.in47
-rw-r--r--clients/zlocate/zlocate.c22
-rw-r--r--clients/zmailnotify/Imakefile19
-rw-r--r--clients/zmailnotify/Makefile.in47
-rw-r--r--clients/zmailnotify/zmailnotify.c66
-rw-r--r--clients/znol/Imakefile15
-rw-r--r--clients/znol/Makefile.in47
-rw-r--r--clients/znol/znol.c9
-rw-r--r--clients/zpopnotify/Imakefile13
-rw-r--r--clients/zpopnotify/Makefile.in47
-rw-r--r--clients/zpopnotify/zpopnotify.c5
-rw-r--r--clients/zshutdown_notify/Imakefile16
-rw-r--r--clients/zshutdown_notify/Makefile.in47
-rw-r--r--clients/zshutdown_notify/zshutdown_notify.c18
-rw-r--r--clients/zstat/Imakefile15
-rw-r--r--clients/zstat/Makefile.in47
-rw-r--r--clients/zstat/zserver.h4
-rw-r--r--clients/zstat/zstat.c143
-rw-r--r--clients/zwrite/Imakefile15
-rw-r--r--clients/zwrite/Makefile.in47
-rw-r--r--clients/zwrite/zwrite.13
-rw-r--r--clients/zwrite/zwrite.c67
59 files changed, 1137 insertions, 2059 deletions
diff --git a/clients/Imakefile b/clients/Imakefile
deleted file mode 100644
index c657507..0000000
--- a/clients/Imakefile
+++ /dev/null
@@ -1,20 +0,0 @@
-/**/# Copyright 1988, 1993 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Header$
-/**/#
-
-#ifndef X11_NO_XAW
-XZWRITE=xzwrite
-#endif
-#if defined(HESIOD) && defined(KERBEROS)
-ZMAILNOTIFY= zmailnotify
-#endif
-
-#define ISUBDIRS zaway zctl zleave zlocate znol \
- zmailnotify zpopnotify zshutdown_notify zstat zwrite \
- syslogd xzwrite
diff --git a/clients/syslogd/Imakefile b/clients/syslogd/Imakefile
deleted file mode 100644
index 7700960..0000000
--- a/clients/syslogd/Imakefile
+++ /dev/null
@@ -1,28 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-#ifdef _AIX
-MACHLIBS= -lsrc
-#endif
-
-SRCS = syslogd.c logger.c syslog.c
-
-DOBJS = syslogd.o
-LOBJS= logger.o syslog.o
-
-#ifdef SYSLOG_COMPAT42
-COMPAT = -DCOMPAT42
-SimpleProgram(logger,$(LOBJS),,$(ATHETCDIR))
-#endif
-
-XDEFS = -I. $(COMPAT)
-
-SimpleProgram(syslogd,$(DOBJS) $(ZLIB),$(ZLIBS) $(MACHLIBS),$(ATHRETCDIR))
-install_man(syslogd.8,syslogd.8)
diff --git a/clients/syslogd/Makefile.in b/clients/syslogd/Makefile.in
new file mode 100644
index 0000000..15c64da
--- /dev/null
+++ b/clients/syslogd/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${srcdir} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err @SLIB@
+
+OBJS= syslogd.o
+
+all: syslogd
+
+syslogd: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: syslogd
+ ${INSTALL} -m 755 -s syslogd ${DESTDIR}${sbindir}
+ ${INSTALL} -m 644 ${srcdir}/syslogd.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ rm -f ${OBJS} syslogd
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/syslogd/syslog.3 b/clients/syslogd/syslog.3
deleted file mode 100644
index 8acef78..0000000
--- a/clients/syslogd/syslog.3
+++ /dev/null
@@ -1,184 +0,0 @@
-.\" Copyright (c) 1983 Regents of the University of California.
-.\" All rights reserved. The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
-.\"
-.\" @(#)syslog.3 6.6 (Berkeley) 5/15/86
-.\"
-.TH SYSLOG 3 "May 15, 1986"
-.UC 5
-.SH NAME
-syslog, openlog, closelog, setlogmask \- control system log
-.SH SYNOPSIS
-.B "#include <syslog.h>
-.PP
-.B "openlog(ident, logopt, facility)
-.br
-.B "char *ident;
-.PP
-.B "syslog(priority, message, parameters ... )
-.br
-.B "char *message;
-.PP
-.B "closelog()
-.PP
-.B "setlogmask(maskpri)
-.SH DESCRIPTION
-.I Syslog
-arranges to write
-.I message
-onto the system log maintained by
-.IR syslogd (8).
-The message is tagged with
-.IR priority .
-The message looks like a
-.IR printf (3)
-string except that
-.B %m
-is replaced by the current error message (collected from
-.IR errno ).
-A trailing newline is added if needed.
-This message will be read by
-.IR syslogd (8)
-and written to the system console, log files, or forwarded to
-.I syslogd
-on another host as appropriate.
-.PP
-Priorities are encoded as a
-.I facility
-and a
-.IR level .
-The facility describes the part of the system
-generating the message.
-The level is selected from an ordered list:
-.IP LOG_EMERG \w'LOG_WARNING'u+3
-A panic condition.
-This is normally broadcast to all users.
-.IP LOG_ALERT \w'LOG_WARNING'u+3
-A condition that should be corrected immediately,
-such as a corrupted system database.
-.IP LOG_CRIT \w'LOG_WARNING'u+3
-Critical conditions,
-e.g., hard device errors.
-.IP LOG_ERR \w'LOG_WARNING'u+3
-Errors.
-.IP LOG_WARNING \w'LOG_WARNING'u+3
-Warning messages.
-.IP LOG_NOTICE \w'LOG_WARNING'u+3
-Conditions that are not error conditions,
-but should possibly be handled specially.
-.IP LOG_INFO \w'LOG_WARNING'u+3
-Informational messages.
-.IP LOG_DEBUG \w'LOG_WARNING'u+3
-Messages that contain information
-normally of use only when debugging a program.
-.PP
-If
-.I syslog
-cannot pass the message to
-.IR syslogd ,
-it will attempt to write the message on
-.I /dev/console
-if the LOG_CONS option is set (see below).
-.PP
-If special processing is needed,
-.I openlog
-can be called to initialize the log file.
-The parameter
-.I ident
-is a string that is prepended to every message.
-.I Logopt
-is a bit field indicating logging options.
-Current values for
-.I logopt
-are:
-.IP LOG_PID \w'LOG_WARNING'u+3
-log the process id with each message:
-useful for identifying instantiations of daemons.
-.IP LOG_CONS \w'LOG_WARNING'u+3
-Force writing messages to the console if unable to send it to
-.I syslogd.
-This option is safe to use in daemon processes that have no controlling
-terminal since
-.I syslog
-will fork before opening the console.
-.IP LOG_NDELAY \w'LOG_WARNING'u+3
-Open the connection to
-.I syslogd
-immediately.
-Normally the open is delayed
-until the first message is logged.
-Useful for programs that need to manage the
-order in which file descriptors are allocated.
-.IP LOG_NOWAIT \w'LOG_WARNING'u+3
-Don't wait for children forked to log messages on the console.
-This option should be used by processes that enable notification
-of child termination via SIGCHLD, as
-.I syslog
-may otherwise block waiting for a child whose exit status has already
-been collected.
-.PP
-The
-.I facility
-parameter encodes a default facility to be assigned to all messages
-that do not have an explicit facility encoded:
-.IP LOG_KERN \w'LOG_WARNING'u+3
-Messages generated by the kernel.
-These cannot be generated by any user processes.
-.IP LOG_USER \w'LOG_WARNING'u+3
-Messages generated by random user processes.
-This is the default facility identifier if none is specified.
-.IP LOG_MAIL \w'LOG_WARNING'u+3
-The mail system.
-.IP LOG_DAEMON \w'LOG_WARNING'u+3
-System daemons, such as
-.IR ftpd (8),
-.IR routed (8),
-etc.
-.IP LOG_AUTH \w'LOG_WARNING'u+3
-The authorization system:
-.IR login (1),
-.IR su (1),
-.IR getty (8),
-etc.
-.IP LOG_LPR \w'LOG_WARNING'u+3
-The line printer spooling system:
-.IR lpr (1),
-.IR lpc (8),
-.IR lpd (8),
-etc.
-.IP LOG_LOCAL0 \w'LOG_WARNING'u+3
-Reserved for local use.
-Similarly for LOG_LOCAL1 through LOG_LOCAL7.
-.PP
-.I Closelog
-can be used to close the log file.
-.PP
-.I Setlogmask
-sets the log priority mask to
-.I maskpri
-and returns the previous mask.
-Calls to
-.I syslog
-with a priority not set in
-.I maskpri
-are rejected.
-The mask for an individual priority
-.I pri
-is calculated by the macro LOG_MASK(\fIpri\fP);
-the mask for all priorities up to and including
-.I toppri
-is given by the macro LOG_UPTO(\fItoppri\fP).
-The default allows all priorities to be logged.
-.SH EXAMPLES
-.nf
-syslog(LOG_ALERT, "who: internal error 23");
-
-openlog("ftpd", LOG_PID, LOG_DAEMON);
-setlogmask(LOG_UPTO(LOG_ERR));
-syslog(LOG_INFO, "Connection from host %d", CallingHost);
-
-syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
-.fi
-.SH "SEE ALSO"
-logger(1),
-syslogd(8)
diff --git a/clients/syslogd/syslog.c b/clients/syslogd/syslog.c
deleted file mode 100644
index 378c987..0000000
--- a/clients/syslogd/syslog.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1983, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)syslog.c 5.14 (Berkeley) 5/20/88";
-#endif /* LIBC_SCCS and not lint */
-
-
-/*
- * SYSLOG -- print message on log file
- *
- * This routine looks a lot like printf, except that it
- * outputs to the log file instead of the standard output.
- * Also:
- * adds a timestamp,
- * prints the module name in front of the message,
- * has some other formatting types (or will sometime),
- * adds a newline on the end of the message.
- *
- * The output of this routine is intended to be read by /etc/syslogd.
- *
- * Author: Eric Allman
- * Modified to use UNIX domain IPC by Ralph Campbell
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/signal.h>
-#include <syslog.h>
-#include <netdb.h>
-#include <string.h>
-
-#define MAXLINE 1024 /* max message size */
-#define NULL 0 /* manifest */
-
-#define PRIFAC(p) (((p) & LOG_FACMASK) >> 3)
- /* XXX should be in <syslog.h> */
-#define IMPORTANT LOG_ERR
-
-static char logname[] = "/dev/log";
-static char ctty[] = "/dev/console";
-
-static int LogFile = -1; /* fd for log */
-static int LogStat = 0; /* status bits, set by openlog() */
-static char *LogTag = "syslog"; /* string to tag the entry with */
-static int LogMask = 0xff; /* mask of priorities to be logged */
-static int LogFacility = LOG_USER; /* default facility code */
-
-static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
-
-extern int errno, sys_nerr;
-extern char *sys_errlist[];
-
-syslog(pri, fmt, p0, p1, p2, p3, p4)
- int pri;
- char *fmt;
-{
- char buf[MAXLINE + 1], outline[MAXLINE + 1];
- register char *b, *f, *o;
- register int c;
- long now;
- int pid, olderrno = errno;
-
- /* see if we should just throw out this message */
- if ((unsigned) PRIFAC(pri) >= LOG_NFACILITIES ||
- (LOG_MASK(pri & LOG_PRIMASK) & LogMask) == 0 ||
- (pri &~ (LOG_PRIMASK|LOG_FACMASK)) != 0)
- return;
- if (LogFile < 0)
- openlog(LogTag, LogStat | LOG_NDELAY, 0);
-
- /* set default facility if none specified */
- if ((pri & LOG_FACMASK) == 0)
- pri |= LogFacility;
-
- /* build the message */
- o = outline;
- (void)sprintf(o, "<%d>", pri);
- o += strlen(o);
- time(&now);
- (void)sprintf(o, "%.15s ", ctime(&now) + 4);
- o += strlen(o);
- if (LogTag) {
- strcpy(o, LogTag);
- o += strlen(o);
- }
- if (LogStat & LOG_PID) {
- (void)sprintf(o, "[%d]", getpid());
- o += strlen(o);
- }
- if (LogTag) {
- strcpy(o, ": ");
- o += 2;
- }
-
- b = buf;
- f = fmt;
- while ((c = *f++) != '\0' && c != '\n' && b < &buf[MAXLINE]) {
- if (c != '%') {
- *b++ = c;
- continue;
- }
- if ((c = *f++) != 'm') {
- *b++ = '%';
- *b++ = c;
- continue;
- }
- if ((unsigned)olderrno > sys_nerr)
- (void)sprintf(b, "error %d", olderrno);
- else
- strcpy(b, sys_errlist[olderrno]);
- b += strlen(b);
- }
- *b++ = '\n';
- *b = '\0';
- (void)sprintf(o, buf, p0, p1, p2, p3, p4);
- c = strlen(outline);
- if (c > MAXLINE)
- c = MAXLINE;
-
- /* output the message to the local logger */
- if (sendto(LogFile, outline, c, 0, &SyslogAddr, sizeof SyslogAddr) >= 0)
- return;
- if (!(LogStat & LOG_CONS))
- return;
-
- /* output the message to the console */
- pid = vfork();
- if (pid == -1)
- return;
- if (pid == 0) {
- int fd;
-
- signal(SIGALRM, SIG_DFL);
- sigsetmask(sigblock(0L) & ~sigmask(SIGALRM));
- alarm(5);
- fd = open(ctty, O_WRONLY);
- alarm(0);
- strcat(o, "\r");
- o = index(outline, '>') + 1;
- write(fd, o, c + 1 - (o - outline));
- close(fd);
- _exit(0);
- }
- if (!(LogStat & LOG_NOWAIT))
- while ((c = wait((int *)0)) > 0 && c != pid)
- ;
-}
-
-/*
- * OPENLOG -- open system log
- */
-
-openlog(ident, logstat, logfac)
- char *ident;
- int logstat, logfac;
-{
- if (ident != NULL)
- LogTag = ident;
- LogStat = logstat;
- if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
- LogFacility = logfac;
- if (LogFile >= 0)
- return;
- SyslogAddr.sa_family = AF_UNIX;
- strncpy(SyslogAddr.sa_data, logname, sizeof SyslogAddr.sa_data);
- if (LogStat & LOG_NDELAY) {
- LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
- fcntl(LogFile, F_SETFD, 1);
- }
-}
-
-/*
- * CLOSELOG -- close the system log
- */
-
-closelog()
-{
-
- (void) close(LogFile);
- LogFile = -1;
-}
-
-/*
- * SETLOGMASK -- set the log mask level
- */
-setlogmask(pmask)
- int pmask;
-{
- int omask;
-
- omask = LogMask;
- if (pmask != 0)
- LogMask = pmask;
- return (omask);
-}
diff --git a/clients/syslogd/syslog.conf b/clients/syslogd/syslog.conf
deleted file mode 100644
index 52dc6b1..0000000
--- a/clients/syslogd/syslog.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-# Syslog daemon configuration file
-#
-# $Header$
-# $Source$
-# $Author$
-#
-*.alert;kern.debug;auth.notice /dev/console
-*.alert;kern.debug;auth.notice jon
-*.notice;kern.debug /site/usr/adm/messages
-*.notice;kern.debug jon
-mail.info /site/usr/spool/mqueue/syslog
-mail.info jon
-local0.info jon
-# local0 is for rshd
-local1.info /site/usr/adm/sulog
-local1.info jon
-#local1 is for su
-*.panic !*
-local2.debug jon
-
diff --git a/clients/syslogd/syslog.h b/clients/syslogd/syslog.h
index 139742c..eee7ec0 100644
--- a/clients/syslogd/syslog.h
+++ b/clients/syslogd/syslog.h
@@ -19,6 +19,9 @@
#define LOG_LPR (6<<3) /* line printer subsystem */
#define LOG_NEWS (7<<3) /* network news subsystem */
#define LOG_UUCP (8<<3) /* UUCP subsystem */
+#define LOG_CRON (9<<3) /* clock daemon */
+#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
+#define LOG_FTP (11<<3) /* ftp daemon */
/* other codes through 15 reserved for system use */
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
@@ -47,7 +50,7 @@
#define LOG_INFO 6 /* informational */
#define LOG_DEBUG 7 /* debug-level messages */
-#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */
+#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
#define LOG_PRI(p) ((p) & LOG_PRIMASK) /* extract priority */
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
diff --git a/clients/syslogd/syslogd.c b/clients/syslogd/syslogd.c
index 7a86006..5886fe8 100644
--- a/clients/syslogd/syslogd.c
+++ b/clients/syslogd/syslogd.c
@@ -45,6 +45,8 @@ static char sccsid[] = "@(#)syslogd.c 5.24 (Berkeley) 6/18/88";
* more extensive changes by Eric Allman (again)
* changes for Zephyr and a little dynamic allocation
* by Jon Rochlis (MIT), July 1987
+ * fixes, dynamic allocation, autoconf changes by Greg Hudson (MIT), 1995
+ * Solaris support by John Hawkinson (MIT), 1995
*/
#define MAXLINE 1024 /* maximum line length */
@@ -53,85 +55,51 @@ static char sccsid[] = "@(#)syslogd.c 5.24 (Berkeley) 6/18/88";
#define DEFSPRI (LOG_KERN|LOG_CRIT)
#define TIMERINTVL 30 /* interval for checking flush, mark */
-#ifdef SOLARIS
-#define MSG_BSIZE BUFSIZ
+#if defined(__sun__) && defined(__svr4__)
#define STREAMS_LOG_DRIVER
#endif
+#ifdef STREAMS_LOG_DRIVER
+#undef COMPAT42
+#endif
-#include <stdio.h>
-#include <sys/types.h>
-#include <time.h>
-#ifdef _IBMR2
-#include <sys/select.h>
+#include <sysdep.h>
+#ifdef HAVE_SRC
#include <spc.h> /* For support of the SRC system */
#endif
#include <utmp.h>
-#include <ctype.h>
-#include <string.h>
#include <setjmp.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
#include <sys/socket.h>
-#include <sys/file.h>
-#ifndef COMPAT42
-#include <sys/msgbuf.h>
-#endif
-#include <sys/uio.h>
#include <sys/un.h>
-#include <sys/time.h>
#include <sys/resource.h>
-#include <sys/signal.h>
+#include <sys/uio.h>
#include <netdb.h>
-
#ifdef STREAMS_LOG_DRIVER
#include <sys/stream.h>
#include <sys/strlog.h>
#include <sys/log.h>
-
#include <poll.h>
#include <stropts.h>
#endif
-#ifdef POSIX
-#include <termios.h>
-#endif
-
#include <zephyr/zephyr.h>
+#include <com_err.h>
-extern int sys_nerr;
-#ifdef SUNOS
-extern char *sys_errlist[];
-#define strerror(n) sys_errlist[n]
-#endif
-
-#if defined(ultrix) || defined(POSIX)
-#define sighandler_type void
+#ifdef _PATH_VARRUN
+#define PIDDIR _PATH_VARRUN
#else
-#define sighandler_type int
+#define PIDDIR "/etc/"
#endif
#define CTTY "/dev/console"
char *LogName = "/dev/log";
-#ifdef COMPAT42
-char *ConfFile = "/etc/nsyslog.conf";
-char *PidFile = "/etc/nsyslog.pid";
-#else /* !COMPAT42 */
-char *ConfFile = "/etc/syslog.conf";
-char *PidFile = "/etc/syslog.pid";
-#endif /* COMPAT42 */
+char ConfFile[128];
+char PidFile[128];
char ctty[] = CTTY;
#define FDMASK(fd) (1 << (fd))
#define dprintf if (Debug) printf
-#define UNAMESZ ANAME_SZ+INST_SZ+REALM_SZ /* 8 isn't good enough anymore */
-#define UTMPNAMESZ 8
#define MAXUNAMES 20 /* maximum number of user names */
#define MAXFNAME 200 /* max file pathname length */
@@ -159,7 +127,7 @@ struct filed {
time_t f_time; /* time this was last written */
u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
union {
- char f_uname[MAXUNAMES][UNAMESZ+1];
+ char *f_uname[MAXUNAMES];
struct {
char f_hname[MAXHOSTNAMELEN+1];
struct sockaddr_in f_addr;
@@ -215,6 +183,7 @@ int LogPort; /* port number for INET connections */
int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
+time_t now;
ZNotice_t znotice; /* for zephyr notices */
@@ -228,73 +197,95 @@ struct code {
};
struct code PriNames[] = {
- "panic", LOG_EMERG,
- "alert", LOG_ALERT,
- "crit", LOG_CRIT,
- "error", LOG_ERR,
- "warning", LOG_WARNING,
- "notice", LOG_NOTICE,
- "info", LOG_INFO,
- "debug", LOG_DEBUG,
- "none", NOPRI,
- "emerg", LOG_EMERG,
- "err", LOG_ERR,
- "warn", LOG_WARNING,
- NULL, -1
+ { "panic", LOG_EMERG },
+ { "alert", LOG_ALERT },
+ { "crit", LOG_CRIT },
+ { "error", LOG_ERR },
+ { "warning", LOG_WARNING },
+ { "notice", LOG_NOTICE },
+ { "info", LOG_INFO },
+ { "debug", LOG_DEBUG },
+ { "none", NOPRI },
+ { "emerg", LOG_EMERG },
+ { "err", LOG_ERR },
+ { "warn", LOG_WARNING },
+ { NULL, -1 }
};
/* reserved added so zephyr can use this table */
struct code FacNames[] = {
- "kern", LOG_KERN,
- "user", LOG_USER,
- "mail", LOG_MAIL,
- "daemon", LOG_DAEMON,
- "auth", LOG_AUTH,
- "syslog", LOG_SYSLOG,
- "lpr", LOG_LPR,
- "news", LOG_NEWS,
- "uucp", LOG_UUCP,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "reserved", -1,
- "local0", LOG_LOCAL0,
- "local1", LOG_LOCAL1,
- "local2", LOG_LOCAL2,
- "local3", LOG_LOCAL3,
- "local4", LOG_LOCAL4,
- "local5", LOG_LOCAL5,
- "local6", LOG_LOCAL6,
- "local7", LOG_LOCAL7,
- "security", LOG_AUTH,
- "mark", LOG_MARK,
- NULL, -1
+ { "kern", LOG_KERN },
+ { "user", LOG_USER },
+ { "mail", LOG_MAIL },
+ { "daemon", LOG_DAEMON },
+ { "auth", LOG_AUTH },
+ { "syslog", LOG_SYSLOG },
+ { "lpr", LOG_LPR },
+ { "news", LOG_NEWS },
+ { "uucp", LOG_UUCP },
+ { "cron", LOG_CRON },
+ { "authpriv", LOG_AUTHPRIV },
+ { "ftp", LOG_FTP },
+ { "reserved", -1 },
+ { "reserved", -1 },
+ { "reserved", -1 },
+ { "cron", LOG_CRON },
+ { "local0", LOG_LOCAL0 },
+ { "local1", LOG_LOCAL1 },
+ { "local2", LOG_LOCAL2 },
+ { "local3", LOG_LOCAL3 },
+ { "local4", LOG_LOCAL4 },
+ { "local5", LOG_LOCAL5 },
+ { "local6", LOG_LOCAL6 },
+ { "local7", LOG_LOCAL7 },
+ { "security", LOG_AUTH },
+ { "mark", LOG_MARK },
+ { NULL, -1 }
};
-static sighandler_type
- die(),
- domark(),
- reapchild(),
- init(),
- endtty();
+static void usage __P((void));
+static void untty __P((void));
+static void printline __P((const char *hname, char *msg));
+#ifndef STREAMS_LOG_DRIVER
+static void printsys __P((char *msg));
+#endif
+static void logmsg __P((int pri, const char *msg, const char *from,
+ int flags));
+static void fprintlog __P((register struct filed *f, int flags,
+ const char *msg, int fac, int prilev));
+static RETSIGTYPE endtty __P((int sig));
+static void wallmsg __P((register struct filed *f, struct iovec *iov));
+static RETSIGTYPE reapchild __P((int sig));
+static const char *cvthname __P((struct sockaddr_in *f));
+static RETSIGTYPE domark __P((int sig));
+static void logerror __P((const char *type));
+static RETSIGTYPE die __P((int sig));
+static RETSIGTYPE init __P((int sig));
+static void cfline __P((char *line, register struct filed *f));
+static int decode __P((char *name, struct code *codetab));
+#ifdef HAVE_SRC
+static void handle_src __P((struct srcreq packet));
+static void send_src_reply __P((struct srcreq orig_packet, int rtncode,
+ char *packet, int len));
+#endif
-main(argc, argv)
+int main(argc, argv)
int argc;
char **argv;
{
register int i;
register char *p;
- int funix, inetm = 0, fklog, klogm, len;
+ int funix, inetm = 0, klogm, len;
+#ifndef STREAMS_LOG_DRIVER
struct sockaddr_un sunx, fromunix;
+ int fklog;
+#endif
struct sockaddr_in sin, frominet;
FILE *fp;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction action;
#endif
-#ifdef _AIX
+#ifdef HAVE_SRC
int using_src = 1;
struct sockaddr srcsockaddr, fromsrc;
struct srcreq srcreq;
@@ -307,6 +298,8 @@ main(argc, argv)
char line[MSG_BSIZE + 1];
#endif
+ strcpy(ConfFile, "/etc/syslog.conf");
+ sprintf(PidFile, "%ssyslog.pid", PIDDIR);
while (--argc > 0) {
p = *++argv;
if (p[0] != '-')
@@ -314,7 +307,7 @@ main(argc, argv)
switch (p[1]) {
case 'f': /* configuration file */
if (p[2] != '\0')
- ConfFile = &p[2];
+ strcpy(ConfFile, &p[2]);
break;
case 'd': /* debug */
@@ -336,7 +329,7 @@ main(argc, argv)
}
}
-#ifdef _AIX
+#ifdef HAVE_SRC
addrlen = sizeof(struct sockaddr);
if (getsockname(0, &srcsockaddr, &addrlen) < 0) {
using_src = 0;
@@ -351,7 +344,7 @@ main(argc, argv)
#endif
if (!Debug) {
-#ifdef _AIX
+#ifdef HAVE_SRC
/* Don't fork if using SRC;
* SRC will think the program exited */
if (!using_src)
@@ -366,7 +359,7 @@ main(argc, argv)
(void) dup2(0, 2);
untty();
} else {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
static char buf[BUFSIZ];
setvbuf (stdout, buf, _IOLBF, BUFSIZ);
#else
@@ -377,13 +370,13 @@ main(argc, argv)
consfile.f_type = F_CONSOLE;
(void) strcpy(consfile.f_un.f_fname, ctty);
(void) gethostname(LocalHostName, sizeof LocalHostName);
- if (p = strchr(LocalHostName, '.')) {
+ if ((p = strchr(LocalHostName, '.')) != NULL) {
*p++ = '\0';
LocalDomain = p;
}
else
LocalDomain = "";
-#ifdef POSIX
+#ifdef _POSIX_VERSION
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
@@ -412,15 +405,15 @@ main(argc, argv)
(void) signal(SIGALRM, domark);
#endif
(void) alarm(TIMERINTVL);
-
+
#ifndef STREAMS_LOG_DRIVER
(void) unlink(LogName);
sunx.sun_family = AF_UNIX;
(void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
funix = socket(AF_UNIX, SOCK_DGRAM, 0);
- if (funix < 0 || bind(funix, (struct sockaddr *) &sunx,
- sizeof(sunx.sun_family)+strlen(sunx.sun_path)) < 0 ||
+ if (funix < 0 ||
+ bind(funix, (struct sockaddr *) &sunx, sizeof(sunx)) < 0 ||
chmod(LogName, 0666) < 0) {
(void) sprintf(line, "cannot create %s", LogName);
logerror(line);
@@ -451,7 +444,6 @@ main(argc, argv)
finet = socket(AF_INET, SOCK_DGRAM, 0);
if (finet >= 0) {
struct servent *sp;
- int one = 1;
sp = getservbyname("syslog", "udp");
if (sp == NULL) {
@@ -465,7 +457,7 @@ main(argc, argv)
#ifdef COMPAT42
(void) close(finet);
#else
- if (bind(finet, &sin, sizeof(sin)) < 0) {
+ if (bind(finet, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
logerror("bind");
if (!Debug)
die(0);
@@ -475,25 +467,27 @@ main(argc, argv)
}
#endif /* COMPAT42 */
}
-#if defined(COMPAT42)
+#ifdef COMPAT42
InetInuse = 1;
inetm = 0;
klogm = 0;
-#elif defined(STREAMS_LOG_DRIVER)
+#else
+#ifdef STREAMS_LOG_DRIVER
klogm = 0;
-#else /* !COMPAT42, !STREAMS_LOG_DRIVER */
+#else
if ((fklog = open("/dev/klog", O_RDONLY)) >= 0)
klogm = FDMASK(fklog);
else {
dprintf("can't open /dev/klog (%d)\n", errno);
klogm = 0;
}
+#endif
#endif /* COMPAT42 */
/* tuck my process id away */
fp = fopen(PidFile, "w");
if (fp != NULL) {
- fprintf(fp, "%d\n", getpid());
+ fprintf(fp, "%d\n", (int) getpid());
(void) fclose(fp);
}
@@ -507,19 +501,14 @@ main(argc, argv)
znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
(void) ZInitialize ();
- init();
-#ifdef POSIX
+ init(0);
+#ifdef _POSIX_VERSION
action.sa_handler = init;
sigaction(SIGHUP, &action, NULL);
#else
(void) signal(SIGHUP, init);
#endif
-#ifndef STREAMS_LOG_DRIVER
- dprintf("fdmasks: funix=%d, inetm=%d, klogm=%d\n",
- FDMASK(funix), inetm, klogm);
-#endif
-
for (;;) {
int nfds;
#ifdef STREAMS_LOG_DRIVER
@@ -534,12 +523,12 @@ main(argc, argv)
readfds[POLLFD_unix].revents,
readfds[POLLFD_inet].fd,
readfds[POLLFD_inet].revents);
-
nfds = poll(readfds, 2, INFTIM);
#else /* STREAMS_LOG_DRIVER */
int readfds = FDMASK(funix) | inetm | klogm;
-#ifdef _AIX
+
+#ifdef HAVE_SRC
if (using_src)
readfds |= FDMASK(src_fd);
#endif
@@ -547,16 +536,15 @@ main(argc, argv)
dprintf("readfds = %#x\n", readfds);
nfds = select(20, (fd_set *) &readfds, (fd_set *) NULL,
(fd_set *) NULL, (struct timeval *) NULL);
- dprintf("got a message (%d, %#x)\n", nfds, readfds);
#endif /* STREAMS_LOG_DRIVER */
if (nfds == 0)
continue;
if (nfds < 0) {
if (errno != EINTR)
#ifdef STREAMS_LOG_DRIVER
- logerror("poll");
+ logerror("poll");
#else
- logerror("select");
+ logerror("select");
#endif
continue;
}
@@ -576,7 +564,10 @@ main(argc, argv)
i = getmsg(funix, &ctl, &dat, &flags);
if ((i==0)) {
#if (NLOGARGS != 3)
-#error This section of code assumes that NLOGARGS is 3. If that is not the case, this needs to be editted by hand. Sorry, but sed magic was too much for me.
+ error "This section of code assumes that NLOGARGS is 3.";
+ error "If that's not the case, this needs to be editted";
+ error "by hand. Sorry, but sed magic was too much for";
+ error "me.";
#else
{
char null[] = "", *p;
@@ -599,7 +590,7 @@ main(argc, argv)
} else if (i > 0) {
sprintf(line, "getmsg() > 1 (%X)", i);
logerror(line);
- }
+ }
}
#else /* STREAMS_LOG_DRIVER */
dprintf("got a message (%d, %#x)\n", nfds, readfds);
@@ -623,7 +614,7 @@ main(argc, argv)
printline(LocalHostName, line);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom unix");
- }
+ }
#endif /* STREAMS_LOG_DRIVER */
#ifdef STREAMS_LOG_DRIVER
if (readfds[POLLFD_inet].revents & (POLLIN|POLLPRI)) {
@@ -631,16 +622,15 @@ main(argc, argv)
if (readfds & inetm) {
#endif
len = sizeof frominet;
- i = recvfrom(finet, line, MAXLINE, 0, &frominet, &len);
+ i = recvfrom(finet, line, MAXLINE, 0,
+ (struct sockaddr *) &frominet, &len);
if (i > 0) {
- extern char *cvthname();
-
line[i] = '\0';
printline(cvthname(&frominet), line);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom inet");
}
-#ifdef _AIX
+#ifdef HAVE_SRC
dprintf("%d %d %d\n", using_src, readfds, FDMASK(src_fd));
if (using_src && (readfds & (FDMASK(src_fd)))) {
dprintf("got a src packet\n");
@@ -649,29 +639,33 @@ main(argc, argv)
&len);
dprintf("finished recvfrom, %d\n",i);
}
-/* if (i > 0) {
+#if 0
+ if (i > 0) {
handle_src(srcreq);
} else if (i < 0 && errno != EINTR)
logerror("recvfrom src");
- } */
-#endif /* _AIX */
+ }
+#endif
+#endif /* HAVE_SRC */
}
}
-usage()
+static void usage()
{
fprintf(stderr, "usage: syslogd [-d] [-mmarkinterval] [-ppath] [-fconffile]\n");
exit(1);
}
-untty()
+static void untty()
{
int i;
if (!Debug) {
i = open("/dev/tty", O_RDWR);
if (i >= 0) {
+#ifdef TIOCNOTTY /* Only necessary on old systems. */
(void) ioctl(i, (int) TIOCNOTTY, (char *)0);
+#endif
(void) close(i);
}
}
@@ -682,8 +676,8 @@ untty()
* on the appropriate log files.
*/
-printline(hname, msg)
- char *hname;
+static void printline(hname, msg)
+ const char *hname;
char *msg;
{
register char *p, *q;
@@ -727,7 +721,8 @@ printline(hname, msg)
* Take a raw input line from /dev/klog, split and format similar to syslog().
*/
-printsys(msg)
+#ifndef STREAMS_LOG_DRIVER
+static void printsys(msg)
char *msg;
{
register char *p, *q;
@@ -761,23 +756,22 @@ printsys(msg)
logmsg(pri, line, LocalHostName, flags);
}
}
-
-time_t now;
+#endif
/*
* Log a message to the appropriate log files, users, etc. based on
* the priority.
*/
-logmsg(pri, msg, from, flags)
+static void logmsg(pri, msg, from, flags)
int pri;
- char *msg, *from;
+ const char *msg, *from;
int flags;
{
register struct filed *f;
int fac, prilev, msglen;
- char *timestamp;
-#ifdef POSIX
+ const char *timestamp;
+#ifdef _POSIX_VERSION
sigset_t osig, sig;
#else
int omask;
@@ -785,7 +779,7 @@ logmsg(pri, msg, from, flags)
dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n", pri, flags, from, msg);
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigemptyset(&sig);
(void) sigaddset(&sig, SIGHUP);
(void) sigaddset(&sig, SIGALRM);
@@ -828,7 +822,7 @@ logmsg(pri, msg, from, flags)
fprintlog(f, flags, (char *)NULL, fac, prilev);
(void) close(f->f_file);
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigprocmask(SIG_SETMASK, &osig, (sigset_t *)0);
#else
(void) sigsetmask(omask);
@@ -855,8 +849,8 @@ logmsg(pri, msg, from, flags)
!strcmp(from, f->f_prevhost)) {
(void) strncpy(f->f_lasttime, timestamp, 15);
f->f_prevcount++;
- dprintf("msg repeated %d times, %d sec of %d\n",
- f->f_prevcount, now - f->f_time,
+ dprintf("msg repeated %d times, %ld sec of %d\n",
+ f->f_prevcount, (long)(now - f->f_time),
repeatinterval[f->f_repeatcount]);
/*
* If domark would have logged this by now,
@@ -876,6 +870,7 @@ logmsg(pri, msg, from, flags)
(void) strncpy(f->f_lasttime, timestamp, 15);
(void) strncpy(f->f_prevhost, from,
sizeof(f->f_prevhost));
+ f->f_prevhost[sizeof(f->f_prevhost) - 1] = 0;
if (msglen < MAXSVLINE) {
f->f_prevlen = msglen;
f->f_prevpri = pri;
@@ -889,23 +884,23 @@ logmsg(pri, msg, from, flags)
}
}
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigprocmask(SIG_SETMASK, &osig, (sigset_t *)0);
#else
(void) sigsetmask(omask);
#endif
}
-fprintlog(f, flags, msg, fac, prilev)
+static void fprintlog(f, flags, msg, fac, prilev)
register struct filed *f;
int flags;
- char *msg;
+ const char *msg;
int fac, prilev;
{
struct iovec iov[6];
register struct iovec *v = iov;
register int l;
- char line[MAXLINE + 1];
+ char line[MAXLINE + MAXHOSTNAMELEN + 21];
char repbuf[80];
char pri_fac_str[35];
int i;
@@ -924,7 +919,7 @@ fprintlog(f, flags, msg, fac, prilev)
v->iov_len = 1;
v++;
if (msg) {
- v->iov_base = msg;
+ v->iov_base = (char *) msg;
v->iov_len = strlen(msg);
} else if (f->f_prevcount > 1) {
(void) sprintf(repbuf, "last message repeated %d times",
@@ -953,9 +948,11 @@ fprintlog(f, flags, msg, fac, prilev)
if (l > MAXLINE)
l = MAXLINE;
#ifdef COMPAT42
- if (sendto(f->f_file, line, l, 0, &f->f_un.f_forw.f_addr,
+ if (sendto(f->f_file, line, l, 0,
+ (struct sockaddr *) &f->f_un.f_forw.f_addr,
#else
- if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
+ if (sendto(finet, line, l, 0,
+ (struct sockaddr *) &f->f_un.f_forw.f_addr,
#endif
sizeof f->f_un.f_forw.f_addr) != l) {
int e = errno;
@@ -1013,6 +1010,11 @@ fprintlog(f, flags, msg, fac, prilev)
iov[0].iov_base,
iov[2].iov_base,
iov[4].iov_base);
+ if (!msg && f->f_prevcount > 1) {
+ /* Include previous line with Zephyrgram. */
+ sprintf(line + strlen(line), ":\n%*s",
+ f->f_prevlen, f->f_prevline);
+ }
(void) sprintf(pri_fac_str, "%s.%s",
FacNames[fac].c_name,
PriNames[(prilev & LOG_PRIMASK)].c_name);
@@ -1022,7 +1024,7 @@ fprintlog(f, flags, msg, fac, prilev)
znotice.z_opcode = pri_fac_str;
dprintf (" z_opcode %s\n", pri_fac_str);
for (i = 0; i < MAXUNAMES; i++) {
- if (!f->f_un.f_uname[i][0])
+ if (!f->f_un.f_uname[i])
break;
/* map "*" into null recipient and therefore
anybody who is listening */
@@ -1047,16 +1049,16 @@ fprintlog(f, flags, msg, fac, prilev)
f->f_prevcount = 0;
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
sigjmp_buf ttybuf;
#else
jmp_buf ttybuf;
#endif
-static sighandler_type
-endtty()
+static RETSIGTYPE endtty(sig)
+ int sig;
{
-#ifdef POSIX
+#ifdef _POSIX_VERSION
siglongjmp(ttybuf, 1);
#else
longjmp(ttybuf, 1);
@@ -1070,7 +1072,7 @@ endtty()
* world, or a list of approved users.
*/
-wallmsg(f, iov)
+static void wallmsg(f, iov)
register struct filed *f;
struct iovec *iov;
{
@@ -1081,7 +1083,7 @@ wallmsg(f, iov)
struct utmp ut;
static char p[6+sizeof(ut.ut_line)] = "/dev/";
char greetings[200];
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction action;
#endif
@@ -1100,7 +1102,7 @@ wallmsg(f, iov)
* and doing notty().
*/
if (fork() == 0) {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
action.sa_flags = 0;
(void) sigemptyset(&action.sa_mask);
@@ -1136,7 +1138,7 @@ wallmsg(f, iov)
/* should we send the message to this user? */
if (f->f_type == F_USERS) {
for (i = 0; i < MAXUNAMES; i++) {
- if (!f->f_un.f_uname[i][0]) {
+ if (!f->f_un.f_uname[i]) {
i = MAXUNAMES;
break;
}
@@ -1156,7 +1158,7 @@ wallmsg(f, iov)
iov[0].iov_len = len;
iov[1].iov_len = 0;
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
if (sigsetjmp(ttybuf, 1) == 0)
#else
if (setjmp(ttybuf) == 0)
@@ -1184,23 +1186,22 @@ wallmsg(f, iov)
reenter = 0;
}
-static sighandler_type
-reapchild()
+static RETSIGTYPE reapchild(sig)
+ int sig;
{
-#ifdef POSIX
- int status;
- while (waitpid(-1, &status, WNOHANG) > 0) ;
+#ifdef HAVE_WAITPID
+ int status;
+ while (waitpid(-1, &status, WNOHANG) > 0) ;
#else
- union wait status;
- while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) ;
+ union wait status;
+ while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) ;
#endif
}
/*
* Return a printable representation of a host address.
*/
-char *
-cvthname(f)
+static const char *cvthname(f)
struct sockaddr_in *f;
{
struct hostent *hp;
@@ -1213,7 +1214,8 @@ cvthname(f)
dprintf("Malformed from address\n");
return ("???");
}
- hp = gethostbyaddr(&f->sin_addr, sizeof(struct in_addr), f->sin_family);
+ hp = gethostbyaddr((const char *) &f->sin_addr, sizeof(struct in_addr),
+ f->sin_family);
if (hp == 0) {
dprintf("Host name for your address (%s) unknown\n",
inet_ntoa(f->sin_addr));
@@ -1224,8 +1226,8 @@ cvthname(f)
return (hp->h_name);
}
-static sighandler_type
-domark()
+static RETSIGTYPE domark(sig)
+ int sig;
{
register struct filed *f;
@@ -1252,24 +1254,19 @@ domark()
/*
* Print syslogd errors some place.
*/
-logerror(type)
- char *type;
+static void logerror(type)
+ const char *type;
{
char buf[100];
- if (errno == 0)
- (void) sprintf(buf, "syslogd: %s", type);
- else if ((unsigned) errno > sys_nerr)
- (void) sprintf(buf, "syslogd: %s: error %d", type, errno);
- else
- (void) sprintf(buf, "syslogd: %s: %s", type, strerror(errno));
+ sprintf(buf, "syslogd: %s", strerror(errno));
errno = 0;
dprintf("%s\n", buf);
logmsg(LOG_SYSLOG|LOG_ERR, buf, LocalHostName, ADDDATE);
}
-static sighandler_type
-die(sig)
+static RETSIGTYPE die(sig)
+ int sig;
{
register struct filed *f;
char buf[100];
@@ -1287,7 +1284,7 @@ die(sig)
logerror(buf);
}
#ifndef STREAMS_LOG_DRIVER
- (void) unlink(LogName);
+ (void) unlink(LogName);
#endif
exit(0);
}
@@ -1296,8 +1293,8 @@ die(sig)
* INIT -- Initialize syslogd from configuration table
*/
-static sighandler_type
-init()
+static RETSIGTYPE init(sig)
+ int sig;
{
register int i;
register FILE *cf;
@@ -1316,7 +1313,6 @@ init()
if (f->f_prevcount)
fprintlog(f, 0, (char *)NULL, f->f_prevfac,
f->f_prevpri);
-
switch (f->f_type) {
case F_FILE:
case F_TTY:
@@ -1326,6 +1322,13 @@ init()
#endif
(void) close(f->f_file);
break;
+
+ case F_USERS:
+ case F_ZEPHYR:
+
+ for (i = 0; i < MAXUNAMES && f->f_un.f_uname[i]; i++)
+ free(f->f_un.f_uname[i]);
+ break;
}
next = f->f_next;
free((char *) f);
@@ -1389,7 +1392,7 @@ init()
break;
case F_USERS:
- for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++)
+ for (i = 0; i < MAXUNAMES && f->f_un.f_uname[i]; i++)
printf("%s, ", f->f_un.f_uname[i]);
break;
}
@@ -1405,7 +1408,7 @@ init()
* Crack a configuration file line
*/
-cfline(line, f)
+static void cfline(line, f)
char *line;
register struct filed *f;
{
@@ -1541,15 +1544,18 @@ cfline(line, f)
for (i = 0; i < MAXUNAMES && *p; i++) {
for (q = p; *q && *q != ','; )
q++;
- (void) strncpy(f->f_un.f_uname[i], p, UTMPNAMESZ);
- if ((q - p) > UTMPNAMESZ)
- f->f_un.f_uname[i][UTMPNAMESZ] = '\0';
- else
- f->f_un.f_uname[i][q - p] = '\0';
+ f->f_un.f_uname[i] = malloc(q - p + 1);
+ if (f->f_un.f_uname[i]) {
+ strncpy(f->f_un.f_uname[i], p, q - p);
+ f->f_un.f_uname[i][q - p] = 0;
+ } else {
+ break;
+ }
while (*q == ',' || *q == ' ')
q++;
p = q;
}
+ f->f_un.f_uname[i] = NULL;
f->f_type = F_USERS;
break;
@@ -1557,15 +1563,18 @@ cfline(line, f)
for (i = 0; i < MAXUNAMES && *p; i++) {
for (q = p; *q && *q != ','; )
q++;
- (void) strncpy(f->f_un.f_uname[i], p, UNAMESZ);
- if ((q - p) > UNAMESZ)
- f->f_un.f_uname[i][UNAMESZ] = '\0';
- else
- f->f_un.f_uname[i][q - p] = '\0';
+ f->f_un.f_uname[i] = malloc(q - p + 1);
+ if (f->f_un.f_uname[i]) {
+ strncpy(f->f_un.f_uname[i], p, q - p);
+ f->f_un.f_uname[i][q - p] = 0;
+ } else {
+ break;
+ }
while (*q == ',' || *q == ' ')
q++;
p = q;
}
+ f->f_un.f_uname[i] = NULL;
f->f_type = F_ZEPHYR;
break;
}
@@ -1576,7 +1585,7 @@ cfline(line, f)
* Decode a symbolic name to a numeric value
*/
-decode(name, codetab)
+static int decode(name, codetab)
char *name;
struct code *codetab;
{
@@ -1598,11 +1607,10 @@ decode(name, codetab)
return (-1);
}
-#ifdef _AIX
+#ifdef HAVE_SRC
/* Routines for handling the SRC (System Resource Controller) system */
-void
-handle_src(packet)
+static void handle_src(packet)
struct srcreq packet;
{
void send_src_reply();
@@ -1638,7 +1646,7 @@ handle_src(packet)
break;
case REFRESH:
if (packet.subreq.object == SUBSYSTEM) {
- init();
+ init(0);
send_src_reply(packet, SRC_OK, "", sizeof(struct srcrep));
} else {
send_src_reply(packet, SRC_SUBMSG,
@@ -1649,8 +1657,7 @@ handle_src(packet)
}
}
-void
-send_src_reply(orig_packet, rtncode, packet,len)
+static void send_src_reply(orig_packet, rtncode, packet,len)
struct srcreq orig_packet;
int rtncode;
char *packet;
@@ -1668,4 +1675,4 @@ send_src_reply(orig_packet, rtncode, packet,len)
srcsrpy(srcrrqs(&orig_packet), (char *)&reply, len, cont);
}
-#endif /* _AIX */
+#endif /* HAVE_SRC */
diff --git a/clients/xzwrite/GetString.c b/clients/xzwrite/GetString.c
index 3195c26..85e3463 100644
--- a/clients/xzwrite/GetString.c
+++ b/clients/xzwrite/GetString.c
@@ -12,7 +12,6 @@
static int accepted, cancelled;
static void Accept(), Cancel(), Focus();
-static int HierEvent();
extern void Popup();
@@ -94,30 +93,6 @@ int GetString(getStringWindow, label, value, pop_type, buf, len)
return GETSTRING_CANCEL;
}
-/*
- * I thought I needed this routine becaues XtAppNextEvent was
- * returning events for widgets that should have been blocked by the
- * XtGrabExclusive.. but it turns out that XtDispatch deals with that
- * (correctly) so this code is useless.
- */
-static int HierEvent(w, event)
- Widget w;
- XAnyEvent *event;
-{
- Widget event_w;
-
- event_w = XtWindowToWidget(XtDisplay(w), event->window);
-
- while (event_w = XtParent(event_w)) {
- if (w == event_w)
- return 1;
- else if (XtIsShell(event_w))
- break;
- }
-
- return 0;
-}
-
/* ARGSUSED */
static void Accept(w, e, p, n)
Widget w;
diff --git a/clients/xzwrite/Imakefile b/clients/xzwrite/Imakefile
deleted file mode 100644
index 16d9853..0000000
--- a/clients/xzwrite/Imakefile
+++ /dev/null
@@ -1,28 +0,0 @@
-/**/# Copyright 1990 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = interface.c resource.c destlist.c util.c bfgets.c \
- gethomedir.c dest_window.c xzwrite.c edit_window.c zephyr.c\
- GetString.c Popup.c yank.c menu_window.c logins.c
-
-OBJS = interface.o resource.o destlist.o util.o bfgets.o \
- gethomedir.o dest_window.o xzwrite.o edit_window.o zephyr.o\
- GetString.o Popup.o yank.o menu_window.o logins.o
-
-XDEFS=-DXZWRITE_SEARCH_PATHS=\"$(ZLIBDIR)/%N\"
-
-zprogram(xzwrite,$(DYN_LIB) $(LIB_XAW))
-install_man(xzwrite.1,xzwrite.1)
-install_file(xzwrite.bitmap,$(ZLIBDIR))
-
-install::
- $(RM) $(DESTDIR)$(ZLIBDIR)/XZwrite
- sed -e "s,ACLDIR,$(ZLIBDIR)," \
- < XZwrite > $(DESTDIR)$(ZLIBDIR)/XZwrite
diff --git a/clients/xzwrite/Makefile.in b/clients/xzwrite/Makefile.in
new file mode 100644
index 0000000..9d706b6
--- /dev/null
+++ b/clients/xzwrite/Makefile.in
@@ -0,0 +1,57 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \
+ -I${BUILDTOP}/h @X_CFLAGS@ @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr -L${BUILDTOP}/lib/dyn @ET_LDFLAGS@ \
+ @X_LIBS@ @LDFLAGS@
+LIBS=-lzephyr -ldyn -lXaw -lXmu -lXt @X_PRE_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@ \
+ @LIBS@ -lcom_err
+
+OBJS= interface.o resource.o destlist.o util.o bfgets.o gethomedir.o \
+ dest_window.o xzwrite.o edit_window.o zephyr.o GetString.o Popup.o \
+ yank.o menu_window.o logins.o
+
+all: xzwrite
+
+xzwrite: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a \
+ ${BUILDTOP}/lib/dyn/libdyn.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: xzwrite XZwrite
+ ${INSTALL} -m 755 -s xzwrite ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/xzwrite.1 ${DESTDIR}${mandir}/man1
+ ${INSTALL} -m 644 XZwrite ${DESTDIR}${datadir}
+ ${INSTALL} -m 644 ${srcdir}/xzwrite.bitmap ${DESTDIR}${datadir}
+
+clean:
+ rm -f ${OBJS} xzwrite
+
+${OBJS}: xzwrite.h xzwrite-proto.h ${top_srcdir}/h/sysdep.h
+${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h
+destlist.o logins.o xzwrite.o zephyr.o: ${top_srcdir}/h/dyn.h
+
+.PHONY: all check install clean
+
diff --git a/clients/xzwrite/Makefile.old b/clients/xzwrite/Makefile.old
deleted file mode 100644
index 82ab462..0000000
--- a/clients/xzwrite/Makefile.old
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Makefile for xzwrite, X11R4
-# Written by Barr3y Jaspan, bjaspan@athena.mit.edu
-# MIT Student Information Processing Board and MIT-Project Athena
-#
-
-SRCS = interface.c resource.c destlist.c util.c bfgets.c \
- gethomedir.c dest_window.c xzwrite.c edit_window.c zephyr.c\
- GetString.c Popup.c yank.c menu_window.c logins.c
-
-OBJS = interface.o resource.o destlist.o util.o bfgets.o \
- gethomedir.o dest_window.o xzwrite.o edit_window.o zephyr.o\
- GetString.o Popup.o yank.o menu_window.o logins.o
-
-HDRS = xzwrite.h GetString.h
-
-DYNLIBDIR = /mit/sipb/$(MACHINE)lib
-X11LIBDIR = /mit/x11/$(MACHINE)lib
-
-TARGET = xzwrite
-INCLUDES= -I/mit/sipb/include -I/mit/x11/include
-DEBUG = -O
-CFLAGS = $(DEBUG) $(INCLUDES)
-LDFLAGS = -L$(DYNLIBDIR) -L$(X11LIBDIR)
-LIBS = -lzephyr -lkrb -ldes -lcom_err -lXaw -lXmu -lXt -lXext -lX11 -ldyn
-CC = gcc
-
-DESTDIR = /afs/.athena.mit.edu/contrib/sipb
-BINDEST = $(DESTDIR)/$(MACHINE)bin
-MANDEST = $(DESTDIR)/man
-RESDEST = $(DESTDIR)/lib/app-defaults
-MANSECT = 1
-
-$(TARGET): $(OBJS)
- $(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
-
-install: bin_install man_install resource_install
-
-clean:
- -rm -f $(OBJS) $(TARGET) *~ core
-
-proto:
- mkproto $(SRCS) $(HDRS) > xzwrite-proto.h
-
-saber:
- #setopt program_name xzwrite
- #load ${CFLAGS} ${LDFLAGS} ${SRCS} -G ${LIBS}
-
-osaber:
- #setopt program_name xzwrite
- #load $(CFLAGS) $(LDFLAGS) -G $(OBJS) $(LIBS)
-
-bin_install: $(TARGET)
- -if [ -f $(BINDEST)/$(TARGET) ]; then \
- mv $(BINDEST)/$(TARGET) $(BINDEST)/.#$(TARGET).old; \
- exit 0; \
- fi
- install -c -s $(TARGET) $(BINDEST)/$(TARGET)
-
-man_install:
- nroff -man $(TARGET).man > \
- $(MANDEST)/cat$(MANSECT)/$(TARGET).$(MANSECT)
- cp $(TARGET).man $(MANDEST)/man$(MANSECT)/$(TARGET).$(MANSECT)
-
-resource_install:
- cp XZwrite $(RESDEST)/XZwrite
-
-depend:
- makedepend -- $(CFLAGS) -- $(SRCS) $(HDRS)
-
-interface.o resource.o destlist.o util.o dest_window.o: xzwrite.h
-xzwrite.o edit_window.o zephyr.o yank.o: xzwrite.h
-dest_window.o: GetString.h
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/clients/xzwrite/XZwrite b/clients/xzwrite/XZwrite.in
index 3fb574f..f7b21c8 100644
--- a/clients/xzwrite/XZwrite
+++ b/clients/xzwrite/XZwrite.in
@@ -1,3 +1,5 @@
+! @configure_input@
+
*resize: on
*allowShellResize: on
@@ -15,7 +17,7 @@
*readAnyone: on
*readXzwrite: on
-*icon.bitmap: ACLDIR/xzwrite.bitmap
+*icon.bitmap: @datadir@/xzwrite.bitmap
*icon.translations: #override\
<BtnDown>: set() \n\
<Btn1Up>: OpenSend() unset() \n\
diff --git a/clients/xzwrite/bfgets.c b/clients/xzwrite/bfgets.c
index 19df253..96636f9 100644
--- a/clients/xzwrite/bfgets.c
+++ b/clients/xzwrite/bfgets.c
@@ -21,7 +21,7 @@ char *bfgets(s, n, iop)
int n;
FILE *iop;
{
- register int c;
+ register int c = 0;
register char *cs;
cs = s;
diff --git a/clients/xzwrite/destlist.c b/clients/xzwrite/destlist.c
index 57a03f0..21b9b89 100644
--- a/clients/xzwrite/destlist.c
+++ b/clients/xzwrite/destlist.c
@@ -1,6 +1,5 @@
-#include <stdio.h>
+#include <sysdep.h>
#include <dyn.h>
-#include <string.h>
#include "xzwrite.h"
@@ -154,7 +153,7 @@ char **dest_add(dest)
*dest->zinst ? dest->zinst : "*",
*dest->zrecip ? dest->zrecip : "*");
- if (DynAdd(dests, &buf) == DYN_NOMEM) {
+ if (DynAdd(dests, (DynPtr) &buf) == DYN_NOMEM) {
Warning("Out of memory adding destination ", buf, ". Skipping.",
NULL);
free(buf);
@@ -173,7 +172,7 @@ char **dest_add_string(s)
if (! parse_into_dest(&dest, s))
return NULL;
- if (DynAdd(dests, &s) == DYN_NOMEM)
+ if (DynAdd(dests, (DynPtr) &s) == DYN_NOMEM)
Warning("Out of memory adding destination ", s, ". Skipping.",
NULL);
@@ -211,9 +210,10 @@ char **delete_dest_index(i)
}
-static int sort_dest_func(c1, c2)
- char **c1, **c2;
+static int sort_dest_func(a1, a2)
+ const void *a1, *a2;
{
+ char **c1 = (char **) a1, **c2 = (char **) a2;
char *s1, *s2, *i1, *i2;
/* A string with a , in it is always less than one without */
@@ -291,7 +291,6 @@ char **sort_destinations()
}
/* Fills in dest from s */
-#define distance(a,b) ((int) b - (int) a)
int parse_into_dest(dest, s)
Dest dest;
char *s;
@@ -311,7 +310,7 @@ int parse_into_dest(dest, s)
/* Check for just class,instance or instace,recipient */
else if ((b=strchr((++a), ','))==0) {
if (defs.class_inst) {
- x = distance(s, a-1);
+ x = a - 1 - s;
if (x >= ZLEN)
return 0;
@@ -320,7 +319,7 @@ int parse_into_dest(dest, s)
strcpy(dest->zinst, a);
strcpy(dest->zrecip, "*"); }
else {
- x = distance(s, a-1);
+ x = a - 1 - s;
if (x >= ZLEN)
return 0;
@@ -333,8 +332,8 @@ int parse_into_dest(dest, s)
/* Otherwise, deal with class,instance,recipent */
else {
++b;
- x = distance(s, a-1);
- y = distance(a, b-1);
+ x = a - 1 - s;
+ y = b - 1 - a;
if (x >= ZLEN || y >= ZLEN)
return 0;
@@ -349,7 +348,6 @@ int parse_into_dest(dest, s)
return 1;
}
-#undef distance
/*
* notice is from <MESSAGE,inst,sender>. If inst is "PERSONAL", add
@@ -362,7 +360,6 @@ int parse_into_dest(dest, s)
void dest_add_reply(notice)
ZNotice_t *notice;
{
- Dest dest;
char **list, *newdest, buf[ZLEN*3+2];
int i, num;
diff --git a/clients/xzwrite/destlist.c.old b/clients/xzwrite/destlist.c.old
deleted file mode 100644
index a81d2c9..0000000
--- a/clients/xzwrite/destlist.c.old
+++ /dev/null
@@ -1,417 +0,0 @@
-#include <stdio.h>
-#include <dyn.h>
-#include <strings.h>
-
-#include "xzwrite.h"
-
-/*
- * The following code extracts keypressed from an X event:
- *
- * keyevent = event->xkey;
- * XLookupString(&keyevent, buffer, 1, NULL, NULL);
- */
-
-/*
- * This entire file could easily be changes so that multiple destination
- * lists could be used. But I don't know that that's necessary for this
- * program.
- */
-
-/* Globals */
-DestRec current_dest;
-
-static DynObject dests;
-extern Defaults defs;
-
-static void get_dest_from_file(), _get_default_dest();
-static int sort_dest_func();
-
-/* A function for debugging */
-void dest_print()
-{
- char **d;
- int i;
-
- d = (char **) DynGet(dests, 0);
- for (i=0; i<DynSize(dests); i++)
- printf("%d %s\n", i, d[i]);
-}
-
-char **dest_text()
-{
- return ((char **) DynGet(dests, 0));
-}
-
-int dest_num()
-{
- return (DynSize(dests));
-}
-
-void dest_set_current_dest(dest)
- Dest dest;
-{
- (void) memcpy((char *) &current_dest, (char *) dest, sizeof(DestRec));
-}
-
-void dest_init()
-{
- dests = DynCreate(sizeof(char *), 0);
- if (! dests)
- Error("Out of memory reading destinations", NULL);
-
- strcpy(current_dest.zclass, DEFAULT_CLASS);
- strcpy(current_dest.zinst, DEFAULT_INST);
- strcpy(current_dest.zrecip, get_username());
-}
-
-char **load_default_dest()
-{
- char *get_home_dir();
-
- if (! *get_home_dir())
- Error("Cannot find your home directory.", NULL);
-
- if (defs.read_xzwrite)
- _get_default_dest(XZWRITE_DEST_FILE);
- if (defs.read_zephyr)
- _get_default_dest(ZEPHYR_FILE);
- if (defs.read_anyone)
- _get_default_dest(ANYONE_FILE);
-
- if (DynSize(dests) == 0) {
- char *def;
-
- Warning("XZwrite: No destinations specified, using default.",
- NULL);
-
- def = (char *) Malloc(strlen("...") + 1, "adding default dests",
- NULL);
- strcpy(def, "...");
- if (DynAdd(dests, (char *) &def) == DYN_NOMEM)
- Error("Out of memory adding default destinations.", NULL);
- }
-
- sort_destinations();
- return ((char **) DynGet(dests, 0));
-}
-
-static void _get_default_dest(s)
- char *s;
-{
- char *filename;
-
- filename = (char *) Malloc(strlen(get_home_dir()) + strlen(s) + 1,
- "While reading file ", s, NULL);
- sprintf(filename, "%s%s", get_home_dir(), s);
- get_dest_from_file(dests, filename);
- free(filename);
-}
-
-static void get_dest_from_file(dests, f)
- DynObject dests;
- char *f;
-{
- FILE *file;
- char *line, buf[BUFSIZ];
- DestRec dest;
-
- if ((file = fopen(f, "r")) == NULL) {
- Warning("Cannot find destinations file ", f, NULL);
- return;
- }
-
- while (bfgets(buf, 80, file)) {
- if (buf[0] == '#' || buf[0] == '\0') {
- if (defs.debug)
- printf("xzwrite: skipping comment or blank line\n");
- continue;
- }
-
- if (! parse_into_dest(&dest, buf)) {
- Warning("Ignoring incorrect destination: ", buf, NULL);
- continue;
- }
-
- line = (char *) Malloc(strlen(buf) + 1, "parsing file ", f, NULL);
- strcpy(line, buf);
- if (DynAdd(dests, (char *) &line) == DYN_NOMEM)
- Error("Out of memory parsing file ", f, NULL);
- }
-
- fclose(file);
-}
-
-char **dest_add(dest)
- Dest dest;
-{
- char *buf;
-
- /* Two extra bytes if instance or recipient are "" */
- buf = (char *) Malloc(strlen(dest->zclass) + strlen(dest->zinst) +
- strlen(dest->zrecip) + 5,
- "while adding destination ", NULL);
- sprintf(buf, "%s,%s,%s", dest->zclass,
- *dest->zinst ? dest->zinst : "*",
- *dest->zrecip ? dest->zrecip : "*");
-
- if (DynAdd(dests, &buf) == DYN_NOMEM) {
- Warning("Out of memory adding destination ", buf, ". Skipping.",
- NULL);
- free(buf);
- }
-
- sort_destinations();
- return ((char **) DynGet(dests, 0));
-}
-
-/* XXX The return/output semantics of this function are not good */
-char **dest_add_string(s)
- char *s;
-{
- DestRec dest;
-
- if (! parse_into_dest(&dest, s))
- return NULL;
-
- if (DynAdd(dests, &s) == DYN_NOMEM)
- Warning("Out of memory adding destination ", s, ". Skipping.",
- NULL);
-
- sort_destinations();
- return ((char **) DynGet(dests, 0));
-}
-
-char **dest_delete_string(s)
- char *s;
-{
- int i;
- char **d;
-
- d = (char **) DynGet(dests, 0);
- for (i=0; i<DynSize(dests); i++) {
- if (! strcmp(s, d[i])) {
- DynDelete(dests, i);
- break;
- }
- }
-
- return ((char **) DynGet(dests, 0));
-}
-
-char **delete_dest_index(i)
- int i;
-{
- int ret;
-
- ret = DynDelete(dests, i);
- if (ret != DYN_OK)
- return NULL;
-
- return ((char **) DynGet(dests, 0));
-}
-
-
-static int sort_dest_func(c1, c2)
- char **c1, **c2;
-{
- char *s1, *s2, *i1, *i2;
-
- /* A string with a , in it is always less than one without */
- s1 = *c1; s2 = *c2;
- i1 = strchr(s1, ',');
- i2 = strchr(s2, ',');
- if (i1 == NULL && i2 != NULL)
- return 1;
- else if (i1 != NULL && i2 == NULL)
- return -1;
- else
- return strcmp(s1, s2);
-}
-
-static int
-binary_find_dest(key)
-char *key;
-{
- register int low = 0, high = DynHigh(dests), mid;
- register int val;
- register char **d;
-
- d = (char **) DynGet(dests, 0);
-
- /* do binary search */
- while (low <= high) {
- mid = (low + high) / 2;
- val = sort_dest_func(&key, &d[mid]);
- if (val < 0) {
- high = mid - 1;
- } else if (val > 0) {
- low = mid + 1;
- } else {
- return (mid);
- }
- }
-
- return -1;
-}
-
-char **sort_destinations()
-{
- register char **d;
- register int idx, idx2;
- int dsiz = DynSize(dests);
-
- d = (char **) DynGet(dests, 0);
- qsort(d, dsiz, sizeof(char *), sort_dest_func);
-
- for (idx = 0; idx < DynSize(dests);) {
- if (d[idx][0] == '!') {
- /* unsubscription */
- char *next = d[idx];
- next++;
- while ((idx2 = binary_find_dest(next)) >= 0) {
- /* found one to nuke */
- DynDelete(dests, idx2);
- if (idx2 <= idx) {
- /* indexes shifted, so restart this pass. */
- idx--;
- if (idx <= 0)
- idx = 0;
- continue;
- }
- }
- /* ok, no more to nuke from this one, so delete it and
- move on. */
- DynDelete(dests, idx);
- continue;
- }
- /* nope, continue on to next unsub */
- idx++;
- }
- return d;
-}
-
-/* Fills in dest from s */
-#define distance(a,b) ((int) b - (int) a)
-int parse_into_dest(dest, s)
- Dest dest;
- char *s;
-{
- char *a, *b;
- int x, y;
-
- /* Check for just recipient */
- if ((a=strchr(s, ','))==0) {
- if (strlen(s) > ZLEN)
- return 0;
- strcpy(dest->zclass, DEFAULT_CLASS);
- strcpy(dest->zinst, DEFAULT_INST);
- strcpy(dest->zrecip, s);
- }
-
- /* Check for just class,instance or instace,recipient */
- else if ((b=strchr((++a), ','))==0) {
- if (defs.class_inst) {
- x = distance(s, a-1);
- if (x >= ZLEN)
- return 0;
-
- strncpy(dest->zclass, s, x);
- dest->zclass[x] = '\0';
- strcpy(dest->zinst, a);
- strcpy(dest->zrecip, "*"); }
- else {
- x = distance(s, a-1);
- if (x >= ZLEN)
- return 0;
-
- strcpy(dest->zclass, DEFAULT_CLASS);
- strncpy(dest->zinst, s, x);
- dest->zinst[x] = '\0';
- strcpy(dest->zrecip, a); }
- }
-
- /* Otherwise, deal with class,instance,recipent */
- else {
- ++b;
- x = distance(s, a-1);
- y = distance(a, b-1);
- if (x >= ZLEN || y >= ZLEN)
- return 0;
-
- strncpy(dest->zclass, s, x);
- dest->zclass[x] = '\0';
- strncpy(dest->zinst, a, y);
- dest->zinst[y] = '\0';
- strcpy(dest->zrecip, b);
- }
- if (!strcmp(dest->zrecip,"*")) *(dest->zrecip) = '\0';
- if (!strcmp(dest->zinst,"*")) *(dest->zinst) = '\0';
-
- return 1;
-}
-#undef distance
-
-/*
- * notice is from <MESSAGE,inst,sender>. If inst is "PERSONAL", add
- * destination string "<sender>" if
- * 1) MESSAGE,PERSONAL,<sender> is not in list, and
- * 2) <sender> is not in list.
- * If inst is not "PERSONAL", add destination string
- * "<MESSAGE,<inst>,<sender>>" if it is not in the list.
- */
-void dest_add_reply(notice)
- ZNotice_t *notice;
-{
- Dest dest;
- char **list, *newdest, buf[ZLEN*3+2];
- int i, num;
-
- list = dest_text();
- num = dest_num();
-
-
- /* A hack so local-realm is less annoying */
- {
- char *r;
-
- r = strchr(notice->z_sender, '@');
- if (r && ! strcmp(r+1, ZGetRealm()))
- *r = '\0';
- }
-
- if (! strcasecmp(notice->z_class_inst, DEFAULT_INST)) {
- sprintf(buf, "message,personal,%s", notice->z_sender);
- for (i=0; i < num; i++) {
- if (! strcasecmp(list[i], buf) ||
- ! strcasecmp(list[i], notice->z_sender))
- return;
- }
-
- newdest = (char *) Malloc(strlen(notice->z_sender) + 1,
- "while adding reply destination", NULL);
- sprintf(newdest, "%s", notice->z_sender);
- }
- else {
- sprintf(buf, "message,%s,%s", notice->z_class_inst,
- notice->z_sender);
- for (i=0; i < num; i++) {
- if (! strcasecmp(list[i], buf))
- return;
- }
-
- newdest = (char *) Malloc(strlen(notice->z_class) +
- strlen(notice->z_class_inst) +
- strlen(notice->z_sender) + 3,
- "while adding reply destintion",
- NULL);
- sprintf(newdest, "%s,%s,%s", notice->z_class,
- notice->z_class_inst, notice->z_sender);
- }
-
- dest_add_string(newdest);
- display_dest();
-
- if (defs.track_logins)
- zeph_subto_logins(&notice->z_sender, 1);
-}
-
diff --git a/clients/xzwrite/gethomedir.c b/clients/xzwrite/gethomedir.c
index 5c3d372..ffd25bf 100644
--- a/clients/xzwrite/gethomedir.c
+++ b/clients/xzwrite/gethomedir.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <pwd.h>
+#include "xzwrite.h"
char *get_home_dir()
{
@@ -8,7 +9,7 @@ char *get_home_dir()
if (h) return h;
- if (h = (char *) getenv("HOME")) return h;
+ if ((h = getenv("HOME")) != NULL) return h;
pwuid = getpwuid(getuid());
return (pwuid->pw_dir);
diff --git a/clients/xzwrite/interface.c b/clients/xzwrite/interface.c
index a92ec3c..d48e73c 100644
--- a/clients/xzwrite/interface.c
+++ b/clients/xzwrite/interface.c
@@ -44,6 +44,9 @@
* getStringCancel - the cancel button
*/
+#include "xzwrite.h"
+#include "GetString.h"
+
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
@@ -59,9 +62,6 @@
#include <zephyr/zephyr.h> /* for ZGetFD() */
-#include "xzwrite.h"
-#include "GetString.h"
-
#define XVCMW XtVaCreateManagedWidget
/* Action Procedure declarations */
@@ -134,17 +134,16 @@ void build_interface(argc, argv)
path1 = (char *) getenv("XFILESEARCHPATH");
if (! path1) path1 = "";
path2 = (char *) malloc(strlen(path1) +
-#ifdef USE_PUTENV
+#ifdef HAVE_PUTENV
strlen("XFILESEARCHPATH=") +
#endif
- strlen(XZWRITE_SEARCH_PATHS) + 2);
+ strlen(DATADIR) + 5);
if (path2 != NULL) {
-#ifdef USE_PUTENV
- sprintf(path2, "XFILESEARCHPATH=%s:%s", path1,
- XZWRITE_SEARCH_PATHS);
+#ifdef HAVE_PUTENV
+ sprintf(path2, "XFILESEARCHPATH=%s:%s/%%N", path1, DATADIR);
putenv(path2);
#else
- sprintf(path2, "%s:%s", path1, XZWRITE_SEARCH_PATHS);
+ sprintf(path2, "%s:%s/%N", path1, DATADIR);
setenv("XFILESEARCHPATH", path2, 1);
free(path2);
#endif
@@ -226,7 +225,7 @@ static void Quit(w, e, p, n)
Cardinal *n;
{
XtDestroyApplicationContext(app_con);
- ZCancelSubscriptions();
+ ZCancelSubscriptions(0);
exit(0);
}
@@ -388,7 +387,7 @@ static void CloseMenu(w, e, p, n)
XtPopdown(menuWindow);
}
-static void set_editor_width (void)
+static void set_editor_width ()
{
int w, c; char m = 'm';
XFontStruct *fs = (XFontStruct *) NULL;
@@ -410,7 +409,7 @@ static void set_editor_width (void)
XtVaSetValues(destForm, XtNwidth, (Dimension)(w*3/8), NULL);
}
-static void set_sendclose_width (void)
+static void set_sendclose_width ()
{
/* make the Close Window button the width of the form */
Dimension wi = 0;
diff --git a/clients/xzwrite/logins.c b/clients/xzwrite/logins.c
index 7f4e17b..66fe825 100644
--- a/clients/xzwrite/logins.c
+++ b/clients/xzwrite/logins.c
@@ -1,19 +1,19 @@
+#include "xzwrite.h"
+
#include <X11/Intrinsic.h> /* for Boolean */
-#include <zephyr/zephyr.h>
#include <dyn.h>
-
-#include "xzwrite.h"
+#include <zephyr/zephyr.h>
extern Defaults defs;
-#define distance(a,b) ((int) b - (int) a)
void logins_deal(notice)
ZNotice_t *notice;
{
- char *newdest;
+ char *newdest, *p;
int d;
- d = distance(notice->z_class_inst, strchr(notice->z_class_inst, '@'));
+ p = strchr(notice->z_class_inst, '@');
+ d = (p) ? p - notice->z_class_inst : strlen(notice->z_class_inst);
newdest = (char *) Malloc(d+1, "while dealing with login/logout notice",
NULL);
strncpy(newdest, notice->z_class_inst, d);
@@ -33,7 +33,6 @@ void logins_deal(notice)
free(newdest);
}
}
-#undef distance
/* Considers a destination with a , and without a . in to be a username */
void logins_subscribe()
@@ -52,7 +51,7 @@ void logins_subscribe()
while (--num) {
parse_into_dest(&dest, list[num]);
if (*dest.zrecip)
- if (DynAdd(users, list + num) != DYN_OK)
+ if (DynAdd(users, (DynPtr)(list + num)) != DYN_OK)
Error("Out of memory subscribing to logins", NULL);
}
diff --git a/clients/xzwrite/util.c b/clients/xzwrite/util.c
index 38c7f13..f52ee7e 100644
--- a/clients/xzwrite/util.c
+++ b/clients/xzwrite/util.c
@@ -1,37 +1,44 @@
#include <stdio.h>
-#include <varargs.h>
#include <pwd.h>
#include "xzwrite.h"
+#ifdef __STDC__
+void Warning(const char *first, ...)
+#else
/*VARARGS*/
void Warning(first, va_alist)
- char *first;
+ const char *first;
va_dcl
+#endif
{
va_list vp;
char *s;
fputs(first, stderr);
- va_start(vp);
+ VA_START(vp, first);
while ((s = va_arg(vp, char *)) != NULL)
fputs(s, stderr);
va_end(vp);
putc('\n', stderr);
}
+#ifdef __STDC__
+void Error(const char *first, ...)
+#else
/*VARARGS*/
void Error(first, va_alist)
- char *first;
+ const char *first;
va_dcl
+#endif
{
va_list vp;
char *s;
fputs(first, stderr);
- va_start(vp);
+ VA_START(vp, first);
while ((s = va_arg(vp, char *)) != NULL)
fputs(s, stderr);
va_end(vp);
@@ -40,10 +47,14 @@ void Error(first, va_alist)
exit(1);
}
+#ifdef __STDC__
+char *Malloc(int n, ...)
+#else
/*VARARGS*/
char *Malloc(n, va_alist)
int n;
va_dcl
+#endif
{
va_list vp;
char *ptr, *s;
@@ -54,7 +65,7 @@ char *Malloc(n, va_alist)
fputs("Out of memory: ", stderr);
- va_start(vp);
+ VA_START(vp, n);
while ((s = va_arg(vp, char *)) != NULL)
fputs(s, stderr);
va_end(vp);
@@ -70,7 +81,7 @@ char *get_username()
if (u) return u;
- if (u = (char *) getenv("USER")) return u;
+ if ((u = getenv("USER")) != NULL) return u;
pwuid = getpwuid(getuid());
if (pwuid)
diff --git a/clients/xzwrite/xzwrite-proto.h b/clients/xzwrite/xzwrite-proto.h
index 0e0b0e6..baeccca 100644
--- a/clients/xzwrite/xzwrite-proto.h
+++ b/clients/xzwrite/xzwrite-proto.h
@@ -1,96 +1,101 @@
+#ifndef __P
#ifdef __STDC__
-# define P(s) s
+# define __P(s) s
#else
-# define P(s) ()
+# define __P(s) ()
+#endif
#endif
/* interface.c */
-void go P((void ));
-void build_interface P((int *argc , char **argv ));
+void go __P((void ));
+void build_interface __P((int *argc , char **argv ));
/* resource.c */
/* destlist.c */
-void dest_print P((void ));
-char **dest_text P((void ));
-int dest_num P((void ));
-void dest_set_current_dest P((Dest dest ));
-void dest_init P((void ));
-char **load_default_dest P((void ));
-char **dest_add P((Dest dest ));
-char **dest_add_string P((char *s ));
-char **dest_delete_string P((char *s ));
-char **delete_dest_index P((int i ));
-char **sort_destinations P((void ));
-int parse_into_dest P((Dest dest , char *s ));
-void dest_add_reply P((ZNotice_t *notice ));
+void dest_print __P((void ));
+char **dest_text __P((void ));
+int dest_num __P((void ));
+void dest_set_current_dest __P((Dest dest ));
+void dest_init __P((void ));
+char **load_default_dest __P((void ));
+char **dest_add __P((Dest dest ));
+char **dest_add_string __P((char *s ));
+char **dest_delete_string __P((char *s ));
+char **delete_dest_index __P((int i ));
+char **sort_destinations __P((void ));
+int parse_into_dest __P((Dest dest , char *s ));
+void dest_add_reply __P((ZNotice_t *notice ));
/* util.c */
-char *get_username P((void ));
+void Warning __P((const char *first, ...));
+void Error __P((const char *first, ...));
+char *Malloc __P((int n, ...));
+char *get_username __P((void ));
/* bfgets.c */
-char *bfgets P((char *s , int n , FILE *iop ));
+char *bfgets __P((char *s , int n , FILE *iop ));
/* gethomedir.c */
-char *get_home_dir P((void ));
+char *get_home_dir __P((void ));
/* dest_window.c */
-void dest_add_reply P((ZNotice_t *notice ));
-void display_dest P((void ));
-void delete_dest P((void ));
-void create_dest P((void ));
-void select_dest P((void ));
+void dest_add_reply __P((ZNotice_t *notice ));
+void display_dest __P((void ));
+void delete_dest __P((void ));
+void create_dest __P((void ));
+void select_dest __P((void ));
/* xzwrite.c */
-int main P((int argc , char **argv ));
-int usage P((void ));
+int main __P((int argc , char **argv ));
+void usage __P((void ));
/* edit_window.c */
-void edit_win_init P((void ));
-void send_message P((void ));
-void edit_set_title P((Dest dest ));
-void edit_clear P((void ));
-void edit_yank_prev P((void ));
-void edit_yank_next P((void ));
-void edit_yank_store P((void ));
+void edit_win_init __P((void ));
+void send_message __P((void ));
+void edit_set_title __P((Dest dest ));
+void edit_clear __P((void ));
+void edit_yank_prev __P((void ));
+void edit_yank_next __P((void ));
+void edit_yank_store __P((void ));
/* zephyr.c */
-void zeph_dispatch P((XtPointer client_data , int *source , XtInputId *input_id ));
-void zeph_init P((void ));
-int zeph_locateable P((char *user ));
-void zeph_subto_logins P((char **users , int num ));
-void zeph_subto_replys P((void ));
-int zeph_send_message P((Dest dest , char *msg ));
-int zeph_ping P((Dest dest ));
-int zeph_pong P((Dest dest ));
-char *zeph_get_signature P((void ));
-void log_message P((Dest dest , char *msg ));
+void zeph_dispatch __P((XtPointer client_data , int *source , XtInputId *input_id ));
+void zeph_init __P((void ));
+int zeph_locateable __P((char *user ));
+void zeph_subto_logins __P((char **users , int num ));
+void zeph_subto_replies __P((void ));
+int zeph_send_message __P((Dest dest , char *msg ));
+int zeph_ping __P((Dest dest ));
+int zeph_pong __P((Dest dest ));
+char *zeph_get_signature __P((void ));
+void log_message __P((Dest dest , char *msg ));
/* GetString.c */
-Widget InitGetString P((Widget parent , char *name ));
-int GetString P((Widget getStringWindow , String label , String value , int pop_type , char *buf , int len ));
+Widget InitGetString __P((Widget parent , char *name ));
+int GetString __P((Widget getStringWindow , String label , String value , int pop_type , char *buf , int len ));
/* Popup.c */
-void Popup P((Widget shell , XtGrabKind GrabType , int pop_type ));
-void PopupSafe P((Widget w , Dimension x , Dimension y , XtGrabKind GrabType ));
-void PopupAtPointer P((Widget w , XtGrabKind GrabType ));
+void Popup __P((Widget shell , XtGrabKind GrabType , int pop_type ));
+void PopupSafe __P((Widget w , Dimension x , Dimension y , XtGrabKind GrabType ));
+void PopupAtPointer __P((Widget w , XtGrabKind GrabType ));
/* yank.c */
-void yank_init P((void ));
-Yank yank_prev P((void ));
-Yank yank_next P((void ));
-void yank_store P((Dest dest , char *msg ));
+void yank_init __P((void ));
+Yank yank_prev __P((void ));
+Yank yank_next __P((void ));
+void yank_store __P((Dest dest , char *msg ));
/* menu_window.c */
-void menu_toggle P((Widget w ));
-void menu_match_defs P((void ));
-void menu_signature P((void ));
+void menu_toggle __P((Widget w ));
+void menu_match_defs __P((void ));
+void menu_signature __P((void ));
/* logins.c */
-void logins_deal P((ZNotice_t *notice ));
-void logins_subscribe P((void ));
-Boolean login_scan_work P((caddr_t client_data ));
+void logins_deal __P((ZNotice_t *notice ));
+void logins_subscribe __P((void ));
+Boolean login_scan_work __P((caddr_t client_data ));
/* xzwrite.h */
diff --git a/clients/xzwrite/xzwrite.c b/clients/xzwrite/xzwrite.c
index 55ea848..318e5e9 100644
--- a/clients/xzwrite/xzwrite.c
+++ b/clients/xzwrite/xzwrite.c
@@ -8,12 +8,10 @@
extern Defaults defs;
DynObject zsigs = NULL;
-#define islower(foo) ((foo) >= 'a' && (foo) <= 'z')
-#define toupper(foo) ((foo)+'A'-'a')
+static void set_signature __P((void));
+static Boolean set_random_zsigs __P((void));
-Boolean set_random_zsigs();
-
-main(argc, argv)
+int main(argc, argv)
int argc;
char **argv;
{
@@ -37,9 +35,10 @@ main(argc, argv)
zeph_subto_replies();
go();
+ return 0;
}
-set_signature()
+static void set_signature()
{
char *sig, sigbfr[BUFSIZ];
@@ -86,7 +85,7 @@ set_signature()
-usage()
+void usage()
{
fprintf(stderr, "Usage: xzwrite [ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n]\n\t[+v | -v] [+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks]\n\t[+l | -l] [+a | -a] [+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]\n");
exit(1);
@@ -94,7 +93,7 @@ usage()
#define BUF_SIZE 1024
-Boolean set_random_zsigs()
+static Boolean set_random_zsigs()
{ int x, n;
char z[BUF_SIZE], *z2;
FILE *fp;
diff --git a/clients/xzwrite/xzwrite.h b/clients/xzwrite/xzwrite.h
index 4a8a47c..a9b020b 100644
--- a/clients/xzwrite/xzwrite.h
+++ b/clients/xzwrite/xzwrite.h
@@ -1,4 +1,4 @@
-#include <stdio.h>
+#include <sysdep.h>
#include <X11/Intrinsic.h> /* for String and Boolean */
#define ZLEN 60
diff --git a/clients/xzwrite/zephyr.c b/clients/xzwrite/zephyr.c
index 5d8f6cc..6e25dd5 100644
--- a/clients/xzwrite/zephyr.c
+++ b/clients/xzwrite/zephyr.c
@@ -1,8 +1,9 @@
-#include <zephyr/zephyr.h>
-
#include "xzwrite.h"
#include <string.h>
#include <dyn.h>
+#include <com_err.h>
+
+#include <zephyr/zephyr.h>
static int zeph_send_notice();
extern Defaults defs;
@@ -61,7 +62,7 @@ void zeph_init()
if (retval != ZERR_NONE)
Error("Cannot initialize the Zephyr library.", NULL);
- retval = ZOpenPort((int *) 0);
+ retval = ZOpenPort(NULL);
if (retval != ZERR_NONE)
Error("Cannot open Zephyr port.", NULL);
}
@@ -255,33 +256,6 @@ static int zeph_send_notice(notice, auth)
return SEND_OK;
}
-#ifdef DEBUG
-/* debugging function */
-void zeph_display_subscriptions()
-{
- ZSubscription_t sub;
- int n, retval, i = 1;
-
- retval = ZRetrieveSubscriptions((unsigned short) 0, &n);
- if (retval != ZERR_NONE) {
- Warning(error_message(retval), " while retrieving subscriptions.",
- NULL);
- return;
- }
-
- printf("Retrieving %d subscriptions.\n", n);
-
- while (ZGetSubscriptions(&sub, &i) == ZERR_NONE) {
- if (i != 1)
- Warning("Subscriptions skipped while printing.", NULL);
-
- printf("<%s,%s,%s>\n", sub.class, (*sub.zsub_classinst) ?
- sub.zsub_classinst : "**", (*sub.zsub_recipient) ?
- sub.zsub_recipient : "**");
- }
-}
-#endif
-
void log_message(dest, msg)
Dest dest;
char *msg;
diff --git a/clients/xzwrite/zephyr.c.old b/clients/xzwrite/zephyr.c.old
deleted file mode 100644
index 40d9958..0000000
--- a/clients/xzwrite/zephyr.c.old
+++ /dev/null
@@ -1,269 +0,0 @@
-#include <zephyr/zephyr.h>
-
-#include "xzwrite.h"
-#include <strings.h>
-
-static int zeph_send_notice();
-extern Defaults defs;
-
-/* ARGSUSED */
-void zeph_dispatch(client_data, source, input_id)
- XtPointer client_data;
- int *source;
- XtInputId *input_id;
-{
- ZNotice_t notice;
- struct sockaddr_in from;
- int ret;
-
- while (ZPending() > 0) {
- ret = ZReceiveNotice(&notice, &from);
- if (ret != ZERR_NONE) {
- Warning(error_message(ret), " while receiving Zephyr notice.",
- NULL);
- continue;
- }
-
- if (defs.track_logins &&
- (! strcmp(notice.z_opcode, "USER_LOGIN") ||
- ! strcmp(notice.z_opcode, "USER_LOGOUT")))
- logins_deal(&notice);
-
- else if (defs.auto_reply &&
- ! strcasecmp(notice.z_class, DEFAULT_CLASS) &&
- ! strcasecmp(notice.z_recipient, ZGetSender()))
- dest_add_reply(&notice);
-
- /* Handle the zlocating bug the Zephyr library explicitly. */
- /* Only display bogon zlocate packets in debug mode */
- else if (strcmp(notice.z_class, LOCATE_CLASS) || defs.debug) {
- Warning("XZwrite: Unexpected notice received. ",
- "You can probably ignore this.\n",
- "To: <", notice.z_class, ", ",
- notice.z_class_inst, ", ", (*notice.z_recipient) ?
- notice.z_recipient : "*", ">\n",
- "From: ", notice.z_sender, "\nOpcode: ",
- notice.z_opcode, "\nMessage: ", notice.z_message,
- "\n", NULL);
- }
-
- ZFreeNotice(&notice);
- }
-}
-
-void zeph_init()
-{
- int retval;
-
- retval = ZInitialize();
- if (retval != ZERR_NONE)
- Error("Cannot initialize the Zephyr library.", NULL);
-
- retval = ZOpenPort((int *) 0);
- if (retval != ZERR_NONE)
- Error("Cannot open Zephyr port.", NULL);
-}
-
-int zeph_locateable(user)
- char *user;
-{
- char buf[BUFSIZ];
- int n;
-
- if (strchr(user, '@') == NULL)
- sprintf(buf, "%s@%s", user, ZGetRealm());
- ZLocateUser(buf, &n, ZAUTH);
- return (!! n);
-}
-
-/* XXX This will break on interrealm zephyr */
-void zeph_subto_logins(users, num)
- char **users;
- int num;
-{
- ZSubscription_t *sublist;
- char *name, *realm;
- int rlen, c = 0;
-
- realm = ZGetRealm();
- rlen = strlen(realm);
- sublist = (ZSubscription_t *) Malloc(num*sizeof(ZSubscription_t),
- "while subscribing to logins", NULL);
-
- while (c < num) {
- sublist[c].zsub_class = "login";
- sublist[c].zsub_recipient = "";
- name = (char *) Malloc(strlen(users[c])+rlen+2,
- "while subscribing to login, ", users[c],
- NULL);
- if (strchr(users[c], '@'))
- sprintf(name, "%s", users[c]);
- else
- sprintf(name, "%s@%s", users[c], realm);
- sublist[c].zsub_classinst = name;
- c += 1;
- }
-
- ZSubscribeToSansDefaults(sublist, c, (unsigned short) 0);
- for(; c; --c)
- free(sublist[c-1].zsub_classinst);
- free(sublist);
-}
-
-void zeph_subto_replies()
-{
- ZSubscription_t sub;
-
- sub.zsub_class = "message";
- sub.zsub_classinst = "*";
- sub.zsub_recipient = ZGetSender();
-
- ZSubscribeToSansDefaults(&sub, 1, (unsigned short) 0);
-}
-
-int zeph_send_message(dest, msg)
- Dest dest;
- char *msg;
-{
- ZNotice_t notice;
- int msglen, siglen, ret;
- char *sig_msg;
-
- msglen = strlen(msg);
- siglen = strlen(defs.signature);
- sig_msg = (char *) Malloc(msglen + siglen + 2, "while sending message",
- NULL);
- sprintf(sig_msg, "%s%c%s", defs.signature, '\0', msg);
-
- (void) memset((char *) &notice, 0, sizeof(ZNotice_t));
- notice.z_kind = ACKED;
- notice.z_class = dest->zclass;
- notice.z_class_inst = dest->zinst;
- notice.z_recipient = dest->zrecip;
- notice.z_sender = 0;
- notice.z_opcode = defs.opcode;
- notice.z_port = 0;
- notice.z_message = sig_msg;
- notice.z_message_len = msglen + siglen + 1;
-
- /* This really gross looking mess is brought to you by zwrite.c */
- if (defs.auth) {
- if (*defs.signature)
- notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n@bold($1) <$sender>\n\n$2";
- else
- notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n$message";
- }
- else {
- if (*defs.signature)
- notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n@bold($1) <$sender>\n\n$2";
- else
- notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n$message";
- }
-
- ret = zeph_send_notice(&notice, (defs.auth) ? ZAUTH : ZNOAUTH);
- free(sig_msg);
- return ret;
-}
-
-int zeph_ping(dest)
- Dest dest;
-{
- ZNotice_t notice;
-
- (void) memset((char *) &notice, 0, sizeof(ZNotice_t));
- notice.z_kind = ACKED;
- notice.z_class = dest->zclass;
- notice.z_class_inst = dest->zinst;
- notice.z_recipient = dest->zrecip;
- notice.z_opcode = "PING";
-
- /* Should a PING ever be authenticated? */
- return (zeph_send_notice(&notice, ZNOAUTH));
-}
-
-int zeph_pong(dest)
- Dest dest;
-{
- ZNotice_t notice;
-
- (void) memset((char *) &notice, 0, sizeof(ZNotice_t));
- notice.z_kind = ACKED;
- notice.z_class = dest->zclass;
- notice.z_class_inst = dest->zinst;
- notice.z_recipient = dest->zrecip;
- notice.z_opcode = "PING";
- notice.z_message = "PONG";
- notice.z_message_len = 4;
-
- /* Should a PING ever be authenticated? */
- return (zeph_send_notice(&notice, ZNOAUTH));
-}
-
-char *zeph_get_signature()
-{
- char *sig;
-
- sig = ZGetVariable("xzwrite-signature");
- if (! sig) sig = ZGetVariable("zwrite-signature");
- return sig;
-}
-
-static int zeph_send_notice(notice, auth)
- ZNotice_t *notice;
- int (*auth)();
-{
- int retval;
- ZNotice_t retnotice;
-
- /* Send message with appropriate authentication */
- retval = ZSendNotice(notice, auth);
- if (retval != ZERR_NONE) {
- if (defs.debug)
- Warning(error_message(retval), " while sending message.", NULL);
- return SENDFAIL_SEND;
- }
-
- /* Wait for server acknowledgement */
- retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
- ZCompareUIDPred, (char *) &notice->z_uid);
-
- if (retval != ZERR_NONE) {
- if (defs.debug)
- Warning(error_message(retval),
- " while waiting for acknowledgement.", NULL);
- return SENDFAIL_ACK;
- }
-
- /* Make sure someone receives it */
- if (strcmp(retnotice.z_message, ZSRVACK_NOTSENT)==0)
- return SENDFAIL_RECV;
-
- return SEND_OK;
-}
-
-#ifdef DEBUG
-/* debugging function */
-void zeph_display_subscriptions()
-{
- ZSubscription_t sub;
- int n, retval, i = 1;
-
- retval = ZRetrieveSubscriptions((unsigned short) 0, &n);
- if (retval != ZERR_NONE) {
- Warning(error_message(retval), " while retrieving subscriptions.",
- NULL);
- return;
- }
-
- printf("Retrieving %d subscriptions.\n", n);
-
- while (ZGetSubscriptions(&sub, &i) == ZERR_NONE) {
- if (i != 1)
- Warning("Subscriptions skipped while printing.", NULL);
-
- printf("<%s,%s,%s>\n", sub.class, (*sub.zsub_classinst) ?
- sub.zsub_classinst : "**", (*sub.zsub_recipient) ?
- sub.zsub_recipient : "**");
- }
-}
-#endif
diff --git a/clients/zaway/Imakefile b/clients/zaway/Imakefile
deleted file mode 100644
index aabe953..0000000
--- a/clients/zaway/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Header$
-/**/#
-
-SRCS = zaway.c
-OBJS = zaway.o
-
-zprogram(zaway,)
-install_man(zaway.1,zaway.1)
diff --git a/clients/zaway/Makefile.in b/clients/zaway/Makefile.in
new file mode 100644
index 0000000..64db77d
--- /dev/null
+++ b/clients/zaway/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zaway.o
+
+all: zaway
+
+zaway: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zaway
+ ${INSTALL} -m 755 -s zaway ${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zaway.1 ${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zaway
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zaway/zaway.c b/clients/zaway/zaway.c
index 8da42c9..5dfdc8d 100644
--- a/clients/zaway/zaway.c
+++ b/clients/zaway/zaway.c
@@ -11,34 +11,23 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/mit-copyright.h>
-
#include <zephyr/zephyr.h>
-
#include <pwd.h>
-#include <string.h>
-#include <signal.h>
+#include <com_err.h>
#ifndef lint
-static char rcsid_zaway_c[] = "$Id$";
+static const char rcsid_zaway_c[] = "$Id$";
#endif
#define MESSAGE_CLASS "MESSAGE"
#define DEFAULT_MSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
-#ifdef POSIX
-#include <stdlib.h>
-#define SIGNAL_RETURN_TYPE void
-#else
-extern char *getenv(), *malloc(), *realloc();
-extern uid_t getuid();
-#define SIGNAL_RETURN_TYPE int
-#endif
-
-SIGNAL_RETURN_TYPE cleanup();
+RETSIGTYPE cleanup();
u_short port;
-main(argc,argv)
+int main(argc,argv)
int argc;
char *argv[];
{
@@ -50,7 +39,7 @@ main(argc,argv)
register char *ptr;
char awayfile[BUFSIZ],*msg[2],*envptr;
char *find_message();
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
@@ -89,7 +78,7 @@ main(argc,argv)
fprintf(stderr,"File %s not found!\n",awayfile);
exit(1);
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
(void) sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = cleanup;
@@ -101,7 +90,7 @@ main(argc,argv)
(void) signal(SIGTERM, cleanup);
(void) signal(SIGHUP, cleanup);
#endif
- if ((retval = ZSubscribeTo(&sub,1,port)) != ZERR_NONE) {
+ if ((retval = ZSubscribeToSansDefaults(&sub,1,port)) != ZERR_NONE) {
com_err(argv[0],retval,"while subscribing");
exit(1);
}
@@ -199,7 +188,7 @@ char *find_message(notice,fp)
return (ptr);
}
-SIGNAL_RETURN_TYPE cleanup()
+RETSIGTYPE cleanup()
{
ZCancelSubscriptions(port);
exit(1);
diff --git a/clients/zctl/Imakefile b/clients/zctl/Imakefile
deleted file mode 100644
index 69418d6..0000000
--- a/clients/zctl/Imakefile
+++ /dev/null
@@ -1,16 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = zctl.c zctl_cmds.c
-OBJS = zctl.o zctl_cmds.o
-
-cmd_table(zctl_cmds)
-zprogram(zctl,$(LIB_SS))
-install_man(zctl.1,zctl.1)
diff --git a/clients/zctl/Makefile.in b/clients/zctl/Makefile.in
new file mode 100644
index 0000000..c9fb8d0
--- /dev/null
+++ b/clients/zctl/Makefile.in
@@ -0,0 +1,61 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+MK_CMDS=@MK_CMDS@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @X_CFLAGS@ @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @SS_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr -lss @LIBS@ -lcom_err
+
+OBJS= zctl.o zctl_cmds.o
+
+all: zctl
+
+zctl: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@ @SSDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+# The Athena mk_cmds insists on writing output to source directory. Bleah.
+# After the patch to fix it goes into an Athena release, replace it with:
+# ${MK_CMDS} ${srcdir}/zctl_cmds.ct
+zctl_cmds.c: zctl_cmds.ct
+ cp ${srcdir}/zctl_cmds.ct /tmp/zctl_cmds.$$$$.ct; \
+ ${MK_CMDS} /tmp/zctl_cmds.$$$$.ct; \
+ if [ -f /tmp/zctl_cmds.$$$$.c ]; then \
+ mv /tmp/zctl_cmds.$$$$.c zctl_cmds.c; \
+ else \
+ mv zctl_cmds.$$$$.c zctl_cmds.c; \
+ fi; \
+ rm -f /tmp/zctl_cmds.$$$$.ct
+
+check:
+
+install: zctl
+ ${INSTALL} -m 755 -s zctl ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zctl.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zctl_cmds.c zctl
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zctl/zctl.1 b/clients/zctl/zctl.1
index 4608dab..6b6e4c0 100644
--- a/clients/zctl/zctl.1
+++ b/clients/zctl/zctl.1
@@ -153,6 +153,11 @@ Delete the definitions of the specified Zephyr variables.
Unsubscribe to \fIclass, instance, recipient\fR, but don't remove this triplet
from the subscriptions file.
.TP
+.B wg_exit
+Tell the WindowGram client,
+.I zwgc(1),
+to exit.
+.TP
.B wg_read
Tell the WindowGram client,
.I zwgc(1),
@@ -269,10 +274,6 @@ Save all current subscriptions to the default subscriptions file.
.TP
.B zctl set exposure none
Set your exposure level to `none', effectively turning off Zephyr.
-.SH BUGS
-The current implementation of the Zephyr server (\fIzephyrd(8)\fR) makes
-no distinction between realm-announced, net-visible and net-announced
-exposure levels.
.SH SEE ALSO
zephyr(1), zwgc(1), zhm(8), zephyrd(8)
gethostbyname(3)
diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c
index 3516680..e8aa1cb 100644
--- a/clients/zctl/zctl.c
+++ b/clients/zctl/zctl.c
@@ -11,19 +11,14 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/zephyr.h>
#include <ss/ss.h>
#include <com_err.h>
#include <pwd.h>
#include <netdb.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/param.h>
-#ifdef POSIX
-#include <sys/utsname.h>
-#endif
#ifndef lint
-static char *rcsid_zctl_c = "$Id$";
+static const char *rcsid_zctl_c = "$Id$";
#endif
#define SUBSATONCE 7
@@ -60,9 +55,9 @@ main(argc,argv)
{
struct passwd *pwd;
struct hostent *hent;
- char ssline[BUFSIZ],oldsubsname[BUFSIZ],*envptr;
+ char ssline[BUFSIZ],oldsubsname[BUFSIZ],*envptr,*tty = NULL;
int retval,code,i;
-#ifdef POSIX
+#ifdef HAVE_SYS_UTSNAME
struct utsname name;
#endif
@@ -71,20 +66,28 @@ main(argc,argv)
exit (1);
}
- envptr = (char *)getenv("HOME");
+ /* Set hostname and tty for locations. If we support X, use the
+ * DISPLAY environment variable for the tty name. */
+#ifndef X_DISPLAY_MISSING
+ tty = getenv("DISPLAY");
+#endif
+ if ((retval = ZInitLocationInfo(NULL, tty)) != ZERR_NONE)
+ com_err(argv[0], retval, "initializing location information");
+
+ envptr = getenv("HOME");
if (envptr)
- (void) strcpy(subsname,envptr);
+ strcpy(subsname,envptr);
else {
if (!(pwd = getpwuid((int) getuid()))) {
fprintf(stderr,"Who are you?\n");
exit (1);
}
- (void) strcpy(subsname,pwd->pw_dir);
+ strcpy(subsname,pwd->pw_dir);
}
- (void) strcpy(oldsubsname,subsname);
- (void) strcat(oldsubsname,OLD_SUBS);
- (void) strcat(subsname,USERS_SUBS);
+ strcpy(oldsubsname,subsname);
+ strcat(oldsubsname,OLD_SUBS);
+ strcat(subsname,USERS_SUBS);
if (!access(oldsubsname,F_OK) && access(subsname, F_OK)) {
/* only if old one exists and new one does not exist */
printf("The .subscriptions file in your home directory is now being used as\n.zephyr.subs . I will rename it to .zephyr.subs for you.\n");
@@ -92,7 +95,7 @@ main(argc,argv)
com_err(argv[0], errno, "renaming .subscriptions");
}
-#ifdef POSIX
+#ifdef HAVE_SYS_UTSNAME
uname(&name);
strcpy(ourhost, name.nodename);
#else
@@ -205,6 +208,8 @@ wgc_control(argc,argv)
notice.z_opcode = USER_SHUTDOWN;
if (!strcmp(argv[0],"wg_startup"))
notice.z_opcode = USER_STARTUP;
+ if (!strcmp(argv[0],"wg_exit"))
+ notice.z_opcode = USER_EXIT;
if (!notice.z_opcode) {
fprintf(stderr,
"unknown WindowGram client control command %s\n",
@@ -371,10 +376,15 @@ do_hide(argc,argv)
fprintf(stderr, "Usage: %s\n",argv[0]);
return;
}
- if (!strcmp(argv[0],"unhide"))
- exp_level = EXPOSE_REALMVIS;
- else
+ if (!strcmp(argv[0],"unhide")) {
+ exp_level = ZGetVariable("exposure");
+ if (exp_level)
+ exp_level = ZParseExposureLevel(exp_level);
+ if (!exp_level)
+ exp_level = EXPOSE_NONE;
+ } else {
exp_level = EXPOSE_OPSTAFF;
+ }
if ((retval = ZSetLocation(exp_level)) != ZERR_NONE)
ss_perror(sci_idx,retval,"while changing exposure status");
return;
@@ -473,8 +483,7 @@ sub_file(argc,argv)
}
sub.zsub_class = argv[1];
sub.zsub_classinst = argv[2];
- sub.zsub_recipient = (argc == 3)?TOKEN_ME:TOKEN_WILD;
-
+ sub.zsub_recipient = (argc == 3)?TOKEN_ME:argv[3];
if (make_exist(subsname))
return;
diff --git a/clients/zctl/zctl_cmds.ct b/clients/zctl/zctl_cmds.ct
index fe39283..363ca66 100644
--- a/clients/zctl/zctl_cmds.ct
+++ b/clients/zctl/zctl_cmds.ct
@@ -63,6 +63,9 @@
request wgc_control, "Tell the WindowGram to react to incoming notices.",
wg_startup;
+ request wgc_control, "Tell the WindowGram to exit completely.",
+ wg_exit;
+
request hm_control, "Tell the server to flush information about this host.",
hm_flush;
diff --git a/clients/zleave/Imakefile b/clients/zleave/Imakefile
deleted file mode 100644
index aae9ed2..0000000
--- a/clients/zleave/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = zleave.c
-OBJS = zleave.o
-
-zprogram(zleave,)
-install_man(zleave.1,zleave.1)
diff --git a/clients/zleave/Makefile.in b/clients/zleave/Makefile.in
new file mode 100644
index 0000000..367ce8d
--- /dev/null
+++ b/clients/zleave/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zleave.o
+
+all: zleave
+
+zleave: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zleave
+ ${INSTALL} -m 755 -s zleave ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zleave.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zleave
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zleave/zleave.c b/clients/zleave/zleave.c
index 778f3e2..2484f6a 100644
--- a/clients/zleave/zleave.c
+++ b/clients/zleave/zleave.c
@@ -11,8 +11,8 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/mit-copyright.h>
-
#include <zephyr/zephyr.h>
#ifndef lint
@@ -37,15 +37,6 @@ char copyright[] =
All rights reserved.\n";
#endif /* not lint */
-#ifndef lint
-static char sccsid[] = "@(#)leave.c 5.2 (Berkeley) 12/2/87";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include <string.h>
-
#define MESSAGE_CLASS "MESSAGE"
#define INSTANCE "LEAVE"
/*
@@ -69,7 +60,8 @@ int use_zephyr=1, oldpid;
main(argc, argv)
char **argv;
{
- long when, now, diff, hours, minutes;
+ time_t now;
+ long when, diff, hours, minutes;
char *cp;
FILE *fp;
struct tm *nv;
@@ -93,7 +85,8 @@ char **argv;
sub.zsub_class = MESSAGE_CLASS;
sub.zsub_classinst = INSTANCE;
sub.zsub_recipient = ZGetSender();
- if (ZSubscribeTo(&sub,1,(u_short)port) != ZERR_NONE) {
+ if (ZSubscribeToSansDefaults(&sub,1,(u_short)port)
+ != ZERR_NONE) {
fprintf(stderr,
"Subscription error! Writing to your terminal...\n");
use_zephyr = 0;
@@ -212,13 +205,13 @@ int *hp, *mp;
doalarm(nmins)
long nmins;
{
+ time_t daytime;
char *msg1, *msg2, *msg3, *msg4;
register int i;
long slp1, slp2, slp3, slp4;
long seconds, gseconds;
- long daytime;
FILE *fp;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
@@ -282,7 +275,7 @@ long nmins;
(void) perror("fclose on pid file");
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
@@ -407,7 +400,7 @@ long secs;
}
}
-#ifdef V6
+#ifndef HAVE_GETLOGIN
char *getlogin() {
#include <utmp.h>
diff --git a/clients/zlocate/Imakefile b/clients/zlocate/Imakefile
deleted file mode 100644
index 291d74a..0000000
--- a/clients/zlocate/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Header$
-/**/#
-
-SRCS = zlocate.c
-OBJS = zlocate.o
-
-zprogram(zlocate,)
-install_man(zlocate.1,zlocate.1)
diff --git a/clients/zlocate/Makefile.in b/clients/zlocate/Makefile.in
new file mode 100644
index 0000000..403578d
--- /dev/null
+++ b/clients/zlocate/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-g
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zlocate.o
+
+all: zlocate
+
+zlocate: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zlocate
+ ${INSTALL} -m 755 -s zlocate ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zlocate.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zlocate
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zlocate/zlocate.c b/clients/zlocate/zlocate.c
index c117cb6..6167896 100644
--- a/clients/zlocate/zlocate.c
+++ b/clients/zlocate/zlocate.c
@@ -11,21 +11,18 @@
* "mit-copyright.h".
*/
-#include <zephyr/zephyr_internal.h>
-#include <signal.h>
+#include <sysdep.h>
+#include <zephyr/zephyr.h>
#include <sys/socket.h>
#if !defined(lint) && !defined(SABER)
-static char rcsid_zlocate_c[] = "$Id$";
+static const char rcsid_zlocate_c[] = "$Id$";
#endif
int numusers=0, numleft=0, parallel=0, oneline=0;
char *whoami;
-#ifdef POSIX
-void
-#endif
-timeout(sig)
+RETSIGTYPE timeout(sig)
{
fprintf (stderr, "%s: no response from server\n", whoami);
exit(1);
@@ -75,9 +72,9 @@ main(argc,argv)
{
char user[BUFSIZ],*whichuser;
ZAsyncLocateData_t ald;
- int retval,i,numlocs,loc,auth;
+ int retval,i,numlocs,numfound,loc,auth;
ZNotice_t notice;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
@@ -122,6 +119,7 @@ main(argc,argv)
}
numleft = numusers;
+ numfound = 0;
i = 0;
for (loc = 0; loc < argc; loc++) {
@@ -145,11 +143,12 @@ main(argc,argv)
exit(1);
}
print_locs(user,numlocs);
+ numfound += numlocs;
}
}
if (parallel) {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = timeout;
@@ -171,9 +170,10 @@ main(argc,argv)
if (numlocs >= 0) {
print_locs(whichuser,numlocs);
free(whichuser);
+ numfound += numlocs;
}
ZFreeNotice(&notice);
}
}
- return(0);
+ return((numfound > 0) ? 0 : 1);
}
diff --git a/clients/zmailnotify/Imakefile b/clients/zmailnotify/Imakefile
deleted file mode 100644
index eba7346..0000000
--- a/clients/zmailnotify/Imakefile
+++ /dev/null
@@ -1,19 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-#if defined(KERBEROS)
-XDEFS= -DKPOP
-
-SRCS = zmailnotify.c
-OBJS = zmailnotify.o
-
-zprogram(zmailnotify,)
-install_man(zmailnotify.1,zmailnotify.1)
-#endif
diff --git a/clients/zmailnotify/Makefile.in b/clients/zmailnotify/Makefile.in
new file mode 100644
index 0000000..a742bc9
--- /dev/null
+++ b/clients/zmailnotify/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h -DKPOP @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zmailnotify.o
+
+all: zmailnotify
+
+zmailnotify: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zmailnotify
+ ${INSTALL} -m 755 -s zmailnotify ${DESTDIR}${sbindir}
+ ${INSTALL} -m 644 ${srcdir}/zmailnotify.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zmailnotify
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zmailnotify/zmailnotify.c b/clients/zmailnotify/zmailnotify.c
index 7c5a746..f6575e7 100644
--- a/clients/zmailnotify/zmailnotify.c
+++ b/clients/zmailnotify/zmailnotify.c
@@ -10,25 +10,25 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr.h>
#ifndef lint
-static char rcsid_zmailnotify_c[] =
+static const char rcsid_zmailnotify_c[] =
"$Id$";
#endif
-#include <sys/uio.h>
#include <sys/socket.h>
-#include <sys/file.h>
-#include <fcntl.h>
#include <pwd.h>
-#include <errno.h>
#include <netdb.h>
-#ifdef Z_HaveHesiod
+#ifdef ZEPHYR_USES_HESIOD
#include <hesiod.h>
#endif
-#include <string.h>
+
+#ifndef ZEPHYR_USES_KERBEROS
+#undef KPOP
+#endif
#ifdef KPOP
#include <krb.h>
@@ -47,6 +47,7 @@ char *PrincipalHostname();
#endif
void get_message(), pop_close(), mail_notify(), fatal_pop_err ();
+int pop_command __P((char *, ...));
#define MAXMAIL 4
struct _mail {
@@ -71,7 +72,7 @@ main(argc, argv)
int i,nbytes,retval,uselock;
struct passwd *pwd;
struct _mail mymail;
-#ifdef Z_HaveHesiod
+#ifdef ZEPHYR_USES_HESIOD
struct hes_postoffice *p;
#endif
@@ -103,7 +104,7 @@ main(argc, argv)
(void) sprintf(lockfile,"%s/.maillock",dir);
host = (char *)getenv("MAILHOST");
-#ifdef Z_HaveHesiod
+#ifdef ZEPHYR_USES_HESIOD
if (host == NULL) {
p = hes_getmailhost(user);
if (p != NULL && strcmp(p->po_type, "POP") == 0)
@@ -122,7 +123,7 @@ main(argc, argv)
}
lock = fopen(lockfile,"r+");
-#ifdef POSIX
+#ifdef _POSIX_VERSION
if (lock) {
struct flock fl;
@@ -163,7 +164,7 @@ main(argc, argv)
if (!nmsgs) {
if (lock) {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct flock fl;
/* unlock the whole file */
@@ -204,7 +205,7 @@ main(argc, argv)
}
else {
lock = fopen(lockfile,"w");
-#ifdef POSIX
+#ifdef _POSIX_VERSION
if (lock) {
struct flock fl;
@@ -241,7 +242,7 @@ main(argc, argv)
mail_notify(&maillist[nmsgs-i]);
i--;
if (lock) {
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct flock fl;
/* unlock the whole file */
@@ -395,7 +396,6 @@ char *host;
long authopts;
char *host_save;
#endif
- char *get_errmsg();
char *svc_name;
hp = gethostbyname(host);
@@ -429,12 +429,12 @@ char *host;
s = rresvport(&lport);
#endif
if (s < 0) {
- (void) sprintf(Errmsg, "error creating socket: %s", get_errmsg());
+ (void) sprintf(Errmsg, "error creating socket: %s", strerror(errno));
return(NOTOK);
}
if (connect(s, (struct sockaddr *)&sin, sizeof sin) < 0) {
- (void) sprintf(Errmsg, "error during connect: %s", get_errmsg());
+ (void) sprintf(Errmsg, "error during connect: %s", strerror(errno));
(void) close(s);
return(NOTOK);
}
@@ -445,7 +445,7 @@ char *host;
authopts = KOPT_DO_OLDSTYLE;
rem = krb_sendsvc(s,"pop");
if (rem != KSUCCESS) {
- (void) sprintf(Errmsg, "kerberos error: %s", krb_err_txt[rem]);
+ (void) sprintf(Errmsg, "kerberos error: %s", krb_get_err_text(rem));
(void) close(s);
return(NOTOK);
}
@@ -465,7 +465,7 @@ char *host;
free(host_save);
free(ticket);
if (rem != KSUCCESS) {
- (void) sprintf(Errmsg, "kerberos error: %s",krb_err_txt[rem]);
+ (void) sprintf(Errmsg, "kerberos error: %s",krb_get_err_text(rem));
(void) close(s);
return(NOTOK);
}
@@ -474,7 +474,7 @@ char *host;
sfi = fdopen(s, "r");
sfo = fdopen(s, "w");
if (sfi == NULL || sfo == NULL) {
- (void) sprintf(Errmsg, "error in fdopen: %s", get_errmsg());
+ (void) sprintf(Errmsg, "error in fdopen: %s", strerror(errno));
(void) close(s);
return(NOTOK);
}
@@ -482,13 +482,19 @@ char *host;
return(OK);
}
-/*VARARGS1*/
-pop_command(fmt, a, b, c, d)
-char *fmt;
+#ifdef __STDC__
+pop_command(char *fmt, ...)
+#else
+pop_command(fmt, va_alist)
+ va_dcl
+#endif
{
+ va_list args;
char buf[4096];
- (void) sprintf(buf, fmt, a, b, c, d);
+ VA_START(args, fmt);
+ (void) vsprintf(buf, fmt, args);
+ va_end(args);
if (putline(buf, Errmsg, sfo) == NOTOK) return(NOTOK);
@@ -606,20 +612,6 @@ FILE *f;
return(OK);
}
-char *
-get_errmsg()
-{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
- char *s;
-
- if (errno < sys_nerr)
- s = sys_errlist[errno];
- else
- s = "unknown error";
- return(s);
-}
-
putline(buf, err, f)
char *buf;
char *err;
diff --git a/clients/znol/Imakefile b/clients/znol/Imakefile
deleted file mode 100644
index 40e3833..0000000
--- a/clients/znol/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = znol.c
-OBJS = znol.o
-
-zprogram(znol,)
-install_man(znol.1,znol.1)
diff --git a/clients/znol/Makefile.in b/clients/znol/Makefile.in
new file mode 100644
index 0000000..597ab3f
--- /dev/null
+++ b/clients/znol/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= znol.o
+
+all: znol
+
+znol: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: znol
+ ${INSTALL} -m 755 -s znol ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/znol.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} znol
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/znol/znol.c b/clients/znol/znol.c
index 9bc6764..fe29055 100644
--- a/clients/znol/znol.c
+++ b/clients/znol/znol.c
@@ -11,13 +11,13 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/zephyr.h>
#include <pwd.h>
-#include <string.h>
#ifndef lint
-static char rcsid_znol_c[] = "$Id$";
+static const char rcsid_znol_c[] = "$Id$";
#endif
#define SUBSATONCE 7
@@ -142,9 +142,8 @@ main(argc,argv)
*comment_ptr = '\0'; /* Ignore from # onwards */
/* Get rid of old-style nol entries, just in case */
cp = cleanname + strlen(cleanname) - 1;
- if (*cp == '\n')
- *cp = '\0';
- while (*--cp == ' ')
+ *cp = '\0';
+ while(*--cp == ' ')
*cp = '\0';
if (*cleanname == '@' || !*cleanname)
continue;
diff --git a/clients/zpopnotify/Imakefile b/clients/zpopnotify/Imakefile
deleted file mode 100644
index d0f4439..0000000
--- a/clients/zpopnotify/Imakefile
+++ /dev/null
@@ -1,13 +0,0 @@
-/**/# Copyright 1988, 1993 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Id$
-
-SRCS = zpopnotify.c
-OBJS = zpopnotify.o
-
-SimpleProgram(zpopnotify,$(OBJS) $(ZLIB),$(ZLIBS),$(ATHETCDIR))
-install_man(zpopnotify.8,zpopnotify.8)
-create_depend($(SRCS))
diff --git a/clients/zpopnotify/Makefile.in b/clients/zpopnotify/Makefile.in
new file mode 100644
index 0000000..ca38dd7
--- /dev/null
+++ b/clients/zpopnotify/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zpopnotify.o
+
+all: zpopnotify
+
+zpopnotify: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zpopnotify
+ ${INSTALL} -m 755 -s zpopnotify ${DESTDIR}${sbindir}
+ ${INSTALL} -m 644 ${srcdir}/zpopnotify.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ rm -f ${OBJS} zpopnotify
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zpopnotify/zpopnotify.c b/clients/zpopnotify/zpopnotify.c
index ee298ad..ba4e376 100644
--- a/clients/zpopnotify/zpopnotify.c
+++ b/clients/zpopnotify/zpopnotify.c
@@ -11,13 +11,16 @@
* "mit-copyright.h".
*/
-#include <zephyr/mit-copyright.h>
+#include <sysdep.h>
+#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr.h>
+#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <sys/param.h> /* for MAXHOSTNAMELEN */
#include <com_err.h>
+#include <errno.h>
#ifndef lint
static char rcsid_zpopnotify_c[] = "$Header$";
diff --git a/clients/zshutdown_notify/Imakefile b/clients/zshutdown_notify/Imakefile
deleted file mode 100644
index 9dc7ace..0000000
--- a/clients/zshutdown_notify/Imakefile
+++ /dev/null
@@ -1,16 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = zshutdown_notify.c
-OBJS = zshutdown_notify.o
-
-SimpleProgram(zshutdown_notify,$(OBJS) $(ZLIB),$(ZLIBS),$(ATHRETCDIR))
-install_man(zshutdown_notify.8,zshutdown_notify.8)
-create_depend($(SRCS))
diff --git a/clients/zshutdown_notify/Makefile.in b/clients/zshutdown_notify/Makefile.in
new file mode 100644
index 0000000..0fb5922
--- /dev/null
+++ b/clients/zshutdown_notify/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zshutdown_notify.o
+
+all: zshutdown_notify
+
+zshutdown_notify: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zshutdown_notify
+ ${INSTALL} -m 755 -s zshutdown_notify ${DESTDIR}${lsbindir}
+ ${INSTALL} -m 644 ${srcdir}/zshutdown_notify.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ rm -f ${OBJS} zshutdown_notify
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zshutdown_notify/zshutdown_notify.c b/clients/zshutdown_notify/zshutdown_notify.c
index 99a3fce..e7727e6 100644
--- a/clients/zshutdown_notify/zshutdown_notify.c
+++ b/clients/zshutdown_notify/zshutdown_notify.c
@@ -11,17 +11,15 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr.h>
-#include <sys/param.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
#ifndef lint
-static char *rcsid_zshutdown_notify_c =
+static const char *rcsid_zshutdown_notify_c =
"$Id$";
#endif
@@ -31,7 +29,7 @@ static char *rcsid_zshutdown_notify_c =
#define N_DEF_FORMAT "From $sender:\n@bold(Shutdown message from $1 at $time)\n@center(System going down, message is:)\n\n$2\n\n@center(@bold($3))"
#define N_FIELD_CNT 3
-#ifdef Z_HaveKerberos
+#ifdef ZEPHYR_USES_KERBEROS
#define SVC_NAME "rcmd"
#endif
@@ -54,7 +52,7 @@ main(argc,argv)
char msgbuff[BUFSIZ], message[Z_MAXPKTLEN], *ptr;
char scratch[BUFSIZ];
char *msg[N_FIELD_CNT];
-#ifdef Z_HaveKerberos
+#ifdef ZEPHYR_USES_KERBEROS
char tkt_filename[MAXPATHLEN];
char rlm[REALM_SZ];
char hn2[MAXHOSTNAMELEN];
@@ -75,7 +73,7 @@ main(argc,argv)
sprintf(scratch, warning, hostname);
msg[2] = scratch;
-#ifdef Z_HaveKerberos
+#ifdef ZEPHYR_USES_KERBEROS
(void) sprintf(tkt_filename, "/tmp/tkt_zshut_%d", getpid());
krb_set_tkt_string(tkt_filename);
@@ -88,14 +86,14 @@ main(argc,argv)
}
if (retval = krb_get_lrealm(rlm, 1)) {
fprintf(stderr, "%s: can't get local realm: %s\n",
- argv[0], krb_err_txt[retval]);
+ argv[0], krb_get_err_text(retval));
exit(1);
}
if (retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
SERVER_SERVICE, SERVER_INSTANCE, 1,
KEYFILE)) {
fprintf(stderr, "%s: can't get tickets: %s\n",
- argv[0], krb_err_txt[retval]);
+ argv[0], krb_get_err_text(retval));
exit(1);
}
#endif
@@ -130,7 +128,7 @@ main(argc,argv)
notice.z_default_format = N_DEF_FORMAT;
retval = ZSendList(&notice, msg, N_FIELD_CNT, ZAUTH);
-#ifdef Z_HaveKerberos
+#ifdef ZEPHYR_USES_KERBEROS
(void) dest_tkt();
#endif
diff --git a/clients/zstat/Imakefile b/clients/zstat/Imakefile
deleted file mode 100644
index 9ffd2ac..0000000
--- a/clients/zstat/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = zstat.c
-OBJS = zstat.o
-
-zprogram(zstat,)
-install_man(zstat.8,zstat.8)
diff --git a/clients/zstat/Makefile.in b/clients/zstat/Makefile.in
new file mode 100644
index 0000000..11b2f92
--- /dev/null
+++ b/clients/zstat/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zstat.o
+
+all: zstat
+
+zstat: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zstat
+ ${INSTALL} -m 755 -s zstat ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zstat.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ rm -f ${OBJS} zstat
+
+${OBJS}: zserver.h ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zstat/zserver.h b/clients/zstat/zserver.h
index 9528840..467b41f 100644
--- a/clients/zstat/zserver.h
+++ b/clients/zstat/zserver.h
@@ -25,8 +25,4 @@
#define ADMIN_KILL_CLT "KILL_CLIENT" /* Opcode: client is dead, remove */
#define ADMIN_STATUS "STATUS" /* Opcode: please send status */
-#define ADMIN_LIMBO "LIMBO" /* Class inst: please send limbo info*/
-#define ADMIN_YOU "YOUR_STATE" /* Class inst: please send your state*/
-#define ADMIN_ME "MY_STATE" /* Class inst: please send my info */
-
#endif /* !__ZSERVER_H__ */
diff --git a/clients/zstat/zstat.c b/clients/zstat/zstat.c
index 10204b4..798baf0 100644
--- a/clients/zstat/zstat.c
+++ b/clients/zstat/zstat.c
@@ -11,58 +11,47 @@
* "mit-copyright.h".
*/
-#include <zephyr/zephyr.h>
-#include <sys/param.h>
+/* There should be library interfaces for the operations in zstat; for now,
+ * however, zstat is more or less internal to the Zephyr system. */
+#include <internal.h>
+
#include <sys/socket.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h> /* BSD includes this from <sys/param.h>,
- but AIX does not. */
#include "zserver.h"
#if !defined(lint) && !defined(SABER)
-static char rcsid_zstat_c[] = "$Id$";
+static const char rcsid_zstat_c[] = "$Id$";
#endif
-#ifdef __STDC__
-const
-#endif
- char *hm_head[] = { "Current server =",
- "Items in queue:",
- "Client packets received:",
- "Server packets received:",
- "Server changes:",
- "Version:",
- "Looking for a new server:",
- "Time running:",
- "Size:",
- "Machine type:"
+const char *hm_head[] = {
+ "Current server =",
+ "Items in queue:",
+ "Client packets received:",
+ "Server packets received:",
+ "Server changes:",
+ "Version:",
+ "Looking for a new server:",
+ "Time running:",
+ "Size:",
+ "Machine type:"
};
#define HM_SIZE (sizeof(hm_head) / sizeof (char *))
-#ifdef __STDC__
-const
-#endif
- char *srv_head[] = {
- "Current server version =",
- "Packets handled:",
- "Uptime:",
- "Server states:",
+const char *srv_head[] = {
+ "Current server version =",
+ "Packets handled:",
+ "Uptime:",
+ "Server states:",
};
#define SRV_SIZE (sizeof(srv_head) / sizeof (char *))
int outoftime = 0;
-#if defined(ultrix) || defined(POSIX)
-void
-#endif
-timeout()
+RETSIGTYPE timeout()
{
outoftime = 1;
}
int serveronly = 0,hmonly = 0;
-u_short hm_port,srv_port;
+u_short srv_port;
main(argc, argv)
int argc;
@@ -105,19 +94,8 @@ main(argc, argv)
exit(1);
}
- if (!(sp = getservbyname(HM_SVCNAME,"udp"))) {
- fprintf(stderr,"%s/udp: unknown service\n", HM_SVCNAME);
- exit(-1);
- }
-
- hm_port = sp->s_port;
-
- if (!(sp = getservbyname(SERVER_SVCNAME,"udp"))) {
- fprintf(stderr,"%s/udp: unknown service\n",SERVER_SVCNAME);
- exit(-1);
- }
-
- srv_port = sp->s_port;
+ sp = getservbyname(SERVER_SVCNAME,"udp");
+ srv_port = (sp) ? sp->s_port : SERVER_SVC_FALLBACK;
if (optind == argc) {
if (gethostname(hostname, MAXHOSTNAMELEN) < 0) {
@@ -154,79 +132,34 @@ do_stat(host)
hm_stat(host,server)
char *host,*server;
{
+ struct in_addr inaddr;
+ Code_t code;
+
char *line[20],*mp;
int sock,i,nf,ret;
struct hostent *hp;
- struct sockaddr_in sin;
- long runtime;
+ time_t runtime;
struct tm *tim;
ZNotice_t notice;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
- (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));
-
- sin.sin_port = hm_port;
-
- if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
- perror("socket:");
- exit(-1);
- }
-
- sin.sin_family = AF_INET;
-
- if ((sin.sin_addr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
+ if ((inaddr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
if ((hp = gethostbyname(host)) == NULL) {
fprintf(stderr,"Unknown host: %s\n",host);
exit(-1);
}
- (void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length);
+ (void) memcpy((char *) &inaddr, hp->h_addr, hp->h_length);
printf("Hostmanager stats: %s\n", hp->h_name);
} else {
printf("Hostmanager stats: %s\n", host);
}
- (void) memset((char *)&notice, 0, sizeof(notice));
- notice.z_kind = STAT;
- notice.z_port = 0;
- notice.z_class = HM_STAT_CLASS;
- notice.z_class_inst = HM_STAT_CLIENT;
- notice.z_opcode = HM_GIMMESTATS;
- notice.z_sender = "";
- notice.z_recipient = "";
- notice.z_default_format = "";
- notice.z_message_len = 0;
-
- if ((ret = ZSetDestAddr(&sin)) != ZERR_NONE) {
- com_err("zstat", ret, "setting destination");
- exit(-1);
- }
- if ((ret = ZSendNotice(&notice, ZNOAUTH)) != ZERR_NONE) {
- com_err("zstat", ret, "sending notice");
- exit(-1);
- }
-#ifdef POSIX
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = timeout;
- (void) sigaction(SIGALRM, &sa, (struct sigaction *)0);
-#else
- (void) signal(SIGALRM,timeout);
-#endif
- outoftime = 0;
- (void) alarm(10);
- if (((ret = ZReceiveNotice(&notice, (struct sockaddr_in *) 0))
- != ZERR_NONE) &&
- ret != EINTR) {
- com_err("zstat", ret, "receiving notice");
- return (1);
- }
- (void) alarm(0);
- if (outoftime) {
- fprintf(stderr,"No response after 10 seconds.\n");
- return (1);
+ if ((code = ZhmStat(&inaddr, &notice)) != ZERR_NONE) {
+ com_err("zstat", ret, "getting hostmanager status");
+ exit(-1);
}
mp = notice.z_message;
@@ -268,9 +201,9 @@ srv_stat(host)
struct hostent *hp;
struct sockaddr_in sin;
ZNotice_t notice;
- long runtime;
+ time_t runtime;
struct tm *tim;
-#ifdef POSIX
+#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
@@ -317,7 +250,7 @@ srv_stat(host)
exit(-1);
}
-#ifdef POSIX
+#ifdef _POSIX_VERSION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = timeout;
diff --git a/clients/zwrite/Imakefile b/clients/zwrite/Imakefile
deleted file mode 100644
index b07be96..0000000
--- a/clients/zwrite/Imakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-/**/# Copyright 1988 Massachusetts Institute of Technology.
-/**/#
-/**/# For copying and distribution information, see the file
-/**/# "mit-copyright.h".
-/**/#
-/**/# $Source$
-/**/# $Author$
-/**/# $Id$
-/**/#
-
-SRCS = zwrite.c
-OBJS = zwrite.o
-
-zprogram(zwrite,)
-install_man(zwrite.1,zwrite.1)
diff --git a/clients/zwrite/Makefile.in b/clients/zwrite/Makefile.in
new file mode 100644
index 0000000..9319c24
--- /dev/null
+++ b/clients/zwrite/Makefile.in
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+confdir=@confdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=${prefix}/man
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+CC=@CC@
+INSTALL=@INSTALL@
+
+DEBUG=-O
+CFLAGS=${DEBUG} -I${top_srcdir}/h -I${BUILDTOP}/h @CPPFLAGS@
+LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@
+LIBS=-lzephyr @LIBS@ -lcom_err
+
+OBJS= zwrite.o
+
+all: zwrite
+
+zwrite: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+check:
+
+install: zwrite
+ ${INSTALL} -m 755 -s zwrite ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zwrite.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ rm -f ${OBJS} zwrite
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/clients/zwrite/zwrite.1 b/clients/zwrite/zwrite.1
index 4dfe47c..dac2954 100644
--- a/clients/zwrite/zwrite.1
+++ b/clients/zwrite/zwrite.1
@@ -164,6 +164,9 @@ and recipient "*".
.br
This argument may not be used in conjunction with the -f option.
.TP
+.B \-F \fIformat\fR
+Allows a user to specify a different default format for the message.
+.TP
.B \-O \fIopcode\fR
Allows a user to specify a different opcode for the message.
Some Zephyr notice display programs may use the opcode to decide how
diff --git a/clients/zwrite/zwrite.c b/clients/zwrite/zwrite.c
index 08d9a00..67badb3 100644
--- a/clients/zwrite/zwrite.c
+++ b/clients/zwrite/zwrite.c
@@ -11,16 +11,14 @@
* "mit-copyright.h".
*/
+#include <sysdep.h>
#include <zephyr/mit-copyright.h>
-
#include <zephyr/zephyr.h>
-#include <string.h>
#include <netdb.h>
#include <pwd.h>
-#include <ctype.h>
#ifndef lint
-static char rcsid_zwrite_c[] = "$Id$";
+static const char rcsid_zwrite_c[] = "$Id$";
#endif /* lint */
#define DEFAULT_CLASS "MESSAGE"
@@ -32,8 +30,8 @@ static char rcsid_zwrite_c[] = "$Id$";
#define MAXRECIPS 100
int nrecips, msgarg, verbose, quiet, nodot;
-char *whoami, *inst, *class, *opcode, *recips[MAXRECIPS];
-int (*auth)();
+char *whoami, *inst, *class, *opcode, *realm, *recips[MAXRECIPS];
+Z_AuthProc auth;
void un_tabify();
char *fix_filsrv_inst();
@@ -43,7 +41,7 @@ main(argc, argv)
char *argv[];
{
int retval, arg, nocheck, nchars, msgsize, filsys, tabexpand;
- char *message, *signature = NULL;
+ char *message, *signature = NULL, *format = NULL;
static char bfr[BUFSIZ], classbfr[BUFSIZ], instbfr[BUFSIZ], sigbfr[BUFSIZ];
static char opbfr[BUFSIZ];
static ZNotice_t notice;
@@ -166,6 +164,18 @@ main(argc, argv)
case 'l': /* literal */
nodot = 1;
break;
+ case 'F':
+ if (arg == argc-1)
+ usage(whoami);
+ arg++;
+ format = argv[arg];
+ break;
+ case 'r':
+ if (arg == argc-1)
+ usage(whoami);
+ arg++;
+ realm = argv[arg];
+ break;
default:
usage(whoami);
}
@@ -211,7 +221,9 @@ main(argc, argv)
notice.z_sender = 0;
notice.z_message_len = 0;
notice.z_recipient = "";
- if (filsys == 1)
+ if (format)
+ notice.z_default_format = format;
+ else if (filsys == 1)
notice.z_default_format = "@bold(Filesystem Operation Message for $instance:)\nFrom: @bold($sender) at $time $date\n$message";
else if (auth == ZAUTH) {
if (signature)
@@ -307,13 +319,18 @@ send_off(notice, real)
int real;
{
int i, success, retval;
- char bfr[BUFSIZ];
+ char bfr[BUFSIZ], realm_recip[BUFSIZ], *cp;
ZNotice_t retnotice;
success = 0;
for (i=0;i<nrecips || !nrecips;i++) {
- notice->z_recipient = nrecips?recips[i]:"";
+ if (realm) {
+ sprintf(realm_recip, "%s@%s", (nrecips) ? recips[i] : "", realm);
+ notice->z_recipient = realm_recip;
+ } else {
+ notice->z_recipient = (nrecips) ? recips[i] : "";
+ }
if (verbose && real)
printf("Sending %smessage, class %s, instance %s, to %s\n",
auth?"authenticated ":"",
@@ -362,23 +379,27 @@ send_off(notice, real)
}
} else if (!strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) {
if (verbose && real && !quiet) {
- if (strcmp(class, DEFAULT_CLASS))
- printf("Not logged in or not subscribing to class %s, instance %s\n",
+ if (strcmp(class, DEFAULT_CLASS)) {
+ fprintf(stderr, "Not logged in or not subscribing to class %s, instance %s\n",
class, inst);
- else
- printf("Not logged in or not subscribing to messages\n");
+ } else {
+ fprintf(stderr,
+ "Not logged in or not subscribing to messages\n");
+ }
}
else if (!quiet) {
- if (!nrecips)
- printf("No one subscribing to class %s, instance %s\n",
- class, inst);
- else {
- if (strcmp(class, DEFAULT_CLASS))
- printf("%s: Not logged in or not subscribing to class %s, instance %s\n",
+ if (!nrecips) {
+ fprintf(stderr,
+ "No one subscribing to class %s, instance %s\n",
+ class, inst);
+ } else {
+ if (strcmp(class, DEFAULT_CLASS)) {
+ fprintf(stderr, "%s: Not logged in or not subscribing to class %s, instance %s\n",
notice->z_recipient, class, inst);
- else
- printf("%s: Not logged in or not subscribing to messages\n",
+ } else {
+ fprintf(stderr, "%s: Not logged in or not subscribing to messages\n",
notice->z_recipient);
+ }
}
}
}
@@ -398,7 +419,7 @@ usage(s)
fprintf(stderr,
"Usage: %s [-a] [-o] [-d] [-v] [-q] [-n] [-t] [-u] [-l]\n\
\t[-c class] [-i inst] [-O opcode] [-f fsname] [-s signature]\n\
-\t[user ...] [-m message]\n", s);
+\t[user ...] [-F format] [-r realm] [-m message]\n", s);
fprintf(stderr,"\t-f and -c are mutually exclusive\n\
\t-f and -i are mutually exclusive\n\
\trecipients must be specified unless -c or -f specifies a class\n\