]> git.sesse.net Git - vlc/blob - include/vlc_fixups.h
Provide vlc_gettext on all platforms
[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 #ifndef HAVE_STRDUP
30 # define strdup vlc_strdup
31 #endif
32
33 #ifndef HAVE_VASPRINTF
34 # define vasprintf vlc_vasprintf
35 #endif
36
37 #ifndef HAVE_ASPRINTF
38 # define asprintf vlc_asprintf
39 #endif
40
41 #ifndef HAVE_STRNDUP
42 # define strndup vlc_strndup
43 #endif
44
45 #ifndef HAVE_STRNLEN
46 # define strnlen vlc_strnlen
47 #endif
48
49 #ifndef HAVE_STRLCPY
50 # define strlcpy vlc_strlcpy
51 #endif
52
53 #ifndef HAVE_ATOF
54 # define atof vlc_atof
55 #endif
56
57 #ifndef HAVE_STRTOF
58 # ifdef HAVE_STRTOD
59 #  define strtof( a, b ) ((float)strtod (a, b))
60 # endif
61 #endif
62
63 #ifndef HAVE_ATOLL
64 # define atoll vlc_atoll
65 #endif
66
67 #ifndef HAVE_STRTOLL
68 # define strtoll vlc_strtoll
69 #endif
70
71 #ifndef HAVE_LLDIV
72 # define lldiv vlc_lldiv
73 #endif
74
75 #ifndef HAVE_SCANDIR
76 # define scandir vlc_scandir
77 # define alphasort vlc_alphasort
78 #endif
79
80 #ifndef HAVE_GETENV
81 # define getenv vlc_getenv
82 #endif
83
84 #ifndef HAVE_STRCASECMP
85 # ifndef HAVE_STRICMP
86 #  define strcasecmp vlc_strcasecmp
87 # else
88 #  define strcasecmp stricmp
89 # endif
90 #endif
91
92 #ifndef HAVE_STRNCASECMP
93 # ifndef HAVE_STRNICMP
94 #  define strncasecmp vlc_strncasecmp
95 # else
96 #  define strncasecmp strnicmp
97 # endif
98 #endif
99
100 #ifndef HAVE_STRCASESTR
101 # ifndef HAVE_STRISTR
102 #  define strcasestr vlc_strcasestr
103 # else
104 #  define strcasestr stristr
105 # endif
106 #endif
107
108 #ifndef HAVE_LOCALTIME_R
109 /* If localtime_r() is not provided, we assume localtime() uses
110  * thread-specific storage. */
111 # include <time.h>
112 static inline struct tm *localtime_r (const time_t *timep, struct tm *result)
113 {
114     struct tm *s = localtime (timep);
115     if (s == NULL)
116         return NULL;
117
118     *result = *s;
119     return result;
120 }
121 static inline struct tm *gmtime_r (const time_t *timep, struct tm *result)
122 {
123     struct tm *s = gmtime (timep);
124     if (s == NULL)
125         return NULL;
126
127     *result = *s;
128     return result;
129 }
130 #endif
131
132 #ifndef HAVE_DIRENT_H
133 typedef void DIR;
134 #   ifndef FILENAME_MAX
135 #       define FILENAME_MAX (260)
136 #   endif
137 struct dirent
138 {
139     long            d_ino;          /* Always zero. */
140     unsigned short  d_reclen;       /* Always zero. */
141     unsigned short  d_namlen;       /* Length of name in d_name. */
142     char            d_name[FILENAME_MAX]; /* File name. */
143 };
144 #   define opendir vlc_opendir
145 #   define readdir vlc_readdir
146 #   define closedir vlc_closedir
147 #   define rewinddir vlc_rewindir
148 #   define seekdir vlc_seekdir
149 #   define telldir vlc_telldir
150 VLC_EXPORT( void *, vlc_opendir, ( const char * ) );
151 VLC_EXPORT( void *, vlc_readdir, ( void * ) );
152 VLC_EXPORT( int, vlc_closedir, ( void * ) );
153 VLC_INTERNAL( void, vlc_rewinddir, ( void * ) );
154 VLC_INTERNAL( void, vlc_seekdir, ( void *, long ) );
155 VLC_INTERNAL( long, vlc_telldir, ( void * ) );
156 #endif
157
158 #ifndef HAVE_USELOCALE
159 typedef void *locale_t;
160 # define newlocale( a, b, c ) ((locale_t)0)
161 # define uselocale( a ) ((locale_t)0)
162 # define freelocale( a ) (void)0
163 #endif
164
165 /* libintl support */
166 #define _(str) vlc_gettext (str)
167
168 #if defined (ENABLE_NLS)
169 # include <libintl.h>
170 #else
171 # define dgettext(dom, str) ((char *)(str))
172 #endif
173
174 #define N_(str) gettext_noop (str)
175 #define gettext_noop(str) (str)
176
177 #endif /* !LIBVLC_FIXUPS_H */