Changeset 83d3320758201fc208b3a0e011af10c5e26bd7fe

Show
Ignore:
Timestamp:
04/29/06 16:30:49 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1146321049 +0000
git-parent:

[0a930be206c0211be8a48a7a31749f91eeeca424]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1146321049 +0000
Message:

OpenBSDish strlcpy()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r8a50049 r83d3320  
    405405need_libc=false 
    406406 
    407 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
     407AC_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
    408408 
    409409dnl Check for usual libc functions 
  • include/vlc_common.h

    rbe639de2 r83d3320  
    847847#endif 
    848848 
     849#ifndef HAVE_STRLCPY 
     850#   define strlcpy vlc_strlcpy 
     851    VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) ); 
     852#elif !defined(__PLUGIN__) 
     853#   define vlc_strlcpy NULL 
     854#endif 
     855 
    849856#ifndef HAVE_ATOF 
    850857#   define atof vlc_atof 
  • include/vlc_symbols.h

    r2ad5cc2 r83d3320  
    492492    void (*decode_URI_inner) (char *psz); 
    493493    char * (*encode_URI_component_inner) (const char *psz); 
     494    size_t (*vlc_strlcpy_inner) (char *, const char *, size_t); 
    494495}; 
    495496# if defined (__PLUGIN__) 
     
    963964#  define decode_URI (p_symbols)->decode_URI_inner 
    964965#  define encode_URI_component (p_symbols)->encode_URI_component_inner 
     966#  define vlc_strlcpy (p_symbols)->vlc_strlcpy_inner 
    965967# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 
    966968/****************************************************************** 
     
    14371439    ((p_symbols)->decode_URI_inner) = decode_URI; \ 
    14381440    ((p_symbols)->encode_URI_component_inner) = encode_URI_component; \ 
     1441    ((p_symbols)->vlc_strlcpy_inner) = vlc_strlcpy; \ 
    14391442    (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 
    14401443    (p_symbols)->__stats_CounterGet_deprecated = NULL; \ 
  • modules/access/smb.c

    rf4a8731 r83d3320  
    458458 
    459459    /* Find out server and share names */ 
    460     strncpy( psz_server, psz_path, sizeof( psz_server ) ); 
    461     psz_server[sizeof (psz_server) - 1] = '\0'; 
     460    strlcpy( psz_server, psz_path, sizeof( psz_server ) ); 
    462461    psz_share[0] = 0; 
    463462    psz_parser = strchr( psz_path, '/' ); 
     
    466465        char *psz_parser2 = strchr( ++psz_parser, '/' ); 
    467466        if( psz_parser2 ) 
    468         { 
    469             strncpy( psz_share, psz_parser, sizeof( psz_share ) ); 
    470             psz_parse[sizeof (psz_parse) - 1] = '\0'; 
    471         } 
     467            strlcpy( psz_share, psz_parser, sizeof( psz_share ) ); 
    472468   } 
    473469 
  • src/extras/libc.c

    r470b47f r83d3320  
    22 * libc.c: Extra libc function for some systems. 
    33 ***************************************************************************** 
    4  * Copyright (C) 2002 the VideoLAN team 
     4 * Copyright (C) 2002-2006 the VideoLAN team 
    55 * $Id$ 
    66 * 
     
    1010 *          Derk-Jan Hartman <hartman at videolan dot org> 
    1111 *          Christophe Massiot <massiot@via.ecp.fr> 
     12 *          Rémi Denis-Courmont <rem à videolan.org> 
    1213 * 
    1314 * This program is free software; you can redistribute it and/or modify 
     
    354355    d.rem  = numer % denom; 
    355356    return d; 
     357} 
     358#endif 
     359 
     360 
     361/** 
     362 * Copy a string to a sized buffer. The result is always nul-terminated 
     363 * (contrary to strncpy()). 
     364 * 
     365 * @param dest destination buffer 
     366 * @param src string to be copied 
     367 * @param len maximum number of characters to be copied plus one for the 
     368 * terminating nul. 
     369 * 
     370 * @return strlen(src) 
     371 */ 
     372#ifndef HAVE_STRLCPY 
     373extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize) 
     374{ 
     375    size_t length; 
     376 
     377    for (length = 1; (length < bufsize) && *src; length++) 
     378        *tgt++ = *src++; 
     379 
     380    if (bufsize) 
     381        *tgt = '\0'; 
     382 
     383    while (*src++) 
     384        length++; 
     385 
     386    return length - 1; 
    356387} 
    357388#endif