Use TAILQ for channels in the per-group list

This commit is contained in:
Andreas Öman 2007-12-02 16:32:12 +00:00
parent a1e3cffd49
commit ce7bad8bba
3 changed files with 11 additions and 23 deletions

View file

@ -41,7 +41,6 @@
struct th_channel_list channels;
struct th_transport_list all_transports;
int nchannels;
int grouporder = 1000;
struct th_channel_group_queue all_channel_groups;
@ -49,15 +48,6 @@ th_channel_group_t *defgroup;
void scanner_init(void);
/**
*
*/
static int
ch_order_cmp(th_channel_t *a, th_channel_t *b)
{
return a->ch_order - b->ch_order;
}
/**
*
*/
@ -77,7 +67,8 @@ channel_group_find(const char *name, int create)
tcg->tcg_name = strdup(name);
tcg->tcg_tag = tag_get();
tcg->tcg_order = grouporder++;
TAILQ_INIT(&tcg->tcg_channels);
TAILQ_INSERT_HEAD(&all_channel_groups, tcg, tcg_global_link);
return tcg;
}
@ -92,10 +83,10 @@ void
channel_set_group(th_channel_t *ch, th_channel_group_t *tcg)
{
if(ch->ch_group != NULL)
LIST_REMOVE(ch, ch_group_link);
TAILQ_REMOVE(&ch->ch_group->tcg_channels, ch, ch_group_link);
ch->ch_group = tcg;
LIST_INSERT_SORTED(&tcg->tcg_channels, ch, ch_group_link, ch_order_cmp);
TAILQ_INSERT_TAIL(&tcg->tcg_channels, ch, ch_group_link);
}
/**
@ -109,7 +100,7 @@ channel_group_destroy(th_channel_group_t *tcg)
if(defgroup == tcg)
return;
while((ch = LIST_FIRST(&tcg->tcg_channels)) != NULL) {
while((ch = TAILQ_FIRST(&tcg->tcg_channels)) != NULL) {
channel_set_group(ch, defgroup);
}
@ -158,8 +149,7 @@ channel_find(const char *name, int create)
ch->ch_index = nchannels;
TAILQ_INIT(&ch->ch_epg_events);
ch->ch_order = nchannels + 1000;
LIST_INSERT_SORTED(&channels, ch, ch_global_link, ch_order_cmp);
LIST_INSERT_HEAD(&channels, ch, ch_global_link);
channel_set_group(ch, defgroup);

View file

@ -440,7 +440,7 @@ page_root(http_connection_t *hc, const char *remain, void *opaque)
box_bottom(&tq);
tcp_qprintf(&tq, "<br>");
LIST_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
box_top(&tq, "box");
tcp_qprintf(&tq, "<div class=\"content3\">");
@ -1276,7 +1276,7 @@ page_chgroups(http_connection_t *hc, const char *remain, void *opaque)
tcp_qprintf(&tq, "<div class=\"content3\">");
cnt = 0;
LIST_FOREACH(ch, &tcg->tcg_channels, ch_group_link)
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link)
cnt++;
tcp_qprintf(&tq, "<b>%s</b> (%d channels)<br>", tcg->tcg_name, cnt);

View file

@ -69,6 +69,7 @@ typedef struct dtimer {
LIST_HEAD(th_subscription_list, th_subscription);
LIST_HEAD(th_channel_list, th_channel);
TAILQ_HEAD(th_channel_queue, th_channel);
TAILQ_HEAD(th_channel_group_queue, th_channel_group);
LIST_HEAD(th_dvb_adapter_list, th_dvb_adapter);
LIST_HEAD(th_v4l_adapter_list, th_v4l_adapter);
@ -622,9 +623,8 @@ typedef struct th_channel_group {
TAILQ_ENTRY(th_channel_group) tcg_global_link;
const char *tcg_name;
struct th_channel_list tcg_channels;
struct th_channel_queue tcg_channels;
int tcg_tag;
int tcg_order;
int tcg_cant_delete_me;
} th_channel_group_t;
@ -637,9 +637,7 @@ typedef struct th_channel {
LIST_ENTRY(th_channel) ch_global_link;
int ch_order;
LIST_ENTRY(th_channel) ch_group_link;
TAILQ_ENTRY(th_channel) ch_group_link;
th_channel_group_t *ch_group;
LIST_HEAD(, th_transport) ch_transports;