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

197{
198 int res;
199 res = ast_register_application_xml("SayCountedNoun", saycountednoun_exec);
200 res |= ast_register_application_xml("SayCountedAdj", saycountedadj_exec);
201 return res;
202}
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:640

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 158 of file app_saycounted.c.

159{
160 char *parse;
161 int number;
164 AST_APP_ARG(adjective);
165 AST_APP_ARG(gender);
166 );
167
168 if (ast_strlen_zero(data)) {
169 ast_log(LOG_WARNING, "SayCountedAdj requires two or three arguments (<number>,<adjective>[,<gender>])\n");
170 return -1;
171 }
172
173 parse = ast_strdupa(data);
175
176 if (args.argc < 2) {
177 ast_log(LOG_WARNING, "SayCountedAdj requires at least two arguments\n");
178 return -1;
179 }
180
181 if (sscanf(args.number, "%d", &number) != 1) {
182 ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
183 return -1;
184 }
185
186 if (!ast_strlen_zero(args.gender)) {
187 if (strchr("cCfFmMnN", args.gender[0])) {
188 ast_log(LOG_WARNING, "SayCountedAdj gender option must be one of 'f', 'm', 'c', or 'n'.\n");
189 return -1;
190 }
191 }
192
193 return ast_say_counted_adjective(chan, number, args.adjective, args.gender);
194}
#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:157
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 128 of file app_saycounted.c.

129{
130 char *parse;
131 int number;
134 AST_APP_ARG(noun);
135 );
136
137 if (ast_strlen_zero(data)) {
138 ast_log(LOG_WARNING, "SayCountedNoun requires two arguments (<number>,<noun>)\n");
139 return -1;
140 }
141
142 parse = ast_strdupa(data);
144
145 if (args.argc != 2) {
146 ast_log(LOG_WARNING, "SayCountedNoun requires two arguments\n");
147 return -1;
148 }
149
150 if (sscanf(args.number, "%d", &number) != 1) {
151 ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
152 return -1;
153 }
154
155 return ast_say_counted_noun(chan, number, args.noun);
156}
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 204 of file app_saycounted.c.

205{
206 int res;
207 res = ast_unregister_application("SayCountedNoun");
208 res |= ast_unregister_application("SayCountedAdj");
209 return res;
210}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References ast_unregister_application().