skins2: os2: save and restore FPU cw
[vlc.git] / include / vlc_strings.h
blob2170c240eb2135e9b7e9641d32795e10d104edc0
1 /*****************************************************************************
2 * vlc_strings.h: String functions
3 *****************************************************************************
4 * Copyright (C) 2006 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Antoine Cellerier <dionoea at videolan dot org>
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.
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.
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 *****************************************************************************/
24 #ifndef VLC_STRINGS_H
25 #define VLC_STRINGS_H 1
27 /**
28 * \file
29 * This file defines functions and structures handling misc strings
32 /**
33 * \defgroup strings Strings
34 * @{
37 static inline int vlc_ascii_toupper( int c )
39 if ( c >= 'a' && c <= 'z' )
40 return c + ( 'A' - 'a' );
41 else
42 return c;
45 static inline int vlc_ascii_tolower( int c )
47 if ( c >= 'A' && c <= 'Z' )
48 return c + ( 'a' - 'A' );
49 else
50 return c;
53 /**
54 * Compare two ASCII strings ignoring case.
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.
60 static inline int vlc_ascii_strcasecmp( const char *psz1, const char *psz2 )
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)
67 s1++;
68 s2++;
69 d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
72 return d;
75 static inline int vlc_ascii_strncasecmp( const char *psz1, const char *psz2, size_t n )
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)
83 s1++;
84 s2++;
85 d = vlc_ascii_tolower( *s1 ) - vlc_ascii_tolower( *s2 );
88 if (s1 == s1end)
89 return 0;
90 else
91 return d;
94 VLC_API void resolve_xml_special_chars( char *psz_value );
95 VLC_API char * convert_xml_special_chars( const char *psz_content );
97 VLC_API char * vlc_b64_encode_binary( const uint8_t *, size_t );
98 VLC_API char * vlc_b64_encode( const char * );
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 );
104 VLC_API char * str_format_time( const char * );
105 VLC_API char * str_format_meta( input_thread_t *, const char * );
107 static inline char *str_format( input_thread_t *input, const char *fmt )
109 char *s1 = str_format_time( fmt );
110 char *s2 = str_format_meta( input, s1 );
111 free( s1 );
112 return s2;
115 VLC_API void filename_sanitize( char * );
116 VLC_API void path_sanitize( char * );
118 VLC_API time_t str_duration( const char * );
121 * @}
124 #endif