]> git.notmuchmail.org Git - notmuch/blob - compat/compat.h
Merge tag '0.29.2'
[notmuch] / compat / compat.h
1 /* notmuch - Not much of an email library, (just index and search)
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 https://www.gnu.org/licenses/ .
17  *
18  * Author: Carl Worth <cworth@cworth.org>
19  */
20
21 /* This header file defines functions that will only be conditionally
22  * compiled for compatibility on systems that don't provide their own
23  * implementations of the functions.
24  */
25
26 #ifndef NOTMUCH_COMPAT_H
27 #define NOTMUCH_COMPAT_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #if ! STD_GETPWUID
34 #define _POSIX_PTHREAD_SEMANTICS 1
35 #endif
36 #if ! STD_ASCTIME
37 #define _POSIX_PTHREAD_SEMANTICS 1
38 #endif
39
40 #if ! HAVE_CANONICALIZE_FILE_NAME
41 /* we only call this function from C, and this makes testing easier */
42 #ifndef __cplusplus
43 char *
44 canonicalize_file_name (const char *path);
45 #endif
46 #endif
47
48 #if ! HAVE_GETLINE
49 #include <stdio.h>
50 #include <unistd.h>
51
52 ssize_t
53 getline (char **lineptr, size_t *n, FILE *stream);
54
55 ssize_t
56 getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
57
58 #endif  /* !HAVE_GETLINE */
59
60 #if ! HAVE_STRCASESTR
61 char *strcasestr (const char *haystack, const char *needle);
62 #endif  /* !HAVE_STRCASESTR */
63
64 #if ! HAVE_STRSEP
65 char *strsep (char **stringp, const char *delim);
66 #endif  /* !HAVE_STRSEP */
67
68 #if ! HAVE_TIMEGM
69 #include <time.h>
70 time_t timegm (struct tm *tm);
71 #endif  /* !HAVE_TIMEGM */
72
73 /* Silence gcc warnings about unused results.  These warnings exist
74  * for a reason; any use of this needs to be justified. */
75 #ifdef __GNUC__
76 #define IGNORE_RESULT(x) ({ __typeof__(x) __z = (x); (void) (__z = __z); })
77 #else /* !__GNUC__ */
78 #define IGNORE_RESULT(x) x
79 #endif  /* __GNUC__ */
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif  /* NOTMUCH_COMPAT_H */