return -1;
}
+/**
+ * comp_path_parent - Implements MxOps::path_parent
+ */
+int comp_path_parent(char *buf, size_t buflen)
+{
+ if (!buf)
+ return -1;
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ if (buf[0] == '~')
+ mutt_path_canon(buf, buflen, HomeDir);
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ return -1;
+}
+
// clang-format off
/**
* struct mx_comp_ops - Mailbox callback functions for compressed mailboxes
.path_probe = comp_path_probe,
.path_canon = comp_path_canon,
.path_pretty = comp_path_pretty,
+ .path_parent = comp_path_parent,
};
// clang-format on
return 0;
}
+/**
+ * imap_path_parent - Implements MxOps::path_parent
+ */
+int imap_path_parent(char *buf, size_t buflen)
+{
+ char tmp[PATH_MAX] = { 0 };
+
+ imap_get_parent_path(buf, tmp, sizeof(tmp));
+ mutt_str_strfcpy(buf, tmp, buflen);
+ return 0;
+}
+
// clang-format off
/**
* struct mx_imap_ops - Mailbox callback functions for IMAP mailboxes
.path_probe = imap_path_probe,
.path_canon = imap_path_canon,
.path_pretty = imap_path_pretty,
+ .path_parent = imap_path_parent,
};
// clang-format on
return -1;
}
+/**
+ * maildir_path_parent - Implements MxOps::path_parent
+ */
+int maildir_path_parent(char *buf, size_t buflen)
+{
+ if (!buf)
+ return -1;
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ if (buf[0] == '~')
+ mutt_path_canon(buf, buflen, HomeDir);
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ return -1;
+}
+
// clang-format off
/**
* struct mx_maildir_ops - Mailbox callback functions for Maildir mailboxes
.path_probe = maildir_path_probe,
.path_canon = maildir_path_canon,
.path_pretty = maildir_path_pretty,
+ .path_parent = maildir_path_parent,
};
/**
.path_probe = mh_path_probe,
.path_canon = maildir_path_canon,
.path_pretty = maildir_path_pretty,
+ .path_parent = maildir_path_parent,
};
// clang-format on
return -1;
}
+/**
+ * mbox_path_parent - Implements MxOps::path_parent
+ */
+int mbox_path_parent(char *buf, size_t buflen)
+{
+ if (!buf)
+ return -1;
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ if (buf[0] == '~')
+ mutt_path_canon(buf, buflen, HomeDir);
+
+ if (mutt_path_parent(buf, buflen))
+ return 0;
+
+ return -1;
+}
+
// clang-format off
/**
* struct mx_mbox_ops - Mailbox callback functions for mbox mailboxes
.path_probe = mbox_path_probe,
.path_canon = mbox_path_canon,
.path_pretty = mbox_path_pretty,
+ .path_parent = mbox_path_parent,
};
/**
.path_probe = mbox_path_probe,
.path_canon = mbox_path_canon,
.path_pretty = mbox_path_pretty,
+ .path_parent = mbox_path_parent,
};
// clang-format on
return 0;
}
+
+/**
+ * mx_path_parent - Find the parent of a mailbox path - Wrapper for MxOps::path_parent
+ */
+int mx_path_parent(char *buf, size_t buflen)
+{
+ if (!buf)
+ return -1;
+
+ return 0;
+}
* @retval -1 Failure
*/
int (*path_pretty) (char *buf, size_t buflen, const char *folder);
+ /**
+ * path_parent - Find the parent of a mailbox path
+ * @param buf Path to modify
+ * @param buflen Length of buffer
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
+ int (*path_parent) (char *buf, size_t buflen);
};
#ifdef USE_NOTMUCH
};
/* The Mailbox API, see MxOps */
-struct Context *mx_mbox_open (const char *path, int flags, struct Context *pctx);
int mx_mbox_check (struct Context *ctx, int *index_hint);
-int mx_mbox_sync (struct Context *ctx, int *index_hint);
int mx_mbox_close (struct Context *ctx, int *index_hint);
-struct Message *mx_msg_open (struct Context *ctx, int msgno);
-struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int flags);
-int mx_msg_commit (struct Context *ctx, struct Message *msg);
+struct Context *mx_mbox_open (const char *path, int flags, struct Context *pctx);
+int mx_mbox_sync (struct Context *ctx, int *index_hint);
+
int mx_msg_close (struct Context *ctx, struct Message **msg);
-int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen);
-int mx_tags_commit (struct Context *ctx, struct Header *hdr, char *tags);
-int mx_path_probe (const char *path, const struct stat *st);
+int mx_msg_commit (struct Context *ctx, struct Message *msg);
+struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int flags);
+struct Message *mx_msg_open (struct Context *ctx, int msgno);
+
int mx_path_canon (char *buf, size_t buflen, const char *folder);
+int mx_path_parent (char *buf, size_t buflen);
int mx_path_pretty (char *buf, size_t buflen, const char *folder);
+int mx_path_probe (const char *path, const struct stat *st);
+
+int mx_tags_commit (struct Context *ctx, struct Header *hdr, char *tags);
+int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen);
void mx_fastclose_mailbox(struct Context *ctx);
return 0;
}
+/**
+ * nntp_path_parent - Implements MxOps::path_parent
+ */
+int nntp_path_parent(char *buf, size_t buflen)
+{
+ /* Succeed, but don't do anything, for now */
+ return 0;
+}
+
// clang-format off
/**
* struct mx_nntp_ops - Mailbox callback functions for NNTP mailboxes
.path_probe = nntp_path_probe,
.path_canon = nntp_path_canon,
.path_pretty = nntp_path_pretty,
+ .path_parent = nntp_path_parent,
};
// clang-format on
return 0;
}
+/**
+ * nm_path_parent - Implements MxOps::path_parent
+ */
+int nm_path_parent(char *buf, size_t buflen)
+{
+ /* Succeed, but don't do anything, for now */
+ return 0;
+}
+
// clang-format off
/**
* struct mx_notmuch_ops - Mailbox callback functions for Notmuch mailboxes
.path_probe = nm_path_probe,
.path_canon = nm_path_canon,
.path_pretty = nm_path_pretty,
+ .path_parent = nm_path_parent,
};
// clang-format on
return 0;
}
+/**
+ * pop_path_parent - Implements MxOps::path_parent
+ */
+int pop_path_parent(char *buf, size_t buflen)
+{
+ /* Succeed, but don't do anything, for now */
+ return 0;
+}
+
// clang-format off
/**
* mx_pop_ops - Mailbox callback functions for POP mailboxes
.path_probe = pop_path_probe,
.path_canon = pop_path_canon,
.path_pretty = pop_path_pretty,
+ .path_parent = pop_path_parent,
};
// clang-format on