From d466d6a39f785c44a09adf3fc58b5a425c63f33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 12 Sep 2006 21:24:18 +0000 Subject: Fixed iconv warnings on FreeBSD, fixed build w/o iconv but require it as default. CVS patchset: 8223 CVS date: 2006/09/12 21:24:18 --- configure.ac | 31 +++++++++++++++++----------- src/demuxers/asfheader.c | 48 +++++++++++++++++++++++++++++++++++++++++-- src/demuxers/asfheader.h | 7 +++---- src/input/mms.c | 9 ++++---- src/xine-engine/info_helper.c | 11 +++++----- src/xine-engine/osd.c | 7 ++++--- 6 files changed, 83 insertions(+), 30 deletions(-) diff --git a/configure.ac b/configure.ac index 83b8239da..4057a2071 100644 --- a/configure.ac +++ b/configure.ac @@ -157,6 +157,25 @@ dnl --------------------------------------------- dnl ALL_LINGUAS="cs da de el en@quot en@boldquot es et fr gl id it ja ko nl nn no pl pt pt_BR ru sl sv tr zh" AM_ICONV +AC_ARG_ENABLE([iconvtest], + AS_HELP_STRING([--disable-iconvtest], [don't require iconv library])) +if test x$enable_iconvtest != xno; then + if test x"$am_cv_func_iconv" != xyes; then + AC_MSG_ERROR([ +**************************************************************** +* iconv library not found. It's necessary for proper * +* manipulation with texts so xine requires it as default. * +* * +* You need to install iconv library or to specify prefix * +* by option --with-libiconv-prefix. * +* * +* If you don't want iconv support use the option * +* --disable-iconvtest. * +**************************************************************** + ]) + fi +fi + AM_GNU_GETTEXT([external]) AC_PROG_GMSGFMT_PLURAL @@ -201,18 +220,6 @@ case "$host" in THREAD_CPPFLAGS="-I$pthread_prefix/include" CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS -D_THREAD_SAFE" have_pthread=yes - - if test x"$am_cv_func_iconv" != xyes; then - AC_MSG_WARN([ -**************************************************************** -* You need to install a recent version of the port 'libiconv' * -* (in /usr/ports/converters/libiconv) or to specify prefix * -* by option --with-libiconv-prefix. * -* The library in this port is needed to successfully compile * -* libsputext plugin. * -**************************************************************** - ]) - fi ;; *-*-hpux11*) diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index 62220e225..4416687f5 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -1,3 +1,11 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_ICONV +#include +#endif + #include #include #include @@ -11,6 +19,41 @@ #include "bswap.h" #include "asfheader.h" +#ifndef HAVE_ICONV + +/* dummy conversion perserving ASCII only */ + +#define iconv_open(TO, FROM) 0 +#define iconv(CD, INBUF, INLEFT, OUTBUF, OUTLEFT) iconv_internal(INBUF, INLEFT, OUTBUF, OUTLEFT) +#define iconv_close(CD) +#ifdef ICONV_CONST +# undef ICONV_CONST +#endif +#define ICONV_CONST const + +typedef int iconv_t; + +size_t iconv_internal(const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { + size_t i, n; + const char *ins; + char *outs; + + n = *inbytesleft / 2 > *outbytesleft ? *outbytesleft : *inbytesleft / 2; + for (i = n, ins = *inbuf, outs = *outbuf; i > 0; i--) { + outs[0] = ((ins[0] & 0x80) || ins[1]) ? '?' : ins[0]; + ins += 2; + outs++; + } + *inbuf = ins; + *outbuf = outs; + (*inbytesleft) -= (2 * n); + (*outbytesleft) -= n; + + return 0; +} +#endif + + typedef struct asf_header_internal_s asf_header_internal_t; struct asf_header_internal_s { asf_header_t pub; @@ -105,7 +148,7 @@ static char *asf_reader_get_string(asf_reader_t *reader, size_t size, iconv_t cd outbuf = scratch; outbytesleft = sizeof(scratch); reader->pos += size; - if (iconv (cd, (char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft) != -1) { + if (iconv (cd, (ICONV_CONST char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft) != -1) { return strdup(scratch); } else { lprintf("iconv error\n"); @@ -311,11 +354,12 @@ int asf_header_parse_stream_extended_properties(asf_header_t *header, uint8_t *b uint16_t stream_number; int i; int stream_id; + asf_stream_extension_t *asf_stream_extension; if (buffer_len < 64) return 0; - asf_stream_extension_t *asf_stream_extension = malloc(sizeof(asf_stream_extension_t)); + asf_stream_extension = malloc(sizeof(asf_stream_extension_t)); if (!asf_stream_extension) return 0; diff --git a/src/demuxers/asfheader.h b/src/demuxers/asfheader.h index 31ac6c90b..d52b1c0fb 100644 --- a/src/demuxers/asfheader.h +++ b/src/demuxers/asfheader.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2006 the xine project * * This file is part of xine, a free video player. * @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: asfheader.h,v 1.7 2006/09/07 07:21:09 tmattern Exp $ + * $Id: asfheader.h,v 1.8 2006/09/12 21:24:19 valtri Exp $ * * demultiplexer for asf streams * @@ -33,7 +33,6 @@ #define ASFHEADER_H #include -#include /* * define asf GUIDs (list from avifile) @@ -400,4 +399,4 @@ void asf_header_disable_streams (asf_header_t *header, void asf_header_delete (asf_header_t *header); -#endif +#endif diff --git a/src/input/mms.c b/src/input/mms.c index 6c735295e..fe9ec7532 100644 --- a/src/input/mms.c +++ b/src/input/mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: mms.c,v 1.61 2006/09/07 07:21:06 tmattern Exp $ + * $Id: mms.c,v 1.62 2006/09/12 21:24:21 valtri Exp $ * * MMS over TCP protocol * based on work from major mms @@ -275,7 +275,7 @@ static void string_utf16_close(iconv_t url_conv) { } } -static void string_utf16(iconv_t url_conv, char *dest, char *src, int len) { +static void string_utf16(iconv_t url_conv, char *dest, ICONV_CONST char *src, int len) { memset(dest, 0, 1000); if (url_conv == (iconv_t)-1) { @@ -290,7 +290,8 @@ static void string_utf16(iconv_t url_conv, char *dest, char *src, int len) { } else { size_t len1, len2; - char *ip, *op; + ICONV_CONST char *ip; + char *op; len1 = len; len2 = 1000; ip = src; op = dest; @@ -299,7 +300,7 @@ static void string_utf16(iconv_t url_conv, char *dest, char *src, int len) { } #else -static void string_utf16(int unused, char *dest, char *src, int len) { +static void string_utf16(int unused, char *dest, const char *src, int len) { int i; memset (dest, 0, 1000); diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c index 799e5fd00..c7a493382 100644 --- a/src/xine-engine/info_helper.c +++ b/src/xine-engine/info_helper.c @@ -20,7 +20,7 @@ * stream metainfo helper functions * hide some xine engine details from demuxers and reduce code duplication * - * $Id: info_helper.c,v 1.16 2006/03/03 12:59:31 hadess Exp $ + * $Id: info_helper.c,v 1.17 2006/09/12 21:24:21 valtri Exp $ */ #ifdef HAVE_CONFIG_H @@ -193,14 +193,14 @@ static int meta_info_validate_utf8 (const char *value) { iconv_t cd; char *utf8_value; - char *inbuf, *outbuf; + ICONV_CONST char *inbuf, *outbuf; size_t inbytesleft, outbytesleft; if ((cd = iconv_open("UTF-8", "UTF-8")) == (iconv_t)-1) { return 0; } - inbuf = (char *)value; + inbuf = (ICONV_CONST char *)value; inbytesleft = strlen(value); outbytesleft = 4 * inbytesleft; /* estimative (max) */ outbuf = utf8_value = malloc(outbytesleft+1); @@ -247,10 +247,11 @@ static void meta_info_set_unlocked_encoding(xine_stream_t *stream, int info, con if (cd != (iconv_t)-1) { char *utf8_value; - char *inbuf, *outbuf; + ICONV_CONST char *inbuf; + char *outbuf; size_t inbytesleft, outbytesleft; - inbuf = (char *)value; + inbuf = (ICONV_CONST char *)value; inbytesleft = strlen(value); outbytesleft = 4 * inbytesleft; /* estimative (max) */ outbuf = utf8_value = malloc(outbytesleft+1); diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 80eff7461..320240aa8 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -957,7 +957,8 @@ static int osd_search(osd_fontchar_t *array, size_t n, uint16_t code) { * get next unicode value */ static uint16_t osd_iconv_getunicode(xine_t *xine, - iconv_t *cd, const char *encoding, char **inbuf, size_t *inbytesleft) { + iconv_t *cd, const char *encoding, ICONV_CONST char **inbuf, + size_t *inbytesleft) { uint16_t unicode; char *outbuf = (char*)&unicode; size_t outbytesleft = 2; @@ -1105,7 +1106,7 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, while( inbytesleft ) { #ifdef HAVE_ICONV unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, - (char **)&inbuf, &inbytesleft); + (ICONV_CONST char **)&inbuf, &inbytesleft); #else unicode = inbuf[0]; inbuf++; @@ -1273,7 +1274,7 @@ static int osd_get_text_size(osd_object_t *osd, const char *text, int *width, in while( inbytesleft ) { #ifdef HAVE_ICONV unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, - (char **)&inbuf, &inbytesleft); + (ICONV_CONST char **)&inbuf, &inbytesleft); #else unicode = inbuf[0]; inbuf++; -- cgit v1.2.3