Thu Jul 9 13:40:51 2009

Asterisk developer's documentation


app_waituntil.c File Reference

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 __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, }
static char * app = "WaitUntil"
static const struct ast_module_infoast_module_info = &__mod_info
static char * descrip
static char * synopsis = "Wait (sleep) until the current time is the given epoch"


Detailed Description

Sleep until the given epoch.

Author:
Philip Prindeville <philipp@redfish-solutions.com>

Definition in file app_waituntil.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 93 of file app_waituntil.c.

static void __unreg_module ( void   )  [static]

Definition at line 93 of file app_waituntil.c.

static int load_module ( void   )  [static]

Definition at line 88 of file app_waituntil.c.

References ast_register_application, and waituntil_exec().

00089 {
00090    return ast_register_application(app, waituntil_exec, synopsis, descrip);
00091 }

static int unload_module ( void   )  [static]

Definition at line 83 of file app_waituntil.c.

References ast_unregister_application().

00084 {
00085    return ast_unregister_application(app);
00086 }

static int waituntil_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 47 of file app_waituntil.c.

References ast_log(), ast_safe_sleep(), ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), chan, LOG_NOTICE, LOG_WARNING, and pbx_builtin_setvar_helper().

Referenced by load_module().

00048 {
00049    int res;
00050    double fraction;
00051    struct timeval future = { 0, };
00052    struct timeval tv = ast_tvnow();
00053    int msec;
00054 
00055    if (ast_strlen_zero(data)) {
00056       ast_log(LOG_WARNING, "WaitUntil requires an argument(epoch)\n");
00057       pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE");
00058       return 0;
00059    }
00060 
00061    if (sscanf(data, "%ld%lf", (long *)&future.tv_sec, &fraction) == 0) {
00062       ast_log(LOG_WARNING, "WaitUntil called with non-numeric argument\n");
00063       pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE");
00064       return 0;
00065    }
00066 
00067    future.tv_usec = fraction * 1000000;
00068 
00069    if ((msec = ast_tvdiff_ms(future, tv)) < 0) {
00070       ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)tv.tv_sec, (long)future.tv_sec);
00071       pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST");
00072       return 0;
00073    }
00074 
00075    if ((res = ast_safe_sleep(chan, msec)))
00076       pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "HANGUP");
00077    else
00078       pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "OK");
00079 
00080    return res;
00081 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static]

Definition at line 93 of file app_waituntil.c.

char* app = "WaitUntil" [static]

Definition at line 37 of file app_waituntil.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 93 of file app_waituntil.c.

char* descrip [static]

Definition at line 39 of file app_waituntil.c.

char* synopsis = "Wait (sleep) until the current time is the given epoch" [static]

Definition at line 38 of file app_waituntil.c.


Generated on Thu Jul 9 13:40:51 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7