Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
uuid: remove idnode_uuid_as_sstr() fcn
Use only re-entrant idnode_uuid_as_str() fcn.
  • Loading branch information
perexg committed Dec 7, 2015
1 parent 7643fd7 commit ea0e993
Show file tree
Hide file tree
Showing 52 changed files with 367 additions and 261 deletions.
27 changes: 17 additions & 10 deletions src/access.c
Expand Up @@ -512,6 +512,7 @@ access_update(access_t *a, access_entry_t *ae)
{
idnode_list_mapping_t *ilm;
const char *s;
char ubuf[UUID_HEX_SIZE];

switch (ae->ae_conn_limit_type) {
case ACCESS_CONN_LIMIT_TYPE_ALL:
Expand Down Expand Up @@ -550,7 +551,7 @@ access_update(access_t *a, access_entry_t *ae)
if(pro && pro->pro_name[0] != '\0') {
if (a->aa_profiles == NULL)
a->aa_profiles = htsmsg_create_list();
htsmsg_add_str_exclusive(a->aa_profiles, idnode_uuid_as_sstr(&pro->pro_id));
htsmsg_add_str_exclusive(a->aa_profiles, idnode_uuid_as_str(&pro->pro_id, ubuf));
}
}

Expand All @@ -559,7 +560,7 @@ access_update(access_t *a, access_entry_t *ae)
if(dvr && dvr->dvr_config_name[0] != '\0') {
if (a->aa_dvrcfgs == NULL)
a->aa_dvrcfgs = htsmsg_create_list();
htsmsg_add_str_exclusive(a->aa_dvrcfgs, idnode_uuid_as_sstr(&dvr->dvr_id));
htsmsg_add_str_exclusive(a->aa_dvrcfgs, idnode_uuid_as_str(&dvr->dvr_id, ubuf));
}
}

Expand All @@ -574,7 +575,7 @@ access_update(access_t *a, access_entry_t *ae)
if (ilm == NULL) {
if (a->aa_chtags == NULL)
a->aa_chtags = htsmsg_create_list();
htsmsg_add_str_exclusive(a->aa_chtags, idnode_uuid_as_sstr(&ct->ct_id));
htsmsg_add_str_exclusive(a->aa_chtags, idnode_uuid_as_str(&ct->ct_id, ubuf));
}
}
}
Expand All @@ -584,7 +585,7 @@ access_update(access_t *a, access_entry_t *ae)
if(ct && ct->ct_name[0] != '\0') {
if (a->aa_chtags == NULL)
a->aa_chtags = htsmsg_create_list();
htsmsg_add_str_exclusive(a->aa_chtags, idnode_uuid_as_sstr(&ct->ct_id));
htsmsg_add_str_exclusive(a->aa_chtags, idnode_uuid_as_str(&ct->ct_id, ubuf));
}
}
}
Expand Down Expand Up @@ -1145,8 +1146,9 @@ void
access_entry_save(access_entry_t *ae)
{
htsmsg_t *c = htsmsg_create_map();
char ubuf[UUID_HEX_SIZE];
idnode_save(&ae->ae_id, c);
hts_settings_save(c, "accesscontrol/%s", idnode_uuid_as_sstr(&ae->ae_id));
hts_settings_save(c, "accesscontrol/%s", idnode_uuid_as_str(&ae->ae_id, ubuf));
htsmsg_destroy(c);
}

Expand Down Expand Up @@ -1183,8 +1185,9 @@ static void
access_entry_class_delete(idnode_t *self)
{
access_entry_t *ae = (access_entry_t *)self;
char ubuf[UUID_HEX_SIZE];

hts_settings_remove("accesscontrol/%s", idnode_uuid_as_sstr(&ae->ae_id));
hts_settings_remove("accesscontrol/%s", idnode_uuid_as_str(&ae->ae_id, ubuf));
access_entry_destroy(ae);
}

Expand Down Expand Up @@ -1719,8 +1722,9 @@ void
passwd_entry_save(passwd_entry_t *pw)
{
htsmsg_t *c = htsmsg_create_map();
char ubuf[UUID_HEX_SIZE];
idnode_save(&pw->pw_id, c);
hts_settings_save(c, "passwd/%s", idnode_uuid_as_sstr(&pw->pw_id));
hts_settings_save(c, "passwd/%s", idnode_uuid_as_str(&pw->pw_id, ubuf));
htsmsg_destroy(c);
}

Expand All @@ -1734,8 +1738,9 @@ static void
passwd_entry_class_delete(idnode_t *self)
{
passwd_entry_t *pw = (passwd_entry_t *)self;
char ubuf[UUID_HEX_SIZE];

hts_settings_remove("passwd/%s", idnode_uuid_as_sstr(&pw->pw_id));
hts_settings_remove("passwd/%s", idnode_uuid_as_str(&pw->pw_id, ubuf));
passwd_entry_destroy(pw);
}

Expand Down Expand Up @@ -1884,8 +1889,9 @@ void
ipblock_entry_save(ipblock_entry_t *ib)
{
htsmsg_t *c = htsmsg_create_map();
char ubuf[UUID_HEX_SIZE];
idnode_save(&ib->ib_id, c);
hts_settings_save(c, "ipblock/%s", idnode_uuid_as_sstr(&ib->ib_id));
hts_settings_save(c, "ipblock/%s", idnode_uuid_as_str(&ib->ib_id, ubuf));
htsmsg_destroy(c);
}

Expand All @@ -1909,8 +1915,9 @@ static void
ipblock_entry_class_delete(idnode_t *self)
{
ipblock_entry_t *ib = (ipblock_entry_t *)self;
char ubuf[UUID_HEX_SIZE];

hts_settings_remove("ipblock/%s", idnode_uuid_as_sstr(&ib->ib_id));
hts_settings_remove("ipblock/%s", idnode_uuid_as_str(&ib->ib_id, ubuf));
ipblock_entry_destroy(ib);
}

Expand Down
3 changes: 2 additions & 1 deletion src/api/api_bouquet.c
Expand Up @@ -31,12 +31,13 @@ api_bouquet_list
{
bouquet_t *bq;
htsmsg_t *l, *e;
char ubuf[UUID_HEX_SIZE];

l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
RB_FOREACH(bq, &bouquets, bq_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", idnode_uuid_as_sstr(&bq->bq_id));
htsmsg_add_str(e, "key", idnode_uuid_as_str(&bq->bq_id, ubuf));
htsmsg_add_str(e, "val", bq->bq_name ?: "");
htsmsg_add_msg(l, NULL, e);
}
Expand Down
3 changes: 2 additions & 1 deletion src/api/api_caclient.c
Expand Up @@ -32,12 +32,13 @@ api_caclient_list
{
caclient_t *cac;
htsmsg_t *l, *e;
char ubuf[UUID_HEX_SIZE];

l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
TAILQ_FOREACH(cac, &caclients, cac_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "uuid", idnode_uuid_as_sstr(&cac->cac_id));
htsmsg_add_str(e, "uuid", idnode_uuid_as_str(&cac->cac_id, ubuf));
htsmsg_add_str(e, "title", idnode_get_title(&cac->cac_id, perm->aa_lang_ui));
htsmsg_add_str(e, "status", caclient_get_status(cac));
htsmsg_add_msg(l, NULL, e);
Expand Down
12 changes: 6 additions & 6 deletions src/api/api_channel.c
Expand Up @@ -49,17 +49,17 @@ api_channel_list
channel_t *ch;
htsmsg_t *l;
int cfg = api_channel_is_all(perm, args);
char buf[128];
char buf[128], ubuf[UUID_HEX_SIZE];

l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
CHANNEL_FOREACH(ch) {
if (!cfg && !channel_access(ch, perm, 0)) continue;
if (!ch->ch_enabled) {
snprintf(buf, sizeof(buf), "{%s}", channel_get_name(ch));
api_channel_key_val(l, idnode_uuid_as_sstr(&ch->ch_id), buf);
api_channel_key_val(l, idnode_uuid_as_str(&ch->ch_id, ubuf), buf);
} else {
api_channel_key_val(l, idnode_uuid_as_sstr(&ch->ch_id), channel_get_name(ch));
api_channel_key_val(l, idnode_uuid_as_str(&ch->ch_id, ubuf), channel_get_name(ch));
}
}
pthread_mutex_unlock(&global_lock);
Expand Down Expand Up @@ -107,17 +107,17 @@ api_channel_tag_list
channel_tag_t *ct;
htsmsg_t *l;
int cfg = api_channel_is_all(perm, args);
char buf[128];
char buf[128], ubuf[UUID_HEX_SIZE];

l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
TAILQ_FOREACH(ct, &channel_tags, ct_link)
if (cfg || channel_tag_access(ct, perm, 0)) {
if (ct->ct_enabled) {
api_channel_key_val(l, idnode_uuid_as_sstr(&ct->ct_id), ct->ct_name);
api_channel_key_val(l, idnode_uuid_as_str(&ct->ct_id, ubuf), ct->ct_name);
} else {
snprintf(buf, sizeof(buf), "{%s}", ct->ct_name);
api_channel_key_val(l, idnode_uuid_as_sstr(&ct->ct_id), buf);
api_channel_key_val(l, idnode_uuid_as_str(&ct->ct_id, ubuf), buf);
}
}
pthread_mutex_unlock(&global_lock);
Expand Down
6 changes: 4 additions & 2 deletions src/api/api_dvr.c
Expand Up @@ -137,6 +137,7 @@ api_dvr_entry_create
char *s, *lang;
const char *s1;
int res = EPERM;
char ubuf[UUID_HEX_SIZE];

if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;
Expand All @@ -145,7 +146,7 @@ api_dvr_entry_create
s1 = htsmsg_get_str(conf, "config_name");
cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, s1);
if (cfg) {
htsmsg_set_str(conf, "config_name", idnode_uuid_as_sstr(&cfg->dvr_id));
htsmsg_set_str(conf, "config_name", idnode_uuid_as_str(&cfg->dvr_id, ubuf));
htsmsg_set_str(conf, "owner", perm->aa_username ?: "");
htsmsg_set_str(conf, "creator", perm->aa_representative ?: "");

Expand Down Expand Up @@ -338,6 +339,7 @@ api_dvr_autorec_create
dvr_config_t *cfg;
dvr_autorec_entry_t *dae;
const char *s1;
char ubuf[UUID_HEX_SIZE];

if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;
Expand All @@ -352,7 +354,7 @@ api_dvr_autorec_create
pthread_mutex_lock(&global_lock);
cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, s1);
if (cfg) {
htsmsg_set_str(conf, "config_name", idnode_uuid_as_sstr(&cfg->dvr_id));
htsmsg_set_str(conf, "config_name", idnode_uuid_as_str(&cfg->dvr_id, ubuf));
dae = dvr_autorec_create(NULL, conf);
if (dae) {
dvr_autorec_save(dae);
Expand Down
9 changes: 5 additions & 4 deletions src/api/api_epg.c
Expand Up @@ -53,10 +53,10 @@ static void
api_epg_add_channel ( htsmsg_t *m, channel_t *ch )
{
int64_t chnum;
char buf[32];
char buf[32], ubuf[UUID_HEX_SIZE];
const char *s;
htsmsg_add_str(m, "channelName", channel_get_name(ch));
htsmsg_add_str(m, "channelUuid", channel_get_suuid(ch));
htsmsg_add_str(m, "channelUuid", channel_get_uuid(ch, ubuf));
if ((chnum = channel_get_number(ch)) >= 0) {
uint32_t maj = chnum / CHANNEL_SPLIT;
uint32_t min = chnum % CHANNEL_SPLIT;
Expand All @@ -81,6 +81,7 @@ api_epg_entry ( epg_broadcast_t *eb, const char *lang, access_t *perm )
epg_episode_num_t epnum;
epg_genre_t *eg;
dvr_entry_t *de;
char ubuf[UUID_HEX_SIZE];

if (!ee || !ch) return NULL;

Expand Down Expand Up @@ -170,9 +171,9 @@ api_epg_entry ( epg_broadcast_t *eb, const char *lang, access_t *perm )
if (de->de_bcast != eb)
continue;
if (access_verify_list(perm->aa_dvrcfgs,
idnode_uuid_as_sstr(&de->de_config->dvr_id)))
idnode_uuid_as_str(&de->de_config->dvr_id, ubuf)))
continue;
htsmsg_add_str(m, "dvrUuid", idnode_uuid_as_sstr(&de->de_id));
htsmsg_add_str(m, "dvrUuid", idnode_uuid_as_str(&de->de_id, ubuf));
htsmsg_add_str(m, "dvrState", dvr_entry_schedstatus(de));
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/api/api_epggrab.c
Expand Up @@ -38,10 +38,11 @@ api_epggrab_module_list
{
htsmsg_t *l = htsmsg_create_list(), *m;
epggrab_module_t *mod;
char ubuf[UUID_HEX_SIZE];
pthread_mutex_lock(&global_lock);
LIST_FOREACH(mod, &epggrab_modules, link) {
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_sstr(&mod->idnode));
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(&mod->idnode, ubuf));
htsmsg_add_str(m, "status", epggrab_module_get_status(mod));
htsmsg_add_str(m, "title", idnode_get_title(&mod->idnode, perm->aa_lang_ui));
htsmsg_add_msg(l, NULL, m);
Expand Down
11 changes: 7 additions & 4 deletions src/api/api_idnode.c
Expand Up @@ -126,6 +126,7 @@ api_idnode_grid
idnode_t *in;
idnode_set_t ins = { 0 };
api_idnode_grid_callback_t cb = opaque;
char ubuf[UUID_HEX_SIZE];

/* Grid configuration */
api_idnode_grid_conf(perm, args, &conf);
Expand All @@ -143,7 +144,7 @@ api_idnode_grid
for (i = conf.start; i < ins.is_count && conf.limit != 0; i++) {
in = ins.is_array[i];
e = htsmsg_create_map();
htsmsg_add_str(e, "uuid", idnode_uuid_as_sstr(in));
htsmsg_add_str(e, "uuid", idnode_uuid_as_str(in, ubuf));
if (idnode_perm(in, perm, NULL))
continue;
idnode_read0(in, e, flist, 0, conf.sort.lang);
Expand Down Expand Up @@ -176,6 +177,7 @@ api_idnode_load_by_class0
idnode_set_t *is;
idnode_t *in;
htsmsg_t *l, *e;
char ubuf[UUID_HEX_SIZE];

// TODO: this only works if pass as integer
_enum = htsmsg_get_bool_or_default(args, "enum", 0);
Expand All @@ -195,7 +197,7 @@ api_idnode_load_by_class0
/* Name/UUID only */
if (_enum) {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", idnode_uuid_as_sstr(in));
htsmsg_add_str(e, "key", idnode_uuid_as_str(in, ubuf));
htsmsg_add_str(e, "val", idnode_get_title(in, perm->aa_lang_ui));

/* Full record */
Expand Down Expand Up @@ -240,6 +242,7 @@ api_idnode_load
htsmsg_t *uuids, *l = NULL, *m, *flist;
htsmsg_field_t *f;
const char *uuid = NULL, *class;
char ubuf[UUID_HEX_SIZE];

/* Class based */
if ((class = htsmsg_get_str(args, "class"))) {
Expand Down Expand Up @@ -284,7 +287,7 @@ api_idnode_load
}
if (grid > 0) {
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_sstr(in));
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(in, ubuf));
idnode_read0(in, m, flist, 0, perm->aa_lang_ui);
} else {
m = idnode_serialize0(in, flist, 0, perm->aa_lang_ui);
Expand All @@ -308,7 +311,7 @@ api_idnode_load
} else {
if (grid > 0) {
m = htsmsg_create_map();
htsmsg_add_str(m, "uuid", idnode_uuid_as_sstr(in));
htsmsg_add_str(m, "uuid", idnode_uuid_as_str(in, ubuf));
idnode_read0(in, m, flist, 0, perm->aa_lang_ui);
} else {
m = idnode_serialize0(in, flist, 0, perm->aa_lang_ui);
Expand Down
3 changes: 2 additions & 1 deletion src/api/api_mpegts.c
Expand Up @@ -38,6 +38,7 @@ api_mpegts_input_network_list
mpegts_input_t *mi;
mpegts_network_t *mn;
idnode_set_t *is;
char ubuf[UUID_HEX_SIZE];
extern const idclass_t mpegts_input_class;

if (!(uuid = htsmsg_get_str(args, "uuid")))
Expand All @@ -57,7 +58,7 @@ api_mpegts_input_network_list
char buf[256];
htsmsg_t *e = htsmsg_create_map();
mn = (mpegts_network_t*)is->is_array[i];
htsmsg_add_str(e, "key", idnode_uuid_as_sstr(is->is_array[i]));
htsmsg_add_str(e, "key", idnode_uuid_as_str(is->is_array[i], ubuf));
mn->mn_display_name(mn, buf, sizeof(buf));
htsmsg_add_str(e, "val", buf);
htsmsg_add_msg(l, NULL, e);
Expand Down
3 changes: 2 additions & 1 deletion src/api/api_profile.c
Expand Up @@ -32,12 +32,13 @@ api_profile_list
{
profile_t *pro;
htsmsg_t *l, *e;
char ubuf[UUID_HEX_SIZE];

l = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
TAILQ_FOREACH(pro, &profiles, pro_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", idnode_uuid_as_sstr(&pro->pro_id));
htsmsg_add_str(e, "key", idnode_uuid_as_str(&pro->pro_id, ubuf));
htsmsg_add_str(e, "val", profile_get_name(pro));
htsmsg_add_msg(l, NULL, e);
}
Expand Down
3 changes: 2 additions & 1 deletion src/api/api_service.c
Expand Up @@ -66,14 +66,15 @@ static htsmsg_t *
api_mapper_status_msg ( void )
{
htsmsg_t *m;
char ubuf[UUID_HEX_SIZE];
service_mapper_status_t stat = service_mapper_status();
m = htsmsg_create_map();
htsmsg_add_u32(m, "total", stat.total);
htsmsg_add_u32(m, "ok", stat.ok);
htsmsg_add_u32(m, "fail", stat.fail);
htsmsg_add_u32(m, "ignore", stat.ignore);
if (stat.active)
htsmsg_add_str(m, "active", idnode_uuid_as_sstr(&stat.active->s_id));
htsmsg_add_str(m, "active", idnode_uuid_as_str(&stat.active->s_id, ubuf));
return m;
}

Expand Down

0 comments on commit ea0e993

Please sign in to comment.