Asterisk - The Open Source Telephony Project GIT-master-2de1a68
Enumerations | Functions | Variables
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)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 const struct ast_module_infoast_module_info = &__mod_info
 
static const 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_s.nosp@m.ayun.nosp@m.ixtim.nosp@m.e__2.nosp@m.00309.nosp@m.@the.nosp@m.-tilg.nosp@m.hman.nosp@m..com

Definition in file app_sayunixtime.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPT_JUMP 

Definition at line 101 of file app_sayunixtime.c.

101 {
102 OPT_JUMP = (1 << 0),
103};
@ OPT_JUMP

◆ anonymous enum

anonymous enum
Enumerator
OPT_ARG_JUMP 
OPT_ARG_ARRAY_SIZE 

Definition at line 105 of file app_sayunixtime.c.

105 {
106 OPT_ARG_JUMP = 0,
107 /* note: this entry _MUST_ be the last one in the enum */
109};
@ OPT_ARG_JUMP
@ OPT_ARG_ARRAY_SIZE

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 193 of file app_sayunixtime.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 193 of file app_sayunixtime.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 193 of file app_sayunixtime.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 183 of file app_sayunixtime.c.

184{
185 int res;
186
189
190 return res;
191}
static int sayunixtime_exec(struct ast_channel *chan, const char *data)
static char * app_sayunixtime
static char * app_datetime
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References app_datetime, app_sayunixtime, ast_register_application_xml, and sayunixtime_exec().

◆ sayunixtime_exec()

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

Definition at line 118 of file app_sayunixtime.c.

119{
121 AST_APP_ARG(timeval);
122 AST_APP_ARG(timezone);
123 AST_APP_ARG(format);
125 );
126 char *parse;
127 int res = 0;
128 time_t unixtime;
129 /* New default behavior is do not jump on key pressed */
130 const char * haltondigits = AST_DIGIT_NONE;
131 struct ast_flags64 opts = { 0, };
132 char *opt_args[OPT_ARG_ARRAY_SIZE];
133 const char *interrupt_string;
134
135 if (!data) {
136 return 0;
137 }
138
139 parse = ast_strdupa(data);
140
142
143 /* check if we had the 'j' jump flag in option list */
144 if (!ast_strlen_zero(args.options)) {
145 ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options);
146 if (ast_test_flag64(&opts, OPT_JUMP)){
147 haltondigits = AST_DIGIT_ANY;
148 }
149 }
150
151 /* Check if 'SAY_DTMF_INTERRUPT' is true and apply the same behavior as the j flag. */
152 ast_channel_lock(chan);
153 interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
154 if (ast_true(interrupt_string)) {
155 haltondigits = AST_DIGIT_ANY;
156 }
157 ast_channel_unlock(chan);
158
159 ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
160
161 if (ast_channel_state(chan) != AST_STATE_UP) {
162 res = ast_answer(chan);
163 }
164
165 if (!res) {
166 res = ast_say_date_with_format(chan, unixtime, haltondigits,
167 ast_channel_language(chan), ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone);
168 }
169
170 return res;
171}
static const struct ast_app_option sayunixtime_exec_options[128]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_channel_lock(chan)
Definition: channel.h:2922
const char * ast_channel_language(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2805
#define ast_channel_unlock(chan)
Definition: channel.h:2923
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
#define AST_DIGIT_NONE
Definition: file.h:47
#define AST_DIGIT_ANY
Definition: file.h:48
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:3061
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define NULL
Definition: resample.c:96
SAY_EXTERN int(* ast_say_date_with_format)(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezone) SAY_INIT(ast_say_date_with_format)
Definition: say.h:208
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2199
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
Parse a time (integer) string.
Definition: utils.c:2446
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Structure used to handle a large number of boolean flags == used only in app_dial?
Definition: utils.h:204
const char * args
static struct test_options options
#define ast_test_flag64(p, flag)
Definition: utils.h:120

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(), NULL, OPT_ARG_ARRAY_SIZE, OPT_JUMP, options, pbx_builtin_getvar_helper(), and sayunixtime_exec_options.

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 173 of file app_sayunixtime.c.

174{
175 int res;
176
179
180 return res;
181}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app_datetime, app_sayunixtime, and ast_unregister_application().

Variable Documentation

◆ __mod_info

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 193 of file app_sayunixtime.c.

◆ app_datetime

char* app_datetime = "DateTime"
static

Definition at line 116 of file app_sayunixtime.c.

Referenced by load_module(), and unload_module().

◆ app_sayunixtime

char* app_sayunixtime = "SayUnixTime"
static

Definition at line 115 of file app_sayunixtime.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 193 of file app_sayunixtime.c.

◆ sayunixtime_exec_options

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

Definition at line 113 of file app_sayunixtime.c.

Referenced by sayunixtime_exec().