( const char *name, const char *netu, const char *muxu, htsmsg_t *channels )
{
tvh_uuid_t svcu;
+ char ubuf[UUID_HEX_SIZE];
htsmsg_t *c, *e, *svc;
htsmsg_field_t *f;
const char *str;
if (!(e = htsmsg_field_get_map(f))) continue;
svc = htsmsg_create_map();
- uuid_init_hex(&svcu, NULL);
+ uuid_set(&svcu, NULL);
if (!htsmsg_get_u32(e, "service_id", &u32))
htsmsg_add_u32(svc, "sid", u32);
if ((str = htsmsg_get_str(e, "servicename")))
// TODO: dvb_eit_enable
hts_settings_save(svc, "input/linuxdvb/networks/%s/muxes/%s/services/%s",
- netu, muxu, svcu.hex);
+ netu, muxu, uuid_get_hex(&svcu, ubuf));
/* Map to channel */
if ((str = htsmsg_get_str(e, "channelname")))
- config_migrate_v1_chn_add_svc(channels, str, svcu.hex);
+ config_migrate_v1_chn_add_svc(channels, str, ubuf);
}
htsmsg_destroy(c);
}
{
int i;
tvh_uuid_t netu, muxu;
+ char ubuf[UUID_HEX_SIZE], ubuf2[UUID_HEX_SIZE];
htsmsg_t *e, *net, *mux, *tun;
htsmsg_field_t *f;
const char *str, *type;
type = str;
/* Create network entry */
- uuid_init_hex(&netu, NULL);
+ uuid_set(&netu, NULL);
net = htsmsg_create_map();
if (!strcmp(str, "ATSC"))
htsmsg_add_str(net, "class", "linuxdvb_network_atsc");
htsmsg_add_str(mux, "delsys", "DVBT");
/* Save */
- uuid_init_hex(&muxu, NULL);
+ uuid_set(&muxu, NULL);
hts_settings_save(mux, "input/linuxdvb/networks/%s/muxes/%s/config",
- netu.hex, muxu.hex);
+ uuid_get_hex(&netu, ubuf),
+ uuid_get_hex(&muxu, ubuf2));
htsmsg_destroy(mux);
/* Services */
- config_migrate_v1_dvb_svcs(f->hmf_name, netu.hex, muxu.hex, channels);
+ config_migrate_v1_dvb_svcs(f->hmf_name, ubuf, ubuf2, channels);
}
/* Add properties derived from network */
htsmsg_add_str(net, "networkname", name);
- hts_settings_save(net, "input/linuxdvb/networks/%s/config", netu.hex);
+ hts_settings_save(net, "input/linuxdvb/networks/%s/config",
+ uuid_get_hex(&netu, ubuf));
htsmsg_destroy(net);
}
uint32_t u32;
const char *str;
char buf[1024];
+ char ubufc[UUID_HEX_SIZE];
+ char ubufn[UUID_HEX_SIZE];
+ char ubufm[UUID_HEX_SIZE];
+ char ubufs[UUID_HEX_SIZE];
htsmsg_t *channels = htsmsg_create_map();
/* Channels */
if (!(e = htsmsg_field_get_map(f))) continue;
/* Build entry */
- uuid_init_hex(&chnu, NULL);
+ uuid_set(&chnu, NULL);
m = htsmsg_create_map();
htsmsg_add_u32(m, "channelid", atoi(f->hmf_name));
- htsmsg_add_str(m, "uuid", chnu.hex);
+ htsmsg_add_str(m, "uuid", uuid_get_hex(&chnu, ubufc));
htsmsg_add_msg(m, "services", htsmsg_create_list());
if (!htsmsg_get_u32(e, "dvr_extra_time_pre", &u32))
htsmsg_add_u32(m, "dvr_pre_time", u32);
if ((c = hts_settings_load_r(1, "iptvservices"))) {
/* Create a network */
- uuid_init_hex(&netu, NULL);
+ uuid_set(&netu, NULL);
m = htsmsg_create_map();
htsmsg_add_str(m, "networkname", "IPTV Network");
htsmsg_add_u32(m, "skipinitscan", 1);
htsmsg_add_u32(m, "autodiscovery", 0);
htsmsg_add_u32(m, "max_streams", 0);
htsmsg_add_u32(m, "max_bandwidth", 0);
- hts_settings_save(m, "input/iptv/networks/%s/config", netu.hex);
+ hts_settings_save(m, "input/iptv/networks/%s/config",
+ uuid_get_hex(&netu, ubufn));
htsmsg_destroy(m);
/* Process services */
if (htsmsg_get_u32(e, "port", &u32)) continue;
/* Create mux entry */
- uuid_init_hex(&muxu, NULL);
+ uuid_set(&muxu, NULL);
m = htsmsg_create_map();
snprintf(buf, sizeof(buf), "udp://%s:%d", str, u32);
htsmsg_add_str(m, "iptv_url", buf);
!!htsmsg_get_u32_or_default(e, "disabled", 0));
htsmsg_add_u32(m, "initscan", 1);
hts_settings_save(m, "input/iptv/networks/%s/muxes/%s/config",
- netu.hex, muxu.hex);
+ ubufn, uuid_get_hex(&muxu, ubufm));
htsmsg_destroy(m);
/* Create svc entry */
- uuid_init_hex(&svcu, NULL);
+ uuid_set(&svcu, NULL);
+ uuid_get_hex(&svcu, ubufs);
m = htsmsg_create_map();
if (!htsmsg_get_u32(e, "pmt", &u32))
htsmsg_add_u32(m, "pmt", u32);
htsmsg_add_u32(m, "disabled", u32);
if ((str = htsmsg_get_str(e, "channelname"))) {
htsmsg_add_str(m, "svcname", str);
- config_migrate_v1_chn_add_svc(channels, str, svcu.hex);
+ config_migrate_v1_chn_add_svc(channels, str, ubufs);
}
hts_settings_save(m, "input/iptv/networks/%s/muxes/%s/services/%s",
- netu.hex, muxu.hex, svcu.hex);
+ ubufn, ubufm, ubufs);
htsmsg_destroy(m);
}
{
htsmsg_t *m;
tvh_uuid_t u;
+ char ubuf[UUID_HEX_SIZE];
char src[1024], dst[1024];
/* Do we have IPTV config to migrate ? */
if (hts_settings_exists("input/iptv/muxes")) {
/* Create a dummy network */
- uuid_init_hex(&u, NULL);
+ uuid_set(&u, NULL);
+ uuid_get_hex(&u, ubuf);
m = htsmsg_create_map();
htsmsg_add_str(m, "networkname", "IPTV Network");
htsmsg_add_u32(m, "skipinitscan", 1);
htsmsg_add_u32(m, "autodiscovery", 0);
- hts_settings_save(m, "input/iptv/networks/%s/config", u.hex);
+ hts_settings_save(m, "input/iptv/networks/%s/config", ubuf);
htsmsg_destroy(m);
/* Move muxes */
hts_settings_buildpath(src, sizeof(src),
"input/iptv/muxes");
hts_settings_buildpath(dst, sizeof(dst),
- "input/iptv/networks/%s/muxes", u.hex);
+ "input/iptv/networks/%s/muxes", ubuf);
rename(src, dst);
}
}
htsmsg_t *c, *e;
htsmsg_field_t *f;
tvh_uuid_t u;
+ char ubuf[UUID_HEX_SIZE];
uint32_t index = 1, id;
if (!(c = hts_settings_load(dir)))
HTSMSG_FOREACH(f, c) {
if (!(e = htsmsg_field_get_map(f))) continue;
- uuid_init_hex(&u, NULL);
+ uuid_set(&u, NULL);
+ uuid_get_hex(&u, ubuf);
if (htsmsg_get_u32(e, "id", &id))
id = 0;
else if (list) {
char buf[16];
snprintf(buf, sizeof(buf), "%d", id);
htsmsg_add_str(m, "id", buf);
- htsmsg_add_str(m, "uuid", u.hex);
+ htsmsg_add_str(m, "uuid", ubuf);
htsmsg_add_msg(list, NULL, m);
}
htsmsg_delete_field(e, "id");
htsmsg_add_u32(e, "index", index++);
if (modify)
- modify(e, id, u.hex, aux);
- hts_settings_save(e, "%s/%s", dir, u.hex);
+ modify(e, id, ubuf, aux);
+ hts_settings_save(e, "%s/%s", dir, ubuf);
hts_settings_remove("%s/%s", dir, f->hmf_name);
}
uint32_t u32;
htsmsg_delete_field(c, "index");
- if (chname == NULL || (chuuid != NULL && uuid_init_bin(&uuid0, chuuid))) {
+ if (chname == NULL || (chuuid != NULL && uuid_set(&uuid0, chuuid))) {
chname = strdup(chuuid ?: "");
htsmsg_delete_field(c, "channelname");
htsmsg_delete_field(c, "channel");
htsmsg_t *c, *e;
htsmsg_field_t *f;
tvh_uuid_t u;
+ char ubuf[UUID_HEX_SIZE];
config_migrate_simple("autorec", list, config_modify_autorec, NULL);
config_migrate_simple("dvr/log", NULL, config_modify_dvr_log, list);
if (!(e = htsmsg_field_get_map(f))) continue;
if (strcmp(f->hmf_name, "config")) continue;
htsmsg_add_str(e, "name", f->hmf_name + 6);
- uuid_init_hex(&u, NULL);
+ uuid_set(&u, NULL);
hts_settings_remove("dvr/%s", f->hmf_name);
- hts_settings_save(e, "dvr/config/%s", u.hex);
+ hts_settings_save(e, "dvr/config/%s", uuid_get_hex(&u, ubuf));
}
/* step 2: reset (without "config") */
HTSMSG_FOREACH(f, c) {
if (strcmp(f->hmf_name, "config") == 0) continue;
if (strncmp(f->hmf_name, "config", 6)) continue;
htsmsg_add_str(e, "name", f->hmf_name + 6);
- uuid_init_hex(&u, NULL);
+ uuid_set(&u, NULL);
hts_settings_remove("dvr/%s", f->hmf_name);
- hts_settings_save(e, "dvr/config/%s", u.hex);
+ hts_settings_save(e, "dvr/config/%s", uuid_get_hex(&u, ubuf));
}
htsmsg_destroy(c);
}
htsmsg_field_t *f;
const char *username, *passwd;
tvh_uuid_t u;
+ char ubuf[UUID_HEX_SIZE];
if ((c = hts_settings_load("accesscontrol")) != NULL) {
HTSMSG_FOREACH(f, c) {
m = htsmsg_create_map();
htsmsg_add_str(m, "username", username);
htsmsg_add_str(m, "password2", passwd);
- uuid_init_hex(&u, NULL);
- hts_settings_save(m, "passwd/%s", u.hex);
+ uuid_set(&u, NULL);
+ hts_settings_save(m, "passwd/%s", uuid_get_hex(&u, ubuf));
htsmsg_delete_field(e, "password2");
hts_settings_save(e, "accesscontrol/%s", f->hmf_name);
}
uint32_t maj, min;
int64_t num;
tvh_uuid_t u;
+ char ubuf[UUID_HEX_SIZE];
if ((c = hts_settings_load_r(1, "epggrab/%s/channels", modname)) != NULL) {
HTSMSG_FOREACH(f, c) {
htsmsg_add_s64(n, "lcn", num);
htsmsg_delete_field(n, "major");
htsmsg_delete_field(n, "minor");
- uuid_init_hex(&u, NULL);
+ uuid_set(&u, NULL);
hts_settings_remove("epggrab/%s/channels/%s", modname, f->hmf_name);
- hts_settings_save(n, "epggrab/%s/channels/%s", modname, u.hex);
+ hts_settings_save(n, "epggrab/%s/channels/%s", modname, uuid_get_hex(&u, ubuf));
htsmsg_destroy(n);
}
htsmsg_destroy(c);
/* Initialise binary */
int
-uuid_init_bin ( tvh_uuid_t *u, const char *str )
+uuid_set ( tvh_uuid_t *u, const char *str )
{
- memset(u, 0, sizeof(tvh_uuid_t));
if (str) {
if (strlen(str) != UUID_HEX_SIZE - 1) {
- tvherror(LS_UUID, "wrong uuid size");
+ memset(u, 0, sizeof(*u));
+ tvherror(LS_UUID, "wrong uuid string size (%zd)", strlen(str));
+ return -EINVAL;
+ }
+ if (hex2bin(u->bin, sizeof(u->bin), str)) {
+ memset(u, 0, sizeof(*u));
+ tvherror(LS_UUID, "wrong uuid string '%s'", str);
return -EINVAL;
}
- return hex2bin(u->bin, sizeof(u->bin), str);
} else if (read(fd, u->bin, sizeof(u->bin)) != sizeof(u->bin)) {
tvherror(LS_UUID, "failed to read from %s", RANDOM_PATH);
return -EINVAL;
}
/* Initialise hex string */
-int
-uuid_init_hex ( tvh_uuid_t *u, const char *str )
-{
- tvh_uuid_t tmp;
- if (uuid_init_bin(&tmp, str))
- return 1;
- return uuid_bin2hex(&tmp, u);
-}
-
-/* Convert bin to hex string */
-int
-uuid_bin2hex ( const tvh_uuid_t *a, tvh_uuid_t *b )
+char *
+uuid_get_hex ( const tvh_uuid_t *u, char *dst )
{
- tvh_uuid_t tmp;
- memset(&tmp, 0, sizeof(tmp));
- bin2hex(tmp.hex, sizeof(tmp.hex), a->bin, sizeof(a->bin));
- memcpy(b, &tmp, sizeof(tmp));
- return 0;
-}
-
-/* Convert hex string to bin (in place) */
-int
-uuid_hex2bin ( const tvh_uuid_t *a, tvh_uuid_t *b )
-{
- tvh_uuid_t tmp;
- memset(&tmp, 0, sizeof(tmp));
- if (hex2bin(tmp.bin, sizeof(tmp.bin), a->hex))
- return 1;
- memcpy(b, &tmp, sizeof(tmp));
- return 0;
+ assert(dst);
+ bin2hex(dst, UUID_HEX_SIZE, u->bin, sizeof(u->bin));
+ return dst;
}
-/* Validate hex string */
+/* Validate the hexadecimal representation of uuid */
int
uuid_hexvalid ( const char *uuid )
{