The following patch fixes a problem with requesting a service key for a
machine that has multiple 'A' records.  It also makes "-kpop" a command
line option, for users who would like to use both "kpop" and "pop".

:wes
*** nmh-1.0.2/h/popsbr.h        Sun Aug 23 19:23:58 1998
--- nmh-1.0.2+/h/popsbr.h       Thu May  6 23:58:57 1999
***************
*** 22,28 ****
  int pop_exists (int (*)());
  #endif
  
! int pop_init (char *, char *, char *, int, int);
  int pop_fd (char *, int, char *, int);
  int pop_stat (int *, int *);
  int pop_retr (int, int (*)());
--- 22,28 ----
  int pop_exists (int (*)());
  #endif
  
! int pop_init (char *, char *, char *, int, int, int);
  int pop_fd (char *, int, char *, int);
  int pop_stat (int *, int *);
  int pop_retr (int, int (*)());
*** nmh-1.0.2/uip/inc.c Wed Aug 26 14:17:29 1998
--- nmh-1.0.2+/uip/inc.c        Fri May  7 00:02:03 1999
***************
*** 55,60 ****
--- 55,66 ----
  # define APOPminc(a)  0
  #endif
  
+ #ifndef       KPOP
+ # define KPOPminc(a) (a)
+ #else
+ # define KPOPminc(a)  0
+ #endif
+ 
  static struct swit switches[] = {
  #define       AUDSW                      0
      { "audit audit-file", 0 },
***************
*** 102,107 ****
--- 108,115 ----
      { "help", 4 },
  #define SNOOPSW                   22
      { "snoop", -5 },
+ #define KPOPSW                    23
+     { "kpop", KPOPminc (-4) },
      { NULL, 0 }
  };
  
***************
*** 157,162 ****
--- 165,171 ----
      int chgflag = 1, trnflag = 1;
      int noisy = 1, width = 0, locked = 0;
      int rpop, i, hghnum, msgnum;
+     int kpop = 0;
      char *cp, *maildir, *folder = NULL;
      char *format = NULL, *form = NULL;
      char *newmail, *host = NULL, *user = NULL;
***************
*** 218,228 ****
        snoop++;
  #endif /* POP */
  
- #ifdef KPOP
-     rpop = 1;
- #else
      rpop = 0;
- #endif
  
      while ((cp = *argp++)) {
        if (*cp == '-') {
--- 227,233 ----
***************
*** 346,351 ****
--- 351,360 ----
                rpop = 0;
                continue;
  
+           case KPOPSW:
+               kpop = 1;
+               continue;
+ 
            case SNOOPSW:
                snoop++;
                continue;
***************
*** 393,399 ****
      if (inc_type == INC_POP) {
        if (user == NULL)
            user = getusername ();
!       if (rpop > 0)
            pass = getusername ();
        else
            ruserpass (host, &user, &pass);
--- 402,408 ----
      if (inc_type == INC_POP) {
        if (user == NULL)
            user = getusername ();
!       if (kpop || ( rpop > 0))
            pass = getusername ();
        else
            ruserpass (host, &user, &pass);
***************
*** 401,407 ****
        /*
         * initialize POP connection
         */
!       if (pop_init (host, user, pass, snoop, rpop) == NOTOK)
            adios (NULL, "%s", response);
  
        /* Check if there are any messages */
--- 410,416 ----
        /*
         * initialize POP connection
         */
!       if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK)
            adios (NULL, "%s", response);
  
        /* Check if there are any messages */
*** nmh-1.0.2/uip/msgchk.c      Wed Aug 26 14:19:47 1998
--- nmh-1.0.2+/uip/msgchk.c     Fri May  7 10:31:48 1999
***************
*** 36,41 ****
--- 36,47 ----
  # 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 },
***************
*** 63,68 ****
--- 69,76 ----
      { "help", 4 },
  #define SNOOPSW                 12
      { "snoop", -5 },
+ #define KPOPSW                  13
+     { "kpop", KPOPminc (-4) },
      { NULL, 0 }
  };
  
***************
*** 93,99 ****
  static int checkmail (char *, char *, int, int, int);
  
  #ifdef POP
! static int remotemail (char *, char *, int, int, int, int);
  #endif
  
  
--- 101,107 ----
  static int checkmail (char *, char *, int, int, int);
  
  #ifdef POP
! static int remotemail (char *, char *, int, int, int, int, int);
  #endif
  
  
***************
*** 102,107 ****
--- 110,116 ----
  {
      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];
***************
*** 133,143 ****
        snoop++;
  #endif
  
- #ifdef KPOP
-     rpop = 1;
- #else
      rpop = 0;
- #endif
  
      while ((cp = *argp++)) {
        if (*cp == '-') {
--- 142,148 ----
***************
*** 202,207 ****
--- 207,216 ----
                    rpop = 0;
                    continue;
  
+               case KPOPSW:
+                   kpop = 1;
+                   continue;
+ 
                case SNOOPSW:
                    snoop++;
                    continue;
***************
*** 251,260 ****
  #ifdef POP
      if (host) {
        if (vecp == 0) {
!           status = remotemail (host, user, rpop, notifysw, 1, snoop);
        } else {
            for (vecp = 0; vec[vecp]; vecp++)
!               status += remotemail (host, vec[vecp], rpop, notifysw, 0, snoop);
        }
      } else {
  #endif /* POP */
--- 260,269 ----
  #ifdef POP
      if (host) {
        if (vecp == 0) {
!           status = remotemail (host, user, rpop, kpop, notifysw, 1, snoop);
        } else {
            for (vecp = 0; vec[vecp]; vecp++)
!               status += remotemail (host, vec[vecp], rpop, kpop, notifysw, 0, snoop);
        }
      } else {
  #endif /* POP */
***************
*** 373,379 ****
  extern char response[];
  
  static int
! remotemail (char *host, char *user, int rpop, int notifysw, int personal, int snoop)
  {
      int nmsgs, nbytes, status;
      char *pass = NULL;
--- 382,388 ----
  extern char response[];
  
  static int
! remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, 
int snoop)
  {
      int nmsgs, nbytes, status;
      char *pass = NULL;
***************
*** 380,392 ****
  
      if (user == NULL)
        user = getusername ();
!     if (rpop > 0)
        pass = getusername ();
      else
        ruserpass (host, &user, &pass);
  
      /* open the POP connection */
!     if (pop_init (host, user, pass, snoop, rpop) == NOTOK
            || pop_stat (&nmsgs, &nbytes) == NOTOK      /* check for messages  */
            || pop_quit () == NOTOK) {                  /* quit POP connection */
        advise (NULL, "%s", response);
--- 389,401 ----
  
      if (user == NULL)
        user = getusername ();
!     if (kpop || (rpop > 0))
        pass = getusername ();
      else
        ruserpass (host, &user, &pass);
  
      /* open the POP connection */
!     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);
*** nmh-1.0.2/uip/popsbr.c      Thu Aug 27 00:57:44 1998
--- nmh-1.0.2+/uip/popsbr.c     Fri May  7 00:02:03 1999
***************
*** 116,122 ****
  
  
  int
! pop_init (char *host, char *user, char *pass, int snoop, int rpop)
  {
      int fd1, fd2;
      char buffer[BUFSIZ];
--- 116,122 ----
  
  
  int
! pop_init (char *host, char *user, char *pass, int snoop, int rpop, int kpop)
  {
      int fd1, fd2;
      char buffer[BUFSIZ];
***************
*** 129,144 ****
  #endif
  
  #ifndef NNTP
! # ifndef KPOP
!     if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response, sizeof(response))) 
== NOTOK)
! # else        /* KPOP */
!     snprintf (buffer, sizeof(buffer), "%s/%s", KPOP_PRINCIPAL, POPSERVICE);
!     if ((fd1 = client (host, "tcp", buffer, rpop, response, sizeof(response))) == 
NOTOK)
! # endif
  #else /* NNTP */
      if ((fd1 = client (host, "tcp", "nntp", rpop, response, sizeof(response))) == 
NOTOK)
- #endif
        return NOTOK;
  
      if ((fd2 = dup (fd1)) == NOTOK) {
        char *s;
--- 129,151 ----
  #endif
  
  #ifndef NNTP
! # ifdef KPOP
!     if ( kpop ) {
!       snprintf (buffer, sizeof(buffer), "%s/%s", KPOP_PRINCIPAL, "kpop");
!       if ((fd1 = client (host, "tcp", buffer, 0, response, sizeof(response))) == 
NOTOK) {
!           return NOTOK;
!       }
!     } else {
! # endif /* KPOP */
!       if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response, sizeof(response))) 
== NOTOK)
!           return NOTOK;
! # ifdef KPOP
!    }
! # endif /* KPOP */
  #else /* NNTP */
      if ((fd1 = client (host, "tcp", "nntp", rpop, response, sizeof(response))) == 
NOTOK)
        return NOTOK;
+ #endif
  
      if ((fd2 = dup (fd1)) == NOTOK) {
        char *s;
*** nmh-1.0.2/zotnet/mts/client.c       Wed Aug 26 20:47:50 1998
--- nmh-1.0.2+/zotnet/mts/client.c      Fri May  7 00:02:04 1999
***************
*** 198,203 ****
--- 198,204 ----
      register struct addrent *ap;
      struct sockaddr_in in_socket;
      register struct sockaddr_in *isock = &in_socket;
+     struct hostent *hp2;
  
  #ifdef KPOP
      int rem;
***************
*** 249,255 ****
      if (kservice) {   /* "pop" */
        char *instance;
  
!       if ((instance = strdup (hp->h_name)) == NULL) {
            close (sd);
            strncpy (response, "Out of memory.", len_response);
            return OOPS2;
--- 250,260 ----
      if (kservice) {   /* "pop" */
        char *instance;
  
!       if (( hp2 = gethostbyaddr( hp->h_addr, hp->h_length, hp->h_addrtype ))
!               == NULL ) {
!           return NOTOK;
!       }
!       if ((instance = strdup (hp2->h_name)) == NULL) {
            close (sd);
            strncpy (response, "Out of memory.", len_response);
            return OOPS2;

Reply via email to