summaryrefslogtreecommitdiff
path: root/src/event.c
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2008-01-13 12:40:45 +0000
committerFrederic Culot <calcurse@culot.org>2008-01-13 12:40:45 +0000
commit738a3a417071bfaed53297cbefad39b996e55dfb (patch)
tree006b954aa80383c18ed030d1be3f08855d54a2f8 /src/event.c
parentb7115fbcf2a3a53d52f73ce0693075ab50de96f5 (diff)
downloadcalcurse-738a3a417071bfaed53297cbefad39b996e55dfb.zip
Ability to attach notes to appointments and events added
Diffstat (limited to 'src/event.c')
-rwxr-xr-xsrc/event.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/event.c b/src/event.c
index 6aca296..919d71a 100755
--- a/src/event.c
+++ b/src/event.c
@@ -1,8 +1,8 @@
-/* $calcurse: event.c,v 1.4 2007/07/28 13:11:42 culot Exp $ */
+/* $calcurse: event.c,v 1.5 2008/01/13 12:40:45 culot Exp $ */
/*
* Calcurse - text-based organizer
- * Copyright (c) 2004-2007 Frederic Culot
+ * Copyright (c) 2004-2008 Frederic Culot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,13 +31,14 @@
#include "vars.h"
#include "i18n.h"
+#include "utils.h"
#include "event.h"
struct event_s *eventlist;
/* Create a new event */
struct event_s *
-event_new(char *mesg, long day, int id)
+event_new(char *mesg, char *note, long day, int id)
{
struct event_s *o, **i;
o = (struct event_s *) malloc(sizeof(struct event_s));
@@ -45,6 +46,7 @@ event_new(char *mesg, long day, int id)
strncpy(o->mesg, mesg, strlen(mesg) + 1);
o->day = day;
o->id = id;
+ o->note = note;
i = &eventlist;
for (;;) {
if (*i == 0 || (*i)->day > day) {
@@ -76,13 +78,16 @@ event_write(struct event_s *o, FILE * f)
t = o->day;
lt = localtime(&t);
- fprintf(f, "%02u/%02u/%04u [%d] %s\n",
- lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year, o->id, o->mesg);
+ fprintf(f, "%02u/%02u/%04u [%d] ",
+ lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year, o->id);
+ if (o->note != NULL)
+ fprintf(f, ">%s ", o->note);
+ fprintf(f, "%s\n", o->mesg);
}
/* Load the events from file */
struct event_s *
-event_scan(FILE * f, struct tm start, int id)
+event_scan(FILE * f, struct tm start, int id, char *note)
{
struct tm *lt;
char buf[MESG_MAXSIZE], *nl;
@@ -109,12 +114,12 @@ event_scan(FILE * f, struct tm start, int id)
fputs(_("FATAL ERROR in event_scan: date error in the event\n"), stderr);
exit(EXIT_FAILURE);
}
- return event_new(buf, tstart, id);
+ return (event_new(buf, note, tstart, id));
}
/* Delete an event from the list */
void
-event_delete_bynum(long start, unsigned num)
+event_delete_bynum(long start, unsigned num, int only_note)
{
unsigned n;
struct event_s *i, **iptr;
@@ -124,9 +129,15 @@ event_delete_bynum(long start, unsigned num)
for (i = eventlist; i != 0; i = i->next) {
if (event_inday(i, start)) {
if (n == num) {
- *iptr = i->next;
- free(i->mesg);
- free(i);
+ if (only_note)
+ erase_note(&i->note);
+ else {
+ *iptr = i->next;
+ free(i->mesg);
+ if (i->note != NULL)
+ erase_note(&i->note);
+ free(i);
+ }
return;
}
n++;