Mon Sep 18 09:13:49 2006

Asterisk developer's documentation


app_setcidnum.c File Reference

App to set callerid number. 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/image.h"
#include "asterisk/callerid.h"
#include "asterisk/utils.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 setcallerid_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 = "SetCIDNum"
static char * descrip
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
static char * synopsis = "Set CallerID Number"
static char * tdesc = "Set CallerID Number"


Detailed Description

App to set callerid number.

Definition in file app_setcidnum.c.


Function Documentation

char* description ( void   ) 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 116 of file app_setcidnum.c.

00117 {
00118    return tdesc;
00119 }

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 128 of file app_setcidnum.c.

References ASTERISK_GPL_KEY.

00129 {
00130    return ASTERISK_GPL_KEY;
00131 }

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 111 of file app_setcidnum.c.

References ast_register_application(), and setcallerid_exec().

00112 {
00113    return ast_register_application(app, setcallerid_exec, synopsis, descrip);
00114 }

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

Definition at line 64 of file app_setcidnum.c.

References ast_log(), ast_set_callerid(), ast_strdupa, localuser::chan, LOCAL_USER_ADD, LOCAL_USER_REMOVE, and LOG_WARNING.

00065 {
00066    int res = 0;
00067    struct localuser *u;
00068    char *opt;
00069    int anitoo = 0;
00070    char *tmp = NULL;
00071    static int deprecation_warning = 0;
00072 
00073    LOCAL_USER_ADD(u);
00074    
00075    if (!deprecation_warning) {
00076       ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use Set(CALLERID(number)=value) instead.\n");
00077       deprecation_warning = 1;
00078    }
00079 
00080    if (data)
00081       tmp = ast_strdupa(data);
00082    else
00083       tmp = "";
00084    
00085    opt = strchr(tmp, '|');
00086    if (opt) {
00087       *opt = '\0';
00088       opt++;
00089       if (*opt == 'a')
00090          anitoo = 1;
00091    }
00092    
00093    ast_set_callerid(chan, tmp, NULL, anitoo ? tmp : NULL);
00094 
00095    LOCAL_USER_REMOVE(u);
00096    
00097    return res;
00098 }

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 100 of file app_setcidnum.c.

References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.

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

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 121 of file app_setcidnum.c.

References STANDARD_USECOUNT.

00122 {
00123    int res;
00124    STANDARD_USECOUNT(res);
00125    return res;
00126 }


Variable Documentation

char* app = "SetCIDNum" [static]

Definition at line 48 of file app_setcidnum.c.

char* descrip [static]

Definition at line 52 of file app_setcidnum.c.

LOCAL_USER_DECL

Definition at line 62 of file app_setcidnum.c.

STANDARD_LOCAL_USER

Definition at line 60 of file app_setcidnum.c.

char* synopsis = "Set CallerID Number" [static]

Definition at line 50 of file app_setcidnum.c.

char* tdesc = "Set CallerID Number" [static]

Definition at line 46 of file app_setcidnum.c.


Generated on Mon Sep 18 09:13:49 2006 for Asterisk - the Open Source PBX by  doxygen 1.4.7