Sleep until the given epoch. More...
#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | load_module (void) |
static int | unload_module (void) |
static int | waituntil_exec (struct ast_channel *chan, void *data) |
Variables | |
static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Wait until specified time" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
static char * | app = "WaitUntil" |
static struct ast_module_info * | ast_module_info = &__mod_info |
Sleep until the given epoch.
Definition in file app_waituntil.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 118 of file app_waituntil.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 118 of file app_waituntil.c.
static int load_module | ( | void | ) | [static] |
Definition at line 113 of file app_waituntil.c.
References ast_register_application_xml, and waituntil_exec().
{ return ast_register_application_xml(app, waituntil_exec); }
static int unload_module | ( | void | ) | [static] |
Definition at line 108 of file app_waituntil.c.
References ast_unregister_application().
{ return ast_unregister_application(app); }
static int waituntil_exec | ( | struct ast_channel * | chan, |
void * | data | ||
) | [static] |
Definition at line 70 of file app_waituntil.c.
References ast_log(), ast_safe_sleep(), ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), LOG_NOTICE, LOG_WARNING, and pbx_builtin_setvar_helper().
Referenced by load_module().
{ int res; double fraction; long seconds; struct timeval future = { 0, }; struct timeval now = ast_tvnow(); int msec; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "WaitUntil requires an argument(epoch)\n"); pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE"); return 0; } if (sscanf(data, "%30ld%30lf", &seconds, &fraction) == 0) { ast_log(LOG_WARNING, "WaitUntil called with non-numeric argument\n"); pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE"); return 0; } future.tv_sec = seconds; future.tv_usec = fraction * 1000000; if ((msec = ast_tvdiff_ms(future, now)) < 0) { ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)now.tv_sec, (long)future.tv_sec); pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST"); return 0; } if ((res = ast_safe_sleep(chan, msec))) pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "HANGUP"); else pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "OK"); return res; }
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Wait until specified time" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 118 of file app_waituntil.c.
char* app = "WaitUntil" [static] |
Definition at line 68 of file app_waituntil.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 118 of file app_waituntil.c.