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

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 482 of file func_sayfiles.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 482 of file func_sayfiles.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 476 of file func_sayfiles.c.

477{
478 AST_TEST_REGISTER(test_SAYFILES_function);
480}
static struct ast_custom_function sayfiles
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
#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 98 of file func_sayfiles.c.

99{
100 char *value, *type, *files;
101 const char *lang;
102 struct ast_str *filenames = NULL;
106 );
107
108 if (ast_strlen_zero(data)) {
109 ast_log(LOG_WARNING, "SAYFILES requires an argument\n");
110 return 0;
111 }
112
114
115 value = args.value;
116 type = (ast_strlen_zero(args.type) ? "alpha" : args.type);
117 lang = (chan ? ast_channel_language(chan) : "en"); /* No chan for unit tests */
118
119 if (!strcmp(type, "alpha")) {
121 } else if (!strcmp(type, "phonetic")) {
122 filenames = ast_get_phonetic_str(value, lang);
123 } else if (!strcmp(type, "digits")) {
124 filenames = ast_get_digit_str(value, lang);
125 } else if (!strcmp(type, "number")) {
126 int num;
127 if (ast_str_to_int(value, &num)) {
128 ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value);
129 } else {
130 filenames = ast_get_number_str(num, lang);
131 }
132 } else if (!strcmp(type, "ordinal")) {
133 int num;
134 if (ast_str_to_int(value, &num)) {
135 ast_log(LOG_WARNING, "Invalid numeric argument: %s\n", value);
136 } else {
137 filenames = ast_get_ordinal_str(num, lang);
138 }
139 } else if (!strcmp(type, "money")) {
140 filenames = ast_get_money_str(value, lang);
141 } else {
142 ast_log(LOG_WARNING, "Invalid say type specified: %s\n", type);
143 }
144
145 if (!filenames) {
146 return -1;
147 }
148
149 files = ast_str_buffer(filenames);
150 snprintf(buf, len, "%s", files);
151 ast_free(filenames);
152
153 return 0;
154}
#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 470 of file func_sayfiles.c.

471{
472 AST_TEST_UNREGISTER(test_SAYFILES_function);
474}
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 482 of file func_sayfiles.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 482 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:98

Definition at line 156 of file func_sayfiles.c.

Referenced by load_module(), and unload_module().