Wed Oct 28 15:48:07 2009

Asterisk developer's documentation


app_lookupcidname.c File Reference

App to set callerid name from database, based on directory 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/options.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/astdb.h"

Include dependency graph for app_lookupcidname.c:

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 lookupcidname_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 = "LookupCIDName"
static char * descrip
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
static char * synopsis = "Look up CallerID Name from local database"
static char * tdesc = "Look up CallerID Name from local database"


Detailed Description

App to set callerid name from database, based on directory number.

Definition in file app_lookupcidname.c.


Function Documentation

char* description ( void   ) 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 103 of file app_lookupcidname.c.

00104 {
00105   return tdesc;
00106 }

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 117 of file app_lookupcidname.c.

References ASTERISK_GPL_KEY.

00118 {
00119   return ASTERISK_GPL_KEY;
00120 }

int load_module ( void   ) 

Initialize the module.

This function is called at module load time. Put all code in here that needs to set up your module's hardware, software, registrations, etc.

Returns:
This function should return 0 on success and non-zero on failure. If the module is not loaded successfully, Asterisk will call its unload_module() function.
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.
TE STUFF END

Definition at line 96 of file app_lookupcidname.c.

References ast_register_application(), and lookupcidname_exec().

00097 {
00098   return ast_register_application (app, lookupcidname_exec, synopsis,
00099                descrip);
00100 }

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

Definition at line 65 of file app_lookupcidname.c.

References ast_db_get(), ast_set_callerid(), ast_verbose(), ast_channel::cid, ast_callerid::cid_num, dbname, LOCAL_USER_ADD, LOCAL_USER_REMOVE, option_verbose, and VERBOSE_PREFIX_3.

Referenced by load_module().

00066 {
00067   char dbname[64];
00068   struct localuser *u;
00069 
00070   LOCAL_USER_ADD (u);
00071   if (chan->cid.cid_num) {
00072    if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
00073       ast_set_callerid (chan, NULL, dbname, NULL);
00074         if (option_verbose > 2)
00075           ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",
00076              dbname);
00077    }
00078   }
00079   LOCAL_USER_REMOVE (u);
00080   return 0;
00081 }

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 84 of file app_lookupcidname.c.

References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.

00085 {
00086    int res;
00087 
00088    res = ast_unregister_application (app);
00089 
00090    STANDARD_HANGUP_LOCALUSERS;
00091 
00092    return res;
00093 }

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 109 of file app_lookupcidname.c.

References STANDARD_USECOUNT.

00110 {
00111   int res;
00112   STANDARD_USECOUNT (res);
00113   return res;
00114 }


Variable Documentation

char* app = "LookupCIDName" [static]

Definition at line 48 of file app_lookupcidname.c.

char* descrip [static]

Definition at line 52 of file app_lookupcidname.c.

Definition at line 62 of file app_lookupcidname.c.

Definition at line 60 of file app_lookupcidname.c.

char* synopsis = "Look up CallerID Name from local database" [static]

Definition at line 50 of file app_lookupcidname.c.

char* tdesc = "Look up CallerID Name from local database" [static]

Definition at line 46 of file app_lookupcidname.c.


Generated on Wed Oct 28 15:48:07 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6