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 --- src/demuxers/asfheader.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- src/demuxers/asfheader.h | 7 +++---- 2 files changed, 49 insertions(+), 6 deletions(-) (limited to 'src/demuxers') 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 -- cgit v1.2.3