if (((IMAP_DATA *) ctx->data)->status == IMAP_NEW_MAIL)
if (CTX_DATA->status == IMAP_NEW_MAIL)
int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend){  char buf[LONG_STRING];  char hdrreq[STRING];  FILE *fp;  char tempfile[_POSIX_PATH_MAX];  char seq[SEQLEN+1];  int msgno;  IMAP_HEADER* h;  int rc;  int fetchlast = 0;  const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE IN-REPLY-TO REPLY-TO LINES X-LABEL";    /* define search string */  if (mutt_bit_isset (CTX_DATA->capabilities,IMAP4REV1))  {    snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s)]",       want_headers);   }   else if (mutt_bit_isset (CTX_DATA->capabilities,IMAP4))  {    snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s)",       want_headers);  }  else  {	/* Unable to fetch headers for lower versions */    mutt_error _("Unable to fetch headers from this IMAP server version.");    sleep (1);	/* pause a moment to let the user see the error */    return -1;  }  /* instead of downloading all headers and then parsing them, we parse them   * as they come in. */  mutt_mktemp (tempfile);  if (!(fp = safe_fopen (tempfile, "w+")))    return -1;  unlink (tempfile);  for (msgno = msgbegin; msgno <= msgend ; msgno++)  {    mutt_message (_("Fetching message headers... [%d/%d]"), msgno + 1,      msgend + 1);    if (msgno + 1 > fetchlast)    {      imap_make_sequence (seq, sizeof (seq));      /*       * Make one request for everything. This makes fetching headers an       * order of magnitude faster if you have a large mailbox.       *       * If we get more messages while doing this, we make another       * request for all the new messages.       */      snprintf (buf, sizeof (buf), 	"%s FETCH %d:%d (UID FLAGS INTERNALDATE RFC822.SIZE %s)\r\n", 	seq, msgno + 1, msgend + 1, hdrreq);      mutt_socket_write (CTX_DATA->conn, buf);      fetchlast = msgend + 1;    }    do    {      /* freshen fp, h */      rewind (fp);      h = msg_new_header ();            if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)      {	imap_free_header_data ((void**) &(h->data));	safe_free ((void**) &h);	fclose (fp);        return -1;      }      if (buf[0] == '*')      {	rc = msg_fetch_header (ctx, h, buf, fp);	if ((rc == -1 && imap_handle_untagged (CTX_DATA, buf)) || rc == -2)	{	  imap_free_header_data ((void**) &(h->data));	  safe_free ((void**) &h);	  fclose (fp);	  return -1;	}	/* update context with message header */	ctx->hdrs[ctx->msgcount] = mutt_new_header ();	ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;	ctx->hdrs[msgno]->read = h->read;	ctx->hdrs[msgno]->old = h->old;	ctx->hdrs[msgno]->deleted = h->deleted;	ctx->hdrs[msgno]->flagged = h->flagged;	ctx->hdrs[msgno]->replied = h->replied;	ctx->hdrs[msgno]->changed = h->changed;	ctx->hdrs[msgno]->received = h->received;	ctx->hdrs[msgno]->data = (void *) (h->data);	rewind (fp);	/* NOTE: if Date: header is missing, mutt_read_rfc822_header depends	 *   on h->received being set */	ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno],          0, 0);	/* content built as a side-effect of mutt_read_rfc822_header */	ctx->hdrs[msgno]->content->length = h->content_length;	mx_update_context (ctx); /* increments ->msgcount */	/* h->data shouldn't be freed here, it is kept in ctx->headers */	safe_free ((void**) &h);      }    }    while ((msgno + 1) >= fetchlast && mutt_strncmp (seq, buf, SEQLEN) != 0);    /* in case we get new mail while fetching the headers */    if (((IMAP_DATA *) ctx->data)->status == IMAP_NEW_MAIL)    {      msgend = ((IMAP_DATA *) ctx->data)->newMailCount - 1;      while ((msgend + 1) > ctx->hdrmax)        mx_alloc_memory (ctx);      ((IMAP_DATA *) ctx->data)->status = 0;    }  }  fclose(fp);  return msgend;}