/[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.59 by gray, Tue Jul 2 14:50:31 2002 UTC revision 1.60 by gray, Wed Aug 7 15:31:17 2002 UTC
# Line 177  static const char *mail_capa[] = { Line 177  static const char *mail_capa[] = {
177  static char *  static char *
178  mail_cmdline(void *closure, int cont)  mail_cmdline(void *closure, int cont)
179  {  {
180    struct mail_env_entry *pev = closure;    char *prompt = (char*) (closure ? closure : NULL);
   char *prompt = NULL;  
181    char *rc;    char *rc;
182    
183    (void)cont;    (void)cont;
184    
185    while (1)    while (1)
186      {      {
187        if (util_find_env ("autoinc")->set && !mailbox_is_updated (mbox))        if (util_getenv (NULL, "autoinc", Mail_env_boolean, 0) == 0
188              && !mailbox_is_updated (mbox))
189          {          {
190            mailbox_messages_count (mbox, &total);            mailbox_messages_count (mbox, &total);
191            fprintf (ofile, "New mail has arrived\n");            fprintf (ofile, "New mail has arrived\n");
192          }          }
193    
       if (interactive)  
         prompt = pev->set && pev->value != NULL ? pev->value : (char *)"? ";  
   
194        rc = ml_readline (prompt);        rc = ml_readline (prompt);
195    
196        if (ml_got_interrupt())        if (ml_got_interrupt())
# Line 202  mail_cmdline(void *closure, int cont) Line 199  mail_cmdline(void *closure, int cont)
199            continue;            continue;
200          }          }
201    
202        if (!rc && util_find_env ("ignoreeof")->set)        if (!rc && util_getenv (NULL, "ignoreeof", Mail_env_boolean, 0) == 0)
203          {          {
204            util_error ("Use \"quit\" to quit.");            util_error ("Use \"quit\" to quit.");
205            continue;            continue;
# Line 216  mail_cmdline(void *closure, int cont) Line 213  mail_cmdline(void *closure, int cont)
213  int  int
214  main (int argc, char **argv)  main (int argc, char **argv)
215  {  {
216    struct mail_env_entry *mode = NULL, *prompt = NULL;    char *mode = NULL, *prompt = NULL;
217    size_t modelen = 0;    size_t modelen = 0;
218    struct arguments args;    struct arguments args;
219    int rc;    int rc;
# Line 308  main (int argc, char **argv) Line 305  main (int argc, char **argv)
305    util_do_command ("set noSign");    util_do_command ("set noSign");
306    util_do_command ("set toplines=5");    util_do_command ("set toplines=5");
307    util_do_command ("set autoinc");    util_do_command ("set autoinc");
308      util_do_command ("set regex");
309      
310    /* Set the default mailer to sendmail.  */    /* Set the default mailer to sendmail.  */
311    {    {
312      char *mailer_name = alloca (strlen ("sendmail:")      char *mailer_name = alloca (strlen ("sendmail:")
313                                  + strlen (_PATH_SENDMAIL) + 1);                                  + strlen (_PATH_SENDMAIL) + 1);
314      sprintf (mailer_name, "sendmail:%s", _PATH_SENDMAIL);      sprintf (mailer_name, "sendmail:%s", _PATH_SENDMAIL);
315      util_setenv ("sendmail", mailer_name, 0);      util_setenv ("sendmail", mailer_name, Mail_env_string, 1);
316    }    }
317    
318    /* GNU extensions to the environment, for sparky's sanity */    /* GNU extensions to the environment, for sparky's sanity */
# Line 332  main (int argc, char **argv) Line 330  main (int argc, char **argv)
330    mu_argp_parse (&argp, &argc, &argv, 0, mail_capa, NULL, &args);    mu_argp_parse (&argp, &argc, &argv, 0, mail_capa, NULL, &args);
331    
332    /* read system-wide mail.rc and user's .mailrc */    /* read system-wide mail.rc and user's .mailrc */
333    if ((util_find_env ("rc"))->set)    if (util_getenv (NULL, "rc", Mail_env_boolean, 0) == 0)
334      util_do_command ("source %s", SITE_MAIL_RC);      util_do_command ("source %s", SITE_MAIL_RC);
335    util_do_command ("source %s", getenv ("MAILRC"));    util_do_command ("source %s", getenv ("MAILRC"));
336    if (!interactive)    if (!interactive)
# Line 345  main (int argc, char **argv) Line 343  main (int argc, char **argv)
343      }      }
344    
345    /* how should we be running? */    /* how should we be running? */
346    if ((mode = util_find_env ("mode")) == NULL || mode->set == 0)    if (util_getenv (&mode, "mode", Mail_env_string, 1))
347      exit (EXIT_FAILURE);      exit (EXIT_FAILURE);
348    modelen = strlen (mode->value);    modelen = strlen (mode);
349    
350    /* Interactive mode */    /* Interactive mode */
351    if (!(util_find_env("quiet"))->set)    if (util_getenv (NULL, "quiet", Mail_env_boolean, 0))
352      {      {
353        fprintf (ofile,        fprintf (ofile,
354                 "%s, Copyright (C) 2001 Free Software Foundation, Inc.\n"                 "%s, Copyright (C) 2001 Free Software Foundation, Inc.\n"
# Line 364  main (int argc, char **argv) Line 362  main (int argc, char **argv)
362    mail_set_my_name(args.user);    mail_set_my_name(args.user);
363    
364    /* Mode is just sending */    /* Mode is just sending */
365    if (strlen ("send") == modelen && !strcmp ("send", mode->value))    if (strlen ("send") == modelen && !strcmp ("send", mode))
366      {      {
367        /* FIXME: set cmd to "mail [add1...]" */        /* FIXME: set cmd to "mail [add1...]" */
368        char *buf = NULL;        char *buf = NULL;
# Line 435  main (int argc, char **argv) Line 433  main (int argc, char **argv)
433                exit (EXIT_FAILURE);                exit (EXIT_FAILURE);
434              }              }
435    
436            if (strlen ("exist") == modelen && !strcmp ("exist", mode->value))            if (strlen ("exist") == modelen && !strcmp ("exist", mode))
437              return (total < 1) ? 1 : 0;              return (total < 1) ? 1 : 0;
438            else if (strlen ("print") == modelen            else if (strlen ("print") == modelen
439                     && !strcmp ("print", mode->value))                     && !strcmp ("print", mode))
440              return util_do_command ("print *");              return util_do_command ("print *");
441            else if (strlen ("headers") == modelen            else if (strlen ("headers") == modelen
442                     && !strcmp ("headers", mode->value))                     && !strcmp ("headers", mode))
443              return util_do_command ("from *");              return util_do_command ("from *");
444          }          }
445                
# Line 456  main (int argc, char **argv) Line 454  main (int argc, char **argv)
454          }          }
455    
456        /* initial commands */        /* initial commands */
457        if ((util_find_env("header"))->set)        if (util_getenv(NULL, "header", Mail_env_boolean, 0) == 0)
458          {          {
459            util_do_command ("summary");            util_do_command ("summary");
460            util_do_command ("z.");            util_do_command ("z.");
461          }          }
462    
463        prompt = util_find_env ("prompt");        util_getenv (&prompt, "prompt", Mail_env_string, 0);
464        mail_mainloop(mail_cmdline, (void*) prompt, 1);        mail_mainloop (mail_cmdline, (void*) prompt, 1);
465        fprintf (ofile, "\n");        fprintf (ofile, "\n");
466        util_do_command ("quit");        util_do_command ("quit");
467        return 0;        return 0;
# Line 474  main (int argc, char **argv) Line 472  main (int argc, char **argv)
472    
473    
474  void  void
475  mail_mainloop(char *(*input) __P((void *, int)), void *closure, int do_history)  mail_mainloop (char *(*input) __P((void *, int)), void *closure, int do_history)
476  {  {
477    char *command, *cmd;    char *command, *cmd;
478    while ((command = (*input)(closure, 0)) != NULL)    while ((command = (*input)(closure, 0)) != NULL)

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.60

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