This commit is contained in:
hummypkg 2011-10-25 21:19:58 +00:00 committed by HummyPkg
parent 48eec1f3ba
commit da83a21b67
2 changed files with 30 additions and 2 deletions

View File

@ -42,6 +42,7 @@ epg: ${OBJS}
${CFLAGS} -o $@ \
${OBJS} \
${LIBS}
@strip epg
@echo "Done..."
clean:

31
main.c
View File

@ -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 <file> 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 <text> Search programme names for text.\n"
" searchall <text> "
@ -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);