Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcm / server / reutil.h
1 /* $XConsortium: reutil.h /main/4 1995/11/09 12:51:01 rswiston $ */
2 /*
3  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
4  *  (c) Copyright 1993, 1994 International Business Machines Corp.
5  *  (c) Copyright 1993, 1994 Novell, Inc.
6  *  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
7  */
8
9 #ifndef _REUTIL_H
10 #define _REUTIL_H
11
12 #include "rerule.h"
13 #include "repeat.h"
14
15 #define EOT     2147483647
16
17 #define RE_DAILY(re)    (re->re_data.re_daily)
18 #define RE_WEEKLY(re)   (re->re_data.re_weekly)
19 #define RE_MONTHLY(re)  (re->re_data.re_monthly)
20 #define RE_YEARLY(re)   (re->re_data.re_yearly)
21 #define RES_DSTATE(res) (res->res_data.ds)
22 #define RES_WSTATE(res) (res->res_data.ws)
23 #define RES_MSTATE(res) (res->res_data.ms)
24 #define RES_YSTATE(res) (res->res_data.ys)
25 #define SAME_DAY(tm1, tm2)  (((tm1)->tm_year == (tm2)->tm_year && \
26                              (tm1)->tm_mon == (tm2)->tm_mon && \
27                              (tm1)->tm_mday == (tm2)->tm_mday))
28 #define SAME_MONTH(tm1, tm2) (((tm1)->tm_year == (tm2)->tm_year && \
29                               (tm1)->tm_mon == (tm2)->tm_mon))
30 #define TIME_OF_DAY(tm)   ((tm)->tm_hour * 60 * 60 + \
31                          (tm)->tm_min * 60 + \
32                          (tm)->tm_sec)
33 #define TIMEOFMONTH(tm) (((tm)->tm_mday - 1) * 24 * 60 * 60 + \
34                          (tm)->tm_hour * 60 * 60 + \
35                          (tm)->tm_min * 60 + \
36                          (tm)->tm_sec)
37 #define HOURTOSEC(time) ((time/100) * 60 * 60 + \
38                          (time%100) * 60)
39
40 extern int GetWDayDiff(const int, const int);
41 extern int DayExists(const int, const int, const int);
42 extern WeekNumber GetWeekNumber(const Tick);
43 extern WeekNumber DayToWeekNumber(const Tick);
44 extern Tick WeekNumberToDay(const Tick, const WeekNumber, const WeekDay);
45 extern int OccurenceExists(const WeekDayTime *, const unsigned int, const Tick);
46 extern unsigned int DayOfMonth(const int, const int, const int);
47 extern int InTimeRange(const unsigned int, const Duration);
48 extern int same_week(struct tm *, struct tm *);
49
50 extern Tick ClosestTick(const Tick, const Tick, RepeatEvent *,
51                         RepeatEventState **);
52 extern Tick NextTick(const Tick, const Tick, RepeatEvent *,
53                         RepeatEventState *);
54 extern Tick PrevTick(const Tick, const Tick, RepeatEvent *,
55                         RepeatEventState *);
56 extern Tick LastTick(const Tick, RepeatEvent *);
57 extern int CountEvents(Tick, RepeatEvent *re, CSA_date_time_entry *);
58 extern Tick DeriveNewStartTime(const Tick, RepeatEvent *old_re, const Tick, 
59                         const Tick, RepeatEvent *new_re);
60
61
62 #endif /* _REUTIL_H */