rerule.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. #ifndef _RERULE_H
  31. #define _RERULE_H
  32. typedef unsigned long Time;
  33. typedef unsigned int Interval;
  34. typedef int Duration;
  35. #define RE_INFINITY -1
  36. #define RE_NOTSET -2
  37. #define RE_ERROR -3
  38. #define RE_LASTDAY 32
  39. #define RE_STOP_FLAG 0x80000000
  40. #define RE_SET_FLAG(data) (data |= RE_STOP_FLAG)
  41. #define RE_STOP_IS_SET(data) (data & RE_STOP_FLAG)
  42. #define RE_MASK_STOP(data) (data & ~RE_STOP_FLAG)
  43. #ifndef TRUE
  44. #define TRUE 1
  45. #define FALSE 0
  46. #endif
  47. typedef enum {
  48. WD_SUN = 0,
  49. WD_MON,
  50. WD_TUE,
  51. WD_WED,
  52. WD_THU,
  53. WD_FRI,
  54. WD_SAT
  55. } WeekDay;
  56. typedef enum {
  57. WK_F1 = 0,
  58. WK_F2,
  59. WK_F3,
  60. WK_F4,
  61. WK_F5,
  62. WK_L1,
  63. WK_L2,
  64. WK_L3,
  65. WK_L4,
  66. WK_L5
  67. } WeekNumber;
  68. typedef enum {
  69. RT_MINUTE,
  70. RT_DAILY,
  71. RT_WEEKLY,
  72. RT_MONTHLY_POSITION,
  73. RT_MONTHLY_DAY,
  74. RT_YEARLY_MONTH,
  75. RT_YEARLY_DAY
  76. } RepeatType;
  77. typedef struct _NumberList {
  78. struct _NumberList *nl_next;
  79. unsigned int nl_number;
  80. } NumberList;
  81. typedef struct _DayTime {
  82. WeekDay dt_day;
  83. unsigned int dt_ntime;
  84. Time *dt_time;
  85. } DayTime;
  86. typedef struct _DayTimeList {
  87. struct _DayTimeList *dtl_next;
  88. DayTime *dtl_daytime;
  89. } DayTimeList;
  90. typedef struct _WeekDayTime {
  91. unsigned int wdt_nday;
  92. WeekDay *wdt_day;
  93. unsigned int wdt_ntime;
  94. Time *wdt_time;
  95. unsigned int wdt_nweek;
  96. WeekNumber *wdt_week;
  97. } WeekDayTime;
  98. typedef struct _WeekDayTimeList {
  99. struct _WeekDayTimeList *wdtl_next;
  100. WeekDayTime *wdtl_weektime;
  101. } WeekDayTimeList;
  102. typedef struct _DailyData {
  103. unsigned int dd_ntime;
  104. Time *dd_time;
  105. } DailyData;
  106. typedef struct _WeeklyData {
  107. unsigned int wd_ndaytime;
  108. DayTime *wd_daytime;
  109. } WeeklyData;
  110. typedef struct _MonthlyData {
  111. unsigned int md_nitems; /* # of md_weektime or md_days */
  112. WeekDayTime *md_weektime; /* Used in MP command */
  113. unsigned int *md_days; /* Array of days for MD command */
  114. } MonthlyData;
  115. typedef struct _YearlyData {
  116. unsigned int yd_nitems;
  117. unsigned int *yd_items; /* Array of days/months event occurs */
  118. } YearlyData;
  119. typedef struct _RepeatEvent {
  120. struct _RepeatEvent *re_next;
  121. struct _RepeatEvent *re_prev;
  122. Interval re_interval;
  123. Duration re_duration;
  124. time_t re_end_date;
  125. RepeatType re_type;
  126. union {
  127. DailyData *re_daily;
  128. WeeklyData *re_weekly;
  129. MonthlyData *re_monthly;
  130. YearlyData *re_yearly;
  131. } re_data;
  132. } RepeatEvent;
  133. typedef struct _RepeatEventState {
  134. struct _RepeatEventState *res_next;
  135. const RepeatEvent *res_re;
  136. Duration res_duration; /* # events remaining */
  137. union {
  138. struct _DailyState {
  139. unsigned int res_time;
  140. } ds;
  141. struct _WeeklyState {
  142. unsigned int res_daytime;
  143. unsigned int res_time;
  144. } ws;
  145. struct _MonthlyState {
  146. unsigned int res_day;
  147. unsigned int res_weektime;
  148. unsigned int res_wday;
  149. unsigned int res_wtime;
  150. unsigned int res_wweek;
  151. } ms;
  152. struct _YearlyState {
  153. unsigned int res_daymonth;
  154. } ys;
  155. } res_data;
  156. } RepeatEventState;
  157. extern void _DtCm_free_re(RepeatEvent *);
  158. extern void _DtCm_free_re_state(RepeatEventState *);
  159. #endif /* _RERULE_H */