fetchmail-friends
[Top] [All Lists]

[fetchmail]Lotus Notes R5 IMAP server

2001-10-31 17:56:44
Hi all,

I noticed some funny behavior with the IMAP server that comes with Lotus
Notes R5. Aside from the fact that it's a hunk of junk and doesn't play
very nicely with Pine, I couldn't select a mailbox like so:

fetchmail -v -r "Deutsche\Firstname Surname"

I ended up finding out that the way to do this would be something like:

fetchmail: A0003 SELECT {27}
server: +go ahead
fetchmail: Deutsche\Firstname Surname
server: * 80 EXISTS ... etc.

Since I couldn't see any code in fetchmail 5.9.4 to handle this case, I
made a quick patch and introduced a configuration keyword 'specialselect'
which turns this behavior on.

Now this is the first time I've ever looked at fetchmail or the IMAP
protocol in detail, so if anyone has feedback about this I'd welcome it.
Is it an appropriate to make a change like this? Is the patch well formed?
Is the keyword addition appropriate? etc.

Regards, Luke.

Patch follows:

*** fetchmail-5.9.4/fetchmail.c Tue Oct  2 17:56:09 2001
--- patched/fetchmail.c Thu Nov  1 11:22:09 2001
***************
*** 819,824 ****
--- 819,825 ----
      FLAG_MERGE(keep);
      FLAG_MERGE(flush);
      FLAG_MERGE(fetchall);
+       FLAG_MERGE(specialselect);
      FLAG_MERGE(rewrite);
      FLAG_MERGE(forcecr);
      FLAG_MERGE(stripcr);
***************
*** 1019,1024 ****
--- 1020,1026 ----
                                        flag = (dflt)
            DEFAULT(ctl->keep, FALSE);
            DEFAULT(ctl->fetchall, FALSE);
+               DEFAULT(ctl->specialselect, FALSE);
            DEFAULT(ctl->flush, FALSE);
            DEFAULT(ctl->rewrite, TRUE);
            DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
*** fetchmail-5.9.4/fetchmail.h Wed Oct  3 19:33:57 2001
--- patched/fetchmail.h Thu Nov  1 11:22:05 2001
***************
*** 270,275 ****
--- 270,276 ----
      /* per-user control flags */
      flag keep;                        /* if TRUE, leave messages undeleted */
      flag fetchall;            /* if TRUE, fetch all (not just unseen) */
+     flag specialselect; /* if TRUE, use alternate SELECT syntax */
      flag flush;                       /* if TRUE, delete messages already 
seen */
      flag rewrite;             /* if TRUE, canonicalize recipient addresses */
      flag stripcr;             /* if TRUE, strip CRs in text */
*** fetchmail-5.9.4/imap.c      Tue Oct  2 17:55:58 2001
--- patched/imap.c      Thu Nov  1 11:21:55 2001
***************
*** 34,40 ****
  static flag do_idle;
  static char capabilities[MSGBUFSIZE+1];
  static unsigned int *unseen_messages;
!
  static int imap_ok(int sock, char *argbuf)
  /* parse command response */
  {
--- 34,40 ----
  static flag do_idle;
  static char capabilities[MSGBUFSIZE+1];
  static unsigned int *unseen_messages;
! extern int suppress_tags;
  static int imap_ok(int sock, char *argbuf)
  /* parse command response */
  {
***************
*** 47,52 ****
--- 47,57 ----
        if ((ok = gen_recv(sock, buf, sizeof(buf))))
            return(ok);

+       /* jump out, for a specialselect response like */
+       /* +go ahead */
+       if (buf[0] == '+')
+         return(0);
+
        /* all tokens in responses are caseblind */
        for (cp = buf; *cp; cp++)
            if (islower(*cp))
***************
*** 505,520 ****
      }
      else
      {
!       ok = gen_transact(sock,
!                         check_only ? "EXAMINE \"%s\"" : "SELECT \"%s\"",
!                         folder ? folder : "INBOX");
!       if (ok != 0)
!       {
!           report(stderr, GT_("mailbox selection failed\n"));
!           return(ok);
!       }
!       else if (outlevel >= O_DEBUG)
!           report(stdout, GT_("%d messages waiting after first poll\n"), 
count);

        /* no messages?  then we may need to idle until we get some */
        if (count == 0 && do_idle)
--- 510,548 ----
      }
      else
      {
!         /* special folder selection */
!         if (ctl->specialselect && folder)
!               {
!                 ok = gen_transact(sock, "SELECT {%d}", strlen(folder));
!                 if (ok != 0)
!                       {
!                         report(stderr, GT_("mailbox selection failed\n"));
!                         return(ok);
!                       }
!
!                 suppress_tags = 1;
!                 ok = gen_transact(sock, "%s", folder);
!                 if (ok != 0)
!                       {
!                         report(stderr, GT_("mailbox selection failed\n"));
!                         return(ok);
!                       }
!
!                 suppress_tags = 0;
!               }
!         else
!               {
!                 ok = gen_transact(sock,
!                                                       check_only ? "EXAMINE 
\"%s\"" : "SELECT \"%s\"",
!                                                       folder ? folder : 
"INBOX");
!                 if (ok != 0)
!                       {
!                         report(stderr, GT_("mailbox selection failed\n"));
!                         return(ok);
!                       }
!               }
!         if (outlevel >= O_DEBUG)
!               report(stdout, GT_("%d messages waiting after first poll\n"), 
count);

        /* no messages?  then we may need to idle until we get some */
        if (count == 0 && do_idle)
*** fetchmail-5.9.4/rcfile_l.l  Mon Jun 25 03:51:53 2001
--- patched/rcfile_l.l  Thu Nov  1 11:21:45 2001
***************
*** 136,141 ****
--- 136,142 ----
  nokeep                |
  noflush               |
  nofetchall    |
+ nospecialselect |
  norewrite     |
  noforcecr     |
  nostripcr     |
***************
*** 154,159 ****
--- 155,161 ----
  keep          { return KEEP; }
  flush         { return FLUSH; }
  fetchall      { return FETCHALL; }
+ specialselect { return SPECIALSELECT; }
  rewrite               { return REWRITE; }
  forcecr               { return FORCECR; }
  stripcr               { return STRIPCR; }
*** fetchmail-5.9.4/rcfile_y.y  Tue Sep 25 03:49:59 2001
--- patched/rcfile_y.y  Thu Nov  1 11:21:42 2001
***************
*** 70,76 ****
  %token <proto> PROTO AUTHTYPE
  %token <sval>  STRING
  %token <number> NUMBER
! %token NO KEEP FLUSH FETCHALL REWRITE FORCECR STRIPCR PASS8BITS
  %token DROPSTATUS DROPDELIVERED
  %token DNS SERVICE PORT UIDL INTERVAL MIMEDECODE IDLE CHECKALIAS
  %token SSL SSLKEY SSLCERT SSLPROTO SSLCERTCK SSLCERTPATH SSLFINGERPRINT
--- 70,76 ----
  %token <proto> PROTO AUTHTYPE
  %token <sval>  STRING
  %token <number> NUMBER
! %token NO KEEP FLUSH FETCHALL SPECIALSELECT REWRITE FORCECR STRIPCR PASS8BITS
  %token DROPSTATUS DROPDELIVERED
  %token DNS SERVICE PORT UIDL INTERVAL MIMEDECODE IDLE CHECKALIAS
  %token SSL SSLKEY SSLCERT SSLPROTO SSLCERTCK SSLCERTPATH SSLFINGERPRINT
***************
*** 329,334 ****
--- 329,335 ----
                | KEEP                  {current.keep        = FLAG_TRUE;}
                | FLUSH                 {current.flush       = FLAG_TRUE;}
                | FETCHALL              {current.fetchall    = FLAG_TRUE;}
+         | SPECIALSELECT {current.specialselect = FLAG_TRUE;}
                | REWRITE               {current.rewrite     = FLAG_TRUE;}
                | FORCECR               {current.forcecr     = FLAG_TRUE;}
                | STRIPCR               {current.stripcr     = FLAG_TRUE;}
***************
*** 349,354 ****
--- 350,356 ----
                | NO KEEP               {current.keep        = FLAG_FALSE;}
                | NO FLUSH              {current.flush       = FLAG_FALSE;}
                | NO FETCHALL           {current.fetchall    = FLAG_FALSE;}
+         | NO SPECIALSELECT {current.specialselect = FLAG_FALSE;}
                | NO REWRITE            {current.rewrite     = FLAG_FALSE;}
                | NO FORCECR            {current.forcecr     = FLAG_FALSE;}
                | NO STRIPCR            {current.stripcr     = FLAG_FALSE;}

-- 
Luke Burton

| <- You must be smarter than this stick to ride the Internet







<Prev in Thread] Current Thread [Next in Thread>
  • [fetchmail]Lotus Notes R5 IMAP server, Luke Burton <=