From 18b82bf36fd67aedcb1a52e45ca625611f1c3e1e Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 25 Aug 2011 19:51:00 +0000 Subject: [PATCH] add -/ --- epg.c | 9 ++++++++- main.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/epg.c b/epg.c index 4a5df3d..e2b89d8 100644 --- a/epg.c +++ b/epg.c @@ -120,7 +120,14 @@ check_filter_range(struct epgfilter *f, enum epgfiltertype type, for (; f; f = f->next) { - if (f->type == type && (f->num < idl || f->num > idh)) + if (f->type != type) + continue; + if (f->match == FT_RANGE) + { + if (idl < f->num || idl > f->num2) + return 0; + } + else if (f->num < idl || f->num > idh) return 0; } return 1; diff --git a/main.c b/main.c index 24f4b48..a6a1c6f 100644 --- a/main.c +++ b/main.c @@ -43,8 +43,12 @@ syntax() " -E Show only selected event.\n" " -R Show only events with this Series ID.\n" " -S Show only selected service.\n" + ); + fprintf(stderr, " -T Show only selected content types.\n" " -@ Show only programmes at time.\n" + " -/ Show only programmes on day.\n" + " -/ Show only programmes on day.\n" "\n" ); fprintf(stderr, @@ -126,7 +130,7 @@ sqldumpstart() printf("(\n"); printf("service_id bigint unsigned not null default 0,\n"); printf("event_id bigint unsigned not null default 0,\n"); - printf("start datetime not null,\n"); + printf("start bigint unsigned not null,\n"); printf("duration bigint unsigned not null,\n"); printf("name varchar(255),\n"); printf("text varchar(255),\n"); @@ -138,6 +142,7 @@ sqldumpstart() printf("rec_crid varchar(255),\n"); printf("primary key (service_id, event_id),\n"); printf("index name (name),\n"); + printf("index start (start),\n"); printf("index text (text)\n"); printf(") engine=innodb;\n"); printf("truncate epg;\n"); @@ -525,6 +530,30 @@ main(int argc, char **argv) atoi(cp), 0, NULL, FT_EQUAL); goto nextopt; + case '/': + { + unsigned long dstart, dend, dat; + struct tm *tm; + + GETOPT; + dat = atoi(cp); + /* If specified as number of days, then convert + * to timestamp. */ + if (dat < 1000) + dat = (unsigned long)time(NULL) + + dat * 86400; + tm = localtime((time_t *)&dat); + tm->tm_hour = tm->tm_min = tm->tm_sec = 0; + dstart = mktime(tm); + tm->tm_hour = 23; + tm->tm_min = tm->tm_sec = 59; + dend = mktime(tm); + + add_epgfilter(&filter, FILTER_TIMESTAMP, + dstart, dend, NULL, FT_RANGE); + goto nextopt; + } + case 'C': GETOPT; add_epgfilter(&filter, FILTER_CRID,