Sat Sep 16 07:28:11 2006

Asterisk developer's documentation


app_senddtmf.c File Reference

App to send DTMF digits. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"

Go to the source code of this file.

Functions

char * description (void)
 Provides a description of the module.
char * key ()
 Returns the ASTERISK_GPL_KEY.
int load_module (void)
 Initialize the module.
static int senddtmf_exec (struct ast_channel *chan, void *data)
int unload_module (void)
 Cleanup all module structures, sockets, etc.
int usecount (void)
 Provides a usecount.

Variables

static char * app = "SendDTMF"
static char * descrip
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
static char * synopsis = "Sends arbitrary DTMF digits"
static char * tdesc = "Send DTMF digits Application"


Detailed Description

App to send DTMF digits.

Definition in file app_senddtmf.c.


Function Documentation

char* description ( void   ) 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 114 of file app_senddtmf.c.

00115 {
00116    return tdesc;
00117 }

char* key ( void   ) 

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

 char *key(void) {
         return ASTERISK_GPL_KEY;
 }

Returns:
ASTERISK_GPL_KEY

Definition at line 126 of file app_senddtmf.c.

References ASTERISK_GPL_KEY.

00127 {
00128    return ASTERISK_GPL_KEY;
00129 }

int load_module ( void   ) 

Initialize the module.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
int Always 0.

Definition at line 109 of file app_senddtmf.c.

References ast_register_application(), and senddtmf_exec().

00110 {
00111    return ast_register_application(app, senddtmf_exec, synopsis, descrip);
00112 }

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

Definition at line 61 of file app_senddtmf.c.

References ast_dtmf_stream(), ast_log(), ast_strdupa, ast_strlen_zero(), localuser::chan, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, and LOG_WARNING.

Referenced by load_module().

00062 {
00063    int res = 0;
00064    struct localuser *u;
00065    char *digits = NULL, *to = NULL;
00066    int timeout = 250;
00067 
00068    if (ast_strlen_zero(data)) {
00069       ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
00070       return 0;
00071    }
00072 
00073    LOCAL_USER_ADD(u);
00074 
00075    digits = ast_strdupa(data);
00076    if (!digits) {
00077       ast_log(LOG_ERROR, "Out of Memory!\n");
00078       LOCAL_USER_REMOVE(u);
00079       return -1;
00080    }
00081 
00082    if ((to = strchr(digits,'|'))) {
00083       *to = '\0';
00084       to++;
00085       timeout = atoi(to);
00086    }
00087       
00088    if(timeout <= 0)
00089       timeout = 250;
00090 
00091    res = ast_dtmf_stream(chan,NULL,digits,timeout);
00092       
00093    LOCAL_USER_REMOVE(u);
00094 
00095    return res;
00096 }

int unload_module ( void   ) 

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
Zero on success, or non-zero on error.

Definition at line 98 of file app_senddtmf.c.

References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.

00099 {
00100    int res;
00101 
00102    res = ast_unregister_application(app);
00103 
00104    STANDARD_HANGUP_LOCALUSERS;
00105 
00106    return res; 
00107 }

int usecount ( void   ) 

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
The module's usecount.

Definition at line 119 of file app_senddtmf.c.

References STANDARD_USECOUNT.

00120 {
00121    int res;
00122    STANDARD_USECOUNT(res);
00123    return res;
00124 }


Variable Documentation

char* app = "SendDTMF" [static]

Definition at line 47 of file app_senddtmf.c.

char* descrip [static]

Initial value:

 
" SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n"
" Accepted digits: 0-9, *#abcd, w (.5s pause)\n"
" The application will either pass the assigned digits or terminate if it\n"
" encounters an error.\n"

Definition at line 51 of file app_senddtmf.c.

LOCAL_USER_DECL

Definition at line 59 of file app_senddtmf.c.

STANDARD_LOCAL_USER

Definition at line 57 of file app_senddtmf.c.

char* synopsis = "Sends arbitrary DTMF digits" [static]

Definition at line 49 of file app_senddtmf.c.

char* tdesc = "Send DTMF digits Application" [static]

Definition at line 45 of file app_senddtmf.c.


Generated on Sat Sep 16 07:28:11 2006 for Asterisk - the Open Source PBX by  doxygen 1.4.7