Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
func_sayfiles.c File Reference

Returns files played by Say applications. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/say.h"
#include "asterisk/lock.h"
#include "asterisk/localtime.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/conversions.h"
Include dependency graph for func_sayfiles.c:

Go to the source code of this file.

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 sayfile_exec (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Say application files" , .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 const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function sayfiles
 

Detailed Description

Returns files played by Say applications.

Author
Naveen Albert aster.nosp@m.isk@.nosp@m.phrea.nosp@m.knet.nosp@m..org

Definition in file func_sayfiles.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 483 of file func_sayfiles.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 483 of file func_sayfiles.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 483 of file func_sayfiles.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 477 of file func_sayfiles.c.

478{
479 AST_TEST_REGISTER(test_SAYFILES_function);
481}
static struct ast_custom_function sayfiles
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
#define AST_TEST_REGISTER(cb)
Definition: test.h:127

References ast_custom_function_register, AST_TEST_REGISTER, and sayfiles.

◆ sayfile_exec()

static int sayfile_exec ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 99 of file func_sayfiles.c.

100{
101 char *value, *type, *files;
102 const char *lang;
103 struct ast_str *filenames = NULL;
107 );
108
109 if (ast_strlen_zero(data)) {
110 ast_log(LOG_WARNING, "SAYFILES requires an argument\n");
111 return 0;
112 }
113
115
116 value = args.value;
117 type = (ast_strlen_zero(args.type) ? "alpha" : args.type);
118 lang = (chan ? ast_channel_language(chan) : "en"); /* No chan for unit tests */
119
120 if (!strcmp(type, "alpha")) {
122 } else if (!strcmp(type, "phonetic")) {
123 filenames = ast_get_phonetic_str(value, lang);
124 } else if (!strcmp(type, "digits")) {
125 filenames = ast_get_digit_str(value, lang);
126 } else if (!strcmp(type, "number")) {
127 int num;
128 if (ast_str_to_int(value, &num)) {
129 ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value);
130 } else {
131 filenames = ast_get_number_str(num, lang);
132 }
133 } else if (!strcmp(type, "ordinal")) {
134 int num;
135 if (ast_str_to_int(value, &num)) {
136 ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value);
137 } else {
138 filenames = ast_get_ordinal_str(num, lang);
139 }
140 } else if (!strcmp(type, "money")) {
141 filenames = ast_get_money_str(value, lang);
142 } else {
143 ast_log(LOG_WARNING, "Invalid say type specified: %s\n", type);
144 }
145
146 if (!filenames) {
147 return -1;
148 }
149
150 files = ast_str_buffer(filenames);
151 snprintf(buf, len, "%s", files);
152 ast_free(filenames);
153
154 return 0;
155}
#define ast_free(a)
Definition: astmm.h:180
#define ast_log
Definition: astobj2.c:42
static const char type[]
Definition: chan_ooh323.c:109
const char * ast_channel_language(const struct ast_channel *chan)
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
Definition: conversions.c:44
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#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.
#define LOG_WARNING
#define NULL
Definition: resample.c:96
struct ast_str * ast_get_ordinal_str(int num, const char *lang)
Returns an ast_str of files for SayOrdinal playback.
Definition: say.c:686
struct ast_str * ast_get_character_str(const char *str, const char *lang, enum ast_say_case_sensitivity sensitivity)
Returns an ast_str of files for SayAlpha playback.
Definition: say.c:64
struct ast_str * ast_get_number_str(int num, const char *lang)
Returns an ast_str of files for SayNumber playback.
Definition: say.c:566
struct ast_str * ast_get_phonetic_str(const char *str, const char *lang)
Returns an ast_str of files for SayPhonetic playback.
Definition: say.c:216
struct ast_str * ast_get_money_str(const char *str, const char *lang)
Returns an ast_str of files for SayMoney playback.
Definition: say.c:449
@ AST_SAY_CASE_NONE
Definition: say.h:182
struct ast_str * ast_get_digit_str(const char *str, const char *lang)
Returns an ast_str of files for SayDigits playback.
Definition: say.c:300
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Support for dynamic strings.
Definition: strings.h:623
int value
Definition: syslog.c:37
const char * args

References args, AST_APP_ARG, ast_channel_language(), AST_DECLARE_APP_ARGS, ast_free, ast_get_character_str(), ast_get_digit_str(), ast_get_money_str(), ast_get_number_str(), ast_get_ordinal_str(), ast_get_phonetic_str(), ast_log, AST_SAY_CASE_NONE, AST_STANDARD_APP_ARGS, ast_str_buffer(), ast_str_to_int(), ast_strlen_zero(), buf, len(), LOG_WARNING, NULL, type, and value.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 471 of file func_sayfiles.c.

472{
473 AST_TEST_UNREGISTER(test_SAYFILES_function);
475}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

References ast_custom_function_unregister(), AST_TEST_UNREGISTER, and sayfiles.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Say application files" , .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 483 of file func_sayfiles.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 483 of file func_sayfiles.c.

◆ sayfiles

struct ast_custom_function sayfiles
static
Initial value:
= {
.name = "SAYFILES",
.read = sayfile_exec,
}
static int sayfile_exec(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_sayfiles.c:99

Definition at line 157 of file func_sayfiles.c.

Referenced by load_module(), and unload_module().