Changeset f160db450ae04c034b306510eaca1aeddc2364b3
- Timestamp:
- 24/05/08 18:57:58 (5 months ago)
- git-parent:
- Files:
-
- include/vlc_common.h (modified) (1 diff)
- include/vlc_fixups.h (modified) (1 diff)
- src/extras/libc.c (modified) (4 diffs)
- src/libvlccore.sym (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_common.h
rc80de55 rf160db4 720 720 721 721 /* 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 ) );724 722 VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) ); 725 723 VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) ); include/vlc_fixups.h
r86af35f rf160db4 41 41 42 42 #ifndef HAVE_VASPRINTF 43 # define vasprintf vlc_vasprintf 43 # include <stdarg.h> 44 static 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 } 44 53 #endif 45 54 46 55 #ifndef HAVE_ASPRINTF 47 # define asprintf vlc_asprintf 56 # include <stdarg.h> 57 static 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 } 48 66 #endif 49 67 src/extras/libc.c
rc80de55 rf160db4 75 75 * Case sensitive. Return NULL if not found, return big if little == null 76 76 *****************************************************************************/ 77 #if !defined( HAVE_STRCASESTR ) && !defined( HAVE_STRISTR )78 77 char * vlc_strcasestr( const char *psz_big, const char *psz_little ) 79 78 { 79 #if defined (HAVE_STRCASESTR) || defined (HAVE_STRISTR) 80 return strcasestr (psz_big, psz_little); 81 #else 80 82 char *p_pos = (char *)psz_big; 81 83 … … 99 101 } 100 102 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 } 166 105 167 106 /***************************************************************************** … … 250 189 * @return strlen(src) 251 190 */ 252 #ifndef HAVE_STRLCPY253 191 extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize) 254 192 { 193 #ifdef HAVE_STRLCPY 194 return strlcpy (tgt, src, bufsize); 195 #else 255 196 size_t length; 256 197 … … 265 206 266 207 return length - 1; 267 } 268 #endif 208 #endif 209 } 269 210 270 211 /***************************************************************************** src/libvlccore.sym
r59feb95 rf160db4 368 368 __var_TriggerCallback 369 369 __var_Type 370 vlc_asprintf371 370 vlc_b64_decode 372 371 vlc_b64_decode_binary … … 432 431 vlc_rand_bytes 433 432 vlc_sdp_Start 433 vlc_strlcpy 434 434 vlc_strtoll 435 435 vlc_submodule_create … … 441 441 vlc_threadvar_delete 442 442 vlc_ureduce 443 vlc_vasprintf444 443 VLC_Version 445 444 vlc_wraptext
