tmrec.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. * Kamailio 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. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef _SR_TMREC_H_
  24. #define _SR_TMREC_H_
  25. /**
  26. * ===== imported from "ac_tm.h"
  27. */
  28. #include <time.h>
  29. /* USE_YWEEK_U -- Sunday system - see strftime %U
  30. * USE_YWEEK_V -- ISO 8601 - see strftime %V
  31. * USE_YWEEK_W -- Monday system - see strftime %W
  32. */
  33. #ifndef USE_YWEEK_U
  34. # ifndef USE_YWEEK_V
  35. # ifndef USE_YWEEK_W
  36. # define USE_YWEEK_W
  37. # endif
  38. # endif
  39. #endif
  40. #define tr_is_leap_year(yyyy) ((((yyyy)%400))?(((yyyy)%100)?(((yyyy)%4)?0:1):0):1)
  41. typedef struct _ac_maxval
  42. {
  43. int yweek;
  44. int yday;
  45. int ywday;
  46. int mweek;
  47. int mday;
  48. int mwday;
  49. } ac_maxval_t;
  50. typedef struct _ac_tm
  51. {
  52. time_t time;
  53. struct tm t;
  54. int mweek;
  55. int yweek;
  56. int ywday;
  57. int mwday;
  58. ac_maxval_t *mv;
  59. } ac_tm_t;
  60. ac_tm_t *ac_tm_new(void);
  61. int ac_tm_set_time(ac_tm_t*, time_t);
  62. int ac_tm_reset(ac_tm_t*);
  63. int ac_tm_free(ac_tm_t*);
  64. int ac_tm_destroy(ac_tm_t*);
  65. int ac_get_mweek(struct tm*);
  66. int ac_get_yweek(struct tm*);
  67. ac_maxval_t *ac_get_maxval(ac_tm_t*);
  68. int ac_get_wkst(void);
  69. int ac_print(ac_tm_t*);
  70. /**
  71. * ===== imported from "tmrec.h"
  72. */
  73. #define FREQ_NOFREQ 0
  74. #define FREQ_YEARLY 1
  75. #define FREQ_MONTHLY 2
  76. #define FREQ_WEEKLY 3
  77. #define FREQ_DAILY 4
  78. #define WDAY_SU 0
  79. #define WDAY_MO 1
  80. #define WDAY_TU 2
  81. #define WDAY_WE 3
  82. #define WDAY_TH 4
  83. #define WDAY_FR 5
  84. #define WDAY_SA 6
  85. #define WDAY_NU 7
  86. #define TSW_TSET 1
  87. #define TSW_RSET 2
  88. typedef struct _tr_byxxx
  89. {
  90. int nr;
  91. int *xxx;
  92. int *req;
  93. } tr_byxxx_t;
  94. typedef struct _tmrec
  95. {
  96. time_t dtstart;
  97. struct tm ts;
  98. time_t dtend;
  99. time_t duration;
  100. time_t until;
  101. int freq;
  102. int interval;
  103. tr_byxxx_t *byday;
  104. tr_byxxx_t *bymday;
  105. tr_byxxx_t *byyday;
  106. tr_byxxx_t *bymonth;
  107. tr_byxxx_t *byweekno;
  108. int wkst;
  109. } tmrec_t;
  110. typedef struct _tr_res
  111. {
  112. int flag;
  113. time_t rest;
  114. } tr_res_t;
  115. tr_byxxx_t *tr_byxxx_new(void);
  116. int tr_byxxx_init(tr_byxxx_t*, int);
  117. int tr_byxxx_free(tr_byxxx_t*);
  118. tmrec_t *tmrec_new(void);
  119. int tmrec_free(tmrec_t*);
  120. int tmrec_destroy(tmrec_t*);
  121. int tr_parse_dtstart(tmrec_t*, char*);
  122. int tr_parse_dtend(tmrec_t*, char*);
  123. int tr_parse_duration(tmrec_t*, char*);
  124. int tr_parse_until(tmrec_t*, char*);
  125. int tr_parse_freq(tmrec_t*, char*);
  126. int tr_parse_interval(tmrec_t*, char*);
  127. int tr_parse_byday(tmrec_t*, char*);
  128. int tr_parse_bymday(tmrec_t*, char*);
  129. int tr_parse_byyday(tmrec_t*, char*);
  130. int tr_parse_bymonth(tmrec_t*, char*);
  131. int tr_parse_byweekno(tmrec_t*, char*);
  132. int tr_parse_wkst(tmrec_t*, char*);
  133. int tr_print(tmrec_t*);
  134. time_t ic_parse_datetime(char*,struct tm*);
  135. time_t ic_parse_duration(char*);
  136. tr_byxxx_t *ic_parse_byday(char*);
  137. tr_byxxx_t *ic_parse_byxxx(char*);
  138. int ic_parse_wkst(char*);
  139. int tr_check_recurrence(tmrec_t*, ac_tm_t*, tr_res_t*);
  140. int tr_parse_recurrence_string(tmrec_t *trp, char *rdef, char sep);
  141. #endif