diff --git a/Makefile b/Makefile index 5ef251a..0d95e45 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ epg: ${OBJS} ${CFLAGS} -o $@ \ ${OBJS} \ ${LIBS} + @strip epg @echo "Done..." clean: diff --git a/main.c b/main.c index ed1a53d..7408fb7 100644 --- a/main.c +++ b/main.c @@ -20,9 +20,10 @@ #include "lint.h" int debug = 0; -const char *version = "1.0.5"; +const char *version = "1.0.6"; unsigned long sysopts = 0; unsigned long filterflags = 0; +static time_t latest_stamp = 0; #ifdef HAVE_SQLITE3 sqlite3 *db; @@ -68,7 +69,10 @@ syntax() #ifdef HAVE_SQLITE3 " sqlitedump Create SQLite database from EPG data.\n" #endif + ); + fprintf(stderr, " now Show what is currently on.\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 " @@ -91,6 +95,21 @@ pass(struct epg *epg __attribute__((unused)), /* Do nothing. */ } +void +latest(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 (tm > latest_stamp) + latest_stamp = tm; +} + void dumpraw(struct epg *epg __attribute__((unused)), struct section *s, struct data *d, struct descriptor **ds, @@ -790,6 +809,11 @@ nextopt: parse(epgpath, dump, NULL, filter); else if (!strcmp(argv[0], "parse")) parse(epgpath, pass, NULL, filter); + else if (!strcmp(argv[0], "last")) + { + parse(epgpath, latest, NULL, filter); + printf("%ld\n", latest_stamp); + } else if (!strcmp(argv[0], "dumpraw")) parse(epgpath, dumpraw, NULL, filter); else if (!strcmp(argv[0], "sqldump")) @@ -820,15 +844,18 @@ nextopt: printf("epgd: DB time %ld, last %ld\n", st.st_mtime, last); + fflush(stdout); if (st.st_mtime > last) { time_t tm = time(NULL); printf("epgd: Regenerating.\n"); + fflush(stdout); sqlitedumpstart(argv[1]); parse(epgpath, sqlitedump, NULL, filter); sqlitedumpend(argv[1]); - printf("epgd: Done in %d seconds.\n", + printf("epgd: Done in %ld seconds.\n", time(NULL) - tm); + fflush(stdout); } last = st.st_mtime; sleep(900);