mutt_message ("Sending APPEND command ...");
mutt_message _("Sending APPEND command ...");
int imap_append_message (CONTEXT *ctx, MESSAGE *msg){  FILE *fp;  char seq[8];  char buf[LONG_STRING];  size_t len;  int c, last;    if ((fp = fopen (msg->path, "r")) == NULL)  {    mutt_perror (msg->path);    return (-1);  }  for(last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)  {    if(c == '\n' && last != '\r')      len++;    len++;  }  rewind(fp);    mutt_message ("Sending APPEND command ...");  imap_make_sequence (seq, sizeof (seq));  snprintf (buf, sizeof (buf), "%s APPEND %s {%d}\r\n", seq,       CTX_DATA->mailbox, len);  mutt_socket_write (CTX_DATA->conn, buf);  do   {    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)    {      fclose (fp);      return (-1);    }    if (buf[0] == '*' && imap_handle_untagged (ctx, buf) != 0)    {      return (-1);      fclose (fp);    }  }  while ((strncmp (buf, seq, SEQLEN) != 0) && (buf[0] != '+'));  if (buf[0] != '+')  {    char *pc;    dprint (1, (debugfile, "imap_append_message(): command failed: %s\n", buf));    pc = buf + SEQLEN;    SKIPWS (pc);    pc = imap_next_word (pc);    mutt_error (pc);    sleep (1);    fclose (fp);    return (-1);  }  mutt_message ("Uploading message ...");  for(last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)  {    if(c == '\n' && last != '\r')      buf[len++] = '\r';    buf[len++] = c;    if(len > sizeof(buf) - 3)      flush_buffer(buf, &len, CTX_DATA->conn);  }    if(len)    flush_buffer(buf, &len, CTX_DATA->conn);      mutt_socket_write (CTX_DATA->conn, "\r\n");  fclose (fp);  do  {    if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0)      return (-1);    if (buf[0] == '*' && imap_handle_untagged (ctx, buf) != 0)      return (-1);  }  while (strncmp (buf, seq, SEQLEN) != 0);  if (!imap_code (buf))  {    char *pc;    dprint (1, (debugfile, "imap_append_message(): command failed: %s\n", buf));    pc = buf + SEQLEN;    SKIPWS (pc);    pc = imap_next_word (pc);    mutt_error (pc);    sleep (1);    return (-1);  }  return 0;}