aboutsummaryrefslogtreecommitdiffstats
path: root/src/apoint.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-08-06 08:53:51 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-08-06 12:08:14 +0200
commitbfe73d0e5d66c43006a8a0dd8d58e311432bcb57 (patch)
tree584c1f12effddb2501566a872f7787be65124b89 /src/apoint.c
parent4ec7fe123925144506297df5eba4ed41c6f8331d (diff)
downloadcalcurse-bfe73d0e5d66c43006a8a0dd8d58e311432bcb57.tar.gz
calcurse-bfe73d0e5d66c43006a8a0dd8d58e311432bcb57.zip
Add item filters
This adds the following filter options that allow for restricting the set of items that are read from the appointments file: * --filter-type * --filter-start-from * --filter-start-to * --filter-start-after * --filter-start-before * --filter-end-from * --filter-end-to * --filter-end-after * --filter-end-before Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/apoint.c')
-rw-r--r--src/apoint.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/apoint.c b/src/apoint.c
index f00dd1e..9bdd575 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -163,7 +163,7 @@ void apoint_write(struct apoint *o, FILE * f)
}
struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end,
- char state, char *note)
+ char state, char *note, struct item_filter *filter)
{
char buf[BUFSIZ], *newline;
time_t tstart, tend;
@@ -193,6 +193,21 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end,
tend = mktime(&end);
EXIT_IF(tstart == -1 || tend == -1 || tstart > tend,
_("date error in appointment"));
+
+ /* Filter item. */
+ if (filter) {
+ if (!(filter->type_mask & TYPE_MASK_APPT))
+ return NULL;
+ if (filter->start_from >= 0 && tstart < filter->start_from)
+ return NULL;
+ if (filter->start_to >= 0 && tstart > filter->start_to)
+ return NULL;
+ if (filter->end_from >= 0 && tend < filter->end_from)
+ return NULL;
+ if (filter->end_to >= 0 && tend > filter->end_to)
+ return NULL;
+ }
+
return apoint_new(buf, note, tstart, tend - tstart, state);
}