#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, const char *data) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Wait until specified time" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static char * | app = "WaitUntil" |
static struct ast_module_info * | ast_module_info = &__mod_info |
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().
00114 { 00115 return ast_register_application_xml(app, waituntil_exec); 00116 }
static int unload_module | ( | void | ) | [static] |
Definition at line 108 of file app_waituntil.c.
References ast_unregister_application().
00109 { 00110 return ast_unregister_application(app); 00111 }
static int waituntil_exec | ( | struct ast_channel * | chan, | |
const char * | 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().
00071 { 00072 int res; 00073 double fraction; 00074 long seconds; 00075 struct timeval future = { 0, }; 00076 struct timeval now = ast_tvnow(); 00077 int msec; 00078 00079 if (ast_strlen_zero(data)) { 00080 ast_log(LOG_WARNING, "WaitUntil requires an argument(epoch)\n"); 00081 pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE"); 00082 return 0; 00083 } 00084 00085 if (sscanf(data, "%30ld%30lf", &seconds, &fraction) == 0) { 00086 ast_log(LOG_WARNING, "WaitUntil called with non-numeric argument\n"); 00087 pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE"); 00088 return 0; 00089 } 00090 00091 future.tv_sec = seconds; 00092 future.tv_usec = fraction * 1000000; 00093 00094 if ((msec = ast_tvdiff_ms(future, now)) < 0) { 00095 ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)now.tv_sec, (long)future.tv_sec); 00096 pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST"); 00097 return 0; 00098 } 00099 00100 if ((res = ast_safe_sleep(chan, msec))) 00101 pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "HANGUP"); 00102 else 00103 pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "OK"); 00104 00105 return res; 00106 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Wait until specified time" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [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.