Sat Sep 16 07:28:11 2006

Asterisk developer's documentation


app_setrdnis.c File Reference

App to set rdnis. 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 setrdnis_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 = "SetRDNIS"
static char * descrip
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
static char * synopsis = "Set RDNIS Number"
static char * tdesc = "Set RDNIS Number"


Detailed Description

App to set rdnis.

Definition in file app_setrdnis.c.


Function Documentation

char* description ( void   ) 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 117 of file app_setrdnis.c.

00118 {
00119    return tdesc;
00120 }

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 129 of file app_setrdnis.c.

References ASTERISK_GPL_KEY.

00130 {
00131    return ASTERISK_GPL_KEY;
00132 }

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 112 of file app_setrdnis.c.

References ast_register_application(), and setrdnis_exec().

00113 {
00114    return ast_register_application(app, setrdnis_exec, synopsis, descrip);
00115 }

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

Definition at line 62 of file app_setrdnis.c.

References ast_callerid_parse(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_shrink_phone_number(), ast_strdupa, localuser::chan, ast_channel::cid, ast_callerid::cid_rdnis, free, LOCAL_USER_ADD, LOCAL_USER_REMOVE, ast_channel::lock, LOG_WARNING, n, and strdup.

Referenced by load_module().

00063 {
00064    struct localuser *u;
00065    char *opt, *n, *l;
00066    char *tmp = NULL;
00067    static int deprecation_warning = 0;
00068 
00069    LOCAL_USER_ADD(u);
00070    
00071    if (!deprecation_warning) {
00072       ast_log(LOG_WARNING, "SetRDNIS is deprecated, please use Set(CALLERID(rdnis)=value) instead.\n");
00073       deprecation_warning = 1;
00074    }
00075 
00076    if (data)
00077       tmp = ast_strdupa(data);
00078    else
00079       tmp = "";   
00080 
00081    opt = strchr(tmp, '|');
00082    if (opt)
00083       *opt = '\0';
00084    
00085    n = l = NULL;
00086    ast_callerid_parse(tmp, &n, &l);
00087    if (l) {
00088       ast_shrink_phone_number(l);
00089       ast_mutex_lock(&chan->lock);
00090       if (chan->cid.cid_rdnis)
00091          free(chan->cid.cid_rdnis);
00092       chan->cid.cid_rdnis = (l[0]) ? strdup(l) : NULL;
00093       ast_mutex_unlock(&chan->lock);
00094    }
00095 
00096    LOCAL_USER_REMOVE(u);
00097    
00098    return 0;
00099 }

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 101 of file app_setrdnis.c.

References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.

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

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 122 of file app_setrdnis.c.

References STANDARD_USECOUNT.

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


Variable Documentation

char* app = "SetRDNIS" [static]

Definition at line 48 of file app_setrdnis.c.

char* descrip [static]

Initial value:

 
"  SetRDNIS(cnum): Set RDNIS Number on a call to a new\n"
"value.\n"
"SetRDNIS has been deprecated in favor of the function\n"
"CALLERID(rdnis)\n"

Definition at line 52 of file app_setrdnis.c.

LOCAL_USER_DECL

Definition at line 60 of file app_setrdnis.c.

STANDARD_LOCAL_USER

Definition at line 58 of file app_setrdnis.c.

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

Definition at line 50 of file app_setrdnis.c.

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

Definition at line 46 of file app_setrdnis.c.


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