summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-04-14 11:28:22 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-04-19 11:42:34 +0200
commit6f883c0f3f4c08fe8e125f269da9b940519ccf44 (patch)
treeb66a7de57c6e56004f4f96867884270bc635d27f /src/io.c
parent1de34587abc135edf9af8f9d8d6094ac10f0143c (diff)
downloadcalcurse-6f883c0f3f4c08fe8e125f269da9b940519ccf44.zip
Use generic lists for events.
Use the new generic list implementation instead of those insane "next" pointers in events. Includes some cleanups. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/io.c b/src/io.c
index c46b281..2e6fcf1 100644
--- a/src/io.c
+++ b/src/io.c
@@ -461,15 +461,16 @@ pcal_export_recur_events (FILE *stream)
static void
ical_export_events (FILE *stream)
{
- struct event *i;
+ llist_item_t *i;
char ical_date[BUFSIZ];
- for (i = eventlist; i != NULL; i = i->next)
+ LLIST_FOREACH (&eventlist, i)
{
- date_sec2date_fmt (i->day, ICALDATEFMT, ical_date);
+ struct event *ev = LLIST_TS_GET_DATA (i);
+ date_sec2date_fmt (ev->day, ICALDATEFMT, ical_date);
(void)fprintf (stream, "BEGIN:VEVENT\n");
(void)fprintf (stream, "DTSTART:%s\n", ical_date);
- (void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
+ (void)fprintf (stream, "SUMMARY:%s\n", ev->mesg);
(void)fprintf (stream, "END:VEVENT\n");
}
}
@@ -477,11 +478,14 @@ ical_export_events (FILE *stream)
static void
pcal_export_events (FILE *stream)
{
- struct event *i;
+ llist_item_t *i;
(void)fprintf (stream, "\n# ======\n# Events\n# ======\n");
- for (i = eventlist; i != NULL; i = i->next)
- pcal_dump_event (stream, i->day, 0, i->mesg);
+ LLIST_FOREACH (&eventlist, i)
+ {
+ struct event *ev = LLIST_TS_GET_DATA (i);
+ pcal_dump_event (stream, ev->day, 0, ev->mesg);
+ }
(void)fprintf (stream, "\n");
}
@@ -964,7 +968,6 @@ unsigned
io_save_apts (void)
{
llist_item_t *i;
- struct event *e;
FILE *fp;
if ((fp = fopen (path_apts, "w")) == NULL)
@@ -982,8 +985,11 @@ io_save_apts (void)
if (ui_mode == UI_CURSES)
LLIST_TS_UNLOCK (&alist_p);
- for (e = eventlist; e != NULL; e = e->next)
- event_write (e, fp);
+ LLIST_FOREACH (&eventlist, i)
+ {
+ struct event *ev = LLIST_TS_GET_DATA (i);
+ event_write (ev, fp);
+ }
file_close (fp, __FILE_POS__);
return 1;