add daemon mode

This commit is contained in:
hummypkg 2011-10-14 22:51:16 +00:00 committed by HummyPkg
parent d39e1c32b1
commit 6b516bf434
1 changed files with 24 additions and 0 deletions

24
main.c
View File

@ -803,6 +803,30 @@ nextopt:
parse(epgpath, sqlitedump, NULL, filter);
sqlitedumpend(argv[1]);
}
else if (!strcmp(argv[0], "sqlitedumpd") && argc == 2)
{
time_t last = 0;
for (;;)
{
struct stat st;
if (stat(epgpath, &st) == -1)
{
perror("stat");
return 1;
}
if (st.st_mtime > last)
{
printf("epgd: DB time %ld > last %ld\n", st.st_mtime, last);
sqlitedumpstart(argv[1]);
parse(epgpath, sqlitedump, NULL, filter);
sqlitedumpend(argv[1]);
}
last = st.st_mtime;
sleep(900);
}
}
#endif
else if (!strcmp(argv[0], "now"))
{