1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains code for the "zpopnotify" command.
4 * Created by: Robert French
8 * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
15 #include <zephyr/mit-copyright.h>
16 #include <zephyr/zephyr.h>
20 #include <sys/param.h> /* for MAXHOSTNAMELEN */
25 static char rcsid_zpopnotify_c[] = "$Id$";
28 #define MAIL_CLASS "MAIL"
29 #define MAIL_INSTANCE "POP"
41 char *whoami,myhost[MAXHOSTNAMELEN],mysender[BUFSIZ];
46 if ((retval = ZInitialize()) != ZERR_NONE) {
47 com_err(whoami,retval,"while initializing");
56 if (gethostname(myhost,MAXHOSTNAMELEN) == -1) {
57 com_err(whoami,errno,"Can't get hostname");
60 myhost[MAXHOSTNAMELEN-1] = '\0';
62 if (!(hent = gethostbyname(myhost))) {
63 com_err(whoami,errno,"Can't get canonical hostname");
67 (void) strncpy(myhost,hent->h_name,MAXHOSTNAMELEN);
68 myhost[MAXHOSTNAMELEN-1] = '\0';
71 lines[1] = "You have new mail.";
73 (void) strcpy(mysender,"pop@");
74 (void) strcat(mysender,ZGetRealm());
76 for (i = 1; i < argc; i++) {
77 (void) memset((char *)¬ice, 0, sizeof(notice));
78 notice.z_kind = UNSAFE;
79 notice.z_class = MAIL_CLASS;
80 notice.z_class_inst = MAIL_INSTANCE;
82 notice.z_sender = mysender;
83 notice.z_default_format = "From Post Office $1:\n$2";
85 /* in case it's a mailbox name (pathname), strip to username */
86 notice.z_recipient = (char *)strrchr(argv[i],'/');
87 if (notice.z_recipient)
90 notice.z_recipient = argv[i];
92 if ((retval = ZSendList(¬ice,lines,2,ZNOAUTH)) != ZERR_NONE) {
93 com_err(whoami,retval,"while sending notice");
103 printf("Usage: %s username [ username ... ]\n",whoami);