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.Chappell@trincoll.edu>

Definition in file app_saycounted.c.


Function Documentation

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

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().

00193 {
00194    int res;
00195    res = ast_register_application_xml("SayCountedNoun", saycountednoun_exec);
00196    res |= ast_register_application_xml("SayCountedAdj", saycountedadj_exec);
00197    return res;
00198 }

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().

00155 {
00156    char *parse;
00157    int number;
00158    AST_DECLARE_APP_ARGS(args,
00159       AST_APP_ARG(number);
00160       AST_APP_ARG(adjective);
00161       AST_APP_ARG(gender);
00162    );
00163 
00164    if (ast_strlen_zero(data)) {
00165       ast_log(LOG_WARNING, "SayCountedAdj requires two or three arguments (<number>,<adjective>[,<gender>])\n");
00166       return -1;
00167    }
00168 
00169    parse = ast_strdupa(data);
00170    AST_STANDARD_APP_ARGS(args, parse);
00171 
00172    if (args.argc < 2) {
00173       ast_log(LOG_WARNING, "SayCountedAdj requires at least two arguments\n");
00174       return -1;
00175    }
00176 
00177    if (sscanf(args.number, "%d", &number) != 1) {
00178       ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
00179       return -1;
00180    }
00181 
00182    if (!ast_strlen_zero(args.gender)) {
00183       if (strchr("cCfFmMnN", args.gender[0])) {
00184          ast_log(LOG_WARNING, "SayCountedAdj gender option must be one of 'f', 'm', 'c', or 'n'.\n");
00185          return -1;
00186       }
00187    }
00188 
00189    return ast_say_counted_adjective(chan, number, args.adjective, args.gender);
00190 }

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().

00125 {
00126    char *parse;
00127    int number;
00128    AST_DECLARE_APP_ARGS(args,
00129       AST_APP_ARG(number);
00130       AST_APP_ARG(noun);
00131    );
00132 
00133    if (ast_strlen_zero(data)) {
00134       ast_log(LOG_WARNING, "SayCountedNoun requires two arguments (<number>,<noun>)\n");
00135       return -1;
00136    }
00137 
00138    parse = ast_strdupa(data);
00139    AST_STANDARD_APP_ARGS(args, parse);
00140 
00141    if (args.argc != 2) {
00142       ast_log(LOG_WARNING, "SayCountedNoun requires two arguments\n");
00143       return -1;
00144    }
00145 
00146    if (sscanf(args.number, "%d", &number) != 1) {
00147       ast_log(LOG_WARNING, "First argument must be a number between 0 and 2,147,483,647.\n");
00148       return -1;
00149    }
00150 
00151    return ast_say_counted_noun(chan, number, args.noun);
00152 }

static int unload_module ( void   )  [static]

Definition at line 200 of file app_saycounted.c.

References ast_unregister_application().

00201 {
00202    int res;
00203    res = ast_unregister_application("SayCountedNoun");
00204    res |= ast_unregister_application("SayCountedAdj");
00205    return res;
00206 }


Generated on Thu Apr 16 06:28:41 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6