Wed Jan 8 2020 09:49:55

Asterisk developer's documentation


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"

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
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)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Decline words according to channel language" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static struct ast_module_infoast_module_info = &__mod_info
 

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

static void __reg_module ( void  )
static

Definition at line 208 of file app_saycounted.c.

static void __unreg_module ( void  )
static

Definition at line 208 of file app_saycounted.c.

static int load_module ( void  )
static

Definition at line 192 of file app_saycounted.c.

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

193 {
194  int res;
195  res = ast_register_application_xml("SayCountedNoun", saycountednoun_exec);
196  res |= ast_register_application_xml("SayCountedAdj", saycountedadj_exec);
197  return res;
198 }
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:437
static int saycountednoun_exec(struct ast_channel *chan, const char *data)
static int saycountedadj_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 154 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().

155 {
156  char *parse;
157  int number;
159  AST_APP_ARG(number);
160  AST_APP_ARG(adjective);
161  AST_APP_ARG(gender);
162  );
163 
164  if (ast_strlen_zero(data)) {
165  ast_log(LOG_WARNING, "SayCountedAdj requires two or three arguments (<number>,<adjective>[,<gender>])\n");
166  return -1;
167  }
168 
169  parse = ast_strdupa(data);
170  AST_STANDARD_APP_ARGS(args, parse);
171 
172  if (args.argc < 2) {
173  ast_log(LOG_WARNING, "SayCountedAdj requires at least two arguments\n");
174  return -1;
175  }
176 
177  if (sscanf(args.number, "%d", &number) != 1) {
178  ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
179  return -1;
180  }
181 
182  if (!ast_strlen_zero(args.gender)) {
183  if (strchr("cCfFmMnN", args.gender[0])) {
184  ast_log(LOG_WARNING, "SayCountedAdj gender option must be one of 'f', 'm', 'c', or 'n'.\n");
185  return -1;
186  }
187  }
188 
189  return ast_say_counted_adjective(chan, number, args.adjective, args.gender);
190 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
Number structure.
Definition: app_followme.c:109
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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:1858
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int saycountednoun_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 124 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().

125 {
126  char *parse;
127  int number;
129  AST_APP_ARG(number);
130  AST_APP_ARG(noun);
131  );
132 
133  if (ast_strlen_zero(data)) {
134  ast_log(LOG_WARNING, "SayCountedNoun requires two arguments (<number>,<noun>)\n");
135  return -1;
136  }
137 
138  parse = ast_strdupa(data);
139  AST_STANDARD_APP_ARGS(args, parse);
140 
141  if (args.argc != 2) {
142  ast_log(LOG_WARNING, "SayCountedNoun requires two arguments\n");
143  return -1;
144  }
145 
146  if (sscanf(args.number, "%d", &number) != 1) {
147  ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
148  return -1;
149  }
150 
151  return ast_say_counted_noun(chan, number, args.noun);
152 }
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
Number structure.
Definition: app_followme.c:109
int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int unload_module ( void  )
static

Definition at line 200 of file app_saycounted.c.

References ast_unregister_application().

201 {
202  int res;
203  res = ast_unregister_application("SayCountedNoun");
204  res |= ast_unregister_application("SayCountedAdj");
205  return res;
206 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Decline words according to channel language" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 208 of file app_saycounted.c.

Definition at line 208 of file app_saycounted.c.