#include <asterisk.h>#include <stdio.h>#include <asterisk/file.h>#include <asterisk/logger.h>#include <asterisk/channel.h>#include <asterisk/pbx.h>#include <asterisk/module.h>#include <asterisk/lock.h>#include <stdlib.h>#include <unistd.h>#include <string.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 | sayword_exec (struct ast_channel *chan, void *data) |
| static int | saywords (struct ast_channel *chan, char *word1, char *word2, char *word5, int num) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Say polish counting words" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app = "SayCountPL" |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static char * | descrip |
| static char * | synopsis = "Say the counting word the fits to a number" |
| static void __reg_module | ( | void | ) | [static] |
Definition at line 121 of file app_saycountpl.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 121 of file app_saycountpl.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 116 of file app_saycountpl.c.
References app, ast_register_application(), descrip, sayword_exec(), and synopsis.
00117 { 00118 return ast_register_application(app, sayword_exec, synopsis, descrip); 00119 }
| static int sayword_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 61 of file app_saycountpl.c.
References ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, LOG_WARNING, s, and saywords().
Referenced by load_module().
00062 { 00063 int res=0; 00064 00065 char *word1, *word2, *word5, *num; 00066 char *s; 00067 00068 int inum; 00069 00070 struct ast_module_user *u; 00071 00072 if (!data) { 00073 ast_log(LOG_WARNING, "You didn't pass any arguments - I need 4 arguments, word-1,word-2,word-5,number\n"); 00074 return -1; 00075 } 00076 u = ast_module_user_add(chan); 00077 /* Do our shit here */ 00078 00079 s = ast_strdupa((void *) data); 00080 00081 word1 = strsep(&s, "|"); 00082 word2 = strsep(&s, "|"); 00083 word5 = strsep(&s, "|"); 00084 num = strsep(&s, "|"); 00085 00086 /* check to see if params passed */ 00087 00088 if (!word1 || !word2 || !word5 || !num) { 00089 ast_log(LOG_WARNING, "Saycountpl requires the arguments word-1|word-2|word-3|number\n"); 00090 ast_module_user_remove(u); 00091 return -1; 00092 } 00093 00094 if (sscanf(num, "%d", &inum) != 1) { 00095 ast_log(LOG_WARNING, "'%s' is not a valid number\n", num); 00096 ast_module_user_remove(u); 00097 return -1; 00098 } 00099 00100 /* do the saying part (after a bit of maths) */ 00101 00102 res = saywords(chan,word1,word2,word5,inum); 00103 00104 00105 ast_module_user_remove(u); 00106 00107 return res; 00108 }
| static int saywords | ( | struct ast_channel * | chan, | |
| char * | word1, | |||
| char * | word2, | |||
| char * | word5, | |||
| int | num | |||
| ) | [static] |
Definition at line 31 of file app_saycountpl.c.
References ast_streamfile(), ast_waitstream(), and ast_channel::language.
Referenced by sayword_exec().
00032 { 00033 /* Put this in a separate proc because it's bound to change */ 00034 00035 int md; 00036 int d=0; 00037 00038 if (num >0) { 00039 md = num % 1000; 00040 if (md == 1) { 00041 ast_streamfile(chan, word1, chan->language); 00042 d = ast_waitstream(chan,""); 00043 } 00044 else { 00045 if (((md % 10) >= 2) && ( (md % 10) <= 4 ) && ( ( md % 100) < 10 || (md % 100) > 20)) { 00046 ast_streamfile(chan, word2, chan->language); 00047 d = ast_waitstream(chan,""); 00048 } 00049 else { 00050 ast_streamfile(chan, word5, chan->language); 00051 d = ast_waitstream(chan,""); 00052 } 00053 } 00054 } 00055 00056 return d; 00057 00058 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 110 of file app_saycountpl.c.
References app, ast_module_user_hangup_all, and ast_unregister_application().
00111 { 00112 ast_module_user_hangup_all(); 00113 return ast_unregister_application(app); 00114 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Say polish counting words" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 121 of file app_saycountpl.c.
char* app = "SayCountPL" [static] |
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 121 of file app_saycountpl.c.
char* descrip [static] |
Initial value:
"Polish grammar has some funny rules for counting words. for example 1 zloty, 2 zlote, 5 zlotych. This application will take the words for 1, 2-4 and 5 and\n" "decide based on grammar rules which one to use with the number you pass to it.\n\n" "Example: saycountpl(zloty,zlote,zlotych,122) will give: zlote\n"
Definition at line 26 of file app_saycountpl.c.
Referenced by load_module().
1.5.9