aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-11 22:26:46 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-13 17:39:44 +0100
commit7f8c62bf57b85234c248316505a503602792839a (patch)
treeef8ff6e778840192ee7cfb6c06579602ed6942cb /src/event.c
parentdd85a7374675c3f91e215c2e318b2c5045a01f53 (diff)
downloadcalcurse-7f8c62bf57b85234c248316505a503602792839a.tar.gz
calcurse-7f8c62bf57b85234c248316505a503602792839a.zip
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src/event.c')
-rw-r--r--src/event.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/event.c b/src/event.c
index 1e9d940..e0891a2 100644
--- a/src/event.c
+++ b/src/event.c
@@ -147,6 +147,7 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
{
char buf[BUFSIZ], *nl;
time_t tstart, tend;
+ struct event *ev;
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
!check_time(start.tm_hour, start.tm_min),
@@ -187,7 +188,19 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
return NULL;
}
- return event_new(buf, note, tstart, id);
+ ev = event_new(buf, note, tstart, id);
+
+ /* Filter by hash. */
+ if (filter && filter->hash) {
+ char *hash = event_hash(ev);
+ if (!hash_matches(filter->hash, hash)) {
+ event_delete(ev);
+ ev = NULL;
+ }
+ mem_free(hash);
+ }
+
+ return ev;
}
/* Delete an event from the list. */