libDtHelp: Cov 88209
[oweals/cde.git] / cde / lib / csa / rerule.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: rerule.h /main/1 1996/04/21 19:24:15 drk $ */
24 /*
25  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
26  *  (c) Copyright 1993, 1994 International Business Machines Corp.
27  *  (c) Copyright 1993, 1994 Novell, Inc.
28  *  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
29  */
30
31 #ifndef _RERULE_H
32 #define _RERULE_H
33
34 typedef unsigned long   Time;
35 typedef unsigned int    Interval;
36 typedef int             Duration;
37
38 #define RE_INFINITY             -1
39 #define RE_NOTSET               -2
40 #define RE_ERROR                -3
41 #define RE_LASTDAY              32
42
43 #define RE_STOP_FLAG                    0x80000000
44 #define RE_SET_FLAG(data)               (data |= RE_STOP_FLAG)
45 #define RE_STOP_IS_SET(data)            (data & RE_STOP_FLAG)
46 #define RE_MASK_STOP(data)              (data & ~RE_STOP_FLAG)
47
48 #ifndef TRUE
49 #define TRUE  1
50 #define FALSE 0
51 #endif
52
53 typedef enum {
54         WD_SUN          = 0,
55         WD_MON,
56         WD_TUE,
57         WD_WED,
58         WD_THU,
59         WD_FRI,
60         WD_SAT
61 } WeekDay;
62
63 typedef enum {
64         WK_F1           = 0,
65         WK_F2,
66         WK_F3,
67         WK_F4,
68         WK_F5,
69         WK_L1,
70         WK_L2,
71         WK_L3,
72         WK_L4,
73         WK_L5
74 } WeekNumber;
75
76 typedef enum {
77         RT_MINUTE,
78         RT_DAILY,
79         RT_WEEKLY,
80         RT_MONTHLY_POSITION,
81         RT_MONTHLY_DAY,
82         RT_YEARLY_MONTH,
83         RT_YEARLY_DAY
84 } RepeatType;
85
86 typedef struct _NumberList {
87         struct _NumberList      *nl_next;
88         unsigned int             nl_number;
89 } NumberList;
90
91 typedef struct _DayTime {
92         WeekDay          dt_day;
93         unsigned int     dt_ntime;
94         Time            *dt_time;
95 } DayTime;
96
97 typedef struct _DayTimeList {
98         struct _DayTimeList     *dtl_next;
99         DayTime                 *dtl_daytime;
100 } DayTimeList;
101
102 typedef struct _WeekDayTime {
103         unsigned int     wdt_nday;
104         WeekDay         *wdt_day;
105         unsigned int     wdt_ntime;
106         Time            *wdt_time;
107         unsigned int     wdt_nweek;
108         WeekNumber      *wdt_week;
109 } WeekDayTime;
110
111 typedef struct _WeekDayTimeList {
112         struct _WeekDayTimeList *wdtl_next;
113         WeekDayTime             *wdtl_weektime;
114 } WeekDayTimeList;
115
116 typedef struct _DailyData {
117         unsigned int     dd_ntime;
118         Time            *dd_time;
119 } DailyData;
120
121 typedef struct _WeeklyData {
122         unsigned int     wd_ndaytime;
123         DayTime         *wd_daytime;
124 } WeeklyData;
125
126 typedef struct _MonthlyData {
127         unsigned int     md_nitems;     /* # of md_weektime or md_days */
128         WeekDayTime     *md_weektime;   /* Used in MP command */
129         unsigned int    *md_days;       /* Array of days for MD command */
130 } MonthlyData;
131
132 typedef struct _YearlyData {
133         unsigned int     yd_nitems;
134         unsigned int    *yd_items;      /* Array of days/months event occurs */
135 } YearlyData;
136
137 typedef struct _RepeatEvent {
138         struct _RepeatEvent     *re_next;
139         struct _RepeatEvent     *re_prev;
140         Interval                 re_interval;
141         Duration                 re_duration;
142         time_t                   re_end_date;
143         RepeatType               re_type;
144         union {
145                 DailyData       *re_daily;
146                 WeeklyData      *re_weekly;
147                 MonthlyData     *re_monthly;
148                 YearlyData      *re_yearly;
149         } re_data;
150 } RepeatEvent;
151
152 typedef struct _RepeatEventState {
153         struct _RepeatEventState        *res_next;
154         const RepeatEvent               *res_re;
155         Duration                         res_duration; /* # events remaining */
156         union {
157                 struct _DailyState {
158                         unsigned int    res_time;
159                 } ds;
160                 struct _WeeklyState {
161                         unsigned int    res_daytime;
162                         unsigned int    res_time;
163                 } ws;
164                 struct _MonthlyState {
165                         unsigned int    res_day;
166                         unsigned int    res_weektime;
167                         unsigned int    res_wday;
168                         unsigned int    res_wtime;
169                         unsigned int    res_wweek;
170                 } ms;
171                 struct _YearlyState {
172                         unsigned int    res_daymonth;
173                 } ys;
174         } res_data;
175 } RepeatEventState;
176
177 extern void _DtCm_free_re(RepeatEvent *);
178 extern void _DtCm_free_re_state(RepeatEventState *);
179
180 #endif /* _RERULE_H */