Start moving replacement functions to a static import library

This commit is contained in:
Rémi Denis-Courmont 2009-04-10 20:14:10 +03:00
parent 6c3b289822
commit e1a78b744b
21 changed files with 514 additions and 192 deletions

View File

@ -7,13 +7,13 @@
# which have makefiles with distribution information.
# - src (libvlc) is nedeed by modules, mozilla and bindings
# - libs/* are needed by modules
BASE_SUBDIRS = po src bin modules share doc test
BASE_SUBDIRS = po compat src bin modules share doc test
EXTRA_SUBDIRS = m4 extras/package/ipkg \
libs/loader libs/srtp libs/unzip \
projects/mozilla projects/activex
DIST_SUBDIRS = $(BASE_SUBDIRS) $(EXTRA_SUBDIRS)
SUBDIRS = po src
SUBDIRS = po compat src
if LOADER
SUBDIRS += libs/loader
endif

4
compat/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
noinst_LTLIBRARIES = libcompat.la
libcompat_la_SOURCES =
libcompat_la_LIBADD = $(LTLIBOBJS)
libcompat_la_LDFLAGS = -no-undefined

37
compat/asprintf.c Normal file
View File

@ -0,0 +1,37 @@
/*****************************************************************************
* asprintf.c: asprintf() replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdarg.h>
int asprintf (char **strp, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = vasprintf (strp, fmt, ap);
va_end (ap);
return ret;
}

30
compat/atof.c Normal file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* atof.c: atof replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
double atof (const char *str)
{
return strtod (str, NULL);
}

30
compat/atoll.c Normal file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* atoll.c: atoll replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
long long atoll (const char *str)
{
return strtoll (str, NULL, 10);
}

29
compat/lldiv.c Normal file
View File

@ -0,0 +1,29 @@
/*****************************************************************************
* lldiv.c: lldiv replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
lldiv_t lldiv (long long num, long long denom)
{
lldiv_t d = { num / denom, num % demon, };
return d;
}

35
compat/strdup.c Normal file
View File

@ -0,0 +1,35 @@
/*****************************************************************************
* strdup.c: strdup replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <stdlib.h>
char *strdup (const char *str)
{
size_t len = strlen (str) + 1;
char *res = malloc (len);
if (res)
memcpy (res, str, len);
return res;
}

52
compat/strlcpy.c Normal file
View File

@ -0,0 +1,52 @@
/*****************************************************************************
* strlcpy.c: BSD strlcpy replacement
*****************************************************************************
* Copyright © 2006 Rémi Denis-Courmont
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stddef.h>
/**
* 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)
*/
size_t 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;
}

38
compat/strndup.c Normal file
View File

@ -0,0 +1,38 @@
/*****************************************************************************
* strndup.c: strndup replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <stdlib.h>
char *strndup (const char *str, size_t max)
{
size_t len = strnlen (str, max);
char *res = malloc (len + 1);
if (res)
{
memcpy (res, str, len);
res[len] = '\0';
}
return res;
}

31
compat/strnlen.c Normal file
View File

@ -0,0 +1,31 @@
/*****************************************************************************
* strnlen.c: strnlen replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
size_t strnlen (const char *str, size_t max)
{
const char *end = memchr (str, 0, max);
return end ? (size_t)(end - str) : max;
}

43
compat/strsep.c Normal file
View File

@ -0,0 +1,43 @@
/*****************************************************************************
* strsep.c: BSD strsep replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
char *strsep( char **ppsz_string, const char *psz_delimiters )
{
char *psz_string = *ppsz_string;
if( !psz_string )
return NULL;
char *p = strpbrk( psz_string, psz_delimiters );
if( !p )
{
*ppsz_string = NULL;
return psz_string;
}
*p++ = '\0';
*ppsz_string = p;
return psz_string;
}

30
compat/strtof.c Normal file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* strtof.c: strtof replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
float strtof (const char *str, char **end)
{
return strtod (str, end);
}

92
compat/strtoll.c Normal file
View File

@ -0,0 +1,92 @@
/*****************************************************************************
* strtoll.c: strtoll replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
long long int strtof( const char *nptr, char **endptr, int base )
{
long long i_value = 0;
int sign = 1, newbase = base ? base : 10;
nptr += strspn( nptr, "\t " );
if( *nptr == '-' )
{
sign = -1;
nptr++;
}
/* Try to detect base */
if( *nptr == '0' )
{
newbase = 8;
nptr++;
if( *nptr == 'x' )
{
newbase = 16;
nptr++;
}
}
if( base && newbase != base )
{
if( endptr ) *endptr = (char *)nptr;
return i_value;
}
switch( newbase )
{
case 10:
while( *nptr >= '0' && *nptr <= '9' )
{
i_value *= 10;
i_value += ( *nptr++ - '0' );
}
if( endptr ) *endptr = (char *)nptr;
break;
case 16:
while( (*nptr >= '0' && *nptr <= '9') ||
(*nptr >= 'a' && *nptr <= 'f') ||
(*nptr >= 'A' && *nptr <= 'F') )
{
int i_valc = 0;
if(*nptr >= '0' && *nptr <= '9') i_valc = *nptr - '0';
else if(*nptr >= 'a' && *nptr <= 'f') i_valc = *nptr - 'a' +10;
else if(*nptr >= 'A' && *nptr <= 'F') i_valc = *nptr - 'A' +10;
i_value *= 16;
i_value += i_valc;
nptr++;
}
if( endptr ) *endptr = (char *)nptr;
break;
default:
i_value = strtol( nptr, endptr, newbase );
break;
}
return i_value * sign;
}

37
compat/vasprintf.c Normal file
View File

@ -0,0 +1,37 @@
/*****************************************************************************
* vasprintf.c: vasprintf replacement
*****************************************************************************
* Copyright © 1998-2008 the VideoLAN project
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int vasprintf (char **strp, const char *fmt, va_list ap)
{
ssize_t len = vsnprintf (NULL, 0, fmt, ap) + 1;
char *res = malloc (len);
if (res == NULL)
return -1;
*strp = res;
return vsnprintf (res, len, fmt, ap);
}

View File

@ -18,6 +18,7 @@ AC_PREREQ(2.59c)
AC_CONFIG_SRCDIR(src/libvlc.c)
AC_CONFIG_AUX_DIR(autotools)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_LIBOBJ_DIR(compat)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
@ -550,12 +551,13 @@ dnl Check for system libs needed
need_libc=false
dnl Check for usual libc functions
AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv posix_fadvise posix_madvise uselocale])
AC_CHECK_FUNCS([gettimeofday isatty swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon fork bsearch lstat posix_fadvise posix_madvise uselocale])
AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)])
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(fcntl)
AC_REPLACE_FUNCS([asprintf atof atoll lldiv strdup strlcpy strndup strnlen strsep strtof strtoll vasprintf])
dnl Check for Linux system calls
AC_CHECK_FUNCS([vmsplice])
@ -5964,6 +5966,7 @@ AC_CONFIG_FILES([
share/Makefile
share/vlc_win32_rc.rc
share/libvlc_win32_rc.rc
compat/Makefile
src/Makefile
src/test/Makefile
bin/Makefile

View File

@ -731,9 +731,6 @@ static inline uint64_t ntoh64 (uint64_t ll)
#define VLC_UNUSED(x) (void)(x)
/* Stuff defined in src/extras/libc.c */
VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) LIBVLC_USED );
VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) LIBVLC_USED );
#if defined(WIN32) || defined(UNDER_CE)

View File

@ -40,109 +40,51 @@
#endif
#ifndef HAVE_STRDUP
# include <string.h>
# include <stdlib.h>
static inline char *strdup (const char *str)
{
size_t len = strlen (str) + 1;
char *res = (char *)malloc (len);
if (res) memcpy (res, str, len);
return res;
}
char *strdup (const char *);
#endif
#ifndef HAVE_VASPRINTF
# include <stdio.h>
# include <stdlib.h>
# include <stdarg.h>
static inline int vasprintf (char **strp, const char *fmt, va_list ap)
{
int len = vsnprintf (NULL, 0, fmt, ap) + 1;
char *res = (char *)malloc (len);
if (res == NULL)
return -1;
*strp = res;
return vsnprintf (res, len, fmt, ap);
}
int vasprintf (char **, const char *, va_list);
#endif
#ifndef HAVE_ASPRINTF
# include <stdio.h>
# include <stdarg.h>
static inline int asprintf (char **strp, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = vasprintf (strp, fmt, ap);
va_end (ap);
return ret;
}
int asprintf (char **, const char *, ...);
#endif
#ifndef HAVE_STRNLEN
# include <string.h>
static inline size_t strnlen (const char *str, size_t max)
{
const char *end = (const char *) memchr (str, 0, max);
return end ? (size_t)(end - str) : max;
}
# include <stddef.h>
size_t strnlen (const char *, size_t);
#endif
#ifndef HAVE_STRNDUP
# include <string.h>
# include <stdlib.h>
static inline char *strndup (const char *str, size_t max)
{
size_t len = strnlen (str, max);
char *res = (char *) malloc (len + 1);
if (res)
{
memcpy (res, str, len);
res[len] = '\0';
}
return res;
}
# include <stddef.h>
char *strndup (const char *, size_t);
#endif
#ifndef HAVE_STRLCPY
# define strlcpy vlc_strlcpy
# include <stddef.h>
size_t strlcpy (char *, const char *, size_t);
#endif
#ifndef HAVE_STRTOF
# define strtof( a, b ) ((float)strtod (a, b))
float strtof (const char *, char **);
#endif
#ifndef HAVE_ATOF
# define atof( str ) (strtod ((str), (char **)NULL, 10))
double atof (const char *);
#endif
#ifndef HAVE_STRTOLL
# define strtoll vlc_strtoll
long long int strtoll (const char *, char **, int);
#endif
#ifndef HAVE_STRSEP
static inline char *strsep( char **ppsz_string, const char *psz_delimiters )
{
char *psz_string = *ppsz_string;
if( !psz_string )
return NULL;
char *p = strpbrk( psz_string, psz_delimiters );
if( !p )
{
*ppsz_string = NULL;
return psz_string;
}
*p++ = '\0';
*ppsz_string = p;
return psz_string;
}
char *strsep (char **, const char *);
#endif
#ifndef HAVE_ATOLL
# define atoll( str ) (strtoll ((str), (char **)NULL, 10))
long long atoll (const char *);
#endif
#ifndef HAVE_LLDIV
@ -151,11 +93,7 @@ typedef struct {
long long rem; /* Remainder. */
} lldiv_t;
static inline lldiv_t lldiv (long long numer, long long denom)
{
lldiv_t d = { .quot = numer / denom, .rem = numer % denom };
return d;
}
lldiv_t lldiv (long long, long long);
#endif
#ifndef HAVE_GETENV

View File

@ -23,7 +23,8 @@ AM_LDFLAGS = -rpath '$(libvlcdir)' \
-shrext $(LIBEXT) \
-no-undefined \
`$(VLC_CONFIG) --ldflags plugin $@`
AM_LIBADD = `$(VLC_CONFIG) -libs plugin $@` $(LTLIBVLCCORE)
AM_LIBADD = `$(VLC_CONFIG) -libs plugin $@` \
$(LTLIBVLCCORE) $(top_builddir)/compat/libcompat.la
include $(srcdir)/Modules.am

View File

@ -157,9 +157,11 @@ libvlccore_la_CFLAGS = `$(VLC_CONFIG) --cflags libvlc` \
-DLIBDIR=\"$(libdir)\" \
-DPLUGIN_PATH=\"$(vlclibdir)\"
libvlccore_la_LDFLAGS = `$(VLC_CONFIG) --ldflags libvlc` $(AM_LDFLAGS) \
-no-undefined \
-export-symbols $(srcdir)/libvlccore.sym \
-version-info 2:0:0
libvlccore_la_LIBADD = `$(VLC_CONFIG) -libs libvlc` $(AM_LIBADD) $(LTLIBINTL)
libvlccore_la_LIBADD = `$(VLC_CONFIG) -libs libvlc` $(AM_LIBADD) \
$(LTLIBINTL) ../compat/libcompat.la
libvlccore_la_DEPENDENCIES = libvlccore.sym
if HAVE_WIN32
libvlccore_la_DEPENDENCIES += libvlc_win32_rc.$(OBJEXT)

View File

@ -101,111 +101,6 @@ char * vlc_strcasestr( const char *psz_big, const char *psz_little )
#endif
}
/*****************************************************************************
* strtoll: convert a string to a 64 bits int.
*****************************************************************************/
long long vlc_strtoll( const char *nptr, char **endptr, int base )
{
#if defined( HAVE_STRTOLL )
return strtoll( nptr, endptr, base );
#else
long long i_value = 0;
int sign = 1, newbase = base ? base : 10;
while( isspace(*nptr) ) nptr++;
if( *nptr == '-' )
{
sign = -1;
nptr++;
}
/* Try to detect base */
if( *nptr == '0' )
{
newbase = 8;
nptr++;
if( *nptr == 'x' )
{
newbase = 16;
nptr++;
}
}
if( base && newbase != base )
{
if( endptr ) *endptr = (char *)nptr;
return i_value;
}
switch( newbase )
{
case 10:
while( *nptr >= '0' && *nptr <= '9' )
{
i_value *= 10;
i_value += ( *nptr++ - '0' );
}
if( endptr ) *endptr = (char *)nptr;
break;
case 16:
while( (*nptr >= '0' && *nptr <= '9') ||
(*nptr >= 'a' && *nptr <= 'f') ||
(*nptr >= 'A' && *nptr <= 'F') )
{
int i_valc = 0;
if(*nptr >= '0' && *nptr <= '9') i_valc = *nptr - '0';
else if(*nptr >= 'a' && *nptr <= 'f') i_valc = *nptr - 'a' +10;
else if(*nptr >= 'A' && *nptr <= 'F') i_valc = *nptr - 'A' +10;
i_value *= 16;
i_value += i_valc;
nptr++;
}
if( endptr ) *endptr = (char *)nptr;
break;
default:
i_value = strtol( nptr, endptr, newbase );
break;
}
return i_value * sign;
#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)
*/
extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize)
{
#ifdef HAVE_STRLCPY
return strlcpy (tgt, src, bufsize);
#else
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 '\'

View File

@ -486,8 +486,6 @@ vlc_sd_Start
vlc_sd_Stop
vlc_sendmsg
vlc_strcasestr
vlc_strlcpy
vlc_strtoll
vlc_testcancel
vlc_thread_create
__vlc_thread_join