36 #include "asterisk/file.h"
88 static char *
app =
"Playback";
97 static const char *
const say_old =
"old";
98 static const char *
const say_new =
"new";
103 say_api_buf[i++] = arg;
120 say_api_buf[i++] = arg;
169 char *lang, *x, *
rule = NULL;
174 ast_debug(2,
"string <%s> depth <%d>\n", s, depth);
178 }
else if (!say_cfg) {
197 if ( (x = strchr(lang,
'_')) )
199 else if (strcmp(lang,
"en"))
208 if ( (x = strchr(s,
':')) )
210 if ( (x = strchr(s,
':')) )
221 while ( !ret && (x =
strsep(&rule,
",")) ) {
223 const char *p, *fmt, *data;
234 fmt = strchr(fn,
':');
235 if (!fmt || fmt == fn) {
240 data = strchr(fmt,
':');
241 if (!data || data == fmt) {
242 ret =
do_say(a, fn, options, depth);
246 for (p = fmt; p < data && ret <= 0; p++) {
247 char fn2[
sizeof(fn)];
248 if (*p ==
' ' || *p ==
'\t')
253 y = strchr(fn2,
'\'');
260 p = strchr(p+1,
'\'');
267 strcpy(fn2 + l, data);
268 ret =
do_say(a, fn2, options, depth);
281 const char *ints,
const char *lang,
const char *options,
282 int audiofd,
int ctrlfd)
284 say_args_t a = { chan, ints, lang, audiofd, ctrlfd };
285 return do_say(&a,
string, options, 0);
289 const char *ints,
const char *lang,
const char *options,
290 int audiofd,
int ctrlfd)
293 say_args_t a = { chan, ints, lang, audiofd, ctrlfd };
294 snprintf(buf,
sizeof(buf),
"num:%d", num);
295 return do_say(&a, buf, options, 0);
299 const char *ints,
const char *lang,
const char *options,
300 int audiofd,
int ctrlfd)
303 say_args_t a = { chan, ints, lang, audiofd, ctrlfd };
304 snprintf(buf,
sizeof(buf),
"enum:%d", num);
305 return do_say(&a, buf, options, 0);
309 const char *ints,
const char *lang,
const char *
format,
const char *timezonename,
const char *
prefix)
313 struct timeval when = { t, 0 };
319 snprintf(buf,
sizeof(buf),
"%s:%s:%04d%02d%02d%02d%02d.%02d-%d-%3d",
330 return do_say(&a, buf, NULL, 0);
334 const char *ints,
const char *lang,
const char *
format,
const char *timezonename)
336 return say_date_generic(chan, t, ints, lang, format, timezonename,
"datetime");
358 if (!strcmp(mode, say_new)) {
359 if (say_cfg == NULL) {
378 }
else if (!strcmp(mode, say_old) && say_api_buf[0] == say_new) {
380 }
else if (strcmp(mode, say_old)) {
390 const char *old_mode = say_api_buf[0] ? say_new :
say_old;
394 e->
command =
"say load [new|old]";
396 "Usage: say load [new|old]\n"
398 " Report status of current say mode\n"
400 " Set say method, configured in say.conf\n"
402 " Set old say method, coded in asterisk core\n";
408 ast_cli(a->
fd,
"say mode is [%s]\n", old_mode);
413 if (!strcmp(mode, old_mode))
414 ast_cli(a->
fd,
"say mode is %s already\n", mode);
417 ast_cli(a->
fd,
"setting say mode from %s to %s\n", old_mode, mode);
433 int option_noanswer = 0;
460 }
else if (!option_noanswer) {
466 char *back =
args.filenames;
470 while (!res && (front =
strsep(&back,
"&"))) {
499 ast_log(
LOG_ERROR,
"Config file say.conf is in an invalid format. Aborting.\n");
static void save_say_mode(const void *arg)
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
static int unload_module(void)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk main include file. File version handling, generic pbx functions.
char * strsep(char **str, const char *delims)
static int say_date_with_format(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezonename)
static int do_say(say_args_t *a, const char *s, const char *options, int depth)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static int say_number_full(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd)
struct ast_var_t * ast_var_assign(const char *name, const char *value)
descriptor for a cli entry.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
Structure for variables, used for configurations and for channel variables.
static int say_datetime_from_now(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static struct ast_cli_entry cli_playback[]
void ast_cli(int fd, const char *fmt,...)
int ast_unregister_application(const char *app)
Unregister an application.
void ast_var_delete(struct ast_var_t *var)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
SAY_EXTERN int(* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime)
int args
This gets set in ast_cli_register()
static int say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd)
SAY_EXTERN int(* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date)
#define ast_debug(level,...)
Log a DEBUG message.
SAY_EXTERN int(* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full)
#define ast_config_load(filename, flags)
Load a config file.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static struct ast_config * say_cfg
static int say_full(struct ast_channel *chan, const char *string, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd)
static int s_streamwait3(const say_args_t *a, const char *fn)
static int say_datetime(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
Core PBX routines and definitions.
SAY_EXTERN int(* ast_say_phonetic_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_phonetic_str_full)
#define ast_strdupa(s)
duplicate a string in memory from the stack
SAY_EXTERN int(* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full)
enum ast_channel_state _state
const ast_string_field name
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
static const void * say_api_buf[40]
struct ast_var_t::@158 entries
SAY_EXTERN int(* ast_say_datetime_from_now)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime_from_now)
struct ast_channel * chan
static int say_time(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Structure used to handle boolean flags.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
static int say_date_generic(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezonename, const char *prefix)
static int say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
SAY_EXTERN int(* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full)
Standard Command Line Interface.
static int say_digit_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
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)
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
static int say_phonetic_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static const char *const say_new
SAY_EXTERN int(* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full)
static int load_module(void)
#define AST_APP_ARG(name)
Define an application argument.
struct ast_variable * next
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static char * __say_cli_init(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define CONFIG_STATUS_FILEINVALID
SAY_EXTERN int(* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time)
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
char * strcasestr(const char *, const char *)
static int playback_exec(struct ast_channel *chan, const char *data)
static snd_pcm_format_t format
static int say_init_mode(const char *mode)
static const char *const say_old
const ast_string_field language
static void restore_say_mode(void *arg)
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define CONFIG_STATUS_FILEUNCHANGED
static char prefix[MAX_PREFIX]