#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/indications.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 | morsecode_exec (struct ast_channel *chan, const char *data) |
static void | playtone (struct ast_channel *chan, int tone, int len) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Morse code" , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static const char | app_morsecode [] = "Morsecode" |
static struct ast_module_info * | ast_module_info = &__mod_info |
static const char *const | morsecode [] |
Definition in file app_morsecode.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 184 of file app_morsecode.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 184 of file app_morsecode.c.
static int load_module | ( | void | ) | [static] |
Definition at line 179 of file app_morsecode.c.
References ast_register_application_xml, and morsecode_exec().
00180 { 00181 return ast_register_application_xml(app_morsecode, morsecode_exec); 00182 }
static int morsecode_exec | ( | struct ast_channel * | chan, | |
const char * | data | |||
) | [static] |
Definition at line 121 of file app_morsecode.c.
References ast_channel_lock, ast_channel_unlock, ast_log(), ast_strlen_zero(), LOG_WARNING, pbx_builtin_getvar_helper(), and playtone().
Referenced by load_module().
00122 { 00123 int res=0, ditlen, tone; 00124 const char *digit; 00125 const char *ditlenc, *tonec; 00126 00127 if (ast_strlen_zero(data)) { 00128 ast_log(LOG_WARNING, "Syntax: Morsecode(<string>) - no argument found\n"); 00129 return 0; 00130 } 00131 00132 /* Use variable MORESEDITLEN, if set (else 80) */ 00133 ast_channel_lock(chan); 00134 ditlenc = pbx_builtin_getvar_helper(chan, "MORSEDITLEN"); 00135 if (ast_strlen_zero(ditlenc) || (sscanf(ditlenc, "%30d", &ditlen) != 1)) { 00136 ditlen = 80; 00137 } 00138 ast_channel_unlock(chan); 00139 00140 /* Use variable MORSETONE, if set (else 800) */ 00141 ast_channel_lock(chan); 00142 tonec = pbx_builtin_getvar_helper(chan, "MORSETONE"); 00143 if (ast_strlen_zero(tonec) || (sscanf(tonec, "%30d", &tone) != 1)) { 00144 tone = 800; 00145 } 00146 ast_channel_unlock(chan); 00147 00148 for (digit = data; *digit; digit++) { 00149 int digit2 = *digit; 00150 const char *dahdit; 00151 if (digit2 < 0) { 00152 continue; 00153 } 00154 for (dahdit = morsecode[digit2]; *dahdit; dahdit++) { 00155 if (*dahdit == '-') { 00156 playtone(chan, tone, 3 * ditlen); 00157 } else if (*dahdit == '.') { 00158 playtone(chan, tone, 1 * ditlen); 00159 } else { 00160 /* Account for ditlen of silence immediately following */ 00161 playtone(chan, 0, 2 * ditlen); 00162 } 00163 00164 /* Pause slightly between each dit and dah */ 00165 playtone(chan, 0, 1 * ditlen); 00166 } 00167 /* Pause between characters */ 00168 playtone(chan, 0, 2 * ditlen); 00169 } 00170 00171 return res; 00172 }
static void playtone | ( | struct ast_channel * | chan, | |
int | tone, | |||
int | len | |||
) | [static] |
Definition at line 112 of file app_morsecode.c.
References ast_playtones_start(), ast_playtones_stop(), and ast_safe_sleep().
Referenced by action_bridge(), and morsecode_exec().
00113 { 00114 char dtmf[20]; 00115 snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len); 00116 ast_playtones_start(chan, 0, dtmf, 0); 00117 ast_safe_sleep(chan, len); 00118 ast_playtones_stop(chan); 00119 }
static int unload_module | ( | void | ) | [static] |
Definition at line 174 of file app_morsecode.c.
References ast_unregister_application().
00175 { 00176 return ast_unregister_application(app_morsecode); 00177 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Morse code" , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 184 of file app_morsecode.c.
const char app_morsecode[] = "Morsecode" [static] |
Definition at line 66 of file app_morsecode.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 184 of file app_morsecode.c.
const char* const morsecode[] [static] |
Definition at line 68 of file app_morsecode.c.