cpl_time.h

Go to the documentation of this file.
00001 /*
00002  * $Id: cpl_time.h 5003 2008-09-26 11:01:51Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  *
00023  * History:
00024  * -------
00025  * 2003-06-24: file imported from tmrec (bogdan)
00026  * 2003-xx-xx: file Created (daniel)
00027  */
00028 
00029 #ifndef _CPL_TIME_H_
00030 #define _CPL_TIME_H_
00031 
00032 
00033 /************************ imported from "ac_tm.h"  ***************************/
00034 
00035 #include <time.h>
00036 
00037 
00038 /* USE_YWEEK_U -- Sunday system - see strftime %U
00039  * USE_YWEEK_V -- ISO 8601 - see strftime %V
00040  * USE_YWEEK_W -- Monday system - see strftime %W
00041 */
00042 
00043 #ifndef USE_YWEEK_U
00044 # ifndef USE_YWEEK_V
00045 #  ifndef USE_YWEEK_W
00046 #   define USE_YWEEK_W
00047 #  endif
00048 # endif
00049 #endif
00050 
00051 #define is_leap_year(yyyy) ((((yyyy)%400))?(((yyyy)%100)?(((yyyy)%4)?0:1):0):1)
00052 
00053 
00054 typedef struct _ac_maxval
00055 {
00056    int yweek;
00057    int yday;
00058    int ywday;
00059    int mweek;
00060    int mday;
00061    int mwday;
00062 } ac_maxval_t, *ac_maxval_p;
00063 
00064 typedef struct _ac_tm
00065 {
00066    time_t time;
00067    struct tm t;
00068    int mweek;
00069    int yweek;
00070    int ywday;
00071    int mwday;
00072    ac_maxval_p mv;
00073 } ac_tm_t, *ac_tm_p;
00074 
00075 ac_tm_p ac_tm_new(void);
00076 
00077 int ac_tm_set_time(ac_tm_p, time_t);
00078 
00079 int ac_tm_reset(ac_tm_p);
00080 int ac_tm_free(ac_tm_p);
00081 
00082 int ac_get_mweek(struct tm*);
00083 int ac_get_yweek(struct tm*);
00084 ac_maxval_p ac_get_maxval(ac_tm_p);
00085 int ac_get_wkst(void);
00086 
00087 int ac_print(ac_tm_p);
00088 
00089 
00090 
00091 
00092 /************************ imported from "tmrec.h"  ***************************/
00093 
00094 
00095 #define FREQ_NOFREQ  0
00096 #define FREQ_YEARLY  1
00097 #define FREQ_MONTHLY 2
00098 #define FREQ_WEEKLY  3
00099 #define FREQ_DAILY   4
00100 
00101 #define WDAY_SU 0
00102 #define WDAY_MO 1
00103 #define WDAY_TU 2
00104 #define WDAY_WE 3
00105 #define WDAY_TH 4
00106 #define WDAY_FR 5
00107 #define WDAY_SA 6
00108 #define WDAY_NU 7
00109 
00110 #define TSW_TSET  1
00111 #define TSW_RSET  2
00112 
00113 typedef struct _tr_byxxx
00114 {
00115    int nr;
00116    int *xxx;
00117    int *req;
00118 } tr_byxxx_t, *tr_byxxx_p;
00119 
00120 typedef struct _tmrec
00121 {
00122    time_t dtstart;
00123    struct tm ts;
00124    time_t dtend;
00125    time_t duration;
00126    time_t until;
00127    int freq;
00128    int interval;
00129    tr_byxxx_p byday;
00130    tr_byxxx_p bymday;
00131    tr_byxxx_p byyday;
00132    tr_byxxx_p bymonth;
00133    tr_byxxx_p byweekno;
00134    int wkst;
00135 } tmrec_t, *tmrec_p;
00136 
00137 typedef struct _tr_res
00138 {
00139    int flag;
00140    time_t rest;
00141 } tr_res_t, *tr_res_p;
00142 
00143 tr_byxxx_p tr_byxxx_new(void);
00144 int tr_byxxx_init(tr_byxxx_p, int);
00145 int tr_byxxx_free(tr_byxxx_p);
00146 
00147 tmrec_p tmrec_new(void);
00148 int tmrec_free(tmrec_p);
00149 
00150 int tr_parse_dtstart(tmrec_p, char*);
00151 int tr_parse_dtend(tmrec_p, char*);
00152 int tr_parse_duration(tmrec_p, char*);
00153 int tr_parse_until(tmrec_p, char*);
00154 int tr_parse_freq(tmrec_p, char*);
00155 int tr_parse_interval(tmrec_p, char*);
00156 int tr_parse_byday(tmrec_p, char*);
00157 int tr_parse_bymday(tmrec_p, char*);
00158 int tr_parse_byyday(tmrec_p, char*);
00159 int tr_parse_bymonth(tmrec_p, char*);
00160 int tr_parse_byweekno(tmrec_p, char*);
00161 int tr_parse_wkst(tmrec_p, char*);
00162 
00163 int tr_print(tmrec_p);
00164 time_t ic_parse_datetime(char*,struct tm*);
00165 time_t ic_parse_duration(char*);
00166 
00167 tr_byxxx_p ic_parse_byday(char*);
00168 tr_byxxx_p ic_parse_byxxx(char*);
00169 int ic_parse_wkst(char*);
00170 
00171 int check_tmrec(tmrec_p, ac_tm_p, tr_res_p);
00172 
00173 
00174 #endif
00175 

Generated on Mon May 21 18:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6