Asterisk - The Open Source Telephony Project GIT-master-2de1a68
Functions
app_saycounted.c File Reference

Applications to decline words according to current language. More...

#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/say.h"
Include dependency graph for app_saycounted.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Decline words according to channel language")
 
static int load_module (void)
 
static int saycountedadj_exec (struct ast_channel *chan, const char *data)
 
static int saycountednoun_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Detailed Description

Applications to decline words according to current language.

Author
David Chappell David.nosp@m..Cha.nosp@m.ppell.nosp@m.@tri.nosp@m.ncoll.nosp@m..edu

Definition in file app_saycounted.c.

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Decline words according to channel language  
)

◆ load_module()

static int load_module ( void  )
static

Definition at line 190 of file app_saycounted.c.

191{
192 int res;
193 res = ast_register_application_xml("SayCountedNoun", saycountednoun_exec);
194 res |= ast_register_application_xml("SayCountedAdj", saycountedadj_exec);
195 return res;
196}
static int saycountednoun_exec(struct ast_channel *chan, const char *data)
static int saycountedadj_exec(struct ast_channel *chan, const char *data)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References ast_register_application_xml, saycountedadj_exec(), and saycountednoun_exec().

◆ saycountedadj_exec()

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

Definition at line 152 of file app_saycounted.c.

153{
154 char *parse;
155 int number;
158 AST_APP_ARG(adjective);
159 AST_APP_ARG(gender);
160 );
161
162 if (ast_strlen_zero(data)) {
163 ast_log(LOG_WARNING, "SayCountedAdj requires two or three arguments (<number>,<adjective>[,<gender>])\n");
164 return -1;
165 }
166
167 parse = ast_strdupa(data);
169
170 if (args.argc < 2) {
171 ast_log(LOG_WARNING, "SayCountedAdj requires at least two arguments\n");
172 return -1;
173 }
174
175 if (sscanf(args.number, "%d", &number) != 1) {
176 ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
177 return -1;
178 }
179
180 if (!ast_strlen_zero(args.gender)) {
181 if (strchr("cCfFmMnN", args.gender[0])) {
182 ast_log(LOG_WARNING, "SayCountedAdj gender option must be one of 'f', 'm', 'c', or 'n'.\n");
183 return -1;
184 }
185 }
186
187 return ast_say_counted_adjective(chan, number, args.adjective, args.gender);
188}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
#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
int ast_say_counted_adjective(struct ast_channel *chan, int num, const char *adjective, const char *gender)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Number structure.
Definition: app_followme.c:154
const char * args

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, ast_say_counted_adjective(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), and LOG_WARNING.

Referenced by load_module().

◆ saycountednoun_exec()

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

Definition at line 122 of file app_saycounted.c.

123{
124 char *parse;
125 int number;
128 AST_APP_ARG(noun);
129 );
130
131 if (ast_strlen_zero(data)) {
132 ast_log(LOG_WARNING, "SayCountedNoun requires two arguments (<number>,<noun>)\n");
133 return -1;
134 }
135
136 parse = ast_strdupa(data);
138
139 if (args.argc != 2) {
140 ast_log(LOG_WARNING, "SayCountedNoun requires two arguments\n");
141 return -1;
142 }
143
144 if (sscanf(args.number, "%d", &number) != 1) {
145 ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
146 return -1;
147 }
148
149 return ast_say_counted_noun(chan, number, args.noun);
150}
int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun)

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, ast_say_counted_noun(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), and LOG_WARNING.

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 198 of file app_saycounted.c.

199{
200 int res;
201 res = ast_unregister_application("SayCountedNoun");
202 res |= ast_unregister_application("SayCountedAdj");
203 return res;
204}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References ast_unregister_application().