#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"
Include dependency graph for app_setrdnis.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 | 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" |
Definition in file app_setrdnis.c.
|
Provides a description of the module.
Definition at line 117 of file app_setrdnis.c. References tdesc. 00118 { 00119 return tdesc; 00120 }
|
|
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; }
Definition at line 129 of file app_setrdnis.c. References ASTERISK_GPL_KEY. 00130 { 00131 return ASTERISK_GPL_KEY; 00132 }
|
|
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.
Definition at line 112 of file app_setrdnis.c. References app, ast_register_application(), descrip, setrdnis_exec(), and synopsis. 00113 { 00114 return ast_register_application(app, setrdnis_exec, synopsis, descrip); 00115 }
|
|
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, 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 }
|
|
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).
Definition at line 101 of file app_setrdnis.c. References app, 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 }
|
|
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.
Definition at line 122 of file app_setrdnis.c. References STANDARD_USECOUNT. 00123 { 00124 int res; 00125 STANDARD_USECOUNT(res); 00126 return res; 00127 }
|
|
Definition at line 48 of file app_setrdnis.c. |
|
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. |
|
Definition at line 60 of file app_setrdnis.c. |
|
Definition at line 58 of file app_setrdnis.c. |
|
Definition at line 50 of file app_setrdnis.c. |
|
Definition at line 46 of file app_setrdnis.c. |