add -@
This commit is contained in:
parent
5d5b4c62d6
commit
56b68007d8
50
epg.c
50
epg.c
|
@ -94,9 +94,9 @@ dump_data(struct data *d)
|
|||
DUMPINT(d, event_id);
|
||||
|
||||
tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec);
|
||||
printf(" %30s: %#x %d:%02d:%02d (%s)\n", "start_date",
|
||||
printf(" %30s: %#x %d:%02d:%02d (%s) [%ld]\n", "start_date",
|
||||
d->start_date, d->start_hour, d->start_min, d->start_sec,
|
||||
ctime_nl(&tm));
|
||||
ctime_nl(&tm), tm);
|
||||
|
||||
printf(" %30s: %d:%02d:%02d\n", "duration",
|
||||
d->dur_hour, d->dur_min, d->dur_sec);
|
||||
|
@ -107,15 +107,32 @@ dump_data(struct data *d)
|
|||
}
|
||||
|
||||
static inline int
|
||||
check_filter(struct epgfilter *f, enum epgfiltertype type,
|
||||
unsigned int id, char *str __attribute__((unused)))
|
||||
check_filter_range(struct epgfilter *f, enum epgfiltertype type,
|
||||
unsigned long idl, unsigned long idh)
|
||||
{
|
||||
if (!f)
|
||||
return 1;
|
||||
|
||||
for (; f; f = f->next)
|
||||
{
|
||||
if (f->type == type && (f->num < idl || f->num > idh))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
check_filter(struct epgfilter *f, enum epgfiltertype type,
|
||||
unsigned long id, char *str __attribute__((unused)))
|
||||
{
|
||||
if (!f)
|
||||
return 1;
|
||||
|
||||
for (; f; f = f->next)
|
||||
{
|
||||
if (f->type == type && f->num != id)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -169,6 +186,26 @@ parse(char *epgpath,
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((sysopts & SYSOPT_TIMESTAMP))
|
||||
{
|
||||
time_t tm;
|
||||
int dur;
|
||||
|
||||
tm = mjd(d->start_date, d->start_hour,
|
||||
d->start_min, d->start_sec);
|
||||
|
||||
dur = d->dur_hour * 3600 + d->dur_min * 60 +
|
||||
d->dur_sec;
|
||||
|
||||
if (!check_filter_range(filter,
|
||||
FILTER_TIMESTAMP, tm, tm + dur))
|
||||
{
|
||||
/* Skip this event. */
|
||||
epg->offset = dend;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
dslist[0] = dslist[1] = dslist[2] = NULL;
|
||||
|
||||
while (epg->offset < dend)
|
||||
|
@ -230,13 +267,16 @@ parse(char *epgpath,
|
|||
|
||||
void
|
||||
add_epgfilter(struct epgfilter **filter, enum epgfiltertype type,
|
||||
unsigned int num, char *str)
|
||||
unsigned long num, unsigned long num2, char *str, enum matchtype match)
|
||||
{
|
||||
struct epgfilter *f = malloc(sizeof(struct epgfilter));
|
||||
|
||||
f->type = type;
|
||||
f->num = num;
|
||||
f->num2 = num2;
|
||||
f->str = str;
|
||||
f->match = match;
|
||||
|
||||
f->next = *filter;
|
||||
*filter = f;
|
||||
}
|
||||
|
|
10
epg.h
10
epg.h
|
@ -62,14 +62,20 @@ struct data {
|
|||
enum epgfiltertype {
|
||||
FILTER_SERVICE = 0,
|
||||
FILTER_EVENT,
|
||||
FILTER_DESCRIPTOR
|
||||
FILTER_DESCRIPTOR,
|
||||
FILTER_TIMESTAMP
|
||||
};
|
||||
|
||||
enum matchtype { FT_EQUAL, FT_RANGE, FT_GREATER, FT_LESS };
|
||||
|
||||
struct epgfilter {
|
||||
enum epgfiltertype type;
|
||||
unsigned int num;
|
||||
unsigned long num;
|
||||
unsigned long num2;
|
||||
char *str;
|
||||
|
||||
enum matchtype match;
|
||||
|
||||
struct epgfilter *next;
|
||||
};
|
||||
|
||||
|
|
7
lint.h
7
lint.h
|
@ -3,8 +3,9 @@
|
|||
#include "descriptor.h"
|
||||
#include "util.h"
|
||||
|
||||
#define SYSOPT_PARSABLE 0x1
|
||||
#define SYSOPT_BRIEF 0x2
|
||||
#define SYSOPT_PARSABLE 0x1
|
||||
#define SYSOPT_BRIEF 0x2
|
||||
#define SYSOPT_TIMESTAMP 0x4
|
||||
|
||||
extern int debug;
|
||||
extern const char *version;
|
||||
|
@ -21,7 +22,7 @@ void safeprintf(char *, ...);
|
|||
struct epg *open_file(char *);
|
||||
void close_file(struct epg *);
|
||||
void add_epgfilter(struct epgfilter **, enum epgfiltertype,
|
||||
unsigned int, char *);
|
||||
unsigned long, unsigned long, char *, enum matchtype);
|
||||
|
||||
struct section *read_section(struct epg *);
|
||||
void dump_section(struct section *);
|
||||
|
|
19
main.c
19
main.c
|
@ -40,6 +40,7 @@ syntax()
|
|||
" -D<descriptor type> Show only selected descriptor type.\n"
|
||||
" -E<event id> Show only selected event.\n"
|
||||
" -S<service id> Show only selected service.\n"
|
||||
" -@<unix timestamp> Show only programmes at time.\n"
|
||||
"\n"
|
||||
);
|
||||
fprintf(stderr,
|
||||
|
@ -243,7 +244,7 @@ now(struct epg *epg __attribute__((unused)),
|
|||
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)
|
||||
if (tm <= now && etm > now)
|
||||
dump(epg, s, d, ds, NULL);
|
||||
}
|
||||
|
||||
|
@ -304,22 +305,32 @@ main(int argc, char **argv)
|
|||
break;
|
||||
|
||||
/* Filters */
|
||||
case '@':
|
||||
GETOPT;
|
||||
add_epgfilter(&filter, FILTER_TIMESTAMP,
|
||||
atoi(cp), 0, NULL, FT_EQUAL);
|
||||
/* Global flag to indicate that the
|
||||
* timestamp check is required - has overhead
|
||||
* so don't want to do it in all cases. */
|
||||
sysopts |= SYSOPT_TIMESTAMP;
|
||||
goto nextopt;
|
||||
|
||||
case 'D':
|
||||
GETOPT;
|
||||
add_epgfilter(&filter, FILTER_DESCRIPTOR,
|
||||
atoi(cp), NULL);
|
||||
atoi(cp), 0, NULL, FT_EQUAL);
|
||||
goto nextopt;
|
||||
|
||||
case 'E':
|
||||
GETOPT;
|
||||
add_epgfilter(&filter, FILTER_EVENT,
|
||||
atoi(cp), NULL);
|
||||
atoi(cp), 0, NULL, FT_EQUAL);
|
||||
goto nextopt;
|
||||
|
||||
case 'S':
|
||||
GETOPT;
|
||||
add_epgfilter(&filter, FILTER_SERVICE,
|
||||
atoi(cp), NULL);
|
||||
atoi(cp), 0, NULL, FT_EQUAL);
|
||||
goto nextopt;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue