[vlc-devel] [PATCH] httpd: use locale-independent us_vasprintf() to write HTTP headers
Pierre Ynard
linkfanel at yahoo.fr
Tue Jan 11 19:12:13 CET 2011
This will be useful for RTSP.
Do we still need to export variadic functions us_asprintf(),
msg_Generic(), net_Printf() and utf8_fprintf() when us_vasprintf(),
msg_GenericVa(), net_vaPrintf() and utf8_vfprintf() are available?
diff --git a/include/vlc_charset.h b/include/vlc_charset.h
index 07f9dee..5c7590f 100644
--- a/include/vlc_charset.h
+++ b/include/vlc_charset.h
@@ -114,6 +114,7 @@ VLC_EXPORT( void *, ToCharset, ( const char *charset, const char *in, size_t *ou
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( float, us_strtof, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
+VLC_EXPORT( int, us_vasprintf, ( char **, const char *, va_list ) );
VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
#endif
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 309f88d..3c30e2a 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -451,6 +451,7 @@ us_asprintf
us_atof
us_strtod
us_strtof
+us_vasprintf
vlc_fopen
utf8_fprintf
vlc_loaddir
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 9ec1e6e..e28277a 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -37,6 +37,7 @@
#include <vlc_acl.h>
#include <vlc_strings.h>
#include <vlc_rand.h>
+#include <vlc_charset.h>
#include "../libvlc.h"
#include <string.h>
@@ -1378,7 +1379,7 @@ void httpd_MsgAdd( httpd_message_t *msg, const char *name, const char *psz_value
char *value = NULL;
va_start( args, psz_value );
- if( vasprintf( &value, psz_value, args ) == -1 )
+ if( us_vasprintf( &value, psz_value, args ) == -1 )
value = NULL;
va_end( args );
diff --git a/src/text/charset.c b/src/text/charset.c
index 1722210..2221e0f 100644
--- a/src/text/charset.c
+++ b/src/text/charset.c
@@ -92,19 +92,15 @@ double us_atof( const char *str )
/**
- * us_asprintf() has the same prototype as asprintf(), but doesn't use
+ * us_vasprintf() has the same prototype as vasprintf(), but doesn't use
* the system locale.
*/
-int us_asprintf( char **ret, const char *format, ... )
+int us_vasprintf( char **ret, const char *format, va_list ap )
{
- va_list ap;
locale_t loc = newlocale( LC_NUMERIC_MASK, "C", NULL );
locale_t oldloc = uselocale( loc );
- int i_rc;
- va_start( ap, format );
- i_rc = vasprintf( ret, format, ap );
- va_end( ap );
+ int i_rc = vasprintf( ret, format, ap );
if ( loc != (locale_t)0 )
{
@@ -114,3 +110,20 @@ int us_asprintf( char **ret, const char *format, ... )
return i_rc;
}
+
+
+/**
+ * us_asprintf() has the same prototype as asprintf(), but doesn't use
+ * the system locale.
+ */
+int us_asprintf( char **ret, const char *format, ... )
+{
+ va_list ap;
+ int i_rc;
+
+ va_start( ap, format );
+ i_rc = us_vasprintf( ret, format, ap );
+ va_end( ap );
+
+ return i_rc;
+}
Regards,
--
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."
More information about the vlc-devel
mailing list