summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorGravatar Greg Hudson <ghudson@mit.edu>1999-07-21 08:34:18 +0000
committerGravatar Greg Hudson <ghudson@mit.edu>1999-07-21 08:34:18 +0000
commit0a8b68c7cc60cc1d9016d249f16d718e0198bf54 (patch)
tree69e6f42a0202e17b4ecf2e7bc297a4f276580771 /clients
parenta09ed3e5126e65c2299cc38af8d1ff05551addad (diff)
From Chris Laas: add new options -m (to specify a message), -w (to watch
location and not respond when visible), and -h (help).
Diffstat (limited to 'clients')
-rw-r--r--clients/zaway/zaway.117
-rw-r--r--clients/zaway/zaway.c68
2 files changed, 81 insertions, 4 deletions
diff --git a/clients/zaway/zaway.1 b/clients/zaway/zaway.1
index 480c8c6..0f46f96 100644
--- a/clients/zaway/zaway.1
+++ b/clients/zaway/zaway.1
@@ -13,7 +13,10 @@ zaway \- tell other people via Zephyr that you aren't around
.SH SYNOPSIS
.B zaway
[
-.I file
+.I OPTIONS
+]
+[
+.I FILE
]
.SH DESCRIPTION
.I zaway
@@ -31,6 +34,18 @@ 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
diff --git a/clients/zaway/zaway.c b/clients/zaway/zaway.c
index d871ef8..8186f61 100644
--- a/clients/zaway/zaway.c
+++ b/clients/zaway/zaway.c
@@ -27,6 +27,17 @@ static const char rcsid_zaway_c[] = "$Id$";
RETSIGTYPE cleanup();
u_short port;
+void usage(name)
+ 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(argc,argv)
int argc;
char *argv[];
@@ -38,6 +49,9 @@ int main(argc,argv)
struct passwd *pw;
register char *ptr;
char awayfile[BUFSIZ],*msg[2],*envptr;
+ int optchar, watch_location;
+ char *cmdline_msg;
+ int nlocs;
char *find_message();
#ifdef _POSIX_VERSION
struct sigaction sa;
@@ -58,8 +72,33 @@ int main(argc,argv)
sub.zsub_classinst = "*";
sub.zsub_recipient = ZGetSender();
- if (argc > 1)
- (void) strcpy(awayfile,argv[1]);
+ cmdline_msg = 0;
+ watch_location = 0;
+ while ((optchar = getopt(argc, argv, "m:wh")) != EOF) {
+ switch (optchar) {
+ case 'm':
+ cmdline_msg = optarg;
+ break;
+
+ case 'w':
+ watch_location = 1;
+ break;
+
+ case 'h':
+ usage(argv[0]);
+ return 0;
+
+ case '?':
+ fprintf(stderr,
+ "Unrecognized option '-%c'.\n"
+ "Try '%s -h' for more information.\n",
+ optopt, argv[0]);
+ return 1;
+ }
+ }
+
+ if (argc > optind)
+ (void) strcpy(awayfile,argv[optind]);
else {
envptr = getenv("HOME");
if (envptr)
@@ -108,7 +147,30 @@ int main(argc,argv)
continue;
}
- if (fp) {
+ 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 = malloc(strlen(cmdline_msg));
+ if (!ptr) {
+ com_err(argv[0],ENOMEM,"while getting cmdline message");
+ exit(1);
+ }
+ (void) strcpy(ptr,cmdline_msg);
+ }
+ else if (fp) {
if (!(ptr = find_message(&notice,fp))) {
ZFreeNotice(&notice);
continue;