]> git.notmuchmail.org Git - notmuch/blob - notmuch-private.h
message: Use g_hash_table_destroy instead of g_hash_table_unref
[notmuch] / notmuch-private.h
1 /* notmuch-private.h - Internal interfaces for notmuch.
2  *
3  * Copyright © 2009 Carl Worth
4  *
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.
9  *
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.
14  *
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/ .
17  *
18  * Author: Carl Worth <cworth@cworth.org>
19  */
20
21 #ifndef NOTMUCH_PRIVATE_H
22 #define NOTMUCH_PRIVATE_H
23
24 #include "notmuch.h"
25
26 #ifndef _GNU_SOURCE
27 #define _GNU_SOURCE /* For getline */
28 #endif
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <stdarg.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <sys/mman.h>
36 #include <string.h>
37 #include <errno.h>
38 #include <fcntl.h>
39 #include <unistd.h>
40 #include <ctype.h>
41
42 NOTMUCH_BEGIN_DECLS
43
44 /* xutil.c */
45 void *
46 xcalloc (size_t nmemb, size_t size);
47
48 void *
49 xmalloc (size_t size);
50
51 void *
52 xrealloc (void *ptrr, size_t size);
53
54 char *
55 xstrdup (const char *s);
56
57 char *
58 xstrndup (const char *s, size_t n);
59
60 /* message.c */
61
62 /* XXX: I haven't decided yet whether these will actually get exported
63  * into the public interface in notmuch.h
64  */
65
66 typedef struct _notmuch_message notmuch_message_t;
67
68 /* Open a file containing a single email message.
69  *
70  * The caller should call notmuch_message_close when done with this.
71  *
72  * Returns NULL if any error occurs.
73  */
74 notmuch_message_t *
75 notmuch_message_open (const char *filename);
76
77 /* Close a notmuch message preivously opened with notmuch_message_open. */
78 void
79 notmuch_message_close (notmuch_message_t *message);
80
81 /* Restrict 'message' to only save the named headers.
82  *
83  * When the caller is only interested in a short list of headers,
84  * known in advance, calling this function can avoid wasted time and
85  * memory parsing/saving header values that will never be needed.
86  *
87  * The variable arguments should be a list of const char * with a
88  * final '(const char *) NULL' to terminate the list.
89  *
90  * If this function is called, it must be called before any calls to
91  * notmuch_message_get_header for this message.
92  *
93  * After calling this function, if notmuch_message_get_header is
94  * called with a header name not in this list, then NULL will be
95  * returned even if that header exists in the actual message.
96  */
97 void
98 notmuch_message_restrict_headers (notmuch_message_t *message, ...);
99
100 /* Identical to notmuch_message_restrict_headers but accepting a va_list. */
101 void
102 notmuch_message_restrict_headersv (notmuch_message_t *message,
103                                    va_list va_headers);
104
105 /* Get the value of the specified header from the message.
106  *
107  * The header name is case insensitive.
108  *
109  * The returned value is owned by the notmuch message and is valid
110  * only until the message is closed. The caller should copy it if
111  * needing to modify the value or to hold onto it for longer.
112  *
113  * Returns NULL if the message does not contain a header line matching
114  * 'header'.
115  */
116 const char *
117 notmuch_message_get_header (notmuch_message_t *message,
118                             const char *header);
119
120 /* date.c */
121
122 /* Parse an RFC 8222 date string to a time_t value.
123  *
124  * The tz_offset argument can be used to also obtain the time-zone
125  * offset, (but can be NULL if the call is not interested in that).
126  *
127  * Returns 0 on error.
128  */
129 time_t
130 notmuch_parse_date (const char *str, int *tz_offset);
131
132 NOTMUCH_END_DECLS
133
134 #endif