/* Copy the lang_str instance */ lang_str_t *lang_str_copy ( const lang_str_t *ls ) { lang_str_t *ret = lang_str_create(); lang_str_ele_t *e; RB_FOREACH(e, ls, link) lang_str_add(ret, e->str, e->lang, 0); return ret; }
/* * Short Event - 0x4d */ static int _eit_desc_short_event ( epggrab_module_t *mod, const uint8_t *ptr, int len, eit_event_t *ev ) { int r; char lang[4]; char buf[512]; if ( len < 5 ) return -1; /* Language */ memcpy(lang, ptr, 3); lang[3] = '\0'; len -= 3; ptr += 3; /* Title */ if ( (r = _eit_get_string_with_len(mod, buf, sizeof(buf), ptr, len, ev->default_charset)) < 0 ) { return -1; } else if ( r > 1 ) { if (!ev->title) ev->title = lang_str_create(); lang_str_add(ev->title, buf, lang, 0); } len -= r; ptr += r; if ( len < 1 ) return -1; /* Summary */ if ( (r = _eit_get_string_with_len(mod, buf, sizeof(buf), ptr, len, ev->default_charset)) < 0 ) { return -1; } else if ( r > 1 ) { if (!ev->summary) ev->summary = lang_str_create(); lang_str_add(ev->summary, buf, lang, 0); } return 0; }
/* * Parse a series of language strings */ static void _xmltv_parse_lang_str ( lang_str_t **ls, htsmsg_t *tags, const char *tname ) { htsmsg_t *e, *attrib; htsmsg_field_t *f; const char *lang; HTSMSG_FOREACH(f, tags) { if (!strcmp(f->hmf_name, tname) && (e = htsmsg_get_map_by_field(f))) { if (!*ls) *ls = lang_str_create(); lang = NULL; if ((attrib = htsmsg_get_map(e, "attrib"))) lang = htsmsg_get_str(attrib, "lang"); lang_str_add(*ls, htsmsg_get_str(e, "cdata"), lang, 0); } } }