From 7f8c62bf57b85234c248316505a503602792839a Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 11 Jan 2016 22:26:46 +0100 Subject: Add an option to filter by object hash Implement a new --filter-hash option to filter by object identifiers. Each object having an identifier that has the specified pattern as a prefix is matched. Patterns starting with an exclamation mark (!) are interpreted as negative patterns. Signed-off-by: Lukas Fleischer --- src/apoint.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/apoint.c') diff --git a/src/apoint.c b/src/apoint.c index 23c3163..457317d 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -190,6 +190,7 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, { char buf[BUFSIZ], *newline; time_t tstart, tend; + struct apoint *apt; EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) || !check_date(end.tm_year, end.tm_mon, end.tm_mday) || @@ -233,7 +234,19 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, return NULL; } - return apoint_new(buf, note, tstart, tend - tstart, state); + apt = apoint_new(buf, note, tstart, tend - tstart, state); + + /* Filter by hash. */ + if (filter && filter->hash) { + char *hash = apoint_hash(apt); + if (!hash_matches(filter->hash, hash)) { + apoint_delete(apt); + apt = NULL; + } + mem_free(hash); + } + + return apt; } void apoint_delete(struct apoint *apt) -- cgit v1.2.3-54-g00ecf