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"
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, } |
| static char * | app_datetime = "DateTime" |
| static char * | app_sayunixtime = "SayUnixTime" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_app_option | sayunixtime_exec_options [128] = { [ 'j' ] = { .flag = OPT_JUMP , .arg_index = OPT_ARG_JUMP + 1 }, } |
SayUnixTime application.
Definition in file app_sayunixtime.c.
| anonymous enum |
| anonymous enum |
Definition at line 104 of file app_sayunixtime.c.
{
OPT_ARG_JUMP = 0,
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
};
| static void __reg_module | ( | void | ) | [static] |
Definition at line 183 of file app_sayunixtime.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 183 of file app_sayunixtime.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 173 of file app_sayunixtime.c.
References ast_register_application_xml, and sayunixtime_exec().
{
int res;
res = ast_register_application_xml(app_sayunixtime, sayunixtime_exec);
res |= ast_register_application_xml(app_datetime, sayunixtime_exec);
return res;
}
| static int sayunixtime_exec | ( | struct ast_channel * | chan, |
| const char * | data | ||
| ) | [static] |
Definition at line 117 of file app_sayunixtime.c.
References args, ast_answer(), AST_APP_ARG, ast_app_parse_options64(), ast_channel_language(), 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_strlen_zero(), ast_test_flag64, format, OPT_ARG_ARRAY_SIZE, OPT_JUMP, parse(), and sayunixtime_exec_options.
Referenced by load_module().
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(timeval);
AST_APP_ARG(timezone);
AST_APP_ARG(format);
AST_APP_ARG(options);
);
char *parse;
int res = 0;
time_t unixtime;
/* New default behavior is do not jump on key pressed */
const char * haltondigits = AST_DIGIT_NONE;
struct ast_flags64 opts = { 0, };
char *opt_args[OPT_ARG_ARRAY_SIZE];
if (!data) {
return 0;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
/* check if we had the 'j' jump flag in option list */
if (!ast_strlen_zero(args.options)) {
ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options);
if (ast_test_flag64(&opts, OPT_JUMP)){
haltondigits = AST_DIGIT_ANY;
}
}
ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
if (ast_channel_state(chan) != AST_STATE_UP) {
res = ast_answer(chan);
}
if (!res) {
res = ast_say_date_with_format(chan, unixtime, haltondigits,
ast_channel_language(chan), ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone);
}
return res;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 163 of file app_sayunixtime.c.
References ast_unregister_application().
{
int res;
res = ast_unregister_application(app_sayunixtime);
res |= ast_unregister_application(app_datetime);
return res;
}
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, } [static] |
Definition at line 183 of file app_sayunixtime.c.
char* app_datetime = "DateTime" [static] |
Definition at line 115 of file app_sayunixtime.c.
char* app_sayunixtime = "SayUnixTime" [static] |
Definition at line 114 of file app_sayunixtime.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 183 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 112 of file app_sayunixtime.c.
Referenced by sayunixtime_exec().