Changeset f160db450ae04c034b306510eaca1aeddc2364b3

Show
Ignore:
Timestamp:
24/05/08 18:57:58 (5 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1211648278 +0300
git-parent:

[04e6970605c4c6f63d8ab507bca5126612c98625]

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

Inline and fix some linking errors

Should fix strlcpy() issues on Linux, but Win32 is surely still totally
broken by d754b40584b5fd5ffd5f39a2288a14f9f4662f78

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    rc80de55 rf160db4  
    720720 
    721721/* Stuff defined in src/extras/libc.c */ 
    722 VLC_EXPORT( int, vlc_vasprintf, (char **, const char *, va_list ) ); 
    723 VLC_EXPORT( int, vlc_asprintf, (char **, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) ); 
    724722VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) ); 
    725723VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) ); 
  • include/vlc_fixups.h

    r86af35f rf160db4  
    4141 
    4242#ifndef HAVE_VASPRINTF 
    43 # define vasprintf vlc_vasprintf 
     43# include <stdarg.h> 
     44static inline int vasprintf (char **strp, const char *fmt, va_list ap) 
     45
     46    int len = vsnprintf (NULL, 0, fmt, ap) + 1; 
     47    char *res = malloc (len); 
     48    if (res == NULL) 
     49        return -1; 
     50    *strp = res; 
     51    return vsprintf (res, fmt, ap); 
     52
    4453#endif 
    4554 
    4655#ifndef HAVE_ASPRINTF 
    47 # define asprintf vlc_asprintf 
     56# include <stdarg.h> 
     57static inline int asprintf (char **strp, const char *fmt, ...) 
     58
     59    va_list ap; 
     60    int ret; 
     61    va_start (fmt, ap); 
     62    ret = vasprintf (strp, fmt, ap); 
     63    va_end (ap); 
     64    return ret; 
     65
    4866#endif 
    4967 
  • src/extras/libc.c

    rc80de55 rf160db4  
    7575 * Case sensitive. Return NULL if not found, return big if little == null 
    7676 *****************************************************************************/ 
    77 #if !defined( HAVE_STRCASESTR ) && !defined( HAVE_STRISTR ) 
    7877char * vlc_strcasestr( const char *psz_big, const char *psz_little ) 
    7978{ 
     79#if defined (HAVE_STRCASESTR) || defined (HAVE_STRISTR) 
     80    return strcasestr (psz_big, psz_little); 
     81#else 
    8082    char *p_pos = (char *)psz_big; 
    8183 
     
    99101    } 
    100102    return NULL; 
    101 
    102 #endif 
    103  
    104 /***************************************************************************** 
    105  * vasprintf: 
    106  *****************************************************************************/ 
    107 #if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS) 
    108 int vlc_vasprintf(char **strp, const char *fmt, va_list ap) 
    109 
    110     /* Guess we need no more than 100 bytes. */ 
    111     int     i_size = 100; 
    112     char    *p = malloc( i_size ); 
    113     int     n; 
    114  
    115     if( p == NULL ) 
    116     { 
    117         *strp = NULL; 
    118         return -1; 
    119     } 
    120  
    121     for( ;; ) 
    122     { 
    123         /* Try to print in the allocated space. */ 
    124         n = vsnprintf( p, i_size, fmt, ap ); 
    125  
    126         /* If that worked, return the string. */ 
    127         if (n > -1 && n < i_size) 
    128         { 
    129             *strp = p; 
    130             return strlen( p ); 
    131         } 
    132         /* Else try again with more space. */ 
    133         if (n > -1)    /* glibc 2.1 */ 
    134         { 
    135            i_size = n+1; /* precisely what is needed */ 
    136         } 
    137         else           /* glibc 2.0 */ 
    138         { 
    139            i_size *= 2;  /* twice the old size */ 
    140         } 
    141         if( (p = realloc( p, i_size ) ) == NULL) 
    142         { 
    143             *strp = NULL; 
    144             return -1; 
    145         } 
    146     } 
    147 
    148 #endif 
    149  
    150 /***************************************************************************** 
    151  * asprintf: 
    152  *****************************************************************************/ 
    153 #if !defined(HAVE_ASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS) 
    154 int vlc_asprintf( char **strp, const char *fmt, ... ) 
    155 
    156     va_list args; 
    157     int i_ret; 
    158  
    159     va_start( args, fmt ); 
    160     i_ret = vasprintf( strp, fmt, args ); 
    161     va_end( args ); 
    162  
    163     return i_ret; 
    164 
    165 #endif 
     103#endif 
     104
    166105 
    167106/***************************************************************************** 
     
    250189 * @return strlen(src) 
    251190 */ 
    252 #ifndef HAVE_STRLCPY 
    253191extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize) 
    254192{ 
     193#ifdef HAVE_STRLCPY 
     194    return strlcpy (tgt, src, bufsize); 
     195#else 
    255196    size_t length; 
    256197 
     
    265206 
    266207    return length - 1; 
    267 
    268 #endif 
     208#endif 
     209
    269210 
    270211/***************************************************************************** 
  • src/libvlccore.sym

    r59feb95 rf160db4  
    368368__var_TriggerCallback 
    369369__var_Type 
    370 vlc_asprintf 
    371370vlc_b64_decode 
    372371vlc_b64_decode_binary 
     
    432431vlc_rand_bytes 
    433432vlc_sdp_Start 
     433vlc_strlcpy 
    434434vlc_strtoll 
    435435vlc_submodule_create 
     
    441441vlc_threadvar_delete 
    442442vlc_ureduce 
    443 vlc_vasprintf 
    444443VLC_Version 
    445444vlc_wraptext