app_sayunixtime.c File Reference

SayUnixTime application. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/say.h"
#include "asterisk/app.h"

Include dependency graph for app_sayunixtime.c:

Go to the source code of this file.

Enumerations

enum  { OPT_JUMP = (1 << 0) }
enum  { OPT_ARG_JUMP = 0, OPT_ARG_ARRAY_SIZE }

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int sayunixtime_exec (struct ast_channel *chan, const char *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Say 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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static char * app_datetime = "DateTime"
static char * app_sayunixtime = "SayUnixTime"
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_app_option sayunixtime_exec_options [128] = { [ 'j' ] = { .flag = OPT_JUMP , .arg_index = OPT_ARG_JUMP + 1 }, }


Detailed Description

SayUnixTime application.

Author:
Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>

Definition in file app_sayunixtime.c.


Enumeration Type Documentation

anonymous enum

Enumerator:
OPT_JUMP 

Definition at line 103 of file app_sayunixtime.c.

00103      {
00104    OPT_JUMP =          (1 << 0),
00105 };

anonymous enum

Enumerator:
OPT_ARG_JUMP 
OPT_ARG_ARRAY_SIZE 

Definition at line 107 of file app_sayunixtime.c.

00107      {
00108    OPT_ARG_JUMP = 0,
00109    /* note: this entry _MUST_ be the last one in the enum */
00110    OPT_ARG_ARRAY_SIZE,
00111 };


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 195 of file app_sayunixtime.c.

static void __unreg_module ( void   )  [static]

Definition at line 195 of file app_sayunixtime.c.

static int load_module ( void   )  [static]

Definition at line 185 of file app_sayunixtime.c.

References ast_register_application_xml, and sayunixtime_exec().

00186 {
00187    int res;
00188    
00189    res = ast_register_application_xml(app_sayunixtime, sayunixtime_exec);
00190    res |= ast_register_application_xml(app_datetime, sayunixtime_exec);
00191    
00192    return res;
00193 }

static int sayunixtime_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 120 of file app_sayunixtime.c.

References args, ast_answer(), AST_APP_ARG, ast_app_parse_options64(), ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_DIGIT_NONE, ast_get_time_t(), ast_say_date_with_format, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero, ast_test_flag64, ast_true(), format, NULL, OPT_ARG_ARRAY_SIZE, OPT_JUMP, parse(), pbx_builtin_getvar_helper(), and sayunixtime_exec_options.

Referenced by load_module().

00121 {
00122    AST_DECLARE_APP_ARGS(args,
00123       AST_APP_ARG(timeval);
00124       AST_APP_ARG(timezone);
00125       AST_APP_ARG(format);
00126       AST_APP_ARG(options);
00127    );
00128    char *parse;
00129    int res = 0;
00130    time_t unixtime;
00131    /* New default behavior is do not jump on key pressed */
00132    const char * haltondigits = AST_DIGIT_NONE;
00133    struct ast_flags64 opts = { 0, };
00134    char *opt_args[OPT_ARG_ARRAY_SIZE];
00135    const char *interrupt_string;
00136 
00137    if (!data) {
00138       return 0;
00139    }
00140 
00141    parse = ast_strdupa(data);
00142 
00143    AST_STANDARD_APP_ARGS(args, parse);
00144 
00145    /* check if we had the 'j' jump flag in option list */
00146    if (!ast_strlen_zero(args.options)) {
00147       ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options);
00148       if (ast_test_flag64(&opts, OPT_JUMP)){
00149          haltondigits = AST_DIGIT_ANY;
00150       }
00151    }
00152 
00153    /* Check if 'SAY_DTMF_INTERRUPT' is true and apply the same behavior as the j flag. */
00154    ast_channel_lock(chan);
00155    interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
00156    if (ast_true(interrupt_string)) {
00157       haltondigits = AST_DIGIT_ANY;
00158    }
00159    ast_channel_unlock(chan);
00160 
00161    ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
00162 
00163    if (ast_channel_state(chan) != AST_STATE_UP) {
00164       res = ast_answer(chan);
00165    }
00166 
00167    if (!res) {
00168       res = ast_say_date_with_format(chan, unixtime, haltondigits,
00169                       ast_channel_language(chan), ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone);
00170    }
00171 
00172    return res;
00173 }

static int unload_module ( void   )  [static]

Definition at line 175 of file app_sayunixtime.c.

References ast_unregister_application().

00176 {
00177    int res;
00178    
00179    res = ast_unregister_application(app_sayunixtime);
00180    res |= ast_unregister_application(app_datetime);
00181    
00182    return res;
00183 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Say 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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 195 of file app_sayunixtime.c.

char* app_datetime = "DateTime" [static]

Definition at line 118 of file app_sayunixtime.c.

char* app_sayunixtime = "SayUnixTime" [static]

Definition at line 117 of file app_sayunixtime.c.

Definition at line 195 of file app_sayunixtime.c.

struct ast_app_option sayunixtime_exec_options[128] = { [ 'j' ] = { .flag = OPT_JUMP , .arg_index = OPT_ARG_JUMP + 1 }, } [static]

Definition at line 115 of file app_sayunixtime.c.

Referenced by sayunixtime_exec().


Generated on Thu Apr 16 06:28:42 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6