#include <h/mh.h>
#include <zotnet/mts/mts.h>
-#include <zotnet/tws/tws.h>
+#include <h/tws.h>
#include <pwd.h>
#ifdef POP
# define APOPminc(a) 0
#endif
+#ifndef KPOP
+# define KPOPminc(a) (a)
+#else
+# define KPOPminc(a) 0
+#endif
+
static struct swit switches[] = {
#define DATESW 0
{ "date", 0 },
#define VERSIONSW 10
{ "version", 0 },
#define HELPSW 11
- { "help", 4 },
+ { "help", 0 },
#define SNOOPSW 12
{ "snoop", -5 },
+#define KPOPSW 13
+ { "kpop", KPOPminc (-4) },
{ NULL, 0 }
};
static int checkmail (char *, char *, int, int, int);
#ifdef POP
-static int remotemail (char *, char *, int, int, int, int);
+static int remotemail (char *, char *, int, int, int, int, int);
#endif
{
int datesw = 1, notifysw = NT_ALL;
int rpop, status = 0;
+ int kpop = 0;
int snoop = 0, vecp = 0;
uid_t uid;
char *cp, *host = NULL, *user, buf[BUFSIZ];
snoop++;
#endif
-#ifdef KPOP
- rpop = 1;
-#else
rpop = 0;
-#endif
while ((cp = *argp++)) {
if (*cp == '-') {
rpop = 0;
continue;
+ case KPOPSW:
+ kpop = 1;
+ continue;
+
case SNOOPSW:
snoop++;
continue;
#ifdef POP
if (host) {
+ if ( strcmp( POPSERVICE, "kpop" ) == 0 ) {
+ kpop = 1;
+ }
if (vecp == 0) {
- status = remotemail (host, user, rpop, notifysw, 1, snoop);
+ status = remotemail (host, user, rpop, kpop, notifysw, 1, snoop);
} else {
for (vecp = 0; vec[vecp]; vecp++)
- status += remotemail (host, vec[vecp], rpop, notifysw, 0, snoop);
+ status += remotemail (host, vec[vecp], rpop, kpop, notifysw, 0, snoop);
}
} else {
#endif /* POP */
} /* host == NULL */
#endif
- done (status);
+ return done (status);
}
case NNMAISW:
return NT_NMAI;
}
+
+ return 0; /* Before 1999-07-15, garbage was returned if control got here. */
}
extern char response[];
static int
-remotemail (char *host, char *user, int rpop, int notifysw, int personal, int snoop)
+remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, int snoop)
{
int nmsgs, nbytes, status;
char *pass = NULL;
if (user == NULL)
user = getusername ();
- if (rpop > 0)
+ if (kpop || (rpop > 0))
pass = getusername ();
else
ruserpass (host, &user, &pass);
/* open the POP connection */
- if (pop_init (host, user, pass, snoop, rpop) == NOTOK
+ if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK
|| pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */
|| pop_quit () == NOTOK) { /* quit POP connection */
advise (NULL, "%s", response);