Asterisk - The Open Source Telephony Project GIT-master-7805f28
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 107 of file app_sayunixtime.c.

107 {
108 OPT_JUMP = (1 << 0),
109};
@ OPT_JUMP

◆ anonymous enum

anonymous enum
Enumerator
OPT_ARG_JUMP 
OPT_ARG_ARRAY_SIZE 

Definition at line 111 of file app_sayunixtime.c.

111 {
112 OPT_ARG_JUMP = 0,
113 /* note: this entry _MUST_ be the last one in the enum */
115};
@ OPT_ARG_JUMP
@ OPT_ARG_ARRAY_SIZE

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 199 of file app_sayunixtime.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 199 of file app_sayunixtime.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 199 of file app_sayunixtime.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 189 of file app_sayunixtime.c.

190{
191 int res;
192
195
196 return res;
197}
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:640

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

125{
127 AST_APP_ARG(timeval);
128 AST_APP_ARG(timezone);
129 AST_APP_ARG(format);
131 );
132 char *parse;
133 int res = 0;
134 time_t unixtime;
135 /* New default behavior is do not jump on key pressed */
136 const char * haltondigits = AST_DIGIT_NONE;
137 struct ast_flags64 opts = { 0, };
138 char *opt_args[OPT_ARG_ARRAY_SIZE];
139 const char *interrupt_string;
140
141 if (!data) {
142 return 0;
143 }
144
145 parse = ast_strdupa(data);
146
148
149 /* check if we had the 'j' jump flag in option list */
150 if (!ast_strlen_zero(args.options)) {
151 ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options);
152 if (ast_test_flag64(&opts, OPT_JUMP)){
153 haltondigits = AST_DIGIT_ANY;
154 }
155 }
156
157 /* Check if 'SAY_DTMF_INTERRUPT' is true and apply the same behavior as the j flag. */
158 ast_channel_lock(chan);
159 interrupt_string = pbx_builtin_getvar_helper(chan, "SAY_DTMF_INTERRUPT");
160 if (ast_true(interrupt_string)) {
161 haltondigits = AST_DIGIT_ANY;
162 }
163 ast_channel_unlock(chan);
164
165 ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
166
167 if (ast_channel_state(chan) != AST_STATE_UP) {
168 res = ast_answer(chan);
169 }
170
171 if (!res) {
172 res = ast_say_date_with_format(chan, unixtime, haltondigits,
173 ast_channel_language(chan), ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone);
174 }
175
176 return res;
177}
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:2972
const char * ast_channel_language(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2774
#define ast_channel_unlock(chan)
Definition: channel.h:2973
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:3071
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 179 of file app_sayunixtime.c.

180{
181 int res;
182
185
186 return res;
187}
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 199 of file app_sayunixtime.c.

◆ app_datetime

char* app_datetime = "DateTime"
static

Definition at line 122 of file app_sayunixtime.c.

Referenced by load_module(), and unload_module().

◆ app_sayunixtime

char* app_sayunixtime = "SayUnixTime"
static

Definition at line 121 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 199 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 119 of file app_sayunixtime.c.

Referenced by sayunixtime_exec().