1 /*****************************************************************************
2 * strings.c: String related functions
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan dot org>
8 * Daniel Stranger <vlc at schmaller dot de>
9 * Rémi Denis-Courmont <rem # videolan org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
32 /* Needed by str_format_time */
35 /* Needed by str_format_meta */
36 #include <vlc_input.h>
38 #include <vlc_playlist.h>
41 #include <vlc_strings.h>
43 #include <vlc_charset.h>
46 * Unescape URI encoded string
47 * \return decoded duplicated string
49 char *unescape_URI_duplicate( const char *psz )
51 char *psz_dup = strdup( psz );
52 unescape_URI( psz_dup );
57 * Unescape URI encoded string in place
60 void unescape_URI( char *psz )
62 unsigned char *in = (unsigned char *)psz, *out = in, c;
66 while( ( c = *in++ ) != '\0' )
72 char val[5], *pval = val;
82 if( ( *pval++ = *in++ ) == '\0' )
84 if( ( *pval++ = *in++ ) == '\0' )
90 if( ( *pval++ = *in++ ) == '\0' )
95 cp = strtoul( val, NULL, 0x10 );
101 *out++ = (( cp >> 6) | 0xc0);
102 *out++ = (( cp & 0x3f) | 0x80);
106 assert( cp < 0x10000 );
107 *out++ = (( cp >> 12) | 0xe0);
108 *out++ = (((cp >> 6) & 0x3f) | 0x80);
109 *out++ = (( cp & 0x3f) | 0x80);
114 /* + is not a special case - it means plus, not space. */
117 /* Inserting non-ASCII or non-printable characters is unsafe,
118 * and no sane browser will send these unencoded */
119 if( ( c < 32 ) || ( c > 127 ) )
129 * Decode encoded URI string
130 * \return decoded duplicated string
132 char *decode_URI_duplicate( const char *psz )
134 char *psz_dup = strdup( psz );
135 decode_URI( psz_dup );
140 * Decode encoded URI string in place
143 void decode_URI( char *psz )
145 unsigned char *in = (unsigned char *)psz, *out = in, c;
149 while( ( c = *in++ ) != '\0' )
157 if( ( ( hex[0] = *in++ ) == 0 )
158 || ( ( hex[1] = *in++ ) == 0 ) )
162 *out++ = (unsigned char)strtoul( hex, NULL, 0x10 );
171 /* Inserting non-ASCII or non-printable characters is unsafe,
172 * and no sane browser will send these unencoded */
173 if( ( c < 32 ) || ( c > 127 ) )
183 static inline int isurlsafe( int c )
185 return ( (unsigned char)( c - 'a' ) < 26 )
186 || ( (unsigned char)( c - 'A' ) < 26 )
187 || ( (unsigned char)( c - '0' ) < 10 )
188 /* Hmm, we should not encode character that are allowed in URLs
189 * (even if they are not URL-safe), nor URL-safe characters.
190 * We still encode some of them because of Microsoft's crap browser.
192 || ( strchr( "-_.", c ) != NULL );
195 static inline char url_hexchar( int c )
197 return ( c < 10 ) ? c + '0' : c + 'A' - 10;
201 * encode_URI_component
202 * Encodes an URI component.
204 * @param psz_url nul-terminated UTF-8 representation of the component.
205 * Obviously, you can't pass an URI containing a nul character, but you don't
206 * want to do that, do you?
208 * @return encoded string (must be free()'d)
210 char *encode_URI_component( const char *psz_url )
212 char psz_enc[3 * strlen( psz_url ) + 1], *out = psz_enc;
215 for( in = (const uint8_t *)psz_url; *in; in++ )
227 *out++ = url_hexchar( c >> 4 );
228 *out++ = url_hexchar( c & 0xf );
233 return strdup( psz_enc );
237 * Converts "<", ">" and "&" to "<", ">" and "&"
238 * \param string to convert
240 void resolve_xml_special_chars( char *psz_value )
242 char *p_pos = psz_value;
246 if( *psz_value == '&' )
248 #define TRY_CHAR( src, len, dst ) \
249 if( !strncmp( psz_value, src, len ) ) \
254 #define TRY_LONGCHAR( src, len, dst ) \
255 if( !strncmp( psz_value, src, len ) ) \
257 strncpy( p_pos, dst, strlen( dst ) ); \
258 p_pos += strlen( dst ) - 1; \
261 TRY_CHAR( "<", 4, '<' )
262 else TRY_CHAR( ">", 4, '>' )
263 else TRY_CHAR( "&", 5, '&' )
264 else TRY_CHAR( """, 6, '"' )
265 else TRY_CHAR( "'", 6, '\'' )
266 else if( psz_value[1] == '#' )
269 int i = strtol( psz_value+2, &psz_end, 10 );
270 if( *psz_end == ';' )
272 if( i >= 32 && i <= 126 )
275 psz_value = psz_end+1;
279 /* Unhandled code, FIXME */
286 /* Invalid entity number */
291 else TRY_LONGCHAR( "À", 8, "À" )
292 else TRY_LONGCHAR( "Á", 8, "Á" )
293 else TRY_LONGCHAR( "Â", 7, "Â" )
294 else TRY_LONGCHAR( "Ã", 8, "Ã" )
295 else TRY_LONGCHAR( "Ä", 6, "Ä" )
296 else TRY_LONGCHAR( "Å", 7, "Å" )
297 else TRY_LONGCHAR( "Æ", 7, "Æ" )
298 else TRY_LONGCHAR( "Ç", 8, "Ç" )
299 else TRY_LONGCHAR( "È", 8, "È" )
300 else TRY_LONGCHAR( "É", 8, "É" )
301 else TRY_LONGCHAR( "Ê", 7, "Ê" )
302 else TRY_LONGCHAR( "Ë", 6, "Ë" )
303 else TRY_LONGCHAR( "Ì", 8, "Ì" )
304 else TRY_LONGCHAR( "Í", 8, "Í" )
305 else TRY_LONGCHAR( "Î", 7, "Î" )
306 else TRY_LONGCHAR( "Ï", 6, "Ï" )
307 else TRY_LONGCHAR( "Ð", 5, "Ð" )
308 else TRY_LONGCHAR( "Ñ", 8, "Ñ" )
309 else TRY_LONGCHAR( "Ò", 8, "Ò" )
310 else TRY_LONGCHAR( "Ó", 8, "Ó" )
311 else TRY_LONGCHAR( "Ô", 7, "Ô" )
312 else TRY_LONGCHAR( "Õ", 8, "Õ" )
313 else TRY_LONGCHAR( "Ö", 6, "Ö" )
314 else TRY_LONGCHAR( "Ø", 8, "Ø" )
315 else TRY_LONGCHAR( "Ù", 8, "Ù" )
316 else TRY_LONGCHAR( "Ú", 8, "Ú" )
317 else TRY_LONGCHAR( "Û", 7, "Û" )
318 else TRY_LONGCHAR( "Ü", 6, "Ü" )
319 else TRY_LONGCHAR( "Ý", 8, "Ý" )
320 else TRY_LONGCHAR( "Þ", 7, "Þ" )
321 else TRY_LONGCHAR( "ß", 7, "ß" )
322 else TRY_LONGCHAR( "à", 8, "à" )
323 else TRY_LONGCHAR( "á", 8, "á" )
324 else TRY_LONGCHAR( "â", 7, "â" )
325 else TRY_LONGCHAR( "ã", 8, "ã" )
326 else TRY_LONGCHAR( "ä", 6, "ä" )
327 else TRY_LONGCHAR( "å", 7, "å" )
328 else TRY_LONGCHAR( "æ", 7, "æ" )
329 else TRY_LONGCHAR( "ç", 8, "ç" )
330 else TRY_LONGCHAR( "è", 8, "è" )
331 else TRY_LONGCHAR( "é", 8, "é" )
332 else TRY_LONGCHAR( "ê", 7, "ê" )
333 else TRY_LONGCHAR( "ë", 6, "ë" )
334 else TRY_LONGCHAR( "ì", 8, "ì" )
335 else TRY_LONGCHAR( "í", 8, "í" )
336 else TRY_LONGCHAR( "î", 7, "î" )
337 else TRY_LONGCHAR( "ï", 6, "ï" )
338 else TRY_LONGCHAR( "ð", 5, "ð" )
339 else TRY_LONGCHAR( "ñ", 8, "ñ" )
340 else TRY_LONGCHAR( "ò", 8, "ò" )
341 else TRY_LONGCHAR( "ó", 8, "ó" )
342 else TRY_LONGCHAR( "ô", 7, "ô" )
343 else TRY_LONGCHAR( "õ", 8, "õ" )
344 else TRY_LONGCHAR( "ö", 6, "ö" )
345 else TRY_LONGCHAR( "ø", 8, "ø" )
346 else TRY_LONGCHAR( "ù", 8, "ù" )
347 else TRY_LONGCHAR( "ú", 8, "ú" )
348 else TRY_LONGCHAR( "û", 7, "û" )
349 else TRY_LONGCHAR( "ü", 6, "ü" )
350 else TRY_LONGCHAR( "ý", 8, "ý" )
351 else TRY_LONGCHAR( "þ", 7, "þ" )
352 else TRY_LONGCHAR( "ÿ", 6, "ÿ" )
353 else TRY_LONGCHAR( "¡", 7, "¡" )
354 else TRY_LONGCHAR( "¤", 8, "¤" )
355 else TRY_LONGCHAR( "¢", 6, "¢" )
356 else TRY_LONGCHAR( "£", 7, "£" )
357 else TRY_LONGCHAR( "¥", 5, "¥" )
358 else TRY_LONGCHAR( "¦", 8, "¦" )
359 else TRY_LONGCHAR( "§", 6, "§" )
360 else TRY_LONGCHAR( "¨", 5, "¨" )
361 else TRY_LONGCHAR( "©", 6, "©" )
362 else TRY_LONGCHAR( "ª", 6, "ª" )
363 else TRY_LONGCHAR( "«", 7, "«" )
364 else TRY_LONGCHAR( "¬", 5, "¬" )
365 else TRY_LONGCHAR( "­", 5, "" )
366 else TRY_LONGCHAR( "®", 5, "®" )
367 else TRY_LONGCHAR( "™", 7, "™" )
368 else TRY_LONGCHAR( "¯", 6, "¯" )
369 else TRY_LONGCHAR( "°", 5, "°" )
370 else TRY_LONGCHAR( "±", 8, "±" )
371 else TRY_LONGCHAR( "²", 6, "²" )
372 else TRY_LONGCHAR( "³", 6, "³" )
373 else TRY_LONGCHAR( "´", 7, "´" )
374 else TRY_LONGCHAR( "µ", 7, "µ" )
375 else TRY_LONGCHAR( "¶", 6, "¶" )
376 else TRY_LONGCHAR( "·", 8, "·" )
377 else TRY_LONGCHAR( "¸", 7, "¸" )
378 else TRY_LONGCHAR( "¹", 6, "¹" )
379 else TRY_LONGCHAR( "º", 6, "º" )
380 else TRY_LONGCHAR( "»", 7, "»" )
381 else TRY_LONGCHAR( "¼", 8, "¼" )
382 else TRY_LONGCHAR( "½", 8, "½" )
383 else TRY_LONGCHAR( "¾", 8, "¾" )
384 else TRY_LONGCHAR( "¿", 8, "¿" )
385 else TRY_LONGCHAR( "×", 7, "×" )
386 else TRY_LONGCHAR( "÷", 8, "÷" )
387 else TRY_LONGCHAR( "Œ", 7, "Œ" )
388 else TRY_LONGCHAR( "œ", 7, "œ" )
389 else TRY_LONGCHAR( "Š", 8, "Š" )
390 else TRY_LONGCHAR( "š", 8, "š" )
391 else TRY_LONGCHAR( "Ÿ", 6, "Ÿ" )
392 else TRY_LONGCHAR( "ˆ", 6, "ˆ" )
393 else TRY_LONGCHAR( "˜", 7, "˜" )
394 else TRY_LONGCHAR( "–", 7, "–" )
395 else TRY_LONGCHAR( "—", 7, "—" )
396 else TRY_LONGCHAR( "‘", 7, "‘" )
397 else TRY_LONGCHAR( "’", 7, "’" )
398 else TRY_LONGCHAR( "‚", 7, "‚" )
399 else TRY_LONGCHAR( "“", 7, "“" )
400 else TRY_LONGCHAR( "”", 7, "”" )
401 else TRY_LONGCHAR( "„", 7, "„" )
402 else TRY_LONGCHAR( "†", 8, "†" )
403 else TRY_LONGCHAR( "‡", 8, "‡" )
404 else TRY_LONGCHAR( "…", 8, "…" )
405 else TRY_LONGCHAR( "‰", 8, "‰" )
406 else TRY_LONGCHAR( "‹", 8, "‹" )
407 else TRY_LONGCHAR( "›", 8, "›" )
408 else TRY_LONGCHAR( "€", 6, "€" )
428 * Converts '<', '>', '\"', '\'' and '&' to their html entities
429 * \param psz_content simple element content that is to be converted
431 char *convert_xml_special_chars( const char *psz_content )
433 char *psz_temp = malloc( 6 * strlen( psz_content ) + 1 );
434 const char *p_from = psz_content;
435 char *p_to = psz_temp;
439 if ( *p_from == '<' )
441 strcpy( p_to, "<" );
444 else if ( *p_from == '>' )
446 strcpy( p_to, ">" );
449 else if ( *p_from == '&' )
451 strcpy( p_to, "&" );
454 else if( *p_from == '\"' )
456 strcpy( p_to, """ );
459 else if( *p_from == '\'' )
461 strcpy( p_to, "'" );
476 /* Base64 encoding */
477 char *vlc_b64_encode_binary( const uint8_t *src, size_t i_src )
479 static const char b64[] =
480 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
482 char *ret = malloc( ( i_src + 4 ) * 4 / 3 );
490 /* pops (up to) 3 bytes of input, push 4 bytes */
495 *dst++ = b64[v >> 26];
501 *dst++ = b64[v >> 26];
506 v |= *src++ << 20; // 3/3
507 *dst++ = ( i_src >= 2 ) ? b64[v >> 26] : '='; // 3/4
511 *dst++ = ( i_src >= 3 ) ? b64[v >> 26] : '='; // 4/4
523 char *vlc_b64_encode( const char *src )
526 return vlc_b64_encode_binary( (const uint8_t*)src, strlen(src) );
528 return vlc_b64_encode_binary( (const uint8_t*)"", 0 );
531 /* Base64 decoding */
532 size_t vlc_b64_decode_binary_to_buffer( uint8_t *p_dst, size_t i_dst, const char *p_src )
534 static const int b64[256] = {
535 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
536 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
537 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
538 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
539 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
540 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
541 -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
542 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
543 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
544 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
545 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
546 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
547 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
548 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
549 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
550 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
552 uint8_t *p_start = p_dst;
553 uint8_t *p = (uint8_t *)p_src;
558 for( i_level = 0, i_last = 0; (size_t)( p_dst - p_start ) < i_dst && *p != '\0'; p++ )
560 const int c = b64[(unsigned int)*p];
570 *p_dst++ = ( i_last << 2 ) | ( ( c >> 4)&0x03 );
574 *p_dst++ = ( ( i_last << 4 )&0xf0 ) | ( ( c >> 2 )&0x0f );
578 *p_dst++ = ( ( i_last &0x03 ) << 6 ) | c;
584 return p_dst - p_start;
586 size_t vlc_b64_decode_binary( uint8_t **pp_dst, const char *psz_src )
588 const int i_src = strlen( psz_src );
591 *pp_dst = p_dst = malloc( i_src );
594 return vlc_b64_decode_binary_to_buffer( p_dst, i_src, psz_src );
596 char *vlc_b64_decode( const char *psz_src )
598 const int i_src = strlen( psz_src );
599 char *p_dst = malloc( i_src + 1 );
604 i_dst = vlc_b64_decode_binary_to_buffer( (uint8_t*)p_dst, i_src, psz_src );
610 /****************************************************************************
611 * String formating functions
612 ****************************************************************************/
613 char *str_format_time( const char *tformat )
617 #if defined(HAVE_LOCALTIME_R)
623 /* Get the current time. */
624 curtime = time( NULL );
626 /* Convert it to local time representation. */
627 #if defined(HAVE_LOCALTIME_R)
628 localtime_r( &curtime, &loctime );
629 strftime( buffer, 255, tformat, &loctime );
631 loctime = localtime( &curtime );
632 strftime( buffer, 255, tformat, loctime );
634 return strdup( buffer );
637 #define INSERT_STRING( string ) \
638 if( string != NULL ) \
640 int len = strlen( string ); \
641 dst = realloc( dst, i_size = i_size + len );\
642 memcpy( (dst+d), string, len ); \
652 /* same than INSERT_STRING, except that string won't be freed */
653 #define INSERT_STRING_NO_FREE( string ) \
655 int len = strlen( string ); \
656 dst = realloc( dst, i_size = i_size + len );\
657 memcpy( dst+d, string, len ); \
660 char *__str_format_meta( vlc_object_t *p_object, const char *string )
662 const char *s = string;
664 int b_empty_if_na = 0;
666 int i_size = strlen( string ) + 1; /* +1 to store '\0' */
667 char *dst = malloc( i_size );
670 playlist_t *p_playlist = pl_Yield( p_object );
671 input_thread_t *p_input = p_playlist->p_input;
672 input_item_t *p_item = NULL;
673 pl_Release( p_object );
676 vlc_object_yield( p_input );
677 p_item = input_GetItem(p_input);
680 sprintf( dst, string );
691 INSERT_STRING( input_item_GetArtist( p_item ) );
697 INSERT_STRING( input_item_GetAlbum( p_item ) );
703 INSERT_STRING( input_item_GetCopyright( p_item ) );
709 INSERT_STRING( input_item_GetDescription( p_item ) );
715 INSERT_STRING( input_item_GetEncodedBy( p_item ) );
721 INSERT_STRING( input_item_GetGenre( p_item ) );
727 INSERT_STRING( input_item_GetLanguage( p_item ) );
733 INSERT_STRING( input_item_GetTrackNum( p_item ) );
739 INSERT_STRING( input_item_GetNowPlaying( p_item ) );
745 INSERT_STRING( input_item_GetRating( p_item ) );
752 lang = var_GetNonEmptyString( p_input, "sub-language" );
754 lang = strdup( b_empty_if_na ? "" : "-" );
755 INSERT_STRING( lang );
761 INSERT_STRING( input_item_GetTitle( p_item ) );
767 INSERT_STRING( input_item_GetURL( p_item ) );
773 INSERT_STRING( input_item_GetDate( p_item ) );
779 snprintf( buf, 10, "%d",
780 var_GetInteger( p_input, "bit-rate" )/1000 );
784 sprintf( buf, b_empty_if_na ? "" : "-" );
786 INSERT_STRING_NO_FREE( buf );
791 snprintf( buf, 10, "%d",
792 var_GetInteger( p_input, "chapter" ) );
796 sprintf( buf, b_empty_if_na ? "" : "-" );
798 INSERT_STRING_NO_FREE( buf );
803 mtime_t i_duration = input_item_GetDuration( p_item );
804 sprintf( buf, "%02d:%02d:%02d",
805 (int)(i_duration/(3600000000)),
806 (int)((i_duration/(60000000))%60),
807 (int)((i_duration/1000000)%60) );
811 sprintf( buf, b_empty_if_na ? "" : "--:--:--" );
813 INSERT_STRING_NO_FREE( buf );
818 INSERT_STRING( input_item_GetURI( p_item ) );
824 snprintf( buf, 10, "%d",
825 var_GetInteger( p_input, "title" ) );
829 sprintf( buf, b_empty_if_na ? "" : "-" );
831 INSERT_STRING_NO_FREE( buf );
834 if( p_item && p_input )
836 mtime_t i_duration = input_item_GetDuration( p_item );
837 int64_t i_time = p_input->i_time;
838 sprintf( buf, "%02d:%02d:%02d",
839 (int)( ( i_duration - i_time ) / 3600000000 ),
840 (int)( ( ( i_duration - i_time ) / 60000000 ) % 60 ),
841 (int)( ( ( i_duration - i_time ) / 1000000 ) % 60 ) );
845 sprintf( buf, b_empty_if_na ? "" : "--:--:--" );
847 INSERT_STRING_NO_FREE( buf );
852 INSERT_STRING( input_item_GetName( p_item ) );
859 lang = var_GetNonEmptyString( p_input,
862 lang = strdup( b_empty_if_na ? "" : "-" );
863 INSERT_STRING( lang );
869 snprintf( buf, 10, "%2.1lf",
870 var_GetFloat( p_input, "position" ) * 100. );
874 sprintf( buf, b_empty_if_na ? "" : "--.-%%" );
876 INSERT_STRING_NO_FREE( buf );
881 int r = var_GetInteger( p_input, "rate" );
882 snprintf( buf, 10, "%d.%d", r/1000, r%1000 );
886 sprintf( buf, b_empty_if_na ? "" : "-" );
888 INSERT_STRING_NO_FREE( buf );
893 int r = var_GetInteger( p_input, "sample-rate" );
894 snprintf( buf, 10, "%d.%d", r/1000, (r/100)%10 );
898 sprintf( buf, b_empty_if_na ? "" : "-" );
900 INSERT_STRING_NO_FREE( buf );
905 sprintf( buf, "%02d:%02d:%02d",
906 (int)( p_input->i_time / ( 3600000000 ) ),
907 (int)( ( p_input->i_time / ( 60000000 ) ) % 60 ),
908 (int)( ( p_input->i_time / 1000000 ) % 60 ) );
912 sprintf( buf, b_empty_if_na ? "" : "--:--:--" );
914 INSERT_STRING_NO_FREE( buf );
919 INSERT_STRING( input_item_GetPublisher( p_item ) );
924 audio_volume_t volume;
925 aout_VolumeGet( p_object, &volume );
926 snprintf( buf, 10, "%d", volume );
927 INSERT_STRING_NO_FREE( buf );
962 vlc_object_release( p_input );
968 * Apply str format time and str format meta
970 char *__str_format( vlc_object_t *p_this, const char *psz_src )
972 char *psz_buf1, *psz_buf2;
973 psz_buf1 = str_format_time( psz_src );
974 psz_buf2 = str_format_meta( p_this, psz_buf1 );
980 * Remove forbidden characters from filenames (including slashes)
982 void filename_sanitize( char *str )
984 if( *str == '.' && (str[1] == '\0' || (str[1] == '.' && str[2] == '\0' ) ) )
1016 * Remove forbidden characters from full paths (leaves slashes)
1018 void path_sanitize( char *str )
1022 * Uncomment the two blocks to prevent /../ or /./, i'm not sure that we
1025 char *prev = str - 1;
1028 /* check drive prefix if path is absolute */
1029 if( isalpha(*str) && (':' == *(str+1)) )
1054 if( str - prev == 2 && prev[1] == '.' )
1058 else if( str - prev == 3 && prev[1] == '.' && prev[2] == '.' )