From 63f96d33e4499f7b096827056a2d5cc2ba0ab2d5 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Wed, 30 Nov 2011 21:38:30 +0000 Subject: [PATCH] add first command --- main.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index aac9efb..45516c5 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ #include "lint.h" int debug = 0; -const char *version = "1.0.7"; +const char *version = "1.0.8"; unsigned long sysopts = 0; unsigned long filterflags = 0; static time_t latest_stamp = 0; @@ -72,7 +72,8 @@ syntax() ); fprintf(stderr, " now Show what is currently on.\n" - " last Show the time of the latest record.\n" + " first Show the time of the earliest record.\n" + " last Show the time of the latest record.\n" " parse Parse the EPG, no output.\n" " search Search programme names for text.\n" " searchall " @@ -110,6 +111,21 @@ latest(struct epg *epg __attribute__((unused)), latest_stamp = tm; } +void +earliest(struct epg *epg __attribute__((unused)), + struct section *s __attribute__((unused)), + struct data *d __attribute__((unused)), + struct descriptor **ds __attribute__((unused)), + void *var __attribute__((unused))) +{ + time_t tm; + + tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec); + + if (!latest_stamp || tm < latest_stamp) + latest_stamp = tm; +} + void dumpraw(struct epg *epg __attribute__((unused)), struct section *s, struct data *d, struct descriptor **ds, @@ -814,6 +830,11 @@ nextopt: parse(epgpath, latest, NULL, filter); printf("%ld\n", latest_stamp); } + else if (!strcmp(argv[0], "first")) + { + parse(epgpath, earliest, NULL, filter); + printf("%ld\n", latest_stamp); + } else if (!strcmp(argv[0], "dumpraw")) parse(epgpath, dumpraw, NULL, filter); else if (!strcmp(argv[0], "sqldump"))