[xiph-commits] r13609 - in trunk/ezstream: . doc src win32

moritz at svn.xiph.org moritz at svn.xiph.org
Fri Aug 24 04:57:09 PDT 2007


Author: moritz
Date: 2007-08-24 04:57:09 -0700 (Fri, 24 Aug 2007)
New Revision: 13609

Modified:
   trunk/ezstream/NEWS
   trunk/ezstream/configure.in
   trunk/ezstream/doc/ezstream.1.in
   trunk/ezstream/src/ezstream.c
   trunk/ezstream/src/metadata.c
   trunk/ezstream/src/util.c
   trunk/ezstream/win32/config.h
   trunk/ezstream/win32/ezstream.vcproj
Log:
UTF-8 support is now ready to be used.


Modified: trunk/ezstream/NEWS
===================================================================
--- trunk/ezstream/NEWS	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/NEWS	2007-08-24 11:57:09 UTC (rev 13609)
@@ -11,6 +11,11 @@
              files come from a broken encoder/tagging program. Disabled
              by default, this feature can be enabled with the new `-n'
              command line parameter.
+   - [NEW]   Enable Unicode support in TagLib and convert metadata strings
+             to the current locale (LC_CTYPE) before displaying them on the
+             console. Unsupported characters are displayed as '?', which
+             does not affect the actual metadata. This feature requires
+             iconv() via libc, if available, or libiconv.
    - [MISC]  Add new --enable-debug configuration option to the configure
              script, which enables (also new) memory debugging features.
              (Not interesting for non-developers.)

Modified: trunk/ezstream/configure.in
===================================================================
--- trunk/ezstream/configure.in	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/configure.in	2007-08-24 11:57:09 UTC (rev 13609)
@@ -39,7 +39,7 @@
 		;;
 	esac
 else
-	XIPH_CPPFLAGS="-fstrict-aliasing -Wall -W -Wno-unused-parameter -Wwrite-strings -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
+	XIPH_CPPFLAGS="-fstrict-aliasing -Wall -Wno-unused-parameter -Wwrite-strings -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
 fi
 
 ez_enable_debug=no
@@ -89,7 +89,7 @@
 
 dnl USEFUL HEADERS
 
-AC_CHECK_HEADERS(sys/time.h paths.h signal.h libgen.h)
+AC_CHECK_HEADERS(sys/time.h paths.h signal.h langinfo.h libgen.h locale.h)
 
 COMPAT_INCLUDES=""
 if test x"$ez_enable_debug" = "xyes"; then
@@ -119,13 +119,14 @@
 dnl LIBRARY FUNCTIONS
 
 AC_CHECK_LIB(gen, basename)
-AC_CHECK_FUNCS(arc4random gettimeofday random srandomdev stat)
+AC_CHECK_FUNCS(arc4random gettimeofday nl_langinfo random setlocale srandomdev stat)
 AC_REPLACE_FUNCS(getopt strlcat strlcpy strtonum)
 if test x"$ac_cv_header_signal_h" = "xyes"; then
 	AC_CHECK_FUNCS([sigaction], [
 		AC_DEFINE(HAVE_SIGNALS, 1, [Define whether we have BSD signals])
 		], [], [#include <signal.h>])
 fi
+AM_ICONV
 
 
 dnl CONFIGURE OPTIONS
@@ -208,10 +209,6 @@
 	CFLAGS="$ac_taglib_save_CFLAGS"
 	CPPFLAGS="$ac_taglib_save_CPPFLAGS"
 	LIBS="$ac_taglib_save_LIBS"
-
-	AM_ICONV
-	AC_CHECK_HEADERS(langinfo.h locale.h)
-	AC_CHECK_FUNCS(setlocale nl_langinfo)
 else
 	AC_MSG_RESULT([disabled])
 fi

Modified: trunk/ezstream/doc/ezstream.1.in
===================================================================
--- trunk/ezstream/doc/ezstream.1.in	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/doc/ezstream.1.in	2007-08-24 11:57:09 UTC (rev 13609)
@@ -461,6 +461,8 @@
 .Qq Li title ,
 the program should return only the title information of the metadata.
 .Pq Optional.
+.It
+The supplied metadata should be encoded in UTF-8.
 .El
 .Sh METADATA
 The main tool for handling metadata with

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/src/ezstream.c	2007-08-24 11:57:09 UTC (rev 13609)
@@ -851,8 +851,11 @@
 	}
 
 	if (mdata != NULL) {
-		char	*metaData = metadata_assemble_string(mdata);
+		char	*tmp, *metaData;
 
+		tmp = metadata_assemble_string(mdata);
+		metaData = utf82char(tmp);
+		xfree(tmp);
 		printf("%s: Streaming ``%s''", __progname, metaData);
 		if (vFlag)
 			printf(" (file: %s)\n", fileName);

Modified: trunk/ezstream/src/metadata.c
===================================================================
--- trunk/ezstream/src/metadata.c	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/src/metadata.c	2007-08-24 11:57:09 UTC (rev 13609)
@@ -37,10 +37,12 @@
 # include <taglib/tag_c.h>
 #endif
 #include <vorbis/vorbisfile.h>
+#include <shout/shout.h>
 
 #include "compat.h"
 #include "metadata.h"
 #include "strfctns.h"
+#include "util.h"
 #include "xalloc.h"
 
 extern char		*__progname;
@@ -109,7 +111,11 @@
 
 	metadata_clean_md(md);
 	taglib_set_string_management_enabled(0);
+#ifdef HAVE_ICONV
+	taglib_set_strings_unicode(1);
+#else
 	taglib_set_strings_unicode(0);
+#endif /* HAVE_ICONV */
 
 	if (md->string != NULL) {
 		xfree(md->string);
@@ -179,9 +185,9 @@
 		fread(&id3tag, 1, sizeof(struct ID3Tag), *filep);
 		if (memcmp(id3tag.tag, "TAG", 3) == 0) {
 			if (strlen(id3tag.artistName) > 0)
-				md->artist = xstrdup(id3tag.artistName);
+				md->artist = char2utf8(id3tag.artistName);
 			if (strlen(id3tag.trackName) > 0)
-				md->title = xstrdup(id3tag.trackName);
+				md->title = char2utf8(id3tag.trackName);
 		}
 	} else if (strcmp(extension, ".ogg") == 0) {
 		OggVorbis_File	vf;

Modified: trunk/ezstream/src/util.c
===================================================================
--- trunk/ezstream/src/util.c	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/src/util.c	2007-08-24 11:57:09 UTC (rev 13609)
@@ -46,6 +46,7 @@
 #endif
 #include <shout/shout.h>
 
+#include "compat.h"
 #include "util.h"
 #include "configfile.h"
 #include "xalloc.h"
@@ -230,22 +231,29 @@
 	size_t			 input_len;
 	char			*output;
 	size_t			 output_size;
-	char			 buf[4], *bp;
+	char			 buf[BUFSIZ], *bp;
 	size_t			 bufavail;
 	size_t			 out_pos;
+
+# ifndef WIN32
 	char			*codeset;
 
-	if (in_str == NULL || strlen(in_str) == 0)
-		return (NULL);
-
-# if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE)
+#  if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET)
 	setlocale(LC_CTYPE, "");
 	codeset = nl_langinfo(CODESET);
 	setlocale(LC_CTYPE, "C");
+#  else
+	codeset = (char *)"";
+#  endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
 # else
-	codeset = (char *)"";
-# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
+	char			 codeset[24];
 
+	snprintf(codeset, sizeof(codeset), "CP%u", GetACP());
+# endif /* !WIN32 */
+
+	if (in_str == NULL || strlen(in_str) == 0)
+		return (NULL);
+
 	if ((cd = iconv_open("UTF-8", codeset)) == (iconv_t)-1 &&
 	    (cd = iconv_open("UTF-8", "")) == (iconv_t)-1) {
 		printf("iconv_open: %s\n", strerror(errno));
@@ -264,7 +272,7 @@
 
 		buf[0] = '\0';
 		bp = buf;
-		bufavail = sizeof(buf);
+		bufavail = sizeof(buf) - 1;
 
 		if (iconv(cd, &ip, &input_len, &bp, &bufavail) == (size_t)-1 &&
 		    errno != E2BIG) {
@@ -275,7 +283,7 @@
 		}
 		*bp = '\0';
 
-		count = sizeof(buf) - bufavail;
+		count = sizeof(buf) - bufavail - 1;
 
 		output_size += count;
 		op = output = xrealloc(output, output_size, sizeof(char));
@@ -308,22 +316,29 @@
 	size_t			 input_len;
 	char			*output;
 	size_t			 output_size;
-	char			 buf[4], *bp;
+	char			 buf[BUFSIZ], *bp;
 	size_t			 bufavail;
 	size_t			 out_pos;
+
+# ifndef WIN32
 	char			*codeset;
 
-	if (in_str == NULL || strlen(in_str) == 0)
-		return (NULL);
-
-# if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE)
+#  if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET)
 	setlocale(LC_CTYPE, "");
 	codeset = nl_langinfo(CODESET);
 	setlocale(LC_CTYPE, "C");
+#  else
+	codeset = (char *)"";
+#  endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
 # else
-	codeset = (char *)"";
-# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
+	char			 codeset[24];
 
+	snprintf(codeset, sizeof(codeset), "CP%u", GetACP());
+# endif /* !WIN32 */
+
+	if (in_str == NULL || strlen(in_str) == 0)
+		return (NULL);
+
 	if ((cd = iconv_open(codeset, "UTF-8")) == (iconv_t)-1 &&
 	    (cd = iconv_open("", "UTF-8")) == (iconv_t)-1) {
 		printf("iconv_open: %s\n", strerror(errno));
@@ -342,7 +357,7 @@
 
 		buf[0] = '\0';
 		bp = buf;
-		bufavail = sizeof(buf);
+		bufavail = sizeof(buf) - 1;
 
 		if (iconv(cd, &ip, &input_len, &bp, &bufavail) == (size_t)-1 &&
 		    errno != E2BIG) {
@@ -353,7 +368,7 @@
 		}
 		*bp = '\0';
 
-		count = sizeof(buf) - bufavail;
+		count = sizeof(buf) - bufavail - 1;
 
 		output_size += count;
 		op = output = xrealloc(output, output_size, sizeof(char));

Modified: trunk/ezstream/win32/config.h
===================================================================
--- trunk/ezstream/win32/config.h	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/win32/config.h	2007-08-24 11:57:09 UTC (rev 13609)
@@ -2,11 +2,14 @@
 #include <windows.h>
 #include <io.h>
 
-#define HAVE_INTTYPES_H 1
-#define HAVE_STAT 1
-#define HAVE_STDINT_H 1
-#define HAVE_SYS_STAT_H 1
+#define HAVE_INTTYPES_H 	1
+#define HAVE_LOCALE_H		1
+#define HAVE_STAT		1
+#define HAVE_STDINT_H		1
+#define HAVE_SYS_STAT_H 	1
 
+#define ICONV_CONST		const
+
 /* Name of package */
 #define PACKAGE "ezstream"
 

Modified: trunk/ezstream/win32/ezstream.vcproj
===================================================================
--- trunk/ezstream/win32/ezstream.vcproj	2007-08-24 10:39:14 UTC (rev 13608)
+++ trunk/ezstream/win32/ezstream.vcproj	2007-08-24 11:57:09 UTC (rev 13609)
@@ -28,7 +28,7 @@
 				InlineFunctionExpansion="1"
 				ImproveFloatingPointConsistency="TRUE"
 				AdditionalIncludeDirectories="../../ogg/include;../../vorbis/include;../../shout/include;../src;../../libxml2/include;../../libiconv/include;.;../compat"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_ICONV"
 				StringPooling="TRUE"
 				ExceptionHandling="FALSE"
 				BasicRuntimeChecks="0"
@@ -96,7 +96,7 @@
 				Optimization="0"
 				ImproveFloatingPointConsistency="TRUE"
 				AdditionalIncludeDirectories="../../ogg/include;../../vorbis/include;../../shout/include;../src;../../libxml2/include;../../libiconv/include;.;../compat"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;XALLOC_DEBUG"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_ICONV;XALLOC_DEBUG"
 				ExceptionHandling="FALSE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"



More information about the commits mailing list