conn = mutt_socket_select_connection (host, port, 0); idata = CONN_DATA;  if (!idata || (idata->state == IMAP_DISCONNECTED)) {  if (option (OPTIMAPPASSIVE)) return (-1); if (!idata) {  idata = safe_calloc (1, sizeof (IMAP_DATA)); conn->data = idata; idata->conn = conn; } if (imap_open_connection (idata, conn)) return (-1); }  imap_fix_path (idata, pc, buf, sizeof (buf));  if (strlen (buf) < strlen (pc)) strcpy (pc, buf);  imap_make_sequence (seq, sizeof (seq)); imap_quote_string (mbox, sizeof(mbox), buf); strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted));    if (mutt_strcmp (mbox_unquoted, idata->selected_mailbox) == 0 || (mutt_strcasecmp (mbox_unquoted, "INBOX") == 0 && mutt_strcasecmp (mbox_unquoted, idata->selected_mailbox) == 0)) { snprintf (buf, sizeof (buf), "%s NOOP\r\n", seq); } else if (mutt_bit_isset(idata->capabilities,IMAP4REV1) || mutt_bit_isset(idata->capabilities,STATUS)) { snprintf (buf, sizeof (buf), "%s STATUS %s (RECENT)\r\n", seq, mbox); } else {  return (-1); }  mutt_socket_write (conn, buf);  do { if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0) { return (-1); }  if (buf[0] == '*') { s = imap_next_word (buf); if (mutt_strncasecmp ("STATUS", s, 6) == 0) { s = imap_next_word (s); if (mutt_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0) { s = imap_next_word (s); s = imap_next_word (s); if (isdigit (*s)) { if (*s != '0') { dprint (1, (debugfile, "New mail in %s\n", path)); recent = TRUE; } } } } else { if (conn->data && imap_handle_untagged (idata, buf) != 0) return (-1); } } } while ((mutt_strncmp (buf, seq, SEQLEN) != 0));  conn->uses--;  return recent;
return (retcode > 0) ? TRUE : retcode;
int imap_buffy_check (char *path){  CONNECTION *conn;  IMAP_DATA *idata;  char host[SHORT_STRING];  char buf[LONG_STRING];  char mbox[LONG_STRING];  char mbox_unquoted[LONG_STRING];  char seq[8];  char *s;  char *pc;  char recent = FALSE;  int port;  if (imap_parse_path (path, host, sizeof (host), &port, &pc))    return -1;  conn = mutt_socket_select_connection (host, port, 0);  idata = CONN_DATA;  if (!idata || (idata->state == IMAP_DISCONNECTED))  {    /* If passive is selected, then we don't open connections to check     * for new mail */    if (option (OPTIMAPPASSIVE))      return (-1);    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);  }  imap_fix_path (idata, pc, buf, sizeof (buf));  /* Update the path, if it fits */  if (strlen (buf) < strlen (pc))      strcpy (pc, buf);  imap_make_sequence (seq, sizeof (seq));		  imap_quote_string (mbox, sizeof(mbox), buf);  strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted));  /* The draft IMAP implementor's guide warns againts using the STATUS   * command on a mailbox that you have selected    */  if (mutt_strcmp (mbox_unquoted, idata->selected_mailbox) == 0      || (mutt_strcasecmp (mbox_unquoted, "INBOX") == 0	  && mutt_strcasecmp (mbox_unquoted, idata->selected_mailbox) == 0))  {    snprintf (buf, sizeof (buf), "%s NOOP\r\n", seq);  }  else if (mutt_bit_isset(idata->capabilities,IMAP4REV1) ||	   mutt_bit_isset(idata->capabilities,STATUS))  {				    snprintf (buf, sizeof (buf), "%s STATUS %s (RECENT)\r\n", seq, mbox);  }  else  {    /* Server does not support STATUS, and this is not the current mailbox.     * There is no lightweight way to check recent arrivals */      return (-1);  }  mutt_socket_write (conn, buf);  do   {    if (mutt_socket_read_line_d (buf, sizeof (buf), conn) < 0)    {      return (-1);    }    if (buf[0] == '*')     {      s = imap_next_word (buf);      if (mutt_strncasecmp ("STATUS", s, 6) == 0)      {	s = imap_next_word (s);	if (mutt_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0)	{	  s = imap_next_word (s);	  s = imap_next_word (s);	  if (isdigit (*s))	  {	    if (*s != '0')	    {	      dprint (1, (debugfile, "New mail in %s\n", path));	      recent = TRUE;	    }	  }	}      }      else      {	if (conn->data && 	    imap_handle_untagged (idata, buf) != 0)	  return (-1);      }    }  }  while ((mutt_strncmp (buf, seq, SEQLEN) != 0));  conn->uses--;  return recent;}