/[mailutils]/mailutils/mail/mail.c
ViewVC logotype

Diff of /mailutils/mail/mail.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by gray, Mon Nov 12 13:15:10 2001 UTC revision 1.51 by gray, Thu Feb 7 07:58:22 2002 UTC
# Line 171  main (int argc, char **argv) Line 171  main (int argc, char **argv)
171    struct mail_env_entry *mode = NULL, *prompt = NULL;    struct mail_env_entry *mode = NULL, *prompt = NULL;
172    size_t modelen = 0;    size_t modelen = 0;
173    struct arguments args;    struct arguments args;
174      int rc;
175      
176    ofile = stdout;    ofile = stdout;
177    cursor = 1;    cursor = 1;
178    realcursor = cursor;    realcursor = cursor;
# Line 353  main (int argc, char **argv) Line 354  main (int argc, char **argv)
354            mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);            mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);
355          }          }
356    
357        if (mailbox_open (mbox, MU_STREAM_RDWR) != 0)        if ((rc = mailbox_open (mbox, MU_STREAM_RDWR)) != 0 && rc != ENOENT)
358          {          {
359            util_error ("Can not open mailbox");            url_t url = NULL;
360              mailbox_get_url (mbox, &url);
361              util_error ("Can not open mailbox %s: %s",
362                          url_to_string (url), strerror (rc));
363            exit (EXIT_FAILURE);            exit (EXIT_FAILURE);
364          }          }
365    
366        if (mailbox_scan (mbox, 1, &total) != 0)        if (rc)
367            total = 0;
368          else
369          {          {
370            util_error ("Can not read mailbox");            if (mailbox_scan (mbox, 1, &total) != 0)
371            exit (EXIT_FAILURE);              {
372          }                util_error ("Can not read mailbox");
373                  exit (EXIT_FAILURE);
374        if (strlen ("exist") == modelen && !strcmp ("exist", mode->value))              }
         return (total < 1) ? 1 : 0;  
       else if (strlen ("print") == modelen && !strcmp ("print", mode->value))  
         return util_do_command ("print *");  
       else if (strlen ("headers") == modelen  
                && !strcmp ("headers", mode->value))  
         return util_do_command ("from *");  
375    
376              if (strlen ("exist") == modelen && !strcmp ("exist", mode->value))
377                return (total < 1) ? 1 : 0;
378              else if (strlen ("print") == modelen
379                       && !strcmp ("print", mode->value))
380                return util_do_command ("print *");
381              else if (strlen ("headers") == modelen
382                       && !strcmp ("headers", mode->value))
383                return util_do_command ("from *");
384            }
385          
386        if (total == 0)        if (total == 0)
387          {          {
388            fprintf (ofile, "No mail for %s\n", mail_whoami());            if (args.file)
389                fprintf (ofile, "%s: 0 messages\n", args.file);
390              else
391                fprintf (ofile, "No mail for %s\n",
392                         args.user ? args.user : mail_whoami ());
393            return 1;            return 1;
394          }          }
395    

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26