]> git.sesse.net Git - vlc/blob - include/vlc_strings.h
es_out: do not start buffering when already buferring
[vlc] / include / vlc_strings.h
1 /*****************************************************************************
2  * vlc_strings.h: String functions
3  *****************************************************************************
4  * Copyright (C) 2006 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea at videolan dot org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef VLC_STRINGS_H
25 #define VLC_STRINGS_H 1
26
27 /**
28  * \file
29  * This file defines functions and structures handling misc strings
30  */
31
32 /**
33  * \defgroup strings Strings
34  * @{
35  */
36
37 static inline int vlc_ascii_toupper( int c )
38 {
39     if ( c >= 'a' && c <= 'z' )
40         return c + ( 'A' - 'a' );
41     else
42         return c;
43 }
44
45 static inline int vlc_ascii_tolower( int c )
46 {
47     if ( c >= 'A' && c <= 'Z' )
48         return c + ( 'a' - 'A' );
49     else
50         return c;
51 }
52
53 /**
54  * Compare two ASCII strings ignoring case.
55  *
56  * The result is independent of the locale. If there are non-ASCII
57  * characters in the strings, their cases are NOT ignored in the
58  * comparison.
59  */
60 static inline int vlc_ascii_strcasecmp( const char *psz1, const char *psz2 )
61 {
62     const char *s1 = psz1;
63     const char *s2 = psz2;
64     int d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
65     while ( *s1 && d == 0)
66     {
67         s1++;
68         s2++;
69         d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
70     }
71
72     return d;
73 }
74
75 static inline int vlc_ascii_strncasecmp( const char *psz1, const char *psz2, size_t n )
76 {
77     const char *s1 = psz1;
78     const char *s2 = psz2;
79     const char *s1end = psz1 + n;
80     int d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
81     while ( *s1 && s1 < s1end && d == 0)
82     {
83         s1++;
84         s2++;
85         d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
86     }
87
88     if (s1 == s1end)
89         return 0;
90     else
91         return d;
92 }
93
94 VLC_API void resolve_xml_special_chars( char *psz_value );
95 VLC_API char * convert_xml_special_chars( const char *psz_content );
96
97 VLC_API char * vlc_b64_encode_binary( const uint8_t *, size_t );
98 VLC_API char * vlc_b64_encode( const char * );
99
100 VLC_API size_t vlc_b64_decode_binary_to_buffer( uint8_t *p_dst, size_t i_dst_max, const char *psz_src );
101 VLC_API size_t vlc_b64_decode_binary( uint8_t **pp_dst, const char *psz_src );
102 VLC_API char * vlc_b64_decode( const char *psz_src );
103
104 VLC_API char * str_format_time( const char * );
105 VLC_API char * str_format_meta( input_thread_t *, const char * );
106
107 static inline char *str_format( input_thread_t *input, const char *fmt )
108 {
109     char *s1 = str_format_time( fmt );
110     char *s2 = str_format_meta( input, s1 );
111     free( s1 );
112     return s2;
113 }
114
115 VLC_API void filename_sanitize( char * );
116 VLC_API void path_sanitize( char * );
117
118 VLC_API time_t str_duration( const char * );
119
120 /**
121  * @}
122  */
123
124 #endif