Esempio n. 1
0
int
pop3d_uidl (char *arg, struct pop3d_session *sess)
{
  size_t mesgno;
  char uidl[128];
  mu_message_t msg;
  mu_attribute_t attr;

  if (state != TRANSACTION)
    return ERR_WRONG_STATE;

  if (strchr (arg, ' ') != NULL)
    return ERR_BAD_ARGS;

  if (strlen (arg) == 0)
    {
      size_t total = 0;
      pop3d_outf ("+OK\n");
      mu_mailbox_messages_count (mbox, &total);
      for (mesgno = 1; mesgno <= total; mesgno++)
        {
          mu_mailbox_get_message (mbox, mesgno, &msg);
          mu_message_get_attribute (msg, &attr);
          if (!pop3d_is_deleted (attr))
            {
              mu_message_get_uidl (msg, uidl, sizeof (uidl), NULL);
              pop3d_outf ("%s %s\n", mu_umaxtostr (0, mesgno), uidl);
            }
        }
      pop3d_outf (".\n");
    }
  else
    {
      mesgno = strtoul (arg, NULL, 10);
      if (mu_mailbox_get_message (mbox, mesgno, &msg) != 0)
        return ERR_NO_MESG;
      mu_message_get_attribute (msg, &attr);
      if (pop3d_is_deleted (attr))
        return ERR_MESG_DELE;
      mu_message_get_uidl (msg, uidl, sizeof (uidl), NULL);
      pop3d_outf ("+OK %s %s\n", mu_umaxtostr (0, mesgno), uidl);
    }

  return OK;
}
Esempio n. 2
0
int
pop3d_stat (char *arg)
{
  size_t mesgno;
  size_t size = 0;
  size_t lines = 0;
  size_t total = 0;
  size_t num = 0;
  size_t tsize = 0;
  mu_message_t msg = NULL;
  mu_attribute_t attr = NULL;

  if (strlen (arg) != 0)
    return ERR_BAD_ARGS;

  if (state != TRANSACTION)
    return ERR_WRONG_STATE;

  /* rfc1939: if the POP3 server host internally represents end-of-line as a
     single character, then the POP3 server simply counts each occurrence of
     this character in a message as two octets. */
  mu_mailbox_messages_count (mbox, &total);
  for (mesgno = 1; mesgno <= total; mesgno++)
    {
      mu_mailbox_get_message (mbox, mesgno, &msg);
      mu_message_get_attribute (msg, &attr);
      /* rfc1939: Note that messages marked as deleted are not counted in
	 either total.  */
      if (!pop3d_is_deleted (attr))
	{
	  mu_message_size (msg, &size);
	  mu_message_lines (msg, &lines);
	  tsize += size + lines;
	  num++;
	}
    }
  pop3d_outf ("+OK %s %s\r\n", mu_umaxtostr (0, num), mu_umaxtostr (1, tsize));

  return OK;
}