diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2018-09-01 08:47:59 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2018-09-01 08:47:59 +0800 |
commit | c5b6d181707cade0785f84bbd2df17f8268f5a4a (patch) | |
tree | 9648ba7c2878fcdfb7446ff9e8cabdcf034300cf /lib/extract.c | |
parent | 148eec92611367a6fc0f688377a74f89968bf7e7 (diff) | |
download | nfcollect-c5b6d181707cade0785f84bbd2df17f8268f5a4a.tar.gz nfcollect-c5b6d181707cade0785f84bbd2df17f8268f5a4a.tar.zst nfcollect-c5b6d181707cade0785f84bbd2df17f8268f5a4a.zip |
Add extract time range selection
Diffstat (limited to 'lib/extract.c')
-rw-r--r-- | lib/extract.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/extract.c b/lib/extract.c index ea10582..8907c26 100644 --- a/lib/extract.c +++ b/lib/extract.c @@ -76,7 +76,7 @@ static int nfl_extract_lz4(FILE *f, nfl_state_t *state) { return 0; } -int nfl_extract_worker(const char *filename, nfl_state_t *state) { +int nfl_extract_worker(const char *filename, nfl_state_t *state, const time_range_t *range) { FILE *f; int got = 0, ret = 0; nfl_header_t *h; @@ -91,6 +91,9 @@ int nfl_extract_worker(const char *filename, nfl_state_t *state) { got = fread(state->header, sizeof(nfl_header_t), 1, f); h = state->header; + if(h->end_time < range->from || h->start_time > range->until) + return 0; + // Check header validity WARN_RETURN(ferror(f), "%s", strerror(errno)); WARN_RETURN(got == 0 || nfl_verify_header(h) < 0, |