re-implement now using -@

This commit is contained in:
hummypkg 2011-06-05 19:36:34 +00:00 committed by HummyPkg
parent b0255bc6b0
commit c63e1251dc
1 changed files with 7 additions and 19 deletions

26
main.c
View File

@ -230,24 +230,6 @@ searchall(struct epg *epg __attribute__((unused)),
dump(epg, s, d, ds, NULL);
}
void
now(struct epg *epg __attribute__((unused)),
struct section *s, struct data *d, struct descriptor **ds,
void *var __attribute__((unused)))
{
static time_t now = 0;
time_t tm, etm;
if (!now)
time(&now);
tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec);
etm = tm + d->dur_hour * 3600 + d->dur_min * 60 + d->dur_sec;
if (tm <= now && etm > now)
dump(epg, s, d, ds, NULL);
}
#define GETOPT \
do { \
if (*++cp == '\0' && argc < 2) \
@ -346,7 +328,13 @@ nextopt:
else if (!strcmp(argv[0], "dumpraw"))
parse(epgpath, dumpraw, NULL, filter);
else if (!strcmp(argv[0], "now"))
parse(epgpath, now, NULL, filter);
{
time_t tm;
time(&tm);
add_epgfilter(&filter, FILTER_TIMESTAMP, tm, 0, NULL, FT_EQUAL);
parse(epgpath, dump, NULL, filter);
}
else if (!strcmp(argv[0], "search") && argc > 1)
parse(epgpath, search, (void *)argv[1], filter);
else if (!strcmp(argv[0], "searchall") && argc > 1)