Use generic lists for recurring item exceptions.
Rename "days" structure to "excp" which seems to be a better name here. Use generic linked lists of excp structures instead of using the "days" structure which again contains a linked list implementation. Do some cleanups and invocation fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
0ad23c7a8f
commit
fb5f9d0155
@ -301,8 +301,7 @@ struct day_item {
|
|||||||
char *note; /* note attached to item */
|
char *note; /* note attached to item */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct days {
|
struct excp {
|
||||||
struct days *next;
|
|
||||||
long st; /* beggining of the considered day, in seconds */
|
long st; /* beggining of the considered day, in seconds */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -325,7 +324,7 @@ struct rpt {
|
|||||||
/* Recurrent appointment definition. */
|
/* Recurrent appointment definition. */
|
||||||
struct recur_apoint {
|
struct recur_apoint {
|
||||||
struct rpt *rpt; /* information about repetition */
|
struct rpt *rpt; /* information about repetition */
|
||||||
struct days *exc; /* days when the item should not be repeated */
|
llist_t exc; /* days when the item should not be repeated */
|
||||||
long start; /* beggining of the appointment */
|
long start; /* beggining of the appointment */
|
||||||
long dur; /* duration of the appointment */
|
long dur; /* duration of the appointment */
|
||||||
char state; /* 8 bits to store item state */
|
char state; /* 8 bits to store item state */
|
||||||
@ -336,7 +335,7 @@ struct recur_apoint {
|
|||||||
/* Reccurent event definition. */
|
/* Reccurent event definition. */
|
||||||
struct recur_event {
|
struct recur_event {
|
||||||
struct rpt *rpt; /* information about repetition */
|
struct rpt *rpt; /* information about repetition */
|
||||||
struct days *exc; /* days when the item should not be repeated */
|
llist_t exc; /* days when the item should not be repeated */
|
||||||
int id; /* event type */
|
int id; /* event type */
|
||||||
long day; /* day at which event occurs */
|
long day; /* day at which event occurs */
|
||||||
char *mesg; /* event description */
|
char *mesg; /* event description */
|
||||||
@ -768,20 +767,19 @@ void recur_apoint_llist_init (void);
|
|||||||
void recur_apoint_llist_free (void);
|
void recur_apoint_llist_free (void);
|
||||||
void recur_event_llist_free (void);
|
void recur_event_llist_free (void);
|
||||||
struct recur_apoint *recur_apoint_new (char *, char *, long, long, char,
|
struct recur_apoint *recur_apoint_new (char *, char *, long, long, char,
|
||||||
int, int, long, struct days **);
|
int, int, long, llist_t *);
|
||||||
struct recur_event *recur_event_new (char *, char *, long, int, int, int,
|
struct recur_event *recur_event_new (char *, char *, long, int, int, int,
|
||||||
long, struct days **);
|
long, llist_t *);
|
||||||
char recur_def2char (enum recur_type);
|
char recur_def2char (enum recur_type);
|
||||||
int recur_char2def (char);
|
int recur_char2def (char);
|
||||||
struct recur_apoint *recur_apoint_scan (FILE *, struct tm, struct tm,
|
struct recur_apoint *recur_apoint_scan (FILE *, struct tm, struct tm,
|
||||||
char, int, struct tm, char *,
|
char, int, struct tm, char *,
|
||||||
struct days **, char);
|
llist_t *, char);
|
||||||
struct recur_event *recur_event_scan (FILE *, struct tm, int, char,
|
struct recur_event *recur_event_scan (FILE *, struct tm, int, char,
|
||||||
int, struct tm, char *,
|
int, struct tm, char *,
|
||||||
struct days **);
|
llist_t *);
|
||||||
void recur_save_data (FILE *);
|
void recur_save_data (FILE *);
|
||||||
unsigned recur_item_inday (long, struct days *, int, int,
|
unsigned recur_item_inday (long, llist_t *, int, int, long, long);
|
||||||
long, long);
|
|
||||||
unsigned recur_apoint_inday(struct recur_apoint *, long);
|
unsigned recur_apoint_inday(struct recur_apoint *, long);
|
||||||
unsigned recur_event_inday(struct recur_event *, long);
|
unsigned recur_event_inday(struct recur_event *, long);
|
||||||
void recur_event_erase (long, unsigned, unsigned,
|
void recur_event_erase (long, unsigned, unsigned,
|
||||||
@ -789,7 +787,7 @@ void recur_event_erase (long, unsigned, unsigned,
|
|||||||
void recur_apoint_erase (long, unsigned, unsigned,
|
void recur_apoint_erase (long, unsigned, unsigned,
|
||||||
enum eraseflg);
|
enum eraseflg);
|
||||||
void recur_repeat_item (struct conf *);
|
void recur_repeat_item (struct conf *);
|
||||||
struct days *recur_exc_scan (FILE *);
|
void recur_exc_scan (llist_t *, FILE *);
|
||||||
struct notify_app *recur_apoint_check_next (struct notify_app *, long, long);
|
struct notify_app *recur_apoint_check_next (struct notify_app *, long, long);
|
||||||
struct recur_apoint *recur_get_apoint (long, int);
|
struct recur_apoint *recur_get_apoint (long, int);
|
||||||
struct recur_event *recur_get_event (long, int);
|
struct recur_event *recur_get_event (long, int);
|
||||||
|
103
src/io.c
103
src/io.c
@ -248,7 +248,7 @@ get_export_stream (enum export_type type)
|
|||||||
* (mainly used to export data).
|
* (mainly used to export data).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
foreach_date_dump (const long date_end, struct rpt *rpt, struct days *exc,
|
foreach_date_dump (const long date_end, struct rpt *rpt, llist_t *exc,
|
||||||
long item_first_date, long item_dur, char *item_mesg,
|
long item_first_date, long item_dur, char *item_mesg,
|
||||||
cb_dump_t cb_dump, FILE *stream)
|
cb_dump_t cb_dump, FILE *stream)
|
||||||
{
|
{
|
||||||
@ -342,8 +342,7 @@ pcal_export_footer (FILE *stream)
|
|||||||
static void
|
static void
|
||||||
ical_export_recur_events (FILE *stream)
|
ical_export_recur_events (FILE *stream)
|
||||||
{
|
{
|
||||||
llist_item_t *i;
|
llist_item_t *i, *j;
|
||||||
struct days *day;
|
|
||||||
char ical_date[BUFSIZ];
|
char ical_date[BUFSIZ];
|
||||||
|
|
||||||
LLIST_FOREACH (&recur_elist, i)
|
LLIST_FOREACH (&recur_elist, i)
|
||||||
@ -363,17 +362,20 @@ ical_export_recur_events (FILE *stream)
|
|||||||
else
|
else
|
||||||
(void)fprintf (stream, "\n");
|
(void)fprintf (stream, "\n");
|
||||||
|
|
||||||
if (rev->exc != NULL)
|
if (LLIST_FIRST (&rev->exc))
|
||||||
{
|
{
|
||||||
date_sec2date_fmt (rev->exc->st, ICALDATEFMT, ical_date);
|
(void)fprintf (stream, "EXDATE:");
|
||||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
LLIST_FOREACH (&rev->exc, j)
|
||||||
for (day = rev->exc->next; day; day = day->next)
|
|
||||||
{
|
{
|
||||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
struct excp *exc = LLIST_GET_DATA (j);
|
||||||
(void)fprintf (stream, ",%s", ical_date);
|
date_sec2date_fmt (exc->st, ICALDATEFMT, ical_date);
|
||||||
}
|
(void)fprintf (stream, "%s", ical_date);
|
||||||
|
if (LLIST_NEXT (j))
|
||||||
|
(void)fprintf (stream, ",");
|
||||||
|
else
|
||||||
(void)fprintf (stream, "\n");
|
(void)fprintf (stream, "\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(void)fprintf (stream, "SUMMARY:%s\n", rev->mesg);
|
(void)fprintf (stream, "SUMMARY:%s\n", rev->mesg);
|
||||||
(void)fprintf (stream, "END:VEVENT\n");
|
(void)fprintf (stream, "END:VEVENT\n");
|
||||||
@ -454,7 +456,7 @@ pcal_export_recur_events (FILE *stream)
|
|||||||
const long YEAR_END = calendar_end_of_year ();
|
const long YEAR_END = calendar_end_of_year ();
|
||||||
|
|
||||||
if (rev->day < YEAR_END && rev->day > YEAR_START)
|
if (rev->day < YEAR_END && rev->day > YEAR_START)
|
||||||
foreach_date_dump (YEAR_END, rev->rpt, rev->exc, rev->day, 0,
|
foreach_date_dump (YEAR_END, rev->rpt, &rev->exc, rev->day, 0,
|
||||||
rev->mesg, (cb_dump_t) pcal_dump_event, stream);
|
rev->mesg, (cb_dump_t) pcal_dump_event, stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,8 +498,7 @@ pcal_export_events (FILE *stream)
|
|||||||
static void
|
static void
|
||||||
ical_export_recur_apoints (FILE *stream)
|
ical_export_recur_apoints (FILE *stream)
|
||||||
{
|
{
|
||||||
llist_item_t *i;
|
llist_item_t *i, *j;
|
||||||
struct days *day;
|
|
||||||
char ical_datetime[BUFSIZ];
|
char ical_datetime[BUFSIZ];
|
||||||
char ical_date[BUFSIZ];
|
char ical_date[BUFSIZ];
|
||||||
|
|
||||||
@ -522,17 +523,20 @@ ical_export_recur_apoints (FILE *stream)
|
|||||||
else
|
else
|
||||||
(void)fprintf (stream, "\n");
|
(void)fprintf (stream, "\n");
|
||||||
|
|
||||||
if (rapt->exc != NULL)
|
if (LLIST_FIRST (&rapt->exc))
|
||||||
{
|
{
|
||||||
date_sec2date_fmt (rapt->exc->st, ICALDATEFMT, ical_date);
|
(void)fprintf (stream, "EXDATE:");
|
||||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
LLIST_FOREACH (&rapt->exc, j)
|
||||||
for (day = rapt->exc->next; day; day = day->next)
|
|
||||||
{
|
{
|
||||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
struct excp *exc = LLIST_GET_DATA (j);
|
||||||
(void)fprintf (stream, ",%s", ical_date);
|
date_sec2date_fmt (exc->st, ICALDATEFMT, ical_date);
|
||||||
}
|
(void)fprintf (stream, "%s", ical_date);
|
||||||
|
if (LLIST_NEXT (j))
|
||||||
|
(void)fprintf (stream, ",");
|
||||||
|
else
|
||||||
(void)fprintf (stream, "\n");
|
(void)fprintf (stream, "\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(void)fprintf (stream, "SUMMARY:%s\n", rapt->mesg);
|
(void)fprintf (stream, "SUMMARY:%s\n", rapt->mesg);
|
||||||
if (rapt->state & APOINT_NOTIFY)
|
if (rapt->state & APOINT_NOTIFY)
|
||||||
@ -596,7 +600,7 @@ pcal_export_recur_apoints (FILE *stream)
|
|||||||
const long YEAR_END = calendar_end_of_year ();
|
const long YEAR_END = calendar_end_of_year ();
|
||||||
|
|
||||||
if (rapt->start < YEAR_END && rapt->start > YEAR_START)
|
if (rapt->start < YEAR_END && rapt->start > YEAR_START)
|
||||||
foreach_date_dump (YEAR_END, rapt->rpt, rapt->exc, rapt->start,
|
foreach_date_dump (YEAR_END, rapt->rpt, &rapt->exc, rapt->start,
|
||||||
rapt->dur, rapt->mesg,
|
rapt->dur, rapt->mesg,
|
||||||
(cb_dump_t)pcal_dump_apoint, stream);
|
(cb_dump_t)pcal_dump_apoint, stream);
|
||||||
}
|
}
|
||||||
@ -1104,7 +1108,7 @@ io_load_app (void)
|
|||||||
FILE *data_file;
|
FILE *data_file;
|
||||||
int c, is_appointment, is_event, is_recursive;
|
int c, is_appointment, is_event, is_recursive;
|
||||||
struct tm start, end, until, *lt;
|
struct tm start, end, until, *lt;
|
||||||
struct days *exc;
|
llist_t exc;
|
||||||
time_t t;
|
time_t t;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int freq;
|
int freq;
|
||||||
@ -1118,7 +1122,7 @@ io_load_app (void)
|
|||||||
data_file = fopen (path_apts, "r");
|
data_file = fopen (path_apts, "r");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
exc = 0;
|
LLIST_INIT (&exc);
|
||||||
is_appointment = is_event = is_recursive = 0;
|
is_appointment = is_event = is_recursive = 0;
|
||||||
c = getc (data_file);
|
c = getc (data_file);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
@ -1192,7 +1196,7 @@ io_load_app (void)
|
|||||||
if (c == '!')
|
if (c == '!')
|
||||||
{
|
{
|
||||||
(void)ungetc (c, data_file);
|
(void)ungetc (c, data_file);
|
||||||
exc = recur_exc_scan (data_file);
|
recur_exc_scan (&exc, data_file);
|
||||||
c = getc (data_file);
|
c = getc (data_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1204,7 +1208,7 @@ io_load_app (void)
|
|||||||
else if (c == '!')
|
else if (c == '!')
|
||||||
{ // endless item with exceptions
|
{ // endless item with exceptions
|
||||||
(void)ungetc (c, data_file);
|
(void)ungetc (c, data_file);
|
||||||
exc = recur_exc_scan (data_file);
|
recur_exc_scan (&exc, data_file);
|
||||||
c = getc (data_file);
|
c = getc (data_file);
|
||||||
until.tm_year = 0;
|
until.tm_year = 0;
|
||||||
}
|
}
|
||||||
@ -1754,14 +1758,14 @@ ical_store_todo (int priority, char *mesg, char *note)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt,
|
ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt,
|
||||||
struct days *exc)
|
llist_t *exc)
|
||||||
{
|
{
|
||||||
const int EVENTID = 1;
|
const int EVENTID = 1;
|
||||||
|
|
||||||
if (rpt)
|
if (rpt)
|
||||||
{
|
{
|
||||||
recur_event_new (mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
recur_event_new (mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
||||||
rpt->until, &exc);
|
rpt->until, exc);
|
||||||
mem_free (rpt);
|
mem_free (rpt);
|
||||||
}
|
}
|
||||||
else if (end && end != day)
|
else if (end && end != day)
|
||||||
@ -1773,7 +1777,7 @@ ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt,
|
|||||||
rpt->count = 0;
|
rpt->count = 0;
|
||||||
rpt->until = end;
|
rpt->until = end;
|
||||||
recur_event_new (mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
recur_event_new (mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
||||||
rpt->until, &exc);
|
rpt->until, exc);
|
||||||
mem_free (rpt);
|
mem_free (rpt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1786,7 +1790,7 @@ ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
ical_store_apoint (char *mesg, char *note, long start, long dur,
|
ical_store_apoint (char *mesg, char *note, long start, long dur,
|
||||||
ical_rpt_t *rpt, struct days *exc, int has_alarm)
|
ical_rpt_t *rpt, llist_t *exc, int has_alarm)
|
||||||
{
|
{
|
||||||
char state = 0L;
|
char state = 0L;
|
||||||
|
|
||||||
@ -1795,7 +1799,7 @@ ical_store_apoint (char *mesg, char *note, long start, long dur,
|
|||||||
if (rpt)
|
if (rpt)
|
||||||
{
|
{
|
||||||
recur_apoint_new (mesg, note, start, dur, state, rpt->type, rpt->freq,
|
recur_apoint_new (mesg, note, start, dur, state, rpt->type, rpt->freq,
|
||||||
rpt->until, &exc);
|
rpt->until, exc);
|
||||||
mem_free (rpt);
|
mem_free (rpt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2299,18 +2303,14 @@ ical_read_rrule (FILE *log, char *rrulestr, unsigned *noskipped,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ical_add_exc (struct days **exc_head, long date)
|
ical_add_exc (llist_t *exc_head, long date)
|
||||||
{
|
{
|
||||||
if (date == 0)
|
if (date != 0)
|
||||||
return;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
struct days *exc;
|
struct excp *exc = mem_malloc (sizeof (struct excp));
|
||||||
|
|
||||||
exc = mem_malloc (sizeof (struct days));
|
|
||||||
exc->st = date;
|
exc->st = date;
|
||||||
exc->next = *exc_head;
|
|
||||||
*exc_head = exc;
|
LLIST_ADD (exc_head, exc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2318,15 +2318,14 @@ ical_add_exc (struct days **exc_head, long date)
|
|||||||
* This property defines the list of date/time exceptions for a
|
* This property defines the list of date/time exceptions for a
|
||||||
* recurring calendar component.
|
* recurring calendar component.
|
||||||
*/
|
*/
|
||||||
static struct days *
|
void
|
||||||
ical_read_exdate (FILE *log, char *exstr, unsigned *noskipped,
|
ical_read_exdate (llist_t *exc, FILE *log, char *exstr, unsigned *noskipped,
|
||||||
const int itemline)
|
const int itemline)
|
||||||
{
|
{
|
||||||
struct days *exc;
|
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
long date;
|
long date;
|
||||||
|
|
||||||
exc = NULL;
|
LLIST_INIT (exc);
|
||||||
if ((p = strchr (exstr, ':')) != NULL)
|
if ((p = strchr (exstr, ':')) != NULL)
|
||||||
{
|
{
|
||||||
p++;
|
p++;
|
||||||
@ -2338,11 +2337,11 @@ ical_read_exdate (FILE *log, char *exstr, unsigned *noskipped,
|
|||||||
(void)strncpy (buf, p, buflen);
|
(void)strncpy (buf, p, buflen);
|
||||||
buf[buflen] = '\0';
|
buf[buflen] = '\0';
|
||||||
date = ical_datetime2long (buf, NULL);
|
date = ical_datetime2long (buf, NULL);
|
||||||
ical_add_exc (&exc, date);
|
ical_add_exc (exc, date);
|
||||||
p = ++q;
|
p = ++q;
|
||||||
}
|
}
|
||||||
date = ical_datetime2long (p, NULL);
|
date = ical_datetime2long (p, NULL);
|
||||||
ical_add_exc (&exc, date);
|
ical_add_exc (exc, date);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2350,7 +2349,6 @@ ical_read_exdate (FILE *log, char *exstr, unsigned *noskipped,
|
|||||||
_("recurrence exception dates malformed."));
|
_("recurrence exception dates malformed."));
|
||||||
(*noskipped)++;
|
(*noskipped)++;
|
||||||
}
|
}
|
||||||
return exc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return an allocated string containing the name of the newly created note. */
|
/* Return an allocated string containing the name of the newly created note. */
|
||||||
@ -2440,7 +2438,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
ical_vevent_e vevent_type;
|
ical_vevent_e vevent_type;
|
||||||
char *p, buf[BUFSIZ], buf_upper[BUFSIZ];
|
char *p, buf[BUFSIZ], buf_upper[BUFSIZ];
|
||||||
struct {
|
struct {
|
||||||
struct days *exc;
|
llist_t exc;
|
||||||
ical_rpt_t *rpt;
|
ical_rpt_t *rpt;
|
||||||
char *mesg, *note;
|
char *mesg, *note;
|
||||||
long start, end, dur;
|
long start, end, dur;
|
||||||
@ -2496,7 +2494,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
vevent.end = 0L;
|
vevent.end = 0L;
|
||||||
ical_store_event (vevent.mesg, vevent.note,
|
ical_store_event (vevent.mesg, vevent.note,
|
||||||
vevent.start, vevent.end,
|
vevent.start, vevent.end,
|
||||||
vevent.rpt, vevent.exc);
|
vevent.rpt, &vevent.exc);
|
||||||
(*noevents)++;
|
(*noevents)++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2512,7 +2510,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ical_store_apoint (vevent.mesg, vevent.note, vevent.start,
|
ical_store_apoint (vevent.mesg, vevent.note, vevent.start,
|
||||||
vevent.dur, vevent.rpt, vevent.exc,
|
vevent.dur, vevent.rpt, &vevent.exc,
|
||||||
vevent.has_alarm);
|
vevent.has_alarm);
|
||||||
(*noapoints)++;
|
(*noapoints)++;
|
||||||
break;
|
break;
|
||||||
@ -2524,7 +2522,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ical_store_event (vevent.mesg, vevent.note, vevent.start,
|
ical_store_event (vevent.mesg, vevent.note, vevent.start,
|
||||||
vevent.end, vevent.rpt, vevent.exc);
|
vevent.end, vevent.rpt, &vevent.exc);
|
||||||
(*noevents)++;
|
(*noevents)++;
|
||||||
break;
|
break;
|
||||||
case UNDEFINED:
|
case UNDEFINED:
|
||||||
@ -2581,7 +2579,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
}
|
}
|
||||||
else if (strncmp (buf_upper, exdate.str, exdate.len) == 0)
|
else if (strncmp (buf_upper, exdate.str, exdate.len) == 0)
|
||||||
{
|
{
|
||||||
vevent.exc = ical_read_exdate (log, buf, noskipped, ITEMLINE);
|
ical_read_exdate (&vevent.exc, log, buf, noskipped, ITEMLINE);
|
||||||
}
|
}
|
||||||
else if (strncmp (buf_upper, summary.str, summary.len) == 0)
|
else if (strncmp (buf_upper, summary.str, summary.len) == 0)
|
||||||
{
|
{
|
||||||
@ -2611,8 +2609,7 @@ cleanup:
|
|||||||
mem_free (vevent.mesg);
|
mem_free (vevent.mesg);
|
||||||
if (vevent.rpt)
|
if (vevent.rpt)
|
||||||
mem_free (vevent.rpt);
|
mem_free (vevent.rpt);
|
||||||
if (vevent.exc)
|
LLIST_FREE (&vevent.exc);
|
||||||
mem_free (vevent.exc);
|
|
||||||
(*noskipped)++;
|
(*noskipped)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ notify_check_repeated (struct recur_apoint *i)
|
|||||||
|
|
||||||
current_time = time (NULL);
|
current_time = time (NULL);
|
||||||
pthread_mutex_lock (¬ify_app.mutex);
|
pthread_mutex_lock (¬ify_app.mutex);
|
||||||
if ((real_app_time = recur_item_inday (i->start, i->exc, i->rpt->type,
|
if ((real_app_time = recur_item_inday (i->start, &i->exc, i->rpt->type,
|
||||||
i->rpt->freq, i->rpt->until,
|
i->rpt->freq, i->rpt->until,
|
||||||
get_today ()) > current_time))
|
get_today ()) > current_time))
|
||||||
{
|
{
|
||||||
@ -551,7 +551,7 @@ notify_same_recur_item (struct recur_apoint *i)
|
|||||||
int same = 0;
|
int same = 0;
|
||||||
long item_start = 0;
|
long item_start = 0;
|
||||||
|
|
||||||
item_start = recur_item_inday (i->start, i->exc, i->rpt->type,
|
item_start = recur_item_inday (i->start, &i->exc, i->rpt->type,
|
||||||
i->rpt->freq, i->rpt->until, get_today ());
|
i->rpt->freq, i->rpt->until, get_today ());
|
||||||
pthread_mutex_lock (¬ify_app.mutex);
|
pthread_mutex_lock (¬ify_app.mutex);
|
||||||
if (notify_app.got_app && item_start == notify_app.time)
|
if (notify_app.got_app && item_start == notify_app.time)
|
||||||
|
185
src/recur.c
185
src/recur.c
@ -47,48 +47,49 @@ llist_t recur_elist;
|
|||||||
static struct recur_event bkp_cut_recur_event;
|
static struct recur_event bkp_cut_recur_event;
|
||||||
static struct recur_apoint bkp_cut_recur_apoint;
|
static struct recur_apoint bkp_cut_recur_apoint;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_exc (struct days *exc)
|
free_exc (struct excp *exc)
|
||||||
{
|
{
|
||||||
struct days *o, **i;
|
mem_free (exc);
|
||||||
|
|
||||||
i = &exc;
|
|
||||||
while (*i)
|
|
||||||
{
|
|
||||||
o = *i;
|
|
||||||
*i = o->next;
|
|
||||||
mem_free (o);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recur_add_exc (struct days **exc, long day)
|
free_exc_list (llist_t *exc)
|
||||||
{
|
{
|
||||||
struct days **i, *o;
|
LLIST_FREE_INNER (exc, free_exc);
|
||||||
|
LLIST_FREE (exc);
|
||||||
|
}
|
||||||
|
|
||||||
o = mem_malloc (sizeof (struct days));
|
static int
|
||||||
|
exc_cmp_day (struct excp *a, struct excp *b)
|
||||||
|
{
|
||||||
|
return (a->st < b->st ? -1 : (a->st == b->st ? 0 : 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recur_add_exc (llist_t *exc, long day)
|
||||||
|
{
|
||||||
|
struct excp *o = mem_malloc (sizeof (struct excp));
|
||||||
o->st = day;
|
o->st = day;
|
||||||
i = exc;
|
|
||||||
for (;;)
|
LLIST_ADD_SORTED (exc, o, exc_cmp_day);
|
||||||
{
|
|
||||||
if (*i == NULL || (*i)->st > day)
|
|
||||||
{
|
|
||||||
o->next = *i;
|
|
||||||
*i = o;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i = &(*i)->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exc_dup (struct days **in, struct days *exc)
|
exc_dup (llist_t *in, llist_t *exc)
|
||||||
{
|
{
|
||||||
struct days *p;
|
llist_item_t *i;
|
||||||
|
|
||||||
for (p = exc; p; p = p->next)
|
LLIST_INIT (in);
|
||||||
|
|
||||||
|
if (exc)
|
||||||
|
{
|
||||||
|
LLIST_FOREACH (exc, i)
|
||||||
|
{
|
||||||
|
struct excp *p = LLIST_GET_DATA (i);
|
||||||
recur_add_exc (in, p->st);
|
recur_add_exc (in, p->st);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -104,11 +105,7 @@ recur_event_free_bkp (enum eraseflg flag)
|
|||||||
mem_free (bkp_cut_recur_event.rpt);
|
mem_free (bkp_cut_recur_event.rpt);
|
||||||
bkp_cut_recur_event.rpt = 0;
|
bkp_cut_recur_event.rpt = 0;
|
||||||
}
|
}
|
||||||
if (bkp_cut_recur_event.exc)
|
free_exc_list (&bkp_cut_recur_event.exc);
|
||||||
{
|
|
||||||
free_exc (bkp_cut_recur_event.exc);
|
|
||||||
bkp_cut_recur_event.exc = 0;
|
|
||||||
}
|
|
||||||
erase_note (&bkp_cut_recur_event.note, flag);
|
erase_note (&bkp_cut_recur_event.note, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,11 +122,7 @@ recur_apoint_free_bkp (enum eraseflg flag)
|
|||||||
mem_free (bkp_cut_recur_apoint.rpt);
|
mem_free (bkp_cut_recur_apoint.rpt);
|
||||||
bkp_cut_recur_apoint.rpt = 0;
|
bkp_cut_recur_apoint.rpt = 0;
|
||||||
}
|
}
|
||||||
if (bkp_cut_recur_apoint.exc)
|
free_exc_list (&bkp_cut_recur_apoint.exc);
|
||||||
{
|
|
||||||
free_exc (bkp_cut_recur_apoint.exc);
|
|
||||||
bkp_cut_recur_apoint.exc = 0;
|
|
||||||
}
|
|
||||||
erase_note (&bkp_cut_recur_apoint.note, flag);
|
erase_note (&bkp_cut_recur_apoint.note, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +140,7 @@ recur_event_dup (struct recur_event *in, struct recur_event *bkp)
|
|||||||
bkp->rpt->freq = in->rpt->freq;
|
bkp->rpt->freq = in->rpt->freq;
|
||||||
bkp->rpt->until = in->rpt->until;
|
bkp->rpt->until = in->rpt->until;
|
||||||
|
|
||||||
if (in->exc)
|
exc_dup (&bkp->exc, &in->exc);
|
||||||
exc_dup (&bkp->exc, in->exc);
|
|
||||||
|
|
||||||
if (in->note)
|
if (in->note)
|
||||||
bkp->note = mem_strdup (in->note);
|
bkp->note = mem_strdup (in->note);
|
||||||
@ -169,8 +161,7 @@ recur_apoint_dup (struct recur_apoint *in, struct recur_apoint *bkp)
|
|||||||
bkp->rpt->freq = in->rpt->freq;
|
bkp->rpt->freq = in->rpt->freq;
|
||||||
bkp->rpt->until = in->rpt->until;
|
bkp->rpt->until = in->rpt->until;
|
||||||
|
|
||||||
if (in->exc)
|
exc_dup (&bkp->exc, &in->exc);
|
||||||
exc_dup (&bkp->exc, in->exc);
|
|
||||||
|
|
||||||
if (in->note)
|
if (in->note)
|
||||||
bkp->note = mem_strdup (in->note);
|
bkp->note = mem_strdup (in->note);
|
||||||
@ -190,11 +181,7 @@ recur_apoint_free (struct recur_apoint *rapt)
|
|||||||
mem_free (rapt->note);
|
mem_free (rapt->note);
|
||||||
if (rapt->rpt)
|
if (rapt->rpt)
|
||||||
mem_free (rapt->rpt);
|
mem_free (rapt->rpt);
|
||||||
if (rapt->exc)
|
free_exc_list (&rapt->exc);
|
||||||
{
|
|
||||||
free_exc (rapt->exc);
|
|
||||||
rapt->exc = 0;
|
|
||||||
}
|
|
||||||
mem_free (rapt);
|
mem_free (rapt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,11 +193,7 @@ recur_event_free (struct recur_event *rev)
|
|||||||
mem_free (rev->note);
|
mem_free (rev->note);
|
||||||
if (rev->rpt)
|
if (rev->rpt)
|
||||||
mem_free (rev->rpt);
|
mem_free (rev->rpt);
|
||||||
if (rev->exc)
|
free_exc_list (&rev->exc);
|
||||||
{
|
|
||||||
free_exc (rev->exc);
|
|
||||||
rev->exc = 0;
|
|
||||||
}
|
|
||||||
mem_free (rev);
|
mem_free (rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +226,7 @@ recur_event_cmp_day (struct recur_event *a, struct recur_event *b)
|
|||||||
/* Insert a new recursive appointment in the general linked list */
|
/* Insert a new recursive appointment in the general linked list */
|
||||||
struct recur_apoint *
|
struct recur_apoint *
|
||||||
recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
||||||
int type, int freq, long until, struct days **except)
|
int type, int freq, long until, llist_t *except)
|
||||||
{
|
{
|
||||||
struct recur_apoint *rapt = mem_malloc (sizeof (struct recur_apoint));
|
struct recur_apoint *rapt = mem_malloc (sizeof (struct recur_apoint));
|
||||||
|
|
||||||
@ -256,13 +239,13 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
|||||||
rapt->rpt->type = type;
|
rapt->rpt->type = type;
|
||||||
rapt->rpt->freq = freq;
|
rapt->rpt->freq = freq;
|
||||||
rapt->rpt->until = until;
|
rapt->rpt->until = until;
|
||||||
rapt->exc = 0;
|
if (except)
|
||||||
if (except && *except)
|
|
||||||
{
|
{
|
||||||
exc_dup (&rapt->exc, *except);
|
exc_dup (&rapt->exc, except);
|
||||||
free_exc (*except);
|
free_exc_list (except);
|
||||||
*except = 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
LLIST_INIT (&rapt->exc);
|
||||||
|
|
||||||
LLIST_TS_LOCK (&recur_alist_p);
|
LLIST_TS_LOCK (&recur_alist_p);
|
||||||
LLIST_TS_ADD_SORTED (&recur_alist_p, rapt, recur_apoint_cmp_start);
|
LLIST_TS_ADD_SORTED (&recur_alist_p, rapt, recur_apoint_cmp_start);
|
||||||
@ -274,7 +257,7 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
|||||||
/* Insert a new recursive event in the general linked list */
|
/* Insert a new recursive event in the general linked list */
|
||||||
struct recur_event *
|
struct recur_event *
|
||||||
recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
|
recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
|
||||||
long until, struct days **except)
|
long until, llist_t *except)
|
||||||
{
|
{
|
||||||
struct recur_event *rev = mem_malloc (sizeof (struct recur_event));
|
struct recur_event *rev = mem_malloc (sizeof (struct recur_event));
|
||||||
|
|
||||||
@ -286,13 +269,13 @@ recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
|
|||||||
rev->rpt->type = type;
|
rev->rpt->type = type;
|
||||||
rev->rpt->freq = freq;
|
rev->rpt->freq = freq;
|
||||||
rev->rpt->until = until;
|
rev->rpt->until = until;
|
||||||
rev->exc = 0;
|
if (except)
|
||||||
if (except && *except)
|
|
||||||
{
|
{
|
||||||
exc_dup (&rev->exc, *except);
|
exc_dup (&rev->exc, except);
|
||||||
free_exc (*except);
|
free_exc_list (except);
|
||||||
*except = 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
LLIST_INIT (&rev->exc);
|
||||||
|
|
||||||
LLIST_ADD_SORTED (&recur_elist, rev, recur_event_cmp_day);
|
LLIST_ADD_SORTED (&recur_elist, rev, recur_event_cmp_day);
|
||||||
|
|
||||||
@ -362,28 +345,29 @@ recur_char2def (char type)
|
|||||||
|
|
||||||
/* Write days for which recurrent items should not be repeated. */
|
/* Write days for which recurrent items should not be repeated. */
|
||||||
static void
|
static void
|
||||||
recur_write_exc (struct days *exc, FILE *f)
|
recur_write_exc (llist_t *lexc, FILE *f)
|
||||||
{
|
{
|
||||||
|
llist_item_t *i;
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
time_t t;
|
time_t t;
|
||||||
int st_mon, st_day, st_year;
|
int st_mon, st_day, st_year;
|
||||||
|
|
||||||
while (exc)
|
LLIST_FOREACH (lexc, i)
|
||||||
{
|
{
|
||||||
|
struct excp *exc = LLIST_GET_DATA (i);
|
||||||
t = exc->st;
|
t = exc->st;
|
||||||
lt = localtime (&t);
|
lt = localtime (&t);
|
||||||
st_mon = lt->tm_mon + 1;
|
st_mon = lt->tm_mon + 1;
|
||||||
st_day = lt->tm_mday;
|
st_day = lt->tm_mday;
|
||||||
st_year = lt->tm_year + 1900;
|
st_year = lt->tm_year + 1900;
|
||||||
(void)fprintf (f, " !%02u/%02u/%04u", st_mon, st_day, st_year);
|
(void)fprintf (f, " !%02u/%02u/%04u", st_mon, st_day, st_year);
|
||||||
exc = exc->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the recursive appointment description */
|
/* Load the recursive appointment description */
|
||||||
struct recur_apoint *
|
struct recur_apoint *
|
||||||
recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
|
recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
|
||||||
int freq, struct tm until, char *note, struct days **exc,
|
int freq, struct tm until, char *note, llist_t *exc,
|
||||||
char state)
|
char state)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ], *nl;
|
char buf[BUFSIZ], *nl;
|
||||||
@ -429,7 +413,7 @@ recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
|
|||||||
/* Load the recursive events from file */
|
/* Load the recursive events from file */
|
||||||
struct recur_event *
|
struct recur_event *
|
||||||
recur_event_scan (FILE *f, struct tm start, int id, char type, int freq,
|
recur_event_scan (FILE *f, struct tm start, int id, char type, int freq,
|
||||||
struct tm until, char *note, struct days **exc)
|
struct tm until, char *note, llist_t *exc)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ], *nl;
|
char buf[BUFSIZ], *nl;
|
||||||
time_t tstart, tuntil;
|
time_t tstart, tuntil;
|
||||||
@ -496,8 +480,7 @@ recur_apoint_write (struct recur_apoint *o, FILE *f)
|
|||||||
o->rpt->freq, recur_def2char (o->rpt->type),
|
o->rpt->freq, recur_def2char (o->rpt->type),
|
||||||
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year);
|
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year);
|
||||||
}
|
}
|
||||||
if (o->exc != NULL)
|
recur_write_exc (&o->exc, f);
|
||||||
recur_write_exc (o->exc, f);
|
|
||||||
(void)fprintf (f, "} ");
|
(void)fprintf (f, "} ");
|
||||||
if (o->note != NULL)
|
if (o->note != NULL)
|
||||||
(void)fprintf (f, ">%s ", o->note);
|
(void)fprintf (f, ">%s ", o->note);
|
||||||
@ -540,8 +523,7 @@ recur_event_write (struct recur_event *o, FILE *f)
|
|||||||
o->rpt->freq, recur_def2char (o->rpt->type),
|
o->rpt->freq, recur_def2char (o->rpt->type),
|
||||||
end_mon, end_day, end_year);
|
end_mon, end_day, end_year);
|
||||||
}
|
}
|
||||||
if (o->exc != NULL)
|
recur_write_exc (&o->exc, f);
|
||||||
recur_write_exc (o->exc, f);
|
|
||||||
(void)fprintf (f, "} ");
|
(void)fprintf (f, "} ");
|
||||||
if (o->note != NULL)
|
if (o->note != NULL)
|
||||||
(void)fprintf (f, ">%s ", o->note);
|
(void)fprintf (f, ">%s ", o->note);
|
||||||
@ -633,6 +615,12 @@ diff_years (struct tm lt_start, struct tm lt_end)
|
|||||||
return lt_end.tm_year - lt_start.tm_year;
|
return lt_end.tm_year - lt_start.tm_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
exc_inday (struct excp *exc, long day_start)
|
||||||
|
{
|
||||||
|
return (exc->st >= day_start && exc->st < day_start + DAYINSEC);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the recurrent item belongs to the selected day,
|
* Check if the recurrent item belongs to the selected day,
|
||||||
* and if yes, return the real start time.
|
* and if yes, return the real start time.
|
||||||
@ -643,22 +631,20 @@ diff_years (struct tm lt_start, struct tm lt_end)
|
|||||||
* calculation of recurrent dates after a turn of years.
|
* calculation of recurrent dates after a turn of years.
|
||||||
*/
|
*/
|
||||||
unsigned
|
unsigned
|
||||||
recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
recur_item_inday (long item_start, llist_t *item_exc, int rpt_type,
|
||||||
int rpt_freq, long rpt_until, long day_start)
|
int rpt_freq, long rpt_until, long day_start)
|
||||||
{
|
{
|
||||||
struct date start_date;
|
struct date start_date;
|
||||||
long day_end, diff;
|
long day_end, diff;
|
||||||
struct tm lt_item, lt_day;
|
struct tm lt_item, lt_day;
|
||||||
struct days *exc;
|
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
day_end = day_start + DAYINSEC;
|
day_end = day_start + DAYINSEC;
|
||||||
t = day_start;
|
t = day_start;
|
||||||
lt_day = *localtime (&t);
|
lt_day = *localtime (&t);
|
||||||
|
|
||||||
for (exc = item_exc; exc != NULL; exc = exc->next)
|
if (LLIST_FIND_FIRST (item_exc, day_start, exc_inday))
|
||||||
if (exc->st < day_end && exc->st >= day_start)
|
return 0;
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (rpt_until == 0) /* we have an endless recurrent item */
|
if (rpt_until == 0) /* we have an endless recurrent item */
|
||||||
rpt_until = day_end;
|
rpt_until = day_end;
|
||||||
@ -722,14 +708,14 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
|||||||
unsigned
|
unsigned
|
||||||
recur_apoint_inday(struct recur_apoint *rapt, long day_start)
|
recur_apoint_inday(struct recur_apoint *rapt, long day_start)
|
||||||
{
|
{
|
||||||
return recur_item_inday (rapt->start, rapt->exc, rapt->rpt->type,
|
return recur_item_inday (rapt->start, &rapt->exc, rapt->rpt->type,
|
||||||
rapt->rpt->freq, rapt->rpt->until, day_start);
|
rapt->rpt->freq, rapt->rpt->until, day_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
recur_event_inday(struct recur_event *rev, long day_start)
|
recur_event_inday(struct recur_event *rev, long day_start)
|
||||||
{
|
{
|
||||||
return recur_item_inday (rev->day, rev->exc, rev->rpt->type, rev->rpt->freq,
|
return recur_item_inday (rev->day, &rev->exc, rev->rpt->type, rev->rpt->freq,
|
||||||
rev->rpt->until, day_start);
|
rev->rpt->until, day_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,11 +755,7 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
|||||||
mem_free (rev->rpt);
|
mem_free (rev->rpt);
|
||||||
rev->rpt = 0;
|
rev->rpt = 0;
|
||||||
}
|
}
|
||||||
if (rev->exc)
|
free_exc_list (&rev->exc);
|
||||||
{
|
|
||||||
free_exc (rev->exc);
|
|
||||||
rev->exc = 0;
|
|
||||||
}
|
|
||||||
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
||||||
erase_note (&rev->note, flag);
|
erase_note (&rev->note, flag);
|
||||||
mem_free (rev);
|
mem_free (rev);
|
||||||
@ -824,11 +806,7 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
|
|||||||
mem_free (rapt->rpt);
|
mem_free (rapt->rpt);
|
||||||
rapt->rpt = 0;
|
rapt->rpt = 0;
|
||||||
}
|
}
|
||||||
if (rapt->exc)
|
free_exc_list (&rapt->exc);
|
||||||
{
|
|
||||||
free_exc (rapt->exc);
|
|
||||||
rapt->exc = 0;
|
|
||||||
}
|
|
||||||
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
||||||
erase_note (&rapt->note, flag);
|
erase_note (&rapt->note, flag);
|
||||||
mem_free (rapt);
|
mem_free (rapt);
|
||||||
@ -999,14 +977,13 @@ recur_repeat_item (struct conf *conf)
|
|||||||
* Read days for which recurrent items must not be repeated
|
* Read days for which recurrent items must not be repeated
|
||||||
* (such days are called exceptions).
|
* (such days are called exceptions).
|
||||||
*/
|
*/
|
||||||
struct days *
|
void
|
||||||
recur_exc_scan (FILE *data_file)
|
recur_exc_scan (llist_t *lexc, FILE *data_file)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
struct tm day;
|
struct tm day;
|
||||||
struct days *exc_head, *exc;
|
|
||||||
|
|
||||||
exc_head = 0;
|
LLIST_INIT (lexc);
|
||||||
while ((c = getc (data_file)) == '!')
|
while ((c = getc (data_file)) == '!')
|
||||||
{
|
{
|
||||||
(void)ungetc (c, data_file);
|
(void)ungetc (c, data_file);
|
||||||
@ -1020,12 +997,10 @@ recur_exc_scan (FILE *data_file)
|
|||||||
day.tm_isdst = -1;
|
day.tm_isdst = -1;
|
||||||
day.tm_year -= 1900;
|
day.tm_year -= 1900;
|
||||||
day.tm_mon--;
|
day.tm_mon--;
|
||||||
exc = mem_malloc (sizeof (struct days));
|
struct excp *exc = mem_malloc (sizeof (struct excp));
|
||||||
exc->st = mktime (&day);
|
exc->st = mktime (&day);
|
||||||
exc->next = exc_head;
|
LLIST_ADD (lexc, exc);
|
||||||
exc_head = exc;
|
|
||||||
}
|
}
|
||||||
return exc_head;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1119,6 +1094,7 @@ void
|
|||||||
recur_event_paste_item (void)
|
recur_event_paste_item (void)
|
||||||
{
|
{
|
||||||
long new_start, time_shift;
|
long new_start, time_shift;
|
||||||
|
llist_item_t *i;
|
||||||
|
|
||||||
new_start = date2sec (*calendar_get_slctd_day (), 12, 0);
|
new_start = date2sec (*calendar_get_slctd_day (), 12, 0);
|
||||||
time_shift = new_start - bkp_cut_recur_event.day;
|
time_shift = new_start - bkp_cut_recur_event.day;
|
||||||
@ -1126,11 +1102,9 @@ recur_event_paste_item (void)
|
|||||||
bkp_cut_recur_event.day += time_shift;
|
bkp_cut_recur_event.day += time_shift;
|
||||||
if (bkp_cut_recur_event.rpt->until != 0)
|
if (bkp_cut_recur_event.rpt->until != 0)
|
||||||
bkp_cut_recur_event.rpt->until += time_shift;
|
bkp_cut_recur_event.rpt->until += time_shift;
|
||||||
if (bkp_cut_recur_event.exc)
|
LLIST_FOREACH (&bkp_cut_recur_event.exc, i)
|
||||||
{
|
{
|
||||||
struct days *exc;
|
struct excp *exc = LLIST_GET_DATA (i);
|
||||||
|
|
||||||
for (exc = bkp_cut_recur_event.exc; exc != NULL; exc = exc->next)
|
|
||||||
exc->st += time_shift;
|
exc->st += time_shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,6 +1121,7 @@ void
|
|||||||
recur_apoint_paste_item (void)
|
recur_apoint_paste_item (void)
|
||||||
{
|
{
|
||||||
long new_start, time_shift;
|
long new_start, time_shift;
|
||||||
|
llist_item_t *i;
|
||||||
|
|
||||||
new_start = date2sec (*calendar_get_slctd_day (),
|
new_start = date2sec (*calendar_get_slctd_day (),
|
||||||
get_item_hour (bkp_cut_recur_apoint.start),
|
get_item_hour (bkp_cut_recur_apoint.start),
|
||||||
@ -1156,11 +1131,9 @@ recur_apoint_paste_item (void)
|
|||||||
bkp_cut_recur_apoint.start += time_shift;
|
bkp_cut_recur_apoint.start += time_shift;
|
||||||
if (bkp_cut_recur_apoint.rpt->until != 0)
|
if (bkp_cut_recur_apoint.rpt->until != 0)
|
||||||
bkp_cut_recur_apoint.rpt->until += time_shift;
|
bkp_cut_recur_apoint.rpt->until += time_shift;
|
||||||
if (bkp_cut_recur_apoint.exc)
|
LLIST_FOREACH (&bkp_cut_recur_event.exc, i)
|
||||||
{
|
{
|
||||||
struct days *exc;
|
struct excp *exc = LLIST_GET_DATA (i);
|
||||||
|
|
||||||
for (exc = bkp_cut_recur_apoint.exc; exc != NULL; exc = exc->next)
|
|
||||||
exc->st += time_shift;
|
exc->st += time_shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user