aboutsummaryrefslogtreecommitdiffstats
path: root/src/args.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/args.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/args.c')
-rw-r--r--src/args.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/args.c b/src/args.c
index cd2c5d5..af1dae2 100644
--- a/src/args.c
+++ b/src/args.c
@@ -350,10 +350,10 @@ static int
app_arg (int add_line, struct date *day, long date, int print_note,
struct conf *conf, regex_t *regex)
{
+ llist_item_t *i;
struct recur_event *re;
struct event *j;
struct recur_apoint *ra;
- struct apoint *i;
long today;
unsigned print_date = 1;
int app_found = 0;
@@ -464,38 +464,36 @@ app_arg (int add_line, struct date *day, long date, int print_note,
}
pthread_mutex_unlock (&(recur_alist_p->mutex));
- pthread_mutex_lock (&(alist_p->mutex));
- for (i = alist_p->root; i != NULL; i = i->next)
+ LLIST_TS_LOCK (&alist_p);
+ LLIST_TS_FIND_FOREACH (&alist_p, today, apoint_inday, i)
{
- if (apoint_inday (i, today))
- {
- if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
- continue;
+ struct apoint *apt = LLIST_TS_GET_DATA (i);
+ if (regex && regexec (regex, apt->mesg, 0, 0, 0) != 0)
+ continue;
- app_found = 1;
- if (add_line)
- {
- fputs ("\n", stdout);
- add_line = 0;
- }
- if (print_date)
- {
- arg_print_date (today, conf);
- print_date = 0;
- }
- apoint_sec2str (i, APPT, today, apoint_start_time, apoint_end_time);
- fputs (" - ", stdout);
- fputs (apoint_start_time, stdout);
- fputs (" -> ", stdout);
- fputs (apoint_end_time, stdout);
- fputs ("\n\t", stdout);
- fputs (i->mesg, stdout);
+ app_found = 1;
+ if (add_line)
+ {
fputs ("\n", stdout);
- if (print_note && i->note)
- print_notefile (stdout, i->note, 2);
+ add_line = 0;
+ }
+ if (print_date)
+ {
+ arg_print_date (today, conf);
+ print_date = 0;
}
+ apoint_sec2str (apt, APPT, today, apoint_start_time, apoint_end_time);
+ fputs (" - ", stdout);
+ fputs (apoint_start_time, stdout);
+ fputs (" -> ", stdout);
+ fputs (apoint_end_time, stdout);
+ fputs ("\n\t", stdout);
+ fputs (apt->mesg, stdout);
+ fputs ("\n", stdout);
+ if (print_note && apt->note)
+ print_notefile (stdout, apt->note, 2);
}
- pthread_mutex_unlock (&(alist_p->mutex));
+ LLIST_TS_UNLOCK (&alist_p);
return (app_found);
}