Morsecode application. More...
#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, void *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_DEFAULT , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app_morsecode = "Morsecode" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static char * | morsecode [] |
Morsecode application.
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().
{
return ast_register_application_xml(app_morsecode, morsecode_exec);
}
| static int morsecode_exec | ( | struct ast_channel * | chan, |
| void * | 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().
{
int res=0, ditlen, tone;
char *digit;
const char *ditlenc, *tonec;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: Morsecode(<string>) - no argument found\n");
return 0;
}
/* Use variable MORESEDITLEN, if set (else 80) */
ast_channel_lock(chan);
ditlenc = pbx_builtin_getvar_helper(chan, "MORSEDITLEN");
if (ast_strlen_zero(ditlenc) || (sscanf(ditlenc, "%30d", &ditlen) != 1)) {
ditlen = 80;
}
ast_channel_unlock(chan);
/* Use variable MORSETONE, if set (else 800) */
ast_channel_lock(chan);
tonec = pbx_builtin_getvar_helper(chan, "MORSETONE");
if (ast_strlen_zero(tonec) || (sscanf(tonec, "%30d", &tone) != 1)) {
tone = 800;
}
ast_channel_unlock(chan);
for (digit = data; *digit; digit++) {
int digit2 = *digit;
char *dahdit;
if (digit2 < 0) {
continue;
}
for (dahdit = morsecode[digit2]; *dahdit; dahdit++) {
if (*dahdit == '-') {
playtone(chan, tone, 3 * ditlen);
} else if (*dahdit == '.') {
playtone(chan, tone, 1 * ditlen);
} else {
/* Account for ditlen of silence immediately following */
playtone(chan, 0, 2 * ditlen);
}
/* Pause slightly between each dit and dah */
playtone(chan, 0, 1 * ditlen);
}
/* Pause between characters */
playtone(chan, 0, 2 * ditlen);
}
return res;
}
| 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().
{
char dtmf[20];
snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len);
ast_playtones_start(chan, 0, dtmf, 0);
ast_safe_sleep(chan, len);
ast_playtones_stop(chan);
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 174 of file app_morsecode.c.
References ast_unregister_application().
{
return ast_unregister_application(app_morsecode);
}
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 184 of file app_morsecode.c.
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.
char* morsecode[] [static] |
Definition at line 68 of file app_morsecode.c.