aboutsummaryrefslogtreecommitdiffstats
path: root/src/calcurse.h
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2019-06-04 09:34:45 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2020-04-28 07:32:44 -0400
commitce81c0fa6362f0092f40eab1cddf0a6339c473c5 (patch)
tree4eac07b3b8ce8c24bc2952034b5410ccb5a48838 /src/calcurse.h
parent3f7bd331c875dd889c4d69537b5408396b0e8f16 (diff)
downloadcalcurse-ce81c0fa6362f0092f40eab1cddf0a6339c473c5.tar.gz
calcurse-ce81c0fa6362f0092f40eab1cddf0a6339c473c5.zip
Refactor function calls: recurrence parameters as a single argument
The recurrence parameters are type, frequency, until date and exception list (in RFC 5545 parlance FREQ, INTERVAL, UNTIL and EXDATE's). When these are passed in a function call, the argument list becomes long and not very readable. When support for extended recurrence rules is implemented, the number of recurrence parameters increases, and function signatures must be amended. Solution: The "struct rpt" is extended with the exception list; any future recurrence parameters are added here. A pointer to this structure replaces the recurrence parameters in function calls. Note: Each recurrent event and appoinment instance has (a pointer to) a "struct rpt" and in addition an exception list. The latter is retained to avoid the derived changes, and the exception list in the structure is initialized to an empty list when the recurrent instance is created. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/calcurse.h')
-rw-r--r--src/calcurse.h59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 70a3923..204ee2c 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -379,40 +379,44 @@ struct excp {
};
enum recur_type {
- RECUR_NO,
RECUR_DAILY,
RECUR_WEEKLY,
RECUR_MONTHLY,
RECUR_YEARLY,
- RECUR_TYPES
+ NBRECUR
};
-/* To describe an item's repetition. */
+/*
+ * Recurrence rule according to RFC5545; used
+ * - in each recurrent appointment/event instance
+ * - in passing parameters as a single function argument
+ */
struct rpt {
- enum recur_type type; /* repetition type */
- int freq; /* repetition frequency */
- time_t until; /* ending date for repeated event */
+ enum recur_type type; /* FREQ */
+ int freq; /* INTERVAL */
+ time_t until; /* UNTIL */
+ llist_t exc; /* EXDATE's */
};
/* Recurrent appointment definition. */
struct recur_apoint {
- struct rpt *rpt; /* information about repetition */
- llist_t exc; /* days when the item should not be repeated */
- time_t start; /* beggining of the appointment */
- long dur; /* duration of the appointment */
- char state; /* 8 bits to store item state */
- char *mesg; /* appointment description */
- char *note; /* note attached to appointment */
+ struct rpt *rpt; /* recurrence rule */
+ llist_t exc; /* recurrence exceptions (NOT rpt->exc) */
+ time_t start; /* start time */
+ long dur; /* duration */
+ char state; /* item state */
+ char *mesg; /* description */
+ char *note; /* attached note */
};
-/* Reccurent event definition. */
+/* Recurrent event definition. */
struct recur_event {
- struct rpt *rpt; /* information about repetition */
- llist_t exc; /* days when the item should not be repeated */
+ struct rpt *rpt; /* recurrence rule */
+ llist_t exc; /* recurrence exceptions (NOT rpt->exc) */
int id; /* event type */
- time_t day; /* day at which event occurs */
- char *mesg; /* event description */
- char *note; /* note attached to event */
+ time_t day; /* day of the event */
+ char *mesg; /* description */
+ char *note; /* attached note */
};
/* Generic pointer data type for appointments and events. */
@@ -1042,17 +1046,16 @@ void recur_event_llist_init(void);
void recur_apoint_llist_free(void);
void recur_event_llist_free(void);
struct recur_apoint *recur_apoint_new(char *, char *, time_t, long, char,
- int, int, time_t, llist_t *);
-struct recur_event *recur_event_new(char *, char *, time_t, int, int, int,
- time_t, llist_t *);
+ struct rpt *);
+struct recur_event *recur_event_new(char *, char *, time_t, int,
+ struct rpt *);
char recur_def2char(enum recur_type);
int recur_char2def(char);
-struct recur_apoint *recur_apoint_scan(FILE *, struct tm, struct tm,
- char, int, struct tm, char *,
- llist_t *, char, struct item_filter *);
-struct recur_event *recur_event_scan(FILE *, struct tm, int, char,
- int, struct tm, char *, llist_t *,
- struct item_filter *);
+struct recur_apoint *recur_apoint_scan(FILE *, struct tm, struct tm, char,
+ char *, struct item_filter *,
+ struct rpt *);
+struct recur_event *recur_event_scan(FILE *, struct tm, int, char *,
+ struct item_filter *, struct rpt *);
char *recur_apoint_tostr(struct recur_apoint *);
char *recur_apoint_hash(struct recur_apoint *);
void recur_apoint_write(struct recur_apoint *, FILE *);