aboutsummaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-04-12 19:40:53 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-04-19 11:42:33 +0200
commit77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02 (patch)
treedf93d5ce8ab8f50e05a335839c6578f228783528 /src/io.c
parentd668963e2056027526374098efe2869a0d389b92 (diff)
downloadcalcurse-77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02.tar.gz
calcurse-77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02.zip
Use generic lists for appointments.
Use the new generic list implementation instead of "apoint_list" everywhere. Simplify stuff and drop unused variables as well. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/io.c b/src/io.c
index 8cb9804..c46b281 100644
--- a/src/io.c
+++ b/src/io.c
@@ -594,34 +594,38 @@ pcal_export_recur_apoints (FILE *stream)
static void
ical_export_apoints (FILE *stream)
{
- struct apoint *i;
+ llist_item_t *i;
char ical_datetime[BUFSIZ];
- pthread_mutex_lock (&(alist_p->mutex));
- for (i = alist_p->root; i != NULL; i = i->next)
+ LLIST_TS_LOCK (&alist_p);
+ LLIST_TS_FOREACH (&alist_p, i)
{
- date_sec2date_fmt (i->start, ICALDATETIMEFMT, ical_datetime);
+ struct apoint *apt = LLIST_TS_GET_DATA (i);
+ date_sec2date_fmt (apt->start, ICALDATETIMEFMT, ical_datetime);
(void)fprintf (stream, "BEGIN:VEVENT\n");
(void)fprintf (stream, "DTSTART:%s\n", ical_datetime);
- (void)fprintf (stream, "DURATION:PT0H0M%ldS\n", i->dur);
- (void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
- if (i->state & APOINT_NOTIFY)
+ (void)fprintf (stream, "DURATION:PT0H0M%ldS\n", apt->dur);
+ (void)fprintf (stream, "SUMMARY:%s\n", apt->mesg);
+ if (apt->state & APOINT_NOTIFY)
ical_export_valarm (stream);
(void)fprintf (stream, "END:VEVENT\n");
}
- pthread_mutex_unlock (&(alist_p->mutex));
+ LLIST_TS_UNLOCK (&alist_p);
}
static void
pcal_export_apoints (FILE *stream)
{
- struct apoint *i;
+ llist_item_t *i;
(void)fprintf (stream, "\n# ============\n# Appointments\n# ============\n");
- pthread_mutex_lock (&(alist_p->mutex));
- for (i = alist_p->root; i != NULL; i = i->next)
- pcal_dump_apoint (stream, i->start, i->dur, i->mesg);
- pthread_mutex_unlock (&(alist_p->mutex));
+ LLIST_TS_LOCK (&alist_p);
+ LLIST_TS_FOREACH (&alist_p, i)
+ {
+ struct apoint *apt = LLIST_TS_GET_DATA (i);
+ pcal_dump_apoint (stream, apt->start, apt->dur, apt->mesg);
+ }
+ LLIST_TS_UNLOCK (&alist_p);
(void)fprintf (stream, "\n");
}
@@ -959,7 +963,7 @@ io_save_conf (struct conf *conf)
unsigned
io_save_apts (void)
{
- struct apoint *a;
+ llist_item_t *i;
struct event *e;
FILE *fp;
@@ -969,11 +973,14 @@ io_save_apts (void)
recur_save_data (fp);
if (ui_mode == UI_CURSES)
- pthread_mutex_lock (&(alist_p->mutex));
- for (a = alist_p->root; a != NULL; a = a->next)
- apoint_write (a, fp);
+ LLIST_TS_LOCK (&alist_p);
+ LLIST_TS_FOREACH (&alist_p, i)
+ {
+ struct apoint *apt = LLIST_TS_GET_DATA (i);
+ apoint_write (apt, fp);
+ }
if (ui_mode == UI_CURSES)
- pthread_mutex_unlock (&(alist_p->mutex));
+ LLIST_TS_UNLOCK (&alist_p);
for (e = eventlist; e != NULL; e = e->next)
event_write (e, fp);