]> git.sesse.net Git - vlc/commitdiff
Fix another series of HAVE_ dependencies (string replacement functions mostly).
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 27 Jan 2008 16:31:12 +0000 (16:31 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 27 Jan 2008 16:31:12 +0000 (16:31 +0000)
Now vlc/vlc.h can be included out of the box.
However, I believe it will only work properly on little-endian 32-bits platforms.

configure.ac
include/vlc_common.h
include/vlc_fixups.h [new file with mode: 0644]
src/extras/libc.c
src/test/headers.c

index 71c5d33f7261d97577f94e00be5684a4617e8c3a..fca164e6f7fc76f2d512b6206acc70d4bb313819 100644 (file)
@@ -470,14 +470,14 @@ CPPFLAGS_save="${CPPFLAGS_save} -DSYS_`echo ${SYS} | sed -e 's/-.*//' | tr 'abcd
 dnl Check for system libs needed
 need_libc=false
 
-AC_CHECK_FUNCS(gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy)
-
 dnl Check for usual libc functions
-AC_CHECK_FUNCS(strdup strndup strnlen atof)
+AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv])
 AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
 AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
 AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)])
 
+AH_BOTTOM([#include <vlc_fixups.h>])
+
 AS_IF([test "${SYS}" = "linux"], [
   AC_CHECK_FUNCS(tee)
 ])
index b4ab83cec5119ae377f233885c352209c1e4a988..3ffde4c544d92432fd6bcd2e0db7ce8e3e7c78bd 100644 (file)
@@ -816,57 +816,14 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
 #define VLC_UNUSED(x) (void)(x)
 
 /* Stuff defined in src/extras/libc.c */
-#ifndef HAVE_STRDUP
-#   define strdup vlc_strdup
-    VLC_EXPORT( char *, vlc_strdup, ( const char *s ) );
-#endif
-
-#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
-#   define vasprintf vlc_vasprintf
-    VLC_EXPORT( int, vlc_vasprintf, (char **, const char *, va_list ) );
-#endif
-
-#if !defined(HAVE_ASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
-#   define asprintf vlc_asprintf
-    VLC_EXPORT( int, vlc_asprintf, (char **, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
-#endif
-
-#ifndef HAVE_STRNDUP
-#   if defined(STRNDUP_IN_GNOME_H) && \
-        (defined(MODULE_NAME_IS_gnome)||defined(MODULE_NAME_IS_gnome_main)||\
-         defined(MODULE_NAME_IS_gnome2)||defined(MODULE_NAME_IS_gnome2_main))
-        /* Do nothing: gnome.h defines strndup for us */
-#   else
-#       define strndup vlc_strndup
-        VLC_EXPORT( char *, vlc_strndup, ( const char *s, size_t n ) );
-#   endif
-#endif
-
-#ifndef HAVE_STRLCPY
-#   define strlcpy vlc_strlcpy
-    VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
-#endif
-
-#ifndef HAVE_ATOF
-#   define atof vlc_atof
-    VLC_EXPORT( double, vlc_atof, ( const char *nptr ) );
-#endif
-
-#ifndef HAVE_STRTOF
-#   ifdef HAVE_STRTOD
-#       define strtof strtod
-#   endif
-#endif
-
-#ifndef HAVE_ATOLL
-#   define atoll vlc_atoll
-    VLC_EXPORT( int64_t, vlc_atoll, ( const char *nptr ) );
-#endif
-
-#ifndef HAVE_STRTOLL
-#   define strtoll vlc_strtoll
-    VLC_EXPORT( int64_t, vlc_strtoll, ( const char *nptr, char **endptr, int base ) );
-#endif
+VLC_EXPORT( char *, vlc_strdup, ( const char *s ) );
+VLC_EXPORT( int, vlc_vasprintf, (char **, const char *, va_list ) );
+VLC_EXPORT( int, vlc_asprintf, (char **, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
+VLC_EXPORT( char *, vlc_strndup, ( const char *s, size_t n ) );
+VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
+VLC_EXPORT( double, vlc_atof, ( const char *nptr ) );
+VLC_EXPORT( int64_t, vlc_atoll, ( const char *nptr ) );
+VLC_EXPORT( int64_t, vlc_strtoll, ( const char *nptr, char **endptr, int base ) );
 
 #if defined(SYS_BEOS) \
  || (defined (__FreeBSD__) && (__FreeBSD__ < 5))
@@ -874,49 +831,18 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
         long long quot; /* Quotient. */
         long long rem;  /* Remainder. */
     } lldiv_t;
-#   define lldiv vlc_lldiv
-    VLC_EXPORT( lldiv_t, vlc_lldiv, ( long long numer, long long denom ) );
-#endif
-
-#ifndef HAVE_SCANDIR
-#   define scandir vlc_scandir
-#   define alphasort vlc_alphasort
-    struct dirent;
-    VLC_EXPORT( int, vlc_scandir, ( const char *name, struct dirent ***namelist, int (*filter) ( const struct dirent * ), int (*compar) ( const struct dirent **, const struct dirent ** ) ) );
-    VLC_EXPORT( int, vlc_alphasort, ( const struct dirent **a, const struct dirent **b ) );
-#endif
-
-#ifndef HAVE_GETENV
-#   define getenv vlc_getenv
-    VLC_EXPORT( char *, vlc_getenv, ( const char *name ) );
 #endif
+VLC_EXPORT( lldiv_t, vlc_lldiv, ( long long numer, long long denom ) );
 
-#ifndef HAVE_STRCASECMP
-#   ifndef HAVE_STRICMP
-#       define strcasecmp vlc_strcasecmp
-        VLC_EXPORT( int, vlc_strcasecmp, ( const char *s1, const char *s2 ) );
-#   else
-#       define strcasecmp stricmp
-#   endif
-#endif
+struct dirent;
+VLC_EXPORT( int, vlc_scandir, ( const char *name, struct dirent ***namelist, int (*filter) ( const struct dirent * ), int (*compar) ( const struct dirent **, const struct dirent ** ) ) );
+VLC_EXPORT( int, vlc_alphasort, ( const struct dirent **a, const struct dirent **b ) );
 
-#ifndef HAVE_STRNCASECMP
-#   ifndef HAVE_STRNICMP
-#       define strncasecmp vlc_strncasecmp
-        VLC_EXPORT( int, vlc_strncasecmp, ( const char *s1, const char *s2, size_t n ) );
-#   else
-#       define strncasecmp strnicmp
-#   endif
-#endif
+VLC_EXPORT( char *, vlc_getenv, ( const char *name ) );
 
-#ifndef HAVE_STRCASESTR
-#   ifndef HAVE_STRISTR
-#       define strcasestr vlc_strcasestr
-        VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) );
-#   else
-#       define strcasestr stristr
-#   endif
-#endif
+VLC_EXPORT( int, vlc_strcasecmp, ( const char *s1, const char *s2 ) );
+VLC_EXPORT( int, vlc_strncasecmp, ( const char *s1, const char *s2, size_t n ) );
+VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) );
 
 #ifndef HAVE_DIRENT_H
     typedef void DIR;
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
new file mode 100644 (file)
index 0000000..c1d370f
--- /dev/null
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * fixups.h: portability fixups included from config.h
+ *****************************************************************************
+ * Copyright © 1998-2007 the VideoLAN project
+ * $Id$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/**
+ * \file
+ * This file is a collection of portability fixes
+ */
+
+#ifndef HAVE_STRDUP
+# define strdup vlc_strdup
+#endif
+
+#ifndef HAVE_VASPRINTF
+# define vasprintf vlc_vasprintf
+#endif
+
+#ifndef HAVE_ASPRINTF
+# define asprintf vlc_asprintf
+#endif
+
+#ifndef HAVE_STRNDUP
+# define strndup vlc_strndup
+#endif
+
+#ifndef HAVE_STRLCPY
+# define strlcpy vlc_strlcpy
+#endif
+
+#ifndef HAVE_ATOF
+# define atof vlc_atof
+#endif
+
+#ifndef HAVE_STRTOF
+# ifdef HAVE_STRTOD
+#  define strtof( a, b ) ((float)strtod (a, b))
+# endif
+#endif
+
+#ifndef HAVE_ATOLL
+# define atoll vlc_atoll
+#endif
+
+#ifndef HAVE_STRTOLL
+# define strtoll vlc_strtoll
+#endif
+
+#ifndef HAVE_LLDIV
+# define lldiv vlc_lldiv
+#endif
+
+#ifndef HAVE_SCANDIR
+# define scandir vlc_scandir
+# define alphasort vlc_alphasort
+#endif
+
+#ifndef HAVE_GETENV
+# define getenv vlc_getenv
+#endif
+
+#ifndef HAVE_STRCASECMP
+# ifndef HAVE_STRICMP
+#  define strcasecmp vlc_strcasecmp
+# else
+#  define strcasecmp stricmp
+# endif
+#endif
+
+#ifndef HAVE_STRNCASECMP
+# ifndef HAVE_STRNICMP
+#  define strncasecmp vlc_strncasecmp
+# else
+#  define strncasecmp strnicmp
+# endif
+#endif
+
+#ifndef HAVE_STRCASESTR
+# ifndef HAVE_STRISTR
+#  define strcasestr vlc_strcasestr
+# else
+#  define strcasestr stristr
+# endif
+#endif
+
index 4309aefa9feea9173bbfbc7e3ccf0f8987299c51..826cc578549e7cc190c545a4b531e4e49ee2274f 100644 (file)
@@ -375,8 +375,7 @@ int64_t vlc_atoll( const char *nptr )
 /*****************************************************************************
  * lldiv: returns quotient and remainder
  *****************************************************************************/
-#if defined(SYS_BEOS) \
- || (defined (__FreeBSD__) && (__FreeBSD__ < 5))
+#if !defined( HAVE_LLDIV )
 lldiv_t vlc_lldiv( long long numer, long long denom )
 {
     lldiv_t d;
index 50b7188519ff73c3cf14780a5eb727f23fbcb7b3..986f79831b0fbd85cb51faaac8316dd95c078d30 100644 (file)
@@ -24,6 +24,8 @@
 /* One thing we don't check is the CPPFLAGS - these MUST be exposed publicly,
  * e.g. using pkg-config or the broken old vlc-config. */
 
+#define PACKAGE "vlc"
+
 #include <vlc/vlc.h>
 #include <vlc/libvlc.h>
 #include <vlc/libvlc_structures.h>