add now and brief mode
This commit is contained in:
parent
89736f5fab
commit
9f637857c8
1
lint.h
1
lint.h
|
@ -4,6 +4,7 @@
|
|||
#include "util.h"
|
||||
|
||||
#define SYSOPT_PARSABLE 0x1
|
||||
#define SYSOPT_BRIEF 0x2
|
||||
|
||||
extern int debug;
|
||||
extern const char *version;
|
||||
|
|
59
main.c
59
main.c
|
@ -28,15 +28,17 @@ syntax()
|
|||
"Syntax: epg [options] <command>...\n");
|
||||
fprintf(stderr,
|
||||
" Options:\n"
|
||||
" -d[level] Set debug level.\n"
|
||||
" -f<file> Specify alternate EPG data file.\n"
|
||||
" -h Show help text.\n"
|
||||
" -b Brief output.\n"
|
||||
" -d[level] Set debug level.\n"
|
||||
" -f<file> Specify alternate EPG data file.\n"
|
||||
" -h Show help text.\n"
|
||||
" -p Parsable output.\n"
|
||||
);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr,
|
||||
" Commands:\n"
|
||||
" dump Show a parsed summary of the EPG.\n"
|
||||
" now Show what is currently on.\n"
|
||||
" search <text> Search programme names for text.\n"
|
||||
" searchall <text> "
|
||||
"Search programme names/descriptions for text.\n"
|
||||
|
@ -56,6 +58,33 @@ dump(struct epg *epg __attribute__((unused)),
|
|||
|
||||
printf("----------------------------------------------------------\n");
|
||||
|
||||
if (sysopts & SYSOPT_BRIEF)
|
||||
{
|
||||
safeprintf("%d/%d: %s+%d\n",
|
||||
s->service_id, d->event_id, ctime_nl(&tm),
|
||||
d->dur_hour * 3600 + d->dur_min * 60 + d->dur_sec);
|
||||
if (ds[PARSER_SHORT_EVENT])
|
||||
{
|
||||
struct descriptor *d77 = ds[PARSER_SHORT_EVENT];
|
||||
|
||||
safeprintf("Name:%.*s\n",
|
||||
d77->content.d77.namelen, d77->content.d77.name);
|
||||
safeprintf("Text:%.*s\n",
|
||||
d77->content.d77.textlen, d77->content.d77.text);
|
||||
}
|
||||
|
||||
if (ds[PARSER_USER_DEFINED])
|
||||
{
|
||||
struct descriptor *d137 = ds[PARSER_USER_DEFINED];
|
||||
|
||||
safeprintf("Warning:%.*s\n",
|
||||
d137->content.d137.warninglen,
|
||||
d137->content.d137.warning);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (sysopts & SYSOPT_PARSABLE)
|
||||
{
|
||||
printf("ServiceID:%d\n", s->service_id);
|
||||
|
@ -172,6 +201,24 @@ 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);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -185,6 +232,10 @@ main(int argc, char **argv)
|
|||
{
|
||||
switch (*cp)
|
||||
{
|
||||
case 'b':
|
||||
sysopts |= SYSOPT_BRIEF;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (*++cp == '\0')
|
||||
debug = 1;
|
||||
|
@ -225,6 +276,8 @@ nextopt:
|
|||
|
||||
if (!strcmp(argv[0], "dump"))
|
||||
parse(epgpath, dump, NULL);
|
||||
if (!strcmp(argv[0], "now"))
|
||||
parse(epgpath, now, NULL);
|
||||
else if (!strcmp(argv[0], "search") && argc > 1)
|
||||
parse(epgpath, search, (void *)argv[1]);
|
||||
else if (!strcmp(argv[0], "searchall") && argc > 1)
|
||||
|
|
Loading…
Reference in New Issue