aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-07-04 10:51:26 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-07-06 01:55:40 +0200
commit3b259b56207e6334eb4ec98f7c17d6b11cf15b85 (patch)
tree3d0f5c392829c88fbbf1b137bffa106b220ec9dc
parenta1394e98330eaaae67eb1567013d27ae1a25b77f (diff)
downloadcalcurse-3b259b56207e6334eb4ec98f7c17d6b11cf15b85.tar.gz
calcurse-3b259b56207e6334eb4ec98f7c17d6b11cf15b85.zip
Add day_item_fork()
Add a new function that can be used to copy one day item into another, cloning the actual item that is linked. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/calcurse.h1
-rw-r--r--src/day.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index afbf1b0..cefc850 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -667,6 +667,7 @@ char *day_item_get_mesg(struct day_item *);
char *day_item_get_note(struct day_item *);
long day_item_get_duration(struct day_item *);
int day_item_get_state(struct day_item *);
+void day_item_fork(struct day_item *, struct day_item *);
int day_store_items(long, unsigned *, unsigned *, regex_t *);
struct day_items_nb *day_process_storage(struct date *, unsigned,
struct day_items_nb *);
diff --git a/src/day.c b/src/day.c
index 179b97b..26ae3e0 100644
--- a/src/day.c
+++ b/src/day.c
@@ -149,6 +149,31 @@ int day_item_get_state(struct day_item *day)
}
}
+/* Clone the actual item. */
+void day_item_fork(struct day_item *day_in, struct day_item *day_out)
+{
+ day_out->type = day_in->type;
+ day_out->start = day_in->start;
+
+ switch (day_in->type) {
+ case APPT:
+ day_out->item.apt = apoint_dup(day_in->item.apt);
+ break;
+ case EVNT:
+ day_out->item.ev = event_dup(day_in->item.ev);
+ break;
+ case RECUR_APPT:
+ day_out->item.rapt = recur_apoint_dup(day_in->item.rapt);
+ break;
+ case RECUR_EVNT:
+ day_out->item.rev = recur_event_dup(day_in->item.rev);
+ break;
+ default:
+ EXIT(_("unknown item type"));
+ /* NOTREACHED */
+ }
+}
+
/*
* Store the events for the selected day in structure pointed
* by day_items. This is done by copying the events