if (unseen)  mhs_write_one_sequence (nfp, &mhs, MH_SEQ_UNSEEN, "unseen"); if (flagged) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_FLAGGED, "flagged"); if (replied) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_REPLIED, "replied");
if (unseen)  mhs_write_one_sequence (nfp, &mhs, MH_SEQ_UNSEEN, MH_SEQNAME_UNSEEN); if (flagged) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_FLAGGED, MH_SEQNAME_FLAGGED); if (replied) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_REPLIED, MH_SEQNAME_REPLIED);
void mh_update_sequences (CONTEXT *ctx){  FILE *ofp, *nfp;    char sequences[_POSIX_PATH_MAX];  char *tmpfname;  char *buff = NULL;  char *p;  size_t s;  int l = 0;  int i;  int unseen = 0;   int flagged = 0;  int replied = 0;    struct mh_sequences mhs;  memset (&mhs, 0, sizeof (mhs));    if (mh_mkstemp (ctx, &nfp, &tmpfname) != 0)  {    /* error message? */    return;  }  snprintf (sequences, sizeof (sequences), "%s/.mh_sequences", ctx->path);    /* first, copy unknown sequences */  if ((ofp = fopen (sequences, "r")))  {    while ((buff = mutt_read_line (buff, &s, ofp, &l)))    {      if (!strncmp (buff, "unseen:", 7))	continue;      if (!strncmp (buff, "flagged:", 8))	continue;      if (!strncmp (buff, "replied:", 8))	continue;	      fprintf (nfp, "%s\n", buff);    }  }  safe_fclose (&ofp);    /* now, update our unseen, flagged, and replied sequences */  for (l = 0; l < ctx->msgcount; l++)  {    if ((p = strrchr (ctx->hdrs[l]->path, '/')))      p++;    else      p = ctx->hdrs[l]->path;    i = atoi (p);        if (!ctx->hdrs[l]->read)    {      mhs_set (&mhs, i, MH_SEQ_UNSEEN);      unseen++;    }    if (ctx->hdrs[l]->flagged)    {      mhs_set (&mhs, i, MH_SEQ_FLAGGED);      flagged++;    }    if (ctx->hdrs[l]->replied)    {      mhs_set (&mhs, i, MH_SEQ_REPLIED);      replied++;    }  }  /* write out the new sequences */  if (unseen)  mhs_write_one_sequence (nfp, &mhs, MH_SEQ_UNSEEN, "unseen");  if (flagged) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_FLAGGED, "flagged");  if (replied) mhs_write_one_sequence (nfp, &mhs, MH_SEQ_REPLIED, "replied");  mhs_free_sequences (&mhs);    /* try to commit the changes - no guarantee here */  safe_fclose (&nfp);    unlink (sequences);  if (safe_rename (tmpfname, sequences) != 0)  {    /* report an error? */    unlink (tmpfname);  }    safe_free ((void **) &tmpfname);}