Asterisk - The Open Source Telephony Project
18.5.0
|
PBX timing routines. More...
#include "asterisk.h"
#include "asterisk/localtime.h"
#include "asterisk/logger.h"
#include "asterisk/pbx.h"
#include "asterisk/strings.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Functions | |
int | ast_build_timing (struct ast_timing *i, const char *info_in) |
Construct a timing bitmap, for use in time-based conditionals. More... | |
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. More... | |
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. More... | |
int | ast_destroy_timing (struct ast_timing *i) |
Deallocates memory structures associated with a timing bitmap. More... | |
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. More... | |
static void | get_timerange (struct ast_timing *i, char *times) |
store a bitmask of valid times, one bit each 1 minute More... | |
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 supplied, try numeric values. More... | |
Variables | |
static const char *const | days [] |
static const char *const | months [] |
PBX timing routines.
Definition in file pbx_timing.c.
int ast_build_timing | ( | struct ast_timing * | i, |
const char * | info_in | ||
) |
Construct a timing bitmap, for use in time-based conditionals.
/brief Build timing
/param i info /param info_in
Definition at line 203 of file pbx_timing.c.
References ast_strdup, ast_strdupa, ast_strlen_zero, ast_timing::daymask, days, ast_timing::dowmask, get_range(), get_timerange(), sip_to_pjsip::info(), ast_timing::monthmask, months, NULL, strsep(), and ast_timing::timezone.
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.
i | Pointer to an ast_timing structure. |
Returns | 1, if the time matches or 0, if the current time falls outside of the specified range. |
Definition at line 246 of file pbx_timing.c.
References ast_check_timing2(), and ast_tvnow().
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.
i | Pointer to an ast_timing structure. |
tv | Specified time |
Returns | 1, if the time matches or 0, if the time falls outside of the specified range. |
Definition at line 251 of file pbx_timing.c.
References ast_localtime(), ast_log, ast_timing::daymask, ast_timing::dowmask, LOG_WARNING, ast_timing::minmask, ast_timing::monthmask, ast_timing::timezone, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, and ast_tm::tm_wday.
Referenced by ast_check_timing(), and pbx_builtin_gotoiftime().
int ast_destroy_timing | ( | struct ast_timing * | i | ) |
Deallocates memory structures associated with a timing bitmap.
i | Pointer to an ast_timing structure. |
0 | success |
non-zero | failure (number suitable to pass to |
Definition at line 285 of file pbx_timing.c.
References ast_free, NULL, and ast_timing::timezone.
Referenced by iftime(), include_free(), pbx_builtin_execiftime(), and pbx_builtin_gotoiftime().
|
static |
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.
Definition at line 65 of file pbx_timing.c.
References ast_log, ast_strlen_zero, end, LOG_WARNING, lookup_name(), and strsep().
Referenced by ast_build_timing().
|
static |
store a bitmask of valid times, one bit each 1 minute
Definition at line 108 of file pbx_timing.c.
References ast_log, ast_strlen_zero, LOG_WARNING, ast_timing::minmask, and strsep().
Referenced by ast_build_timing().
|
static |
Helper for get_range. return the index of the matching entry, starting from 1. If names is not supplied, try numeric values.
Definition at line 42 of file pbx_timing.c.
Referenced by get_range().
|
static |
Definition at line 168 of file pbx_timing.c.
Referenced by ast_build_timing().
|
static |
Definition at line 180 of file pbx_timing.c.
Referenced by ast_build_timing().