adding zephyr-im master branch

This commit is contained in:
2022-07-25 09:01:27 -06:00
parent 61f5ed8f01
commit ee1236fa5c
311 changed files with 62265 additions and 0 deletions

56
clients/zaway/Makefile.in Normal file
View File

@ -0,0 +1,56 @@
SHELL=@SHELL@
prefix=@prefix@
exec_prefix=@exec_prefix@
datadir=@datadir@
sysconfdir=@sysconfdir@
sbindir=@sbindir@
lsbindir=@lsbindir@
datarootdir=@datarootdir@
top_builddir=../..
includedir=@includedir@
mandir=@mandir@
libdir=@libdir@
bindir=@bindir@
srcdir=@srcdir@
top_srcdir=@top_srcdir@
BUILDTOP=../..
VPATH=@srcdir@
LIBTOOL=@LIBTOOL@
CC=@CC@
INSTALL=@INSTALL@
LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
CPPFLAGS=@CPPFLAGS@
CFLAGS=@CFLAGS@
ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS}
LDFLAGS=@LDFLAGS@
LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
OBJS= zaway.o
all: zaway
zaway: ${OBJS} ${LIBZEPHYR}
${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
.c.o:
${CC} -c ${ALL_CFLAGS} $<
check:
install: zaway
${LIBTOOL} --mode=install ${INSTALL} -m 755 zaway ${DESTDIR}${bindir}
${INSTALL} -m 644 ${srcdir}/zaway.1 ${DESTDIR}${mandir}/man1
clean:
${LIBTOOL} --mode=clean rm -f zaway
rm -f ${OBJS}
${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

120
clients/zaway/zaway.1 Normal file
View File

@ -0,0 +1,120 @@
.\" $Id$
.\"
.\" Copyright 1987,1988 by the Massachusetts Institute of Technology
.\" All rights reserved. The file /usr/include/zephyr/mit-copyright.h
.\" specifies the terms and conditions for redistribution.
.\"
.\" @(#)zaway.1 6.1 (MIT) 7/9/87
.\"
.TH ZAWAY 1 "July 1, 1988" "MIT Project Athena"
.ds ]W MIT Project Athena
.SH NAME
zaway \- tell other people via Zephyr that you aren't around
.SH SYNOPSIS
.B zaway
[
.I OPTIONS
]
[
.I FILE
]
.SH DESCRIPTION
.I zaway
provides a way for you to automatically send replies when other people
contact you using
.I zwrite(1). zaway
subscribes itself to class "MESSAGE", instance "*", so that it can
monitor your incoming messages. It does not affect the operation of any
other client receiving messages.
.I zaway
is typically run when you are leaving your terminal or display
temporarily.
.I zaway
usually never exits; when you return to your terminal you should type
the interrupt character (usually ^C) in order to make
.I zaway
exit.
.SS OPTIONS
.TP
.I "\-m STRING"
Use STRING as the body of the auto-reply message. Any message file
(specified on the command line or the default) is ignored.
.TP
.I "\-w"
Watch the invoking user's location status. If the user is locatable
anywhere, no auto-replies will be sent.
.TP
.I "\-h"
Displays a short usage message and exits.
.PP
.I zaway
uses a message file (which defaults
to $HOME/.away) to describe what reponses should be sent to which
senders. The general format of this file
is:
.PP
.nf
>name
>name
message
>name
message
.fi
.PP
Any number of user names may be specified preceding the message to send
to those senders. If a user name appears more than once, the message will
be a concatenation of each of the appropriate messages. There are
two special names: "*" indicates that the following message should be
sent to all senders and "%" indicates that the following message should
only be sent if the user name has not matched yet.
.PP
If no file is specified,
and no default file can be found, the following message is returned:
.sp
.in +5
I'm sorry, but I am currently away from the terminal and am
not able to receive your message.
.in -5
.sp
If a user name does not match any of those listed in the file, and no
"*" or "%" field is specified, no return message is sent. All
messages are preceded by a signature "Automated reply:". To avoid
loops, messages are not sent in response to messages beginning with an
"Automated reply:" signature or sent by the same Kerberos principal as
the user running
.I zaway.
.SH SAMPLE FILE
.nf
>eichin
>tony
Hi there guys! I'm in the other room right now.
I'll be back in 5 minutes or so.
>jruser
Sorry, but I'm gone for the day...
>%
Hello...I'm not sure who you are. I'll be back soon,
though.
>*
This message comes to you compliments of zaway!
.fi
The final "compliments" message will be included in all messages,
whereas the "I'm not sure" message will only be included in messages that
are not from "eichin", "tony", or "jruser".
.SH FILES
$HOME/.away
.SH SEE ALSO
zephyr(1), zwgc(1), zwrite(1), zhm(8), zephyrd(8)
.br
Project Athena Technical Plan Section E.4.1, `Zephyr Notification
Service'
.SH AUTHOR
.PP
Robert S. French (MIT-Project Athena)
.SH RESTRICTIONS
Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
All Rights Reserved.
.br
.I zephyr(1)
specifies the terms and conditions for redistribution.

270
clients/zaway/zaway.c Normal file
View File

@ -0,0 +1,270 @@
/* This file is part of the Project Athena Zephyr Notification System.
* It contains code for the "zaway" command.
*
* Created by: Robert French
*
* $Id$
*
* Copyright (c) 1987, 1993 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#include <sysdep.h>
#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr.h>
#include <pwd.h>
#ifndef lint
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"
#define RESPONSE_OPCODE ""
static char *find_message(ZNotice_t *, FILE *);
RETSIGTYPE cleanup(int);
u_short port;
static void
usage(char *name)
{
printf("Usage: %s [OPTIONS] [FILE]\n"
"\n"
" -m STRING use STRING as the body of the reply message\n"
" -w watch your location and only reply if you aren't locatable\n"
" -h display this help and exit\n",
name);
}
int
main(int argc,
char *argv[])
{
FILE *fp;
ZNotice_t notice;
ZSubscription_t sub;
register int retval;
struct passwd *pw;
register char *ptr;
char awayfile[BUFSIZ],*msg[2],*envptr;
int optchar, watch_location;
char *cmdline_msg;
int nlocs;
char *charset = NULL;
unsigned short zcharset;
#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
if ((retval = ZInitialize()) != ZERR_NONE) {
com_err(argv[0],retval,"while initializing");
exit(1);
}
port = 0;
if ((retval = ZOpenPort(&port)) != ZERR_NONE) {
com_err(argv[0],retval,"while opening port");
exit(1);
}
sub.zsub_class = MESSAGE_CLASS;
sub.zsub_classinst = "*";
sub.zsub_recipient = ZGetSender();
cmdline_msg = 0;
watch_location = 0;
while ((optchar = getopt(argc, argv, "m:whx:")) != EOF) {
switch (optchar) {
case 'm':
cmdline_msg = optarg;
break;
case 'w':
watch_location = 1;
break;
case 'h':
usage(argv[0]);
return 0;
case 'x':
charset = optarg;
break;
case '?':
fprintf(stderr,
"Unrecognized option '-%c'.\n"
"Try '%s -h' for more information.\n",
optopt, argv[0]);
return 1;
}
}
zcharset = ZGetCharset(charset);
if (argc > optind)
(void) strcpy(awayfile,argv[optind]);
else {
envptr = getenv("HOME");
if (envptr)
(void) sprintf(awayfile,"%s/.away",envptr);
else {
if (!(pw = getpwuid((int) getuid()))) {
fprintf(stderr,"Who are you?\n");
exit(1);
}
(void) sprintf(awayfile,"%s/.away",pw->pw_dir);
}
}
fp = fopen(awayfile,"r");
if (!fp && argc > optind) {
fprintf(stderr,"File %s not found!\n",awayfile);
exit(1);
}
#ifdef _POSIX_VERSION
(void) sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = cleanup;
(void) sigaction(SIGINT, &sa, (struct sigaction *)0);
(void) sigaction(SIGTERM, &sa, (struct sigaction *)0);
(void) sigaction(SIGHUP, &sa, (struct sigaction *)0);
#else
(void) signal(SIGINT, cleanup);
(void) signal(SIGTERM, cleanup);
(void) signal(SIGHUP, cleanup);
#endif
if ((retval = ZSubscribeToSansDefaults(&sub,1,port)) != ZERR_NONE) {
com_err(argv[0],retval,"while subscribing");
exit(1);
}
for (;;) {
if ((retval = ZReceiveNotice(&notice, (struct sockaddr_in *)0)) != ZERR_NONE) {
if (retval != ETIMEDOUT)
com_err(argv[0],retval,"while receiving notice");
continue;
}
if (strcmp(notice.z_sender,ZGetSender()) == 0 ||
strcmp(notice.z_opcode,"PING") == 0 ||
strcmp(notice.z_opcode,"AUTO") == 0 ||
strcmp(notice.z_message,"Automated reply:") == 0) {
ZFreeNotice(&notice);
continue;
}
if (watch_location) {
if ((retval = ZLocateUser(ZGetSender(), &nlocs, ZNOAUTH))
!= ZERR_NONE) {
com_err(argv[0],retval,"while locating self");
continue;
}
if (nlocs != 0) {
/* User is logged in. Don't send an autoreply. */
continue;
}
ZFlushLocations();
}
if (cmdline_msg) {
ptr = strdup(cmdline_msg);
if (!ptr) {
com_err(argv[0],ENOMEM,"while getting cmdline message");
exit(1);
}
}
else if (fp) {
if (!(ptr = find_message(&notice,fp))) {
ZFreeNotice(&notice);
continue;
}
}
else {
ptr = malloc(sizeof(DEFAULT_MSG)+1);
if (!ptr) {
com_err(argv[0],ENOMEM,"while getting default message");
exit(1);
}
(void) strcpy(ptr,DEFAULT_MSG);
}
notice.z_recipient = notice.z_sender;
notice.z_sender = 0;
notice.z_default_format = "";
notice.z_opcode = RESPONSE_OPCODE;
notice.z_charset = zcharset;
msg[0] = "Automated reply:";
msg[1] = ptr;
notice.z_message_len = strlen(notice.z_message)+1;
if ((retval = ZSendList(&notice,msg,2,ZNOAUTH)) != ZERR_NONE) {
com_err(argv[0],retval,"while sending notice");
}
free(ptr);
ZFreeNotice(&notice);
}
}
char *
find_message(ZNotice_t *notice,
FILE *fp)
{
char *ptr,*ptr2;
char bfr[BUFSIZ],sender[BUFSIZ];
int gotone,lastwasnt;
rewind(fp);
(void) strcpy(sender,notice->z_sender);
ptr2 = strchr(sender,'@');
if (ptr2)
*ptr2 = '\0';
ptr = 0;
gotone = 0;
lastwasnt = 0;
while (fgets(bfr,sizeof bfr,fp) != (char *)0) {
if (*bfr == '>') {
if (lastwasnt)
gotone = 0;
bfr[strlen(bfr)-1] = '\0';
ptr2 = strchr(bfr,'@');
if (ptr2)
*ptr2 = '\0';
if (!strcmp(bfr+1,sender) ||
!strcmp(bfr+1,"*") ||
(!strcmp(bfr+1,"%") && !ptr))
gotone = 1;
lastwasnt = 0;
}
else {
if (gotone) {
if (!ptr) {
ptr = malloc((unsigned)(strlen(bfr)+1));
*ptr = '\0';
}
else
ptr = realloc(ptr,(unsigned)(strlen(bfr)+strlen(ptr)+1));
(void) strcat(ptr,bfr);
}
lastwasnt = 1;
}
}
return (ptr);
}
RETSIGTYPE
cleanup(int ignored)
{
ZCancelSubscriptions(port);
exit(1);
}