Asterisk - The Open Source Telephony Project  18.5.0
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  
)

Referenced by unload_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 190 of file app_saycounted.c.

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

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 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
static int saycountednoun_exec(struct ast_channel *chan, const char *data)

◆ saycountedadj_exec()

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

Definition at line 152 of file app_saycounted.c.

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

Referenced by load_module().

153 {
154  char *parse;
155  int number;
157  AST_APP_ARG(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);
168  AST_STANDARD_APP_ARGS(args, parse);
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_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_say_counted_adjective(struct ast_channel *chan, int num, const char *adjective, const char *gender)
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ saycountednoun_exec()

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

Definition at line 122 of file app_saycounted.c.

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

Referenced by load_module().

123 {
124  char *parse;
125  int number;
127  AST_APP_ARG(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);
137  AST_STANDARD_APP_ARGS(args, parse);
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 }
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_log
Definition: astobj2.c:42
int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 198 of file app_saycounted.c.

References AST_MODULE_INFO_STANDARD_EXTENDED(), ast_unregister_application(), and ASTERISK_GPL_KEY.

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