]> git.sesse.net Git - vlc/blob - include/vlc_fixups.h
WinCE: Require a recent enough mingwce to fix *printf problems
[vlc] / include / vlc_fixups.h
1 /*****************************************************************************
2  * fixups.h: portability fixups included from config.h
3  *****************************************************************************
4  * Copyright © 1998-2008 the VideoLAN project
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 /**
22  * \file
23  * This file is a collection of portability fixes
24  */
25
26 #ifndef LIBVLC_FIXUPS_H
27 # define LIBVLC_FIXUPS_H 1
28
29 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R)
30 # include <time.h> /* time_t */
31 #endif
32
33 #ifndef HAVE_LLDIV
34 typedef struct
35 {
36     long long quot; /* Quotient. */
37     long long rem;  /* Remainder. */
38 } lldiv_t;
39 #endif
40
41 #ifndef HAVE_REWIND
42 # include <stdio.h> /* FILE */
43 #endif
44
45 #if !defined (HAVE_STRLCPY) || \
46     !defined (HAVE_STRNDUP) || \
47     !defined (HAVE_STRNLEN)
48 # include <stddef.h> /* size_t */
49 #endif
50
51 #ifndef HAVE_VASPRINTF
52 # include <stdarg.h> /* va_list */
53 #endif
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 #ifndef HAVE_STRDUP
60 char *strdup (const char *);
61 #endif
62
63 #ifndef HAVE_VASPRINTF
64 int vasprintf (char **, const char *, va_list);
65 #endif
66
67 #ifndef HAVE_ASPRINTF
68 int asprintf (char **, const char *, ...);
69 #endif
70
71 #ifndef HAVE_STRNLEN
72 size_t strnlen (const char *, size_t);
73 #endif
74
75 #ifndef HAVE_STRNDUP
76 char *strndup (const char *, size_t);
77 #endif
78
79 #ifndef HAVE_STRLCPY
80 size_t strlcpy (char *, const char *, size_t);
81 #endif
82
83 #ifndef HAVE_STRTOF
84 float strtof (const char *, char **);
85 #endif
86
87 #ifndef HAVE_ATOF
88 double atof (const char *);
89 #endif
90
91 #ifndef HAVE_STRTOLL
92 long long int strtoll (const char *, char **, int);
93 #endif
94
95 #ifndef HAVE_STRSEP
96 char *strsep (char **, const char *);
97 #endif
98
99 #ifndef HAVE_ATOLL
100 long long atoll (const char *);
101 #endif
102
103 #ifndef HAVE_LLDIV
104 lldiv_t lldiv (long long, long long);
105 #endif
106
107 #ifndef HAVE_STRCASECMP
108 int strcasecmp (const char *, const char *);
109 #endif
110
111 #ifndef HAVE_STRNCASECMP
112 int strncasecmp (const char *, const char *, size_t);
113 #endif
114
115 #ifndef HAVE_STRCASESTR
116 char *strcasestr (const char *, const char *);
117 #endif
118
119 #ifndef HAVE_GMTIME_R
120 struct tm *gmtime_r (const time_t *, struct tm *);
121 #endif
122
123 #ifndef HAVE_LOCALTIME_R
124 struct tm *localtime_r (const time_t *, struct tm *);
125 #endif
126
127 #ifndef HAVE_REWIND
128 void rewind (FILE *);
129 #endif
130
131 #ifdef __cplusplus
132 } /* extern "C" */
133 #endif
134
135 #ifndef HAVE_GETENV
136 static inline char *getenv (const char *name)
137 {
138     (void)name;
139     return NULL;
140 }
141 #endif
142
143 /* Alignment of critical static data structures */
144 #ifdef ATTRIBUTE_ALIGNED_MAX
145 #   define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
146 #else
147 #   define ATTR_ALIGN(align)
148 #endif
149
150 #ifndef HAVE_USELOCALE
151 typedef void *locale_t;
152 # define newlocale( a, b, c ) ((locale_t)0)
153 # define uselocale( a ) ((locale_t)0)
154 # define freelocale( a ) (void)0
155 #endif
156
157 #ifdef WIN32
158 # include <dirent.h>
159 # define opendir Use_utf8_opendir_or_vlc_wopendir_instead!
160 # define readdir Use_utf8_readdir_or_vlc_wreaddir_instead!
161 # define closedir vlc_wclosedir
162 #endif
163
164 /* libintl support */
165 #define _(str)            vlc_gettext (str)
166 #define N_(str)           gettext_noop (str)
167 #define gettext_noop(str) (str)
168
169 #ifndef HAVE_SWAB
170 void swab (const void *, void *, ssize_t);
171 #endif
172
173 #endif /* !LIBVLC_FIXUPS_H */