示例#1
0
int
mail_previous (int argc, char **argv)
{
  size_t n;
  mu_message_t msg;

  if (argc < 2)
    {
      int rc = 1;

      n = get_cursor ();
      if (n)
        while (--n > 0)
	  {
	    if (util_isdeleted (n))
	      continue;
	    rc = util_get_message (mbox, n, &msg);
	    if (rc == 0)
	      break;
	  }

      if (rc)
	{
	  mu_error (_("No applicable message"));
	  return 1;
	}
    }
  else
    {
      msgset_t *list = NULL;
      int rc = msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list);
      if (!rc)
	{
	  n = list->msg_part[0];
	  msgset_free (list);
	  if (util_get_message (mbox, n, &msg))
	    return 1;
	}
      else
	{
	  mu_error (_("No applicable message"));
	  return 1;
	}
    }
  set_cursor (n);
  util_do_command ("print");
  return 0;
}
示例#2
0
文件: imap4d.c 项目: ssvlab/esbmc-gpu
static int
imap4d_mainloop (int fd, FILE *infile, FILE *outfile)
{
  imap4d_tokbuf_t tokp;
  char *text;
  int debug_mode = isatty (fd);

  imap4d_child_signal_setup (imap4d_child_signal);
  util_setio (infile, outfile);

  if (imap4d_preauth_setup (fd) == 0)
    {
      if (debug_mode)
	{
	  mu_diag_output (MU_DIAG_INFO, _("started in debugging mode"));
	  text = "IMAP4rev1 Debugging mode";
	}
      else
	text = "IMAP4rev1";
    }
  else
    {
      util_flush_output ();
      return 0;
    }

  /* Greetings.  */
  util_out ((state == STATE_AUTH) ? RESP_PREAUTH : RESP_OK, "%s", text);
  util_flush_output ();

  tokp = imap4d_tokbuf_init ();
  while (1)
    {
      imap4d_readline (tokp);
      /* check for updates */
      imap4d_sync ();
      util_do_command (tokp);
      imap4d_sync ();
      util_flush_output ();
    }

  return 0;
}
示例#3
0
文件: file.c 项目: ssvlab/esbmc-gpu
int
mail_file (int argc, char **argv)
{
  if (argc == 1)
    {
      mail_summary (0, NULL);
    }
  else if (argc == 2)
    {
      /* switch folders */
      char *pname;
      mu_url_t url;
      mu_mailbox_t newbox = NULL;
      char *name = mail_expand_name (argv[1]);
      int status;

      if (!name)
	return 1;
      
      if ((status = mu_mailbox_create_default (&newbox, name)) != 0 
	  || (status = mu_mailbox_open (newbox, MU_STREAM_RDWR)) != 0)
	{
	  mu_mailbox_destroy (&newbox);
	  util_error(_("Cannot open mailbox %s: %s"), name, mu_strerror (status));
	  free (name);
	  return 1;
	}

      free (name); /* won't need it any more */
      page_invalidate (1); /* Invalidate current page map */
      
      mu_mailbox_get_url (mbox, &url);
      pname = strdup (mu_url_to_string (url));
      if (mail_mbox_close ())
	{
	  if (pname)
	    free (pname);
	  mu_mailbox_close (newbox);
	  mu_mailbox_destroy (&newbox);
	  return 1;
	}
      
      if (prev_name)
	free (prev_name);
      prev_name = pname;
      
      mbox = newbox;
      mu_mailbox_messages_count (mbox, &total);
      set_cursor (1);
      if (mailvar_get (NULL, "header", mailvar_type_boolean, 0) == 0)
	{
	  util_do_command ("summary");
	  util_do_command ("headers");
	}
      return 0;
    }
  else
    {
      util_error(_("%s takes only one argument"), argv[0]);
    }
  return 1;
}