1 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius |
2 |
Copyright (C) 2001, Sergey Poznyakoff |
Copyright (C) 2001, 2003, Sergey Poznyakoff |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
GNU Radius is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
7 |
(at your option) any later version. |
(at your option) any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
GNU Radius is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software Foundation, |
along with GNU Radius; if not, write to the Free Software Foundation, |
16 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
17 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = "@(#) $Id$"; |
|
|
#endif |
|
|
|
|
18 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
19 |
# include <config.h> |
# include <config.h> |
20 |
#endif |
#endif |
44 |
#define DAYMIN (24*60) |
#define DAYMIN (24*60) |
45 |
#define val(x) (( (x) < '0' || (x) > '9') ? 0 : ((x) - '0')) |
#define val(x) (( (x) < '0' || (x) > '9') ? 0 : ((x) - '0')) |
46 |
|
|
47 |
static TIMESPAN *timespan_new(int start, int stop); |
static TIMESPAN * |
48 |
static void timespan_day(TIMESPAN **ts, int day, int start, int stop); |
timespan_new(int start, int stop) |
|
static int timespan_parse(TIMESPAN **ts, char *s, char **endp); |
|
|
|
|
|
TIMESPAN * |
|
|
timespan_new(start, stop) |
|
|
int start; |
|
|
int stop; |
|
49 |
{ |
{ |
50 |
TIMESPAN *ts; |
TIMESPAN *ts; |
51 |
|
|
56 |
return ts; |
return ts; |
57 |
} |
} |
58 |
|
|
59 |
void |
static void |
60 |
timespan_day(ts, day, start, stop) |
timespan_day(TIMESPAN **ts, int day, int start, int stop) |
|
TIMESPAN **ts; |
|
|
int day; |
|
|
int start; |
|
|
int stop; |
|
61 |
{ |
{ |
62 |
TIMESPAN *tp, *prev; |
TIMESPAN *tp, *prev; |
63 |
|
|
116 |
} |
} |
117 |
} |
} |
118 |
|
|
119 |
int |
static int |
120 |
timespan_parse(ts, s, endp) |
timespan_parse(TIMESPAN **ts, char *s, char **endp) |
|
TIMESPAN **ts; |
|
|
char *s; |
|
|
char **endp; |
|
121 |
{ |
{ |
122 |
register int i, j; |
register int i, j; |
123 |
register char *p; |
register char *p; |
197 |
} |
} |
198 |
|
|
199 |
void |
void |
200 |
ts_free(sp) |
ts_free(TIMESPAN *sp) |
|
TIMESPAN *sp; |
|
201 |
{ |
{ |
202 |
TIMESPAN *next; |
TIMESPAN *next; |
203 |
|
|
210 |
|
|
211 |
|
|
212 |
int |
int |
213 |
ts_parse(sp, str, endp) |
ts_parse(TIMESPAN **sp, char *str, char **endp) |
|
TIMESPAN **sp; |
|
|
char *str; |
|
|
char **endp; |
|
214 |
{ |
{ |
215 |
*sp = NULL; |
*sp = NULL; |
216 |
while (1) { |
while (1) { |
231 |
} |
} |
232 |
|
|
233 |
int |
int |
234 |
ts_match(timespan, time_now, rest) |
ts_match(TIMESPAN *timespan, time_t *time_now, unsigned *rest) |
|
TIMESPAN *timespan; |
|
|
time_t *time_now; |
|
|
unsigned *rest; |
|
235 |
{ |
{ |
236 |
TIMESPAN *tp; |
TIMESPAN *tp; |
237 |
struct tm *tm, tms; |
struct tm *tm, tms; |
267 |
} |
} |
268 |
|
|
269 |
int |
int |
270 |
ts_check(str, time, rest, endp) |
ts_check(char *str, time_t *time, unsigned *rest, char **endp) |
|
char *str; |
|
|
time_t *time; |
|
|
unsigned *rest; |
|
|
char **endp; |
|
271 |
{ |
{ |
272 |
TIMESPAN *ts; |
TIMESPAN *ts; |
273 |
int rc; |
int rc; |