summaryrefslogtreecommitdiff
path: root/clients/zmailnotify
diff options
context:
space:
mode:
Diffstat (limited to 'clients/zmailnotify')
-rw-r--r--clients/zmailnotify/Imakefile19
-rw-r--r--clients/zmailnotify/Makefile.in47
-rw-r--r--clients/zmailnotify/zmailnotify.c66
3 files changed, 76 insertions, 56 deletions
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;