intlconv: use iconv for utf8 conversions

This commit is contained in:
Jaroslav Kysela 2014-05-20 21:25:44 +02:00
parent 02f2140708
commit d07071bf90
7 changed files with 1453 additions and 2 deletions

View file

@ -117,7 +117,8 @@ SRCS = src/version.c \
src/rtsp.c \
src/fsmonitor.c \
src/cron.c \
src/esfilter.c
src/esfilter.c \
src/intlconv.c
SRCS-${CONFIG_UPNP} += \
src/upnp.c
@ -133,7 +134,8 @@ SRCS += \
src/api/api_epg.c \
src/api/api_epggrab.c \
src/api/api_imagecache.c \
src/api/api_esfilter.c
src/api/api_esfilter.c \
src/api/api_intlconv.c
SRCS += \
src/parsers/parsers.c \

View file

@ -126,6 +126,7 @@ void api_init ( void )
api_status_init();
api_imagecache_init();
api_esfilter_init();
api_intlconv_init();
}
void api_done ( void )

View file

@ -68,6 +68,7 @@ void api_epggrab_init ( void );
void api_status_init ( void );
void api_imagecache_init ( void );
void api_esfilter_init ( void );
void api_intlconv_init ( void );
/*
* IDnode

68
src/api/api_intlconv.c Normal file
View file

@ -0,0 +1,68 @@
/*
* API - international character conversions
*
* Copyright (C) 2014 Jaroslav Kysela
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TVH_API_INTLCONV_H__
#define __TVH_API_INTLCONV_H__
#include "tvheadend.h"
#include "access.h"
#include "api.h"
#include "intlconv.h"
static int
api_intlconv_charset_enum
( void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
const char **chrst;
htsmsg_t *l, *e;
int _enum = htsmsg_get_bool_or_default(args, "enum", 0);
if (_enum) {
l = htsmsg_create_list();
chrst = intlconv_charsets;
while (*chrst) {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", *chrst);
htsmsg_add_str(e, "val", *chrst);
htsmsg_add_msg(l, NULL, e);
chrst++;
}
*resp = htsmsg_create_map();
htsmsg_add_msg(*resp, "entries", l);
} else {
// TODO: support full listing v enum
}
return 0;
}
void api_intlconv_init ( void )
{
static api_hook_t ah[] = {
{ "intlconv/charsets", ACCESS_ANONYMOUS, api_intlconv_charset_enum, NULL },
{ NULL },
};
api_register_all(ah);
}
#endif /* __TVH_API_INTLCONV_H__ */

1336
src/intlconv.c Normal file

File diff suppressed because it is too large Load diff

39
src/intlconv.h Normal file
View file

@ -0,0 +1,39 @@
/*
* tvheadend, iconv interface
* Copyright (C) 2014 Jaroslav Kysela
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INTLCONV_H_
#define INTLCONV_H_
extern const char *intlconv_charsets[];
void intlconv_init( void );
void intlconv_done( void );
char *
intlconv_charset_id( const char *charset,
int transil,
int ignore_bad_chars );
ssize_t
intlconv_utf8( char *dst, size_t dst_size,
const char *dst_charset_id,
const char *src_utf8 );
char *
intlconv_utf8safestr( const char *dst_charset_id,
const char *src_utf8,
size_t max_size );
#endif /* INTLCONV_H_ */

View file

@ -62,6 +62,7 @@
#include "fsmonitor.h"
#include "lang_codes.h"
#include "esfilter.h"
#include "intlconv.h"
#if ENABLE_LIBAV
#include "libav.h"
#include "plumbing/transcoding.h"
@ -755,6 +756,8 @@ main(int argc, char **argv)
/**
* Initialize subsystems
*/
intlconv_init();
api_init();
@ -880,6 +883,7 @@ main(int argc, char **argv)
tvhftrace("main", dvb_done);
tvhftrace("main", lang_str_done);
tvhftrace("main", esfilter_done);
tvhftrace("main", intlconv_done);
tvhftrace("main", urlparse_done);
tvhlog(LOG_NOTICE, "STOP", "Exiting HTS Tvheadend");