Thu Jul 9 13:40:46 2009

Asterisk developer's documentation


app_morsecode.c File Reference

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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, }
static char * app_morsecode = "Morsecode"
static const struct ast_module_infoast_module_info = &__mod_info
static char * morsecode []
static char * morsecode_descrip
static char * morsecode_synopsis = "Plays morse code"


Detailed Description

Morsecode application.

Author:
Tilghman Lesher <app_morsecode__v001@the-tilghman.com>

Definition in file app_morsecode.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 161 of file app_morsecode.c.

static void __unreg_module ( void   )  [static]

Definition at line 161 of file app_morsecode.c.

static int load_module ( void   )  [static]

Definition at line 156 of file app_morsecode.c.

References ast_register_application, and morsecode_exec().

static int morsecode_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 102 of file app_morsecode.c.

References ast_log(), ast_strlen_zero(), chan, LOG_WARNING, pbx_builtin_getvar_helper(), and playtone().

Referenced by load_module().

00103 {
00104    int res=0, ditlen, tone;
00105    char *digit;
00106    const char *ditlenc, *tonec;
00107 
00108    if (ast_strlen_zero(data)) {
00109       ast_log(LOG_WARNING, "Syntax: Morsecode(<string>) - no argument found\n");
00110       return 0;
00111    }
00112 
00113    /* Use variable MORESEDITLEN, if set (else 80) */
00114    ditlenc = pbx_builtin_getvar_helper(chan, "MORSEDITLEN");
00115    if (ast_strlen_zero(ditlenc) || (sscanf(ditlenc, "%d", &ditlen) != 1)) {
00116       ditlen = 80;
00117    }
00118 
00119    /* Use variable MORSETONE, if set (else 800) */
00120    tonec = pbx_builtin_getvar_helper(chan, "MORSETONE");
00121    if (ast_strlen_zero(tonec) || (sscanf(tonec, "%d", &tone) != 1)) {
00122       tone = 800;
00123    }
00124 
00125    for (digit = data; *digit; digit++) {
00126       int digit2 = *digit;
00127       char *dahdit;
00128       if (digit2 < 0) {
00129          continue;
00130       }
00131       for (dahdit = morsecode[digit2]; *dahdit; dahdit++) {
00132          if (*dahdit == '-') {
00133             playtone(chan, tone, 3 * ditlen);
00134          } else if (*dahdit == '.') {
00135             playtone(chan, tone, 1 * ditlen);
00136          } else {
00137             /* Account for ditlen of silence immediately following */
00138             playtone(chan, 0, 2 * ditlen);
00139          }
00140 
00141          /* Pause slightly between each dit and dah */
00142          playtone(chan, 0, 1 * ditlen);
00143       }
00144       /* Pause between characters */
00145       playtone(chan, 0, 2 * ditlen);
00146    }
00147 
00148    return res;
00149 }

static void playtone ( struct ast_channel chan,
int  tone,
int  len 
) [static]

Definition at line 93 of file app_morsecode.c.

References ast_playtones_start(), ast_playtones_stop(), ast_safe_sleep(), and chan.

Referenced by action_bridge(), and morsecode_exec().

00094 {
00095    char dtmf[20];
00096    snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len);
00097    ast_playtones_start(chan, 0, dtmf, 0);
00098    ast_safe_sleep(chan, len);
00099    ast_playtones_stop(chan);
00100 }

static int unload_module ( void   )  [static]

Definition at line 151 of file app_morsecode.c.

References ast_unregister_application().

00152 {
00153    return ast_unregister_application(app_morsecode);
00154 }


Variable Documentation

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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static]

Definition at line 161 of file app_morsecode.c.

char* app_morsecode = "Morsecode" [static]

Definition at line 37 of file app_morsecode.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 161 of file app_morsecode.c.

char* morsecode[] [static]

Definition at line 49 of file app_morsecode.c.

char* morsecode_descrip [static]

Definition at line 41 of file app_morsecode.c.

char* morsecode_synopsis = "Plays morse code" [static]

Definition at line 39 of file app_morsecode.c.


Generated on Thu Jul 9 13:40:46 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7