conn = mutt_socket_find (&mx, 0); idata = CONN_DATA;
conn = mutt_socket_find (&(mx.account), 0); idata = (IMAP_DATA*) conn->data;
int imap_open_mailbox_append (CONTEXT *ctx){  CONNECTION *conn;  IMAP_DATA *idata;  char buf[LONG_STRING], mbox[LONG_STRING];  char mailbox[LONG_STRING];  int r;  IMAP_MBOX mx;  if (imap_parse_path (ctx->path, &mx))    return (-1);  ctx->magic = M_IMAP;  conn = mutt_socket_find (&mx, 0);  idata = CONN_DATA;  if (!idata || (idata->state == IMAP_DISCONNECTED))  {    if (!idata)    {      /* The current connection is a new connection */      idata = safe_calloc (1, sizeof (IMAP_DATA));      conn->data = idata;      idata->conn = conn;    }    if (imap_open_connection (idata, conn))      return (-1);  }  ctx->data = (void *) idata;  /* check mailbox existance */  imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox));  imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);				  if (mutt_bit_isset(idata->capabilities,IMAP4REV1))  {    snprintf (buf, sizeof (buf), "STATUS %s (UIDVALIDITY)", mbox);  }  else if (mutt_bit_isset(idata->capabilities,STATUS))  {     /* We have no idea what the other guy wants. UW imapd 8.3 wants this     * (but it does not work if another mailbox is selected) */    snprintf (buf, sizeof (buf), "STATUS %s (UID-VALIDITY)", mbox);  }  else  {    /* STATUS not supported */    mutt_message _("Unable to append to IMAP mailboxes at this server");    return -1;  }  r = imap_exec (buf, sizeof (buf), idata, buf, IMAP_CMD_FAIL_OK);  if (r == -2)  {    /* command failed cause folder doesn't exist */    snprintf (buf, sizeof (buf), _("Create %s?"), mailbox);    if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) < 1)      return -1;    if (imap_create_mailbox (ctx, mailbox) < 0)      return -1;  }  else if (r == -1)    /* Hmm, some other failure */    return -1;  return 0;}