1 /* notmuch-private.h - Internal interfaces for notmuch.
3 * Copyright © 2009 Carl Worth
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see http://www.gnu.org/licenses/ .
18 * Author: Carl Worth <cworth@cworth.org>
21 #ifndef NOTMUCH_PRIVATE_H
22 #define NOTMUCH_PRIVATE_H
29 #include <sys/types.h>
42 xcalloc (size_t nmemb, size_t size);
45 xmalloc (size_t size);
48 xrealloc (void *ptrr, size_t size);
51 xstrdup (const char *s);
54 xstrndup (const char *s, size_t n);
58 /* XXX: I haven't decided yet whether these will actually get exported
59 * into the public interface in notmuch.h
62 typedef struct _notmuch_message notmuch_message_t;
64 /* Open a file containing a single email message.
66 * The caller should call notmuch_message_close when done with this.
68 * Returns NULL if any error occurs.
71 notmuch_message_open (const char *filename);
73 /* Close a notmuch message preivously opened with notmuch_message_open. */
75 notmuch_message_close (notmuch_message_t *message);
77 /* Restrict 'message' to only save the named headers.
79 * When the caller is only interested in a short list of headers,
80 * known in advance, calling this function can avoid wasted time and
81 * memory parsing/saving header values that will never be needed.
83 * The variable arguments should be a list of const char * with a
84 * final '(const char *) NULL' to terminate the list.
86 * If this function is called, it must be called before any calls to
87 * notmuch_message_get_header for this message.
89 * After calling this function, if notmuch_message_get_header is
90 * called with a header name not in this list, then NULL will be
91 * returned even if that header exists in the actual message.
94 notmuch_message_restrict_headers (notmuch_message_t *message, ...);
96 /* Identical to notmuch_message_restrict_headers but accepting a va_list. */
98 notmuch_message_restrict_headersv (notmuch_message_t *message,
101 /* Get the value of the specified header from the message.
103 * The header name is case insensitive.
105 * The returned value is owned by the notmuch message and is valid
106 * only until the message is closed. The caller should copy it if
107 * needing to modify the value or to hold onto it for longer.
109 * Returns NULL if the message does not contain a header line matching
113 notmuch_message_get_header (notmuch_message_t *message,
118 /* Parse an RFC 8222 date string to a time_t value.
120 * The tz_offset argument can be used to also obtain the time-zone
121 * offset, (but can be NULL if the call is not interested in that).
123 * Returns 0 on error.
126 notmuch_parse_date (const char *str, int *tz_offset);