mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-06 15:39:06 +00:00
FS-7198 add coma separated values and reverse ranges for time-of-day and day-of-week matches
This commit is contained in:
parent
e994b75e8b
commit
48b44832b2
@ -3320,11 +3320,19 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||||||
char *dup = strdup(exp);
|
char *dup = strdup(exp);
|
||||||
char *sStart;
|
char *sStart;
|
||||||
char *sEnd;
|
char *sEnd;
|
||||||
|
char *cur;
|
||||||
|
char *p;
|
||||||
|
|
||||||
switch_assert(dup);
|
switch_assert(dup);
|
||||||
|
|
||||||
sStart = dup;
|
cur = dup;
|
||||||
if ((sEnd=strchr(dup, '~'))) {
|
if ((p = strchr(cur, ','))) {
|
||||||
|
*p++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur) {
|
||||||
|
sStart = cur;
|
||||||
|
if ((sEnd=strchr(cur, '~'))) {
|
||||||
char *sDate = sStart;
|
char *sDate = sStart;
|
||||||
char *sTime;
|
char *sTime;
|
||||||
*sEnd++ = '\0';
|
*sEnd++ = '\0';
|
||||||
@ -3376,6 +3384,15 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur = p;
|
||||||
|
if (p) {
|
||||||
|
if ((p = strchr(p, ','))) {
|
||||||
|
*p++ = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
switch_safe_free(dup);
|
switch_safe_free(dup);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -3711,7 +3728,7 @@ SWITCH_DECLARE(switch_bool_t) switch_dow_cmp(const char *exp, int val)
|
|||||||
} else {
|
} else {
|
||||||
/* Valid day found */
|
/* Valid day found */
|
||||||
if (range_start != DOW_EOF) { /* Evaluating a range */
|
if (range_start != DOW_EOF) { /* Evaluating a range */
|
||||||
if (val >= range_start && val <= cur) {
|
if (range_start <= cur ? (val >= range_start && val <= cur) : (val >= range_start || val <= cur)) {
|
||||||
return SWITCH_TRUE;
|
return SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
range_start = DOW_EOF;
|
range_start = DOW_EOF;
|
||||||
@ -3754,11 +3771,20 @@ SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val)
|
|||||||
char *maxh;
|
char *maxh;
|
||||||
char *maxm;
|
char *maxm;
|
||||||
char *maxs;
|
char *maxs;
|
||||||
|
char *cur;
|
||||||
|
char *p;
|
||||||
|
int range_start, range_end;
|
||||||
|
|
||||||
switch_assert(dup);
|
switch_assert(dup);
|
||||||
|
|
||||||
minh = dup;
|
cur = dup;
|
||||||
if ((minm=strchr(dup, ':'))) {
|
if ((p = strchr(cur, ','))) {
|
||||||
|
*p++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur) {
|
||||||
|
minh = cur;
|
||||||
|
if ((minm=strchr(cur, ':'))) {
|
||||||
*minm++ = '\0';
|
*minm++ = '\0';
|
||||||
if ((maxh=strchr(minm, '-'))) {
|
if ((maxh=strchr(minm, '-'))) {
|
||||||
if ((maxm=strchr(maxh, ':'))) {
|
if ((maxm=strchr(maxh, ':'))) {
|
||||||
@ -3776,13 +3802,25 @@ SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val)
|
|||||||
maxs = "00";
|
maxs = "00";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val >= (atol(minh) * 60 * 60) + (atol(minm) * 60) + atol(mins) && val < (atol(maxh) * 60 * 60) + (atol(maxm) * 60) + atol(maxs)) {
|
range_start = (atol(minh) * 60 * 60) + (atol(minm) * 60) + atol(mins);
|
||||||
|
range_end = (atol(maxh) * 60 * 60) + (atol(maxm) * 60) + atol(maxs);
|
||||||
|
if (range_start <= range_end ? (val >= range_start && val <= range_end) : (val >= range_start || val <= range_end)) {
|
||||||
switch_safe_free(dup);
|
switch_safe_free(dup);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur = p;
|
||||||
|
if (p) {
|
||||||
|
if ((p = strchr(p, ','))) {
|
||||||
|
*p++ = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
switch_safe_free(dup);
|
switch_safe_free(dup);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user