char newpath[_POSIX_PATH_MAX]; char partpath[_POSIX_PATH_MAX]; char fullpath[_POSIX_PATH_MAX]; char oldpath[_POSIX_PATH_MAX]; char *p;
static int maildir_sync_message (CONTEXT *ctx, int msgno){  HEADER *h = ctx->hdrs[msgno];  char newpath[_POSIX_PATH_MAX];  char partpath[_POSIX_PATH_MAX];  char fullpath[_POSIX_PATH_MAX];  char oldpath[_POSIX_PATH_MAX];  char *p;  if ((p = strrchr (h->path, '/')) == NULL)  {    dprint (1, (debugfile, "maildir_sync_message: %s: unable to find subdir!\n",		h->path));    return (-1);  }  p++;  strfcpy (newpath, p, sizeof (newpath));  /* kill the previous flags */  if ((p = strchr (newpath, ':')) != NULL) *p = 0;  if (h->replied || h->read || h->flagged)  {    strcat (newpath, ":2,");    if (h->flagged) strcat (newpath, "F");    if (h->replied) strcat (newpath, "R");    if (h->read) strcat (newpath, "S");  }  /* decide which subdir this message belongs in */  strfcpy (partpath, (h->read || h->old) ? "cur" : "new", sizeof (partpath));  strcat (partpath, "/");   strcat (partpath, newpath);   snprintf (fullpath, sizeof (fullpath), "%s/%s", ctx->path, partpath);  snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path);  if (mutt_strcmp (fullpath, oldpath) == 0 && !h->attach_del)  {    /* message hasn't really changed */    return 0;  }  /*   * At this point, this should work to actually delete the attachment   * without breaking anything else (mh_sync_message doesn't appear to   * make any mailbox assumptions except the one file per message, which   * is compatible with maildir   */  if (h->attach_del)  {    char tmppath[_POSIX_PATH_MAX];    char ftpath[_POSIX_PATH_MAX];    strfcpy (tmppath, "tmp/", sizeof (tmppath));    strcat (tmppath, newpath);    snprintf (ftpath, sizeof (ftpath), "%s/%s", ctx->path, tmppath);    dprint (1, (debugfile, "maildir_sync_message: deleting attachment!\n"));    if (rename (oldpath, ftpath) != 0)    {      mutt_perror ("rename");      return (-1);    }    safe_free ((void **)&h->path);    h->path = safe_strdup (tmppath);    dprint (1, (debugfile, "maildir_sync_message: deleting attachment2!\n"));    mh_sync_message (ctx, msgno);    dprint (1, (debugfile, "maildir_sync_message: deleting attachment3!\n"));    if (rename (ftpath, fullpath) != 0)    {      mutt_perror ("rename");      return (-1);    }  }  else  {    if (rename (oldpath, fullpath) != 0)    {      mutt_perror ("rename");      return (-1);    }  }  safe_free ((void **) &h->path);  h->path = safe_strdup (partpath);  return (0);}