X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-private.h;h=b7d27e9169b7da486b0855edccf81ec9141fee8d;hp=15d6db4856748c064c58c7968c148fb8d3bbe1d8;hb=f5f8dcf2a00e3d78f862734bafeae0a7b25738c1;hpb=10c176ba0e6d71e920b72a3165c0e56f26b5e4b3 diff --git a/notmuch-private.h b/notmuch-private.h index 15d6db48..b7d27e91 100644 --- a/notmuch-private.h +++ b/notmuch-private.h @@ -23,8 +23,17 @@ #include "notmuch.h" +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include NOTMUCH_BEGIN_DECLS @@ -44,6 +53,78 @@ xstrdup (const char *s); char * xstrndup (const char *s, size_t n); +/* message.c */ + +/* XXX: I haven't decided yet whether these will actually get exported + * into the public interface in notmuch.h + */ + +typedef struct _notmuch_message notmuch_message_t; + +/* Open a file containing a single email message. + * + * The caller should call notmuch_message_close when done with this. + * + * Returns NULL if any error occurs. + */ +notmuch_message_t * +notmuch_message_open (const char *filename); + +/* Close a notmuch message preivously opened with notmuch_message_open. */ +void +notmuch_message_close (notmuch_message_t *message); + +/* Restrict 'message' to only save the named headers. + * + * When the caller is only interested in a short list of headers, + * known in advance, calling this function can avoid wasted time and + * memory parsing/saving header values that will never be needed. + * + * The variable arguments should be a list of const char * with a + * final '(const char *) NULL' to terminate the list. + * + * If this function is called, it must be called before any calls to + * notmuch_message_get_header for this message. + * + * After calling this function, if notmuch_message_get_header is + * called with a header name not in this list, then NULL will be + * returned even if that header exists in the actual message. + */ +void +notmuch_message_restrict_headers (notmuch_message_t *message, ...); + +/* Identical to notmuch_message_restrict_headers but accepting a va_list. */ +void +notmuch_message_restrict_headersv (notmuch_message_t *message, + va_list va_headers); + +/* Get the value of the specified header from the message. + * + * The header name is case insensitive. + * + * The returned value is owned by the notmuch message and is valid + * only until the message is closed. The caller should copy it if + * needing to modify the value or to hold onto it for longer. + * + * Returns NULL if the message does not contain a header line matching + * 'header'. + */ +const char * +notmuch_message_get_header (notmuch_message_t *message, + const char *header); + +/* date.c */ + +/* Parse an RFC 8222 date string to a time_t value. + * + * The tz_offset argument can be used to also obtain the time-zone + * offset, (but can be NULL if the call is not interested in that). + * + * Returns 0 on error. + */ +time_t +notmuch_parse_date (const char *str, int *tz_offset); + NOTMUCH_END_DECLS #endif