Mon Jul 14 17:25:06 2008

Asterisk developer's documentation


app_setcallerid.c File Reference

App to set callerid. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.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 dependency graph for app_setcallerid.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Set CallerID Application")
static int load_module (void)
static int setcallerid_exec (struct ast_channel *chan, void *data)
static int setcallerid_pres_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static char * app = "SetCallerID"
static char * app2 = "SetCallerPres"
static char * descrip
static char * descrip2
static char * synopsis = "Set CallerID"
static char * synopsis2 = "Set CallerID Presentation"


Detailed Description

App to set callerid.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_setcallerid.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Set CallerID Application"   
)

static int load_module ( void   )  [static]

Definition at line 152 of file app_setcallerid.c.

References ast_register_application(), setcallerid_exec(), and setcallerid_pres_exec().

00153 {
00154    int res;
00155    
00156    res = ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2);
00157    res |= ast_register_application(app, setcallerid_exec, synopsis, descrip);
00158 
00159    return res;
00160 }

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

Definition at line 99 of file app_setcallerid.c.

References ast_callerid_split(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_set_callerid(), ast_strdupa, ast_strlen_zero(), ast_module_user::chan, LOG_WARNING, and name.

Referenced by load_module().

00100 {
00101    int res = 0;
00102    char *tmp = NULL;
00103    char name[256];
00104    char num[256];
00105    struct ast_module_user *u;
00106    char *opt;
00107    int anitoo = 0;
00108    static int dep_warning = 0;
00109 
00110    if (ast_strlen_zero(data)) {
00111       ast_log(LOG_WARNING, "SetCallerID requires an argument!\n");
00112       return 0;
00113    }
00114    
00115    u = ast_module_user_add(chan);
00116 
00117    if (!dep_warning) {
00118       dep_warning = 1;
00119       ast_log(LOG_WARNING, "SetCallerID is deprecated.  Please use Set(CALLERID(all)=...) or Set(CALLERID(ani)=...) instead.\n");
00120    }
00121 
00122    tmp = ast_strdupa(data);
00123    
00124    opt = strchr(tmp, '|');
00125    if (opt) {
00126       *opt = '\0';
00127       opt++;
00128       if (*opt == 'a')
00129          anitoo = 1;
00130    }
00131    
00132    ast_callerid_split(tmp, name, sizeof(name), num, sizeof(num));
00133    ast_set_callerid(chan, num, name, anitoo ? num : NULL);
00134 
00135    ast_module_user_remove(u);
00136    
00137    return res;
00138 }

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

Definition at line 67 of file app_setcallerid.c.

References ast_log(), ast_module_user_add, ast_module_user_remove, ast_parse_caller_presentation(), ast_module_user::chan, ast_channel::cid, ast_callerid::cid_pres, and LOG_WARNING.

Referenced by load_module().

00068 {
00069    struct ast_module_user *u;
00070    int pres = -1;
00071 
00072    u = ast_module_user_add(chan);
00073 
00074    /* For interface consistency, permit the argument to be specified as a number */
00075    if (sscanf(data, "%d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
00076       pres = ast_parse_caller_presentation(data);
00077    }
00078 
00079    if (pres < 0) {
00080       ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
00081          (char *) data);
00082       ast_module_user_remove(u);
00083       return 0;
00084    }
00085    
00086    chan->cid.cid_pres = pres;
00087    ast_module_user_remove(u);
00088    return 0;
00089 }

static int unload_module ( void   )  [static]

Definition at line 140 of file app_setcallerid.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00141 {
00142    int res;
00143 
00144    res = ast_unregister_application(app2);
00145    res |= ast_unregister_application(app);
00146 
00147    ast_module_user_hangup_all();
00148 
00149    return res;
00150 }


Variable Documentation

char* app = "SetCallerID" [static]

Definition at line 91 of file app_setcallerid.c.

char* app2 = "SetCallerPres" [static]

Definition at line 46 of file app_setcallerid.c.

char* descrip [static]

Initial value:

 
"  SetCallerID(clid[|a]): Set Caller*ID on a call to a new\n"
"value.  Sets ANI as well if a flag is used. \n"

Definition at line 95 of file app_setcallerid.c.

char* descrip2 [static]

Definition at line 51 of file app_setcallerid.c.

char* synopsis = "Set CallerID" [static]

Definition at line 93 of file app_setcallerid.c.

char* synopsis2 = "Set CallerID Presentation" [static]

Definition at line 48 of file app_setcallerid.c.


Generated on Mon Jul 14 17:25:06 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1