cpl_time.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. *
  27. *
  28. * History:
  29. * -------
  30. * 2003-06-24: file imported from tmrec (bogdan)
  31. * 2003-xx-xx: file Created (daniel)
  32. */
  33. #ifndef _CPL_TIME_H_
  34. #define _CPL_TIME_H_
  35. /************************ imported from "ac_tm.h" ***************************/
  36. #include <time.h>
  37. /* USE_YWEEK_U -- Sunday system - see strftime %U
  38. * USE_YWEEK_V -- ISO 8601 - see strftime %V
  39. * USE_YWEEK_W -- Monday system - see strftime %W
  40. */
  41. #ifndef USE_YWEEK_U
  42. # ifndef USE_YWEEK_V
  43. # ifndef USE_YWEEK_W
  44. # define USE_YWEEK_W
  45. # endif
  46. # endif
  47. #endif
  48. #define is_leap_year(yyyy) ((((yyyy)%400))?(((yyyy)%100)?(((yyyy)%4)?0:1):0):1)
  49. typedef struct _ac_maxval
  50. {
  51. int yweek;
  52. int yday;
  53. int ywday;
  54. int mweek;
  55. int mday;
  56. int mwday;
  57. } ac_maxval_t, *ac_maxval_p;
  58. typedef struct _ac_tm
  59. {
  60. time_t time;
  61. struct tm t;
  62. int mweek;
  63. int yweek;
  64. int ywday;
  65. int mwday;
  66. ac_maxval_p mv;
  67. } ac_tm_t, *ac_tm_p;
  68. ac_tm_p ac_tm_new();
  69. int ac_tm_set(ac_tm_p, struct tm*);
  70. int ac_tm_set_time(ac_tm_p, time_t);
  71. int ac_tm_reset(ac_tm_p);
  72. int ac_tm_free(ac_tm_p);
  73. int ac_get_mweek(struct tm*);
  74. int ac_get_yweek(struct tm*);
  75. ac_maxval_p ac_get_maxval(ac_tm_p);
  76. int ac_get_wkst();
  77. int ac_print(ac_tm_p);
  78. /************************ imported from "tmrec.h" ***************************/
  79. #define FREQ_NOFREQ 0
  80. #define FREQ_YEARLY 1
  81. #define FREQ_MONTHLY 2
  82. #define FREQ_WEEKLY 3
  83. #define FREQ_DAILY 4
  84. #define WDAY_SU 0
  85. #define WDAY_MO 1
  86. #define WDAY_TU 2
  87. #define WDAY_WE 3
  88. #define WDAY_TH 4
  89. #define WDAY_FR 5
  90. #define WDAY_SA 6
  91. #define WDAY_NU 7
  92. #define TSW_TSET 1
  93. #define TSW_RSET 2
  94. typedef struct _tr_byxxx
  95. {
  96. int nr;
  97. int *xxx;
  98. int *req;
  99. } tr_byxxx_t, *tr_byxxx_p;
  100. typedef struct _tmrec
  101. {
  102. time_t dtstart;
  103. struct tm ts;
  104. time_t dtend;
  105. time_t duration;
  106. time_t until;
  107. int freq;
  108. int interval;
  109. tr_byxxx_p byday;
  110. tr_byxxx_p bymday;
  111. tr_byxxx_p byyday;
  112. tr_byxxx_p bymonth;
  113. tr_byxxx_p byweekno;
  114. int wkst;
  115. } tmrec_t, *tmrec_p;
  116. typedef struct _tr_res
  117. {
  118. int flag;
  119. time_t rest;
  120. } tr_res_t, *tr_res_p;
  121. tr_byxxx_p tr_byxxx_new();
  122. int tr_byxxx_init(tr_byxxx_p, int);
  123. int tr_byxxx_free(tr_byxxx_p);
  124. tmrec_p tmrec_new();
  125. int tmrec_free(tmrec_p);
  126. int tr_parse_dtstart(tmrec_p, char*);
  127. int tr_parse_dtend(tmrec_p, char*);
  128. int tr_parse_duration(tmrec_p, char*);
  129. int tr_parse_until(tmrec_p, char*);
  130. int tr_parse_freq(tmrec_p, char*);
  131. int tr_parse_interval(tmrec_p, char*);
  132. int tr_parse_byday(tmrec_p, char*);
  133. int tr_parse_bymday(tmrec_p, char*);
  134. int tr_parse_byyday(tmrec_p, char*);
  135. int tr_parse_bymonth(tmrec_p, char*);
  136. int tr_parse_byweekno(tmrec_p, char*);
  137. int tr_parse_wkst(tmrec_p, char*);
  138. int tr_print(tmrec_p);
  139. time_t ic_parse_datetime(char*,struct tm*);
  140. time_t ic_parse_duration(char*);
  141. tr_byxxx_p ic_parse_byday(char*);
  142. tr_byxxx_p ic_parse_byxxx(char*);
  143. int ic_parse_wkst(char*);
  144. int check_tmrec(tmrec_p, ac_tm_p, tr_res_p);
  145. #endif