]> git.sesse.net Git - vlc/blob - include/vlc_fixups.h
If uselocale() is absent, assume libc does no localization
[vlc] / include / vlc_fixups.h
1 /*****************************************************************************
2  * fixups.h: portability fixups included from config.h
3  *****************************************************************************
4  * Copyright © 1998-2007 the VideoLAN project
5  * $Id$
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20  *****************************************************************************/
21
22 /**
23  * \file
24  * This file is a collection of portability fixes
25  */
26
27 #ifndef LIBVLC_FIXUPS_H
28 # define LIBVLC_FIXUPS_H 1
29
30 #ifndef HAVE_STRDUP
31 # define strdup vlc_strdup
32 #endif
33
34 #ifndef HAVE_VASPRINTF
35 # define vasprintf vlc_vasprintf
36 #endif
37
38 #ifndef HAVE_ASPRINTF
39 # define asprintf vlc_asprintf
40 #endif
41
42 #ifndef HAVE_STRNDUP
43 # define strndup vlc_strndup
44 #endif
45
46 #ifndef HAVE_STRNLEN
47 # define strnlen vlc_strnlen
48 #endif
49
50 #ifndef HAVE_STRLCPY
51 # define strlcpy vlc_strlcpy
52 #endif
53
54 #ifndef HAVE_ATOF
55 # define atof vlc_atof
56 #endif
57
58 #ifndef HAVE_STRTOF
59 # ifdef HAVE_STRTOD
60 #  define strtof( a, b ) ((float)strtod (a, b))
61 # endif
62 #endif
63
64 #ifndef HAVE_ATOLL
65 # define atoll vlc_atoll
66 #endif
67
68 #ifndef HAVE_STRTOLL
69 # define strtoll vlc_strtoll
70 #endif
71
72 #ifndef HAVE_LLDIV
73 # define lldiv vlc_lldiv
74 #endif
75
76 #ifndef HAVE_SCANDIR
77 # define scandir vlc_scandir
78 # define alphasort vlc_alphasort
79 #endif
80
81 #ifndef HAVE_GETENV
82 # define getenv vlc_getenv
83 #endif
84
85 #ifndef HAVE_STRCASECMP
86 # ifndef HAVE_STRICMP
87 #  define strcasecmp vlc_strcasecmp
88 # else
89 #  define strcasecmp stricmp
90 # endif
91 #endif
92
93 #ifndef HAVE_STRNCASECMP
94 # ifndef HAVE_STRNICMP
95 #  define strncasecmp vlc_strncasecmp
96 # else
97 #  define strncasecmp strnicmp
98 # endif
99 #endif
100
101 #ifndef HAVE_STRCASESTR
102 # ifndef HAVE_STRISTR
103 #  define strcasestr vlc_strcasestr
104 # else
105 #  define strcasestr stristr
106 # endif
107 #endif
108
109 #ifndef HAVE_LOCALTIME_R
110 /* If localtime_r() is not provided, we assume localtime() uses
111  * thread-specific storage. */
112 # include <time.h>
113 static inline struct tm *localtime_r (const time_t *timep, struct tm *result)
114 {
115     struct tm *s = localtime (timep);
116     if (s == NULL)
117         return NULL;
118
119     *result = *s;
120     return result;
121 }
122 static inline struct tm *gmtime_r (const time_t *timep, struct tm *result)
123 {
124     struct tm *s = gmtime (timep);
125     if (s == NULL)
126         return NULL;
127
128     *result = *s;
129     return result;
130 }
131 #endif
132
133 #ifndef HAVE_DIRENT_H
134 typedef void DIR;
135 #   ifndef FILENAME_MAX
136 #       define FILENAME_MAX (260)
137 #   endif
138 struct dirent
139 {
140     long            d_ino;          /* Always zero. */
141     unsigned short  d_reclen;       /* Always zero. */
142     unsigned short  d_namlen;       /* Length of name in d_name. */
143     char            d_name[FILENAME_MAX]; /* File name. */
144 };
145 #   define opendir vlc_opendir
146 #   define readdir vlc_readdir
147 #   define closedir vlc_closedir
148 #   define rewinddir vlc_rewindir
149 #   define seekdir vlc_seekdir
150 #   define telldir vlc_telldir
151 VLC_EXPORT( void *, vlc_opendir, ( const char * ) );
152 VLC_EXPORT( void *, vlc_readdir, ( void * ) );
153 VLC_EXPORT( int, vlc_closedir, ( void * ) );
154 VLC_INTERNAL( void, vlc_rewinddir, ( void * ) );
155 VLC_INTERNAL( void, vlc_seekdir, ( void *, long ) );
156 VLC_INTERNAL( long, vlc_telldir, ( void * ) );
157 #endif
158
159 #ifndef HAVE_USELOCALE
160 typedef void *locale_t;
161 # define newlocale( a, b, c ) ((locale_t)0)
162 # define uselocale( a ) ((locale_t)0)
163 # define freelocale( a ) (void)0
164 #endif
165
166 #endif /* !LIBVLC_FIXUPS_H */