]> git.sesse.net Git - vlc/blob - include/vlc_fixups.h
Factorize the localtime_r replacement
[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 HAVE_STRDUP
28 # define strdup vlc_strdup
29 #endif
30
31 #ifndef HAVE_VASPRINTF
32 # define vasprintf vlc_vasprintf
33 #endif
34
35 #ifndef HAVE_ASPRINTF
36 # define asprintf vlc_asprintf
37 #endif
38
39 #ifndef HAVE_STRNDUP
40 # define strndup vlc_strndup
41 #endif
42
43 #ifndef HAVE_STRNLEN
44 # define strnlen vlc_strnlen
45 #endif
46
47 #ifndef HAVE_STRLCPY
48 # define strlcpy vlc_strlcpy
49 #endif
50
51 #ifndef HAVE_ATOF
52 # define atof vlc_atof
53 #endif
54
55 #ifndef HAVE_STRTOF
56 # ifdef HAVE_STRTOD
57 #  define strtof( a, b ) ((float)strtod (a, b))
58 # endif
59 #endif
60
61 #ifndef HAVE_ATOLL
62 # define atoll vlc_atoll
63 #endif
64
65 #ifndef HAVE_STRTOLL
66 # define strtoll vlc_strtoll
67 #endif
68
69 #ifndef HAVE_LLDIV
70 # define lldiv vlc_lldiv
71 #endif
72
73 #ifndef HAVE_SCANDIR
74 # define scandir vlc_scandir
75 # define alphasort vlc_alphasort
76 #endif
77
78 #ifndef HAVE_GETENV
79 # define getenv vlc_getenv
80 #endif
81
82 #ifndef HAVE_STRCASECMP
83 # ifndef HAVE_STRICMP
84 #  define strcasecmp vlc_strcasecmp
85 # else
86 #  define strcasecmp stricmp
87 # endif
88 #endif
89
90 #ifndef HAVE_STRNCASECMP
91 # ifndef HAVE_STRNICMP
92 #  define strncasecmp vlc_strncasecmp
93 # else
94 #  define strncasecmp strnicmp
95 # endif
96 #endif
97
98 #ifndef HAVE_STRCASESTR
99 # ifndef HAVE_STRISTR
100 #  define strcasestr vlc_strcasestr
101 # else
102 #  define strcasestr stristr
103 # endif
104 #endif
105
106 #ifndef HAVE_LOCALTIME_R
107 /* If localtime_r() is not provided, we assume localtime() uses
108  * thread-specific storage. */
109 # include <time.h>
110 static struct tm *localtime_r (const time_t *timep, struct tm *result)
111 {
112     struct tm *s = localtime (timep);
113     if (s == NULL)
114         return NULL;
115
116     *result = *s;
117     return result;
118 }
119 #endif
120