From c61205b9fdd385b83e188e0c21851b7b2f60066e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sat, 28 Feb 2009 16:31:33 +0000 Subject: [PATCH] Use int for tag IDs --- channels.c | 11 ++++++----- channels.h | 2 +- htsp.c | 10 +++++----- webui/extjs.c | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/channels.c b/channels.c index 631dbfc1..cf78195a 100644 --- a/channels.c +++ b/channels.c @@ -324,7 +324,7 @@ channel_save(channel_t *ch) tags = htsmsg_create_array(); LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) - htsmsg_add_str(tags, NULL, ctm->ctm_tag->ct_identifier); + htsmsg_add_u32(tags, NULL, ctm->ctm_tag->ct_identifier); htsmsg_add_msg(m, "tags", tags); @@ -622,10 +622,12 @@ channel_tag_find(const char *id, int create) channel_tag_t *ct; char buf[20]; static int tally; + uint32_t u32; if(id != NULL) { + u32 = atoi(id); TAILQ_FOREACH(ct, &channel_tags, ct_link) - if(!strcmp(ct->ct_identifier, id)) + if(ct->ct_identifier == u32) return ct; } @@ -641,7 +643,7 @@ channel_tag_find(const char *id, int create) tally = MAX(atoi(id), tally); } - ct->ct_identifier = strdup(id); + ct->ct_identifier = atoi(id); ct->ct_name = strdup("New tag"); ct->ct_comment = strdup(""); ct->ct_icon = strdup(""); @@ -682,7 +684,6 @@ channel_tag_destroy(channel_tag_t *ct) if(ct->ct_enabled && !ct->ct_internal) htsp_tag_delete(ct); - free(ct->ct_identifier); free(ct->ct_name); free(ct->ct_comment); free(ct->ct_icon); @@ -705,7 +706,7 @@ channel_tag_record_build(channel_tag_t *ct) htsmsg_add_str(e, "name", ct->ct_name); htsmsg_add_str(e, "comment", ct->ct_comment); htsmsg_add_str(e, "icon", ct->ct_icon); - htsmsg_add_str(e, "id", ct->ct_identifier); + htsmsg_add_u32(e, "id", ct->ct_identifier); return e; } diff --git a/channels.h b/channels.h index a98e6e51..d72fc90d 100644 --- a/channels.h +++ b/channels.h @@ -71,10 +71,10 @@ typedef struct channel_tag { int ct_enabled; int ct_internal; int ct_titled_icon; + int ct_identifier; char *ct_name; char *ct_comment; char *ct_icon; - char *ct_identifier; struct channel_tag_mapping_list ct_ctms; struct dvr_autorec_entry_list ct_autorecs; diff --git a/htsp.c b/htsp.c index 6b0f83fa..84faf0ea 100644 --- a/htsp.c +++ b/htsp.c @@ -262,7 +262,7 @@ htsp_build_channel(channel_t *ch, const char *method) LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) { ct = ctm->ctm_tag; if(ct->ct_enabled && !ct->ct_internal) - htsmsg_add_str(tags, NULL, ct->ct_identifier); + htsmsg_add_u32(tags, NULL, ct->ct_identifier); } htsmsg_add_msg(out, "tags", tags); @@ -278,10 +278,10 @@ static htsmsg_t * htsp_build_tag(channel_tag_t *ct, const char *method, int include_channels) { channel_tag_mapping_t *ctm; - htsmsg_t *out = htsmsg_create(); - htsmsg_t *members = include_channels ? htsmsg_create_array() : NULL; + htsmsg_t *out = htsmsg_create(); + htsmsg_t *members = include_channels ? htsmsg_create_array() : NULL; - htsmsg_add_str(out, "tagId", ct->ct_identifier); + htsmsg_add_u32(out, "tagId", ct->ct_identifier); htsmsg_add_str(out, "tagName", ct->ct_name); htsmsg_add_str(out, "tagIcon", ct->ct_icon); @@ -891,7 +891,7 @@ void htsp_tag_delete(channel_tag_t *ct) { htsmsg_t *m = htsmsg_create(); - htsmsg_add_str(m, "tagId", ct->ct_identifier); + htsmsg_add_u32(m, "tagId", ct->ct_identifier); htsmsg_add_str(m, "method", "tagDelete"); htsp_async_send(m); } diff --git a/webui/extjs.c b/webui/extjs.c index e0f56369..05f2fa83 100644 --- a/webui/extjs.c +++ b/webui/extjs.c @@ -699,7 +699,7 @@ extjs_channel(http_connection_t *hc, const char *remain, void *opaque) buf[0] = 0; LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "%s%s", strlen(buf) == 0 ? "" : ",", + "%s%d", strlen(buf) == 0 ? "" : ",", ctm->ctm_tag->ct_identifier); } htsmsg_add_str(r, "tags", buf); @@ -895,7 +895,7 @@ extjs_channeltags(http_connection_t *hc, const char *remain, void *opaque) continue; e = htsmsg_create(); - htsmsg_add_str(e, "identifier", ct->ct_identifier); + htsmsg_add_u32(e, "identifier", ct->ct_identifier); htsmsg_add_str(e, "name", ct->ct_name); htsmsg_add_msg(array, NULL, e); }