Add some MIME types found in other players
[vlc.git] / include / vlc_fixups.h
blob30fc0bd444cbdcab819a6189986aad21686e175c
1 /*****************************************************************************
2 * vlc_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 it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * 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 /* needed to detect uClibc */
30 #ifdef HAVE_FEATURES_H
31 #include <features.h>
32 #endif
34 /* C++11 says there's no need to define __STDC_*_MACROS when including
35 * inttypes.h and stdint.h. */
36 #if defined (__cplusplus) && (defined(__MINGW32__) || defined(__UCLIBC__))
37 # ifndef __STDC_FORMAT_MACROS
38 # define __STDC_FORMAT_MACROS 1
39 # endif
40 # ifndef __STDC_CONSTANT_MACROS
41 # define __STDC_CONSTANT_MACROS 1
42 # endif
43 # ifndef __STDC_LIMIT_MACROS
44 # define __STDC_LIMIT_MACROS 1
45 # endif
46 #endif
48 #if !defined (HAVE_GMTIME_R) || !defined (HAVE_LOCALTIME_R) \
49 || !defined (HAVE_TIMEGM)
50 # include <time.h> /* time_t */
51 #endif
53 #ifndef HAVE_GETTIMEOFDAY
54 #ifdef _WIN32
55 #include <winsock2.h>
56 #else
57 #include <sys/time.h>
58 #endif
59 #endif
61 #ifndef HAVE_LLDIV
62 typedef struct
64 long long quot; /* Quotient. */
65 long long rem; /* Remainder. */
66 } lldiv_t;
67 #endif
69 #if !defined(HAVE_GETENV) || \
70 !defined(HAVE_USELOCALE)
71 # include <stddef.h> /* NULL */
72 #endif
74 #if !defined (HAVE_REWIND) || \
75 !defined (HAVE_GETDELIM)
76 # include <stdio.h> /* FILE */
77 #endif
79 #if !defined (HAVE_POSIX_MEMALIGN) || \
80 !defined (HAVE_MEMRCHR) || \
81 !defined (HAVE_STRLCPY) || \
82 !defined (HAVE_STRNDUP) || \
83 !defined (HAVE_STRNLEN) || \
84 !defined (HAVE_STRNSTR)
85 # include <stddef.h> /* size_t */
86 #endif
88 #ifndef HAVE_VASPRINTF
89 # include <stdarg.h> /* va_list */
90 #endif
92 #if !defined (HAVE_GETDELIM) || \
93 !defined (HAVE_GETPID) || \
94 !defined (HAVE_SWAB)
95 # include <sys/types.h> /* ssize_t, pid_t */
96 #endif
98 #if !defined (HAVE_DIRFD) || \
99 !defined (HAVE_FDOPENDIR)
100 # include <dirent.h>
101 #endif
103 #ifdef __cplusplus
104 # define VLC_NOTHROW throw ()
105 extern "C" {
106 #else
107 # define VLC_NOTHROW
108 #endif
110 /* stddef.h */
111 #if !defined (__cplusplus) && !defined (HAVE_MAX_ALIGN_T)
112 typedef struct {
113 long long ll;
114 long double ld;
115 } max_align_t;
116 #endif
118 /* stdio.h */
119 #ifndef HAVE_ASPRINTF
120 int asprintf (char **, const char *, ...);
121 #endif
123 #ifndef HAVE_FLOCKFILE
124 void flockfile (FILE *);
125 void funlockfile (FILE *);
126 int getc_unlocked (FILE *);
127 int getchar_unlocked (void);
128 int putc_unlocked (int, FILE *);
129 int putchar_unlocked (int);
130 #endif
132 #ifndef HAVE_GETDELIM
133 ssize_t getdelim (char **, size_t *, int, FILE *);
134 ssize_t getline (char **, size_t *, FILE *);
135 #endif
137 #ifndef HAVE_REWIND
138 void rewind (FILE *);
139 #endif
141 #ifndef HAVE_VASPRINTF
142 int vasprintf (char **, const char *, va_list);
143 #endif
145 /* string.h */
146 #ifndef HAVE_FFSLL
147 int ffsll(long long);
148 #endif
150 #ifndef HAVE_MEMRCHR
151 void *memrchr(const void *, int, size_t);
152 #endif
154 #ifndef HAVE_STRCASECMP
155 int strcasecmp (const char *, const char *);
156 #endif
158 #ifndef HAVE_STRCASESTR
159 char *strcasestr (const char *, const char *);
160 #endif
162 #ifndef HAVE_STRDUP
163 char *strdup (const char *);
164 #endif
166 #ifndef HAVE_STRVERSCMP
167 int strverscmp (const char *, const char *);
168 #endif
170 #ifndef HAVE_STRNLEN
171 size_t strnlen (const char *, size_t);
172 #endif
174 #ifndef HAVE_STRNSTR
175 char * strnstr (const char *, const char *, size_t);
176 #endif
178 #ifndef HAVE_STRNDUP
179 char *strndup (const char *, size_t);
180 #endif
182 #ifndef HAVE_STRLCPY
183 size_t strlcpy (char *, const char *, size_t);
184 #endif
186 #ifndef HAVE_STRSEP
187 char *strsep (char **, const char *);
188 #endif
190 #ifndef HAVE_STRTOK_R
191 char *strtok_r(char *, const char *, char **);
192 #endif
194 /* stdlib.h */
195 #ifndef HAVE_ATOF
196 #ifndef __ANDROID__
197 double atof (const char *);
198 #endif
199 #endif
201 #ifndef HAVE_ATOLL
202 long long atoll (const char *);
203 #endif
205 #ifndef HAVE_LLDIV
206 lldiv_t lldiv (long long, long long);
207 #endif
209 #ifndef HAVE_STRTOF
210 #ifndef __ANDROID__
211 float strtof (const char *, char **);
212 #endif
213 #endif
215 #ifndef HAVE_STRTOLL
216 long long int strtoll (const char *, char **, int);
217 #endif
219 /* time.h */
220 #ifndef HAVE_GMTIME_R
221 struct tm *gmtime_r (const time_t *, struct tm *);
222 #endif
224 #ifndef HAVE_LOCALTIME_R
225 struct tm *localtime_r (const time_t *, struct tm *);
226 #endif
228 #ifndef HAVE_TIMEGM
229 time_t timegm(struct tm *);
230 #endif
232 #ifndef HAVE_TIMESPEC_GET
233 #define TIME_UTC 1
234 struct timespec;
235 int timespec_get(struct timespec *, int);
236 #endif
238 /* sys/time.h */
239 #ifndef HAVE_GETTIMEOFDAY
240 struct timezone;
241 int gettimeofday(struct timeval *, struct timezone *);
242 #endif
244 /* unistd.h */
245 #ifndef HAVE_GETPID
246 pid_t getpid (void) VLC_NOTHROW;
247 #endif
249 #ifndef HAVE_FSYNC
250 int fsync (int fd);
251 #endif
253 /* dirent.h */
254 #ifndef HAVE_DIRFD
255 int (dirfd) (DIR *);
256 #endif
258 #ifndef HAVE_FDOPENDIR
259 DIR *fdopendir (int);
260 #endif
262 #ifdef __cplusplus
263 } /* extern "C" */
264 #endif
266 /* stdlib.h */
267 #ifndef HAVE_GETENV
268 static inline char *getenv (const char *name)
270 (void)name;
271 return NULL;
273 #endif
275 #ifndef HAVE_SETENV
276 int setenv (const char *, const char *, int);
277 int unsetenv (const char *);
278 #endif
280 #ifndef HAVE_POSIX_MEMALIGN
281 int posix_memalign (void **, size_t, size_t);
282 #endif
284 /* locale.h */
285 #ifndef HAVE_USELOCALE
286 #define LC_ALL_MASK 0
287 #define LC_NUMERIC_MASK 0
288 #define LC_MESSAGES_MASK 0
289 #define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
290 typedef void *locale_t;
291 static inline locale_t uselocale(locale_t loc)
293 (void)loc;
294 return NULL;
296 static inline void freelocale(locale_t loc)
298 (void)loc;
300 static inline locale_t newlocale(int mask, const char * locale, locale_t base)
302 (void)mask; (void)locale; (void)base;
303 return NULL;
305 #endif
307 #if !defined (HAVE_STATIC_ASSERT) && !defined(__cpp_static_assert)
308 # define STATIC_ASSERT_CONCAT_(a, b) a##b
309 # define STATIC_ASSERT_CONCAT(a, b) STATIC_ASSERT_CONCAT_(a, b)
310 # define _Static_assert(x, s) extern char STATIC_ASSERT_CONCAT(static_assert_, __LINE__)[sizeof(struct { unsigned:-!(x); })]
311 # define static_assert _Static_assert
312 #endif
314 /* Alignment of critical static data structures */
315 #ifdef ATTRIBUTE_ALIGNED_MAX
316 # define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
317 #else
318 # define ATTR_ALIGN(align)
319 #endif
321 /* libintl support */
322 #define _(str) vlc_gettext (str)
323 #define N_(str) gettext_noop (str)
324 #define gettext_noop(str) (str)
326 #ifdef __cplusplus
327 extern "C" {
328 #endif
330 #ifndef HAVE_SWAB
331 void swab (const void *, void *, ssize_t);
332 #endif
334 /* Socket stuff */
335 #ifndef HAVE_INET_PTON
336 # ifndef _WIN32
337 # include <sys/socket.h>
338 #else
339 typedef int socklen_t;
340 # endif
341 int inet_pton(int, const char *, void *);
342 const char *inet_ntop(int, const void *, char *, socklen_t);
343 #endif
345 #ifndef HAVE_STRUCT_POLLFD
346 enum
348 POLLERR=0x1,
349 POLLHUP=0x2,
350 POLLNVAL=0x4,
351 POLLWRNORM=0x10,
352 POLLWRBAND=0x20,
353 POLLRDNORM=0x100,
354 POLLRDBAND=0x200,
355 POLLPRI=0x400,
357 #define POLLIN (POLLRDNORM|POLLRDBAND)
358 #define POLLOUT (POLLWRNORM|POLLWRBAND)
360 struct pollfd
362 int fd;
363 unsigned events;
364 unsigned revents;
366 #endif
367 #ifndef HAVE_POLL
368 struct pollfd;
369 int poll (struct pollfd *, unsigned, int);
370 #endif
372 #ifndef HAVE_IF_NAMEINDEX
373 #include <errno.h>
374 struct if_nameindex
376 unsigned if_index;
377 char *if_name;
379 # ifndef HAVE_IF_NAMETOINDEX
380 # define if_nametoindex(name) atoi(name)
381 # endif
382 # define if_nameindex() (errno = ENOBUFS, NULL)
383 # define if_freenameindex(list) (void)0
384 #endif
386 #ifndef HAVE_STRUCT_TIMESPEC
387 struct timespec {
388 time_t tv_sec; /* Seconds */
389 long tv_nsec; /* Nanoseconds */
391 #endif
393 #ifdef _WIN32
394 struct iovec
396 void *iov_base;
397 size_t iov_len;
399 #define IOV_MAX 255
400 struct msghdr
402 void *msg_name;
403 size_t msg_namelen;
404 struct iovec *msg_iov;
405 size_t msg_iovlen;
406 void *msg_control;
407 size_t msg_controllen;
408 int msg_flags;
410 #endif
412 #ifndef HAVE_RECVMSG
413 struct msghdr;
414 ssize_t recvmsg(int, struct msghdr *, int);
415 #endif
417 #ifndef HAVE_SENDMSG
418 struct msghdr;
419 ssize_t sendmsg(int, const struct msghdr *, int);
420 #endif
422 /* search.h */
423 #ifndef HAVE_SEARCH_H
424 typedef struct entry {
425 char *key;
426 void *data;
427 } ENTRY;
429 typedef enum {
430 FIND, ENTER
431 } ACTION;
433 typedef enum {
434 preorder,
435 postorder,
436 endorder,
437 leaf
438 } VISIT;
440 void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
441 void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
442 void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
443 void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
444 void tdestroy( void *root, void (*free_node)(void *nodep) );
445 #else // HAVE_SEARCH_H
446 # ifndef HAVE_TDESTROY
447 void vlc_tdestroy( void *, void (*)(void *) );
448 # define tdestroy vlc_tdestroy
449 # endif
450 #endif
452 /* Random numbers */
453 #ifndef HAVE_NRAND48
454 double erand48 (unsigned short subi[3]);
455 long jrand48 (unsigned short subi[3]);
456 long nrand48 (unsigned short subi[3]);
457 #endif
459 #ifdef __OS2__
460 # undef HAVE_FORK /* Implementation of fork() is imperfect on OS/2 */
462 struct addrinfo
464 int ai_flags;
465 int ai_family;
466 int ai_socktype;
467 int ai_protocol;
468 size_t ai_addrlen;
469 struct sockaddr *ai_addr;
470 char *ai_canonname;
471 struct addrinfo *ai_next;
474 void freeaddrinfo (struct addrinfo *res);
476 # include <errno.h>
477 # ifndef EPROTO
478 # define EPROTO (ELAST + 1)
479 # endif
480 #endif
482 /* math.h */
484 #ifndef HAVE_NANF
485 #define nanf(tagp) NAN
486 #endif
488 #ifndef HAVE_SINCOS
489 void sincos(double, double *, double *);
490 void sincosf(float, float *, float *);
491 #endif
493 #ifndef HAVE_REALPATH
494 char *realpath(const char * restrict pathname, char * restrict resolved_path);
495 #endif
497 #ifdef _WIN32
498 FILE *vlc_win32_tmpfile(void);
499 #endif
501 /* mingw-w64 has a broken IN6_IS_ADDR_MULTICAST macro */
502 #if defined(_WIN32) && defined(__MINGW64_VERSION_MAJOR)
503 # define IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_MULTICAST
504 #endif
506 #ifdef __APPLE__
507 # define fdatasync fsync
508 #endif
510 #ifdef __cplusplus
511 } /* extern "C" */
512 #endif
514 #endif /* !LIBVLC_FIXUPS_H */