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)
+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 atof)
# define vlc_strndup NULL
#endif
+#ifndef HAVE_STRLCPY
+# define strlcpy vlc_strlcpy
+ VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
+#elif !defined(__PLUGIN__)
+# define vlc_strlcpy NULL
+#endif
+
#ifndef HAVE_ATOF
# define atof vlc_atof
VLC_EXPORT( double, vlc_atof, ( const char *nptr ) );
char * (*decode_URI_duplicate_inner) (const char *psz);
void (*decode_URI_inner) (char *psz);
char * (*encode_URI_component_inner) (const char *psz);
+ size_t (*vlc_strlcpy_inner) (char *, const char *, size_t);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
# define decode_URI_duplicate (p_symbols)->decode_URI_duplicate_inner
# define decode_URI (p_symbols)->decode_URI_inner
# define encode_URI_component (p_symbols)->encode_URI_component_inner
+# define vlc_strlcpy (p_symbols)->vlc_strlcpy_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
((p_symbols)->decode_URI_duplicate_inner) = decode_URI_duplicate; \
((p_symbols)->decode_URI_inner) = decode_URI; \
((p_symbols)->encode_URI_component_inner) = encode_URI_component; \
+ ((p_symbols)->vlc_strlcpy_inner) = vlc_strlcpy; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__stats_CounterGet_deprecated = NULL; \
(p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \
net_resource.dwType = RESOURCETYPE_DISK;
/* Find out server and share names */
- strncpy( psz_server, psz_path, sizeof( psz_server ) );
- psz_server[sizeof (psz_server) - 1] = '\0';
+ strlcpy( psz_server, psz_path, sizeof( psz_server ) );
psz_share[0] = 0;
psz_parser = strchr( psz_path, '/' );
if( psz_parser )
{
char *psz_parser2 = strchr( ++psz_parser, '/' );
if( psz_parser2 )
- {
- strncpy( psz_share, psz_parser, sizeof( psz_share ) );
- psz_parse[sizeof (psz_parse) - 1] = '\0';
- }
+ strlcpy( psz_share, psz_parser, sizeof( psz_share ) );
}
sprintf( psz_remote, "\\\\%s\\%s", psz_server, psz_share );
/*****************************************************************************
* libc.c: Extra libc function for some systems.
*****************************************************************************
- * Copyright (C) 2002 the VideoLAN team
+ * Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Gildas Bazin <gbazin@videolan.org>
* Derk-Jan Hartman <hartman at videolan dot org>
* Christophe Massiot <massiot@via.ecp.fr>
+ * Rémi Denis-Courmont <rem à videolan.org>
*
* 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
}
#endif
+
+/**
+ * Copy a string to a sized buffer. The result is always nul-terminated
+ * (contrary to strncpy()).
+ *
+ * @param dest destination buffer
+ * @param src string to be copied
+ * @param len maximum number of characters to be copied plus one for the
+ * terminating nul.
+ *
+ * @return strlen(src)
+ */
+#ifndef HAVE_STRLCPY
+extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize)
+{
+ size_t length;
+
+ for (length = 1; (length < bufsize) && *src; length++)
+ *tgt++ = *src++;
+
+ if (bufsize)
+ *tgt = '\0';
+
+ while (*src++)
+ length++;
+
+ return length - 1;
+}
+#endif
+
/*****************************************************************************
* vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
* when called with an empty argument or just '\'