aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-private.h
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-19 12:54:40 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-19 13:00:43 -0700
commit0e777a8f800af062aba39a95a003f3e1d8f33793 (patch)
tree9d1c73931983ad78f60d866185ea07907782b29f /notmuch-private.h
parent9bc4253fa804b62ff31e8de82a139b2cb12b118f (diff)
notmuch: Switch from gmime to custom, ad-hoc parsing of headers.
Since we're currently just trying to stitch together In-Reply-To and References headers we don't need that much sophistication. It's when we later add full-text searching that GMime will be useful. So for now, even though my own code here is surely very buggy compared to GMime it's also a lot faster. And speed is what we're after for the initial index creation.
Diffstat (limited to 'notmuch-private.h')
-rw-r--r--notmuch-private.h81
1 files changed, 81 insertions, 0 deletions
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 <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
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