DVDnav: fix .ifo files opening
[vlc/vlc-skelet.git] / include / vlc_fixups.h
blob1e4336c04668078ebbd94b687d3cd2955e7cb4e6
1 /*****************************************************************************
2 * fixups.h: portability fixups included from config.h
3 *****************************************************************************
4 * Copyright © 1998-2008 the VideoLAN project
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.
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.
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 *****************************************************************************/
21 /**
22 * \file
23 * This file is a collection of portability fixes
26 #ifndef LIBVLC_FIXUPS_H
27 # define LIBVLC_FIXUPS_H 1
29 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R)
30 # include <time.h> /* time_t */
31 #endif
33 #ifndef HAVE_LLDIV
34 typedef struct
36 long long quot; /* Quotient. */
37 long long rem; /* Remainder. */
38 } lldiv_t;
39 #endif
41 #if !defined(HAVE_GETENV) || \
42 !defined(HAVE_USELOCALE)
43 # include <stddef.h> /* NULL */
44 #endif
46 #if !defined (HAVE_REWIND) || \
47 !defined (HAVE_GETDELIM)
48 # include <stdio.h> /* FILE */
49 #endif
51 #if !defined (HAVE_STRLCPY) || \
52 !defined (HAVE_STRNDUP) || \
53 !defined (HAVE_STRNLEN) || \
54 !defined (HAVE_GETCWD)
55 # include <stddef.h> /* size_t */
56 #endif
58 #ifndef HAVE_VASPRINTF
59 # include <stdarg.h> /* va_list */
60 #endif
62 #if !defined (HAVE_GETDELIM) || \
63 !defined (HAVE_GETPID) || \
64 !defined (HAVE_SWAB)
65 # include <sys/types.h> /* ssize_t, pid_t */
66 #endif
68 #ifndef HAVE_DIRFD
69 # include <dirent.h>
70 #endif
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
76 /* stdio.h */
77 #ifndef HAVE_ASPRINTF
78 int asprintf (char **, const char *, ...);
79 #endif
81 #ifndef HAVE_GETDELIM
82 ssize_t getdelim (char **, size_t *, int, FILE *);
83 ssize_t getline (char **, size_t *, FILE *);
84 #endif
86 #ifndef HAVE_REWIND
87 void rewind (FILE *);
88 #endif
90 #ifndef HAVE_VASPRINTF
91 int vasprintf (char **, const char *, va_list);
92 #endif
94 /* string.h */
95 #ifndef HAVE_STRCASECMP
96 int strcasecmp (const char *, const char *);
97 #endif
99 #ifndef HAVE_STRCASESTR
100 char *strcasestr (const char *, const char *);
101 #endif
103 #ifndef HAVE_STRDUP
104 char *strdup (const char *);
105 #endif
107 #ifndef HAVE_STRNCASECMP
108 int strncasecmp (const char *, const char *, size_t);
109 #endif
111 #ifndef HAVE_STRNLEN
112 size_t strnlen (const char *, size_t);
113 #endif
115 #ifndef HAVE_STRNDUP
116 char *strndup (const char *, size_t);
117 #endif
119 #ifndef HAVE_STRLCPY
120 size_t strlcpy (char *, const char *, size_t);
121 #endif
123 #ifndef HAVE_STRSEP
124 char *strsep (char **, const char *);
125 #endif
127 #ifndef HAVE_STRTOK_R
128 char *strtok_r(char *, const char *, char **);
129 #endif
131 /* stdlib.h */
132 #ifndef HAVE_ATOF
133 #ifndef __ANDROID__
134 double atof (const char *);
135 #endif
136 #endif
138 #ifndef HAVE_ATOLL
139 long long atoll (const char *);
140 #endif
142 #ifndef HAVE_LLDIV
143 lldiv_t lldiv (long long, long long);
144 #endif
146 #ifndef HAVE_STRTOF
147 #ifndef __ANDROID__
148 float strtof (const char *, char **);
149 #endif
150 #endif
152 #ifndef HAVE_STRTOLL
153 long long int strtoll (const char *, char **, int);
154 #endif
156 /* time.h */
157 #ifndef HAVE_GMTIME_R
158 struct tm *gmtime_r (const time_t *, struct tm *);
159 #endif
161 #ifndef HAVE_LOCALTIME_R
162 struct tm *localtime_r (const time_t *, struct tm *);
163 #endif
165 /* unistd.h */
166 #ifndef HAVE_GETCWD
167 char *getcwd (char *buf, size_t size);
168 #endif
170 #ifndef HAVE_GETPID
171 pid_t getpid (void);
172 #endif
174 /* dirent.h */
175 #ifndef HAVE_DIRFD
176 #ifdef __APPLE__
177 #undef dirfd
178 #endif
179 int dirfd (DIR *);
180 #endif
182 #ifdef __cplusplus
183 } /* extern "C" */
184 #endif
186 /* stdlib.h */
187 #ifndef HAVE_GETENV
188 static inline char *getenv (const char *name)
190 (void)name;
191 return NULL;
193 #endif
195 #ifndef HAVE_SETENV
196 int setenv (const char *, const char *, int);
197 int unsetenv (const char *);
198 #endif
200 /* locale.h */
201 #ifndef HAVE_USELOCALE
202 #define LC_NUMERIC_MASK 0
203 #define LC_MESSAGES_MASK 0
204 typedef void *locale_t;
205 static inline locale_t uselocale(locale_t loc)
207 (void)loc;
208 return NULL;
210 static inline void freelocale(locale_t loc)
212 (void)loc;
214 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
216 (void)mask; (void)locale; (void)base;
217 return NULL;
219 #endif
221 /* Alignment of critical static data structures */
222 #ifdef ATTRIBUTE_ALIGNED_MAX
223 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
224 #else
225 # define ATTR_ALIGN(align)
226 #endif
228 /* libintl support */
229 #define _(str) vlc_gettext (str)
230 #define N_(str) gettext_noop (str)
231 #define gettext_noop(str) (str)
233 #ifndef HAVE_SWAB
234 void swab (const void *, void *, ssize_t);
235 #endif
237 /* Socket stuff */
238 #ifndef HAVE_INET_PTON
239 # define inet_pton vlc_inet_pton
240 #endif
242 #ifndef HAVE_INET_NTOP
243 # define inet_ntop vlc_inet_ntop
244 #endif
246 #ifndef HAVE_POLL
247 enum
249 POLLIN=1,
250 POLLOUT=2,
251 POLLPRI=4,
252 POLLERR=8, // unsupported stub
253 POLLHUP=16, // unsupported stub
254 POLLNVAL=32 // unsupported stub
257 struct pollfd
259 int fd;
260 unsigned events;
261 unsigned revents;
264 # define poll(a, b, c) vlc_poll(a, b, c)
265 #elif defined (HAVE_MAEMO)
266 # include <poll.h>
267 # define poll(a, b, c) vlc_poll(a, b, c)
268 int vlc_poll (struct pollfd *, unsigned, int);
269 #endif
271 /* search.h */
272 #ifndef HAVE_SEARCH_H
273 typedef struct entry {
274 char *key;
275 void *data;
276 } ENTRY;
278 typedef enum {
279 FIND, ENTER
280 } ACTION;
282 typedef enum {
283 preorder,
284 postorder,
285 endorder,
286 leaf
287 } VISIT;
289 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
290 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
291 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
292 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
293 void tdestroy( void *root, void (*free_node)(void *nodep) );
294 #else // HAVE_SEARCH_H
295 # ifndef HAVE_TDESTROY
296 # define tdestroy vlc_tdestroy
297 # endif
298 #endif
300 /* Random numbers */
301 #ifndef HAVE_NRAND48
302 double erand48 (unsigned short subi[3]);
303 long jrand48 (unsigned short subi[3]);
304 long nrand48 (unsigned short subi[3]);
305 #endif
307 #ifdef __ANDROID__
308 # undef __linux__
309 # ifndef __cplusplus
310 # define __cplusplus 0
311 # endif
312 # include <pthread.h>
313 # if __cplusplus == 0
314 # undef __cplusplus
315 # endif
316 char *tempnam(const char *, const char *);
317 #endif // ANDROID
319 #ifdef __OS2__
320 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
321 #endif
323 #endif /* !LIBVLC_FIXUPS_H */