Removed all POP support
[mmh] / uip / msgchk.c
index 9b56649..7ee5df5 100644 (file)
 #include <h/tws.h>
 #include <pwd.h>
 
-#ifdef POP
-# include <h/popsbr.h>
-#endif
-
-#ifndef        POP
-# define POPminc(a) (a)
-#else
-# define POPminc(a)  0
-#endif
-
-#ifndef CYRUS_SASL
-# define SASLminc(a) (a)
-#else
-# define SASLminc(a)  0
-#endif
-
 static struct swit switches[] = {
 #define        DATESW                   0
     { "date", 0 },
@@ -37,25 +21,10 @@ static struct swit switches[] = {
     { "notify type", 0 },
 #define        NNOTESW                  3
     { "nonotify type", 0 },
-#define        HOSTSW                   4
-    { "host hostname", POPminc (-4) },
-#define        USERSW                   5
-    { "user username", POPminc (-4) },
-#define PORTSW                  6
-    { "port name/number", POPminc(-4) },
 #define VERSIONSW                7
     { "version", 0 },
 #define        HELPSW                   8
     { "help", 0 },
-#define SNOOPSW                  9
-    { "snoop", -5 },
-#define SASLSW                  10
-    { "sasl", SASLminc(-4) },
-#define SASLMECHSW             11
-    { "saslmech", SASLminc(-5) },
-#define PROXYSW                12
-    { "proxy command", POPminc(-5) },
-    { NULL, 0 }
 };
 
 /*
@@ -84,29 +53,19 @@ static struct swit switches[] = {
 static int donote (char *, int);
 static int checkmail (char *, char *, int, int, int);
 
-#ifdef POP
-static int remotemail (char *, char *, char *, char *, int, int, int, int,
-                      char *);
-#endif
-
 
 int
 main (int argc, char **argv)
 {
     int datesw = 1, notifysw = NT_ALL;
-    int status = 0, sasl = 0;
-    int snoop = 0, vecp = 0;
+    int status = 0;
+    int vecp = 0;
     uid_t uid;
-    char *cp, *host = NULL, *port = NULL, *user, *proxy = NULL; 
-    char buf[BUFSIZ], *saslmech = NULL; 
+    char buf[BUFSIZ]; 
+    char *user, *cp;
     char **argp, **arguments, *vec[MAXVEC];
     struct passwd *pw;
 
-#ifdef HESIOD
-    struct hes_postoffice *po;
-    char *tmphost;
-#endif
-
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 #endif
@@ -122,11 +81,6 @@ main (int argc, char **argv)
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
-#ifdef POP
-    if ((cp = getenv ("MHPOPDEBUG")) && *cp)
-       snoop++;
-#endif
-
     while ((cp = *argp++)) {
        if (*cp == '-') {
            switch (smatch (++cp, switches)) {
@@ -162,43 +116,6 @@ main (int argc, char **argv)
                        adios (NULL, "missing argument to %s", argp[-2]);
                    notifysw &= ~donote (cp, 0);
                    continue;
-
-               case HOSTSW: 
-                   if (!(host = *argp++) || *host == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
-
-               case PORTSW:
-                   if (!(port = *argp++) || *port == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-               continue;
-
-               case USERSW: 
-                   if (!(cp = *argp++) || *cp == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   if (vecp >= MAXVEC-1)
-                       adios (NULL, "you can only check %d users at a time", MAXVEC-1);
-                   else
-                       vec[vecp++] = cp;
-                   continue;
-
-               case SNOOPSW:
-                   snoop++;
-                   continue;
-
-               case SASLSW:
-                   sasl++;
-                   continue;
-               
-               case SASLMECHSW:
-                   if (!(saslmech = *argp++) || *saslmech == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
-
-               case PROXYSW:
-                   if (!(proxy = *argp++) || *proxy == '-')
-                       adios (NULL, "missing argument to %s", argp[-2]);
-                   continue;
            }
        }
        if (vecp >= MAXVEC-1)
@@ -207,38 +124,9 @@ main (int argc, char **argv)
            vec[vecp++] = cp;
     }
 
-#ifdef POP
-    /*
-     * If -host is not specified by user
-     */
-    if (!host || !*host) {
-       /*
-        * If "pophost" is specified in mts.conf,
-        * use it as default value.
-        */
-       if (pophost && *pophost)
-           host = pophost;
-    }
-    if (!host || !*host)
-       host = NULL;
-#endif /* POP */
-
     if (vecp != 0)
        vec[vecp] = NULL;
 
-#ifdef POP
-    if (host) {
-       if (vecp == 0) {
-           status = remotemail (host, port, user, proxy, notifysw, 1,
-                                snoop, sasl, saslmech);
-       } else {
-           for (vecp = 0; vec[vecp]; vecp++)
-               status += remotemail (host, port, vec[vecp], proxy, notifysw, 0,
-                                     snoop, sasl, saslmech);
-       }
-    } else {
-#endif /* POP */
-
     if (vecp == 0) {
        char *home;
 
@@ -258,9 +146,6 @@ main (int argc, char **argv)
                advise (NULL, "no such user as %s", vec[vecp]);
        }
     }
-#ifdef POP
-    }          /* host == NULL */
-#endif
 
     done (status);
     return 1;
@@ -349,54 +234,3 @@ checkmail (char *user, char *home, int datesw, int notifysw, int personal)
 
     return status;
 }
-
-
-#ifdef POP
-extern char response[];
-
-static int
-remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
-           int personal, int snoop, int sasl, char *saslmech)
-{
-    int nmsgs, nbytes, status;
-    char *pass = NULL;
-
-    if (user == NULL)
-       user = getusername ();
-    if (sasl)
-       pass = getusername ();
-    else
-       ruserpass (host, &user, &pass);
-
-    /* open the POP connection */
-    if (pop_init (host, port, user, pass, proxy, snoop, sasl, saslmech) == NOTOK
-           || pop_stat (&nmsgs, &nbytes) == NOTOK      /* check for messages  */
-           || pop_quit () == NOTOK) {                  /* quit POP connection */
-       advise (NULL, "%s", response);
-       return 1;
-    }
-
-    if (nmsgs) {
-       if (notifysw & NT_MAIL) {
-           printf (personal ? "You have " : "%s has ", user);
-           printf ("%d message%s (%d bytes)",
-                   nmsgs, nmsgs != 1 ? "s" : "", nbytes);
-       }
-       else
-           notifysw = 0;
-
-       status = 0;
-    } else {
-       if (notifysw & NT_NMAI)
-           printf (personal ? "You don't %s%s" : "%s doesn't %s",
-                   personal ? "" : user, "have any mail waiting");
-       else
-           notifysw = 0;
-       status = 1;
-    }
-    if (notifysw)
-       printf (" on %s\n", host);
-
-    return status;
-}
-#endif /* POP */