46 if (names && *s >
'9') {
47 for (i = 0; names[i]; i++) {
48 if (!strcasecmp(s, names[i])) {
55 if (sscanf(s,
"%2d", &i) == 1 && i >= 1 && i <= max) {
65 static unsigned get_range(
char *src,
int max,
const char *
const names[],
const char *msg)
68 unsigned int mask = 0;
73 return (1 << max) - 1;
76 while ((part =
strsep(&src,
"&"))) {
78 char *endpart = strchr(part,
'-');
97 while (start != end) {
110 char *endpart, *part;
114 int minute_start, minute_end;
123 for (x = 0; x < 48; x++) {
129 while ((part =
strsep(×,
"&"))) {
130 if (!(endpart = strchr(part,
'-'))) {
131 if (sscanf(part,
"%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
135 i->
minmask[st_h * 2 + (st_m >= 30 ? 1 : 0)] |= (1 << (st_m % 30));
140 while (*endpart && !isdigit(*endpart)) {
147 if (sscanf(part,
"%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
151 if (sscanf(endpart,
"%2d:%2d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) {
155 minute_start = st_h * 60 + st_m;
156 minute_end = endh * 60 + endm;
158 for (x = minute_start; x != minute_end; x = (x + 1) % (24 * 60)) {
159 i->
minmask[x / 30] |= (1 << (x % 30));
162 i->
minmask[x / 30] |= (1 << (x % 30));
168 static const char *
const days[] =
206 int j, num_fields, last_sep = -1;
219 for (j = 0, num_fields = 1; info[j] !=
'\0'; j++) {
220 if (info[j] ==
',') {
227 if (num_fields == 5) {
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
int ast_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
int ast_check_timing2(const struct ast_timing *i, const struct timeval tv)
Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified...
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strlen_zero(foo)
Custom localtime functions for multiple timezones.
static void get_timerange(struct ast_timing *i, char *times)
store a bitmask of valid times, one bit each 1 minute
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified...
#define ast_strdupa(s)
duplicate a string in memory from the stack
Core PBX routines and definitions.
static unsigned get_range(char *src, int max, const char *const names[], const char *msg)
helper function to return a range up to max (7, 12, 31 respectively). names, if supplied, is an array of names that should be mapped to numbers.
static const char *const months[]
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
static const char *const days[]
Support for logging to various files, console and syslog Configuration in file logger.conf.
char * strsep(char **str, const char *delims)
static int lookup_name(const char *s, const char *const names[], int max)
Helper for get_range. return the index of the matching entry, starting from 1. If names is not suppli...