Wed Aug 18 22:33:43 2010

Asterisk developer's documentation


app_setcallerid.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief App to set callerid presentation
00022  *
00023  * \author Mark Spencer <markster@digium.com>
00024  * 
00025  * \ingroup applications
00026  */
00027  
00028 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 211569 $")
00031 
00032 #include "asterisk/lock.h"
00033 #include "asterisk/file.h"
00034 #include "asterisk/channel.h"
00035 #include "asterisk/pbx.h"
00036 #include "asterisk/module.h"
00037 #include "asterisk/translate.h"
00038 #include "asterisk/image.h"
00039 #include "asterisk/callerid.h"
00040 
00041 static char *app2 = "SetCallerPres";
00042 
00043 static char *synopsis2 = "Set CallerID Presentation";
00044 
00045 
00046 static char *descrip2 = 
00047 "  SetCallerPres(presentation): Set Caller*ID presentation on a call.\n"
00048 "  Valid presentations are:\n"
00049 "\n"
00050 "      allowed_not_screened    : Presentation Allowed, Not Screened\n"
00051 "      allowed_passed_screen   : Presentation Allowed, Passed Screen\n" 
00052 "      allowed_failed_screen   : Presentation Allowed, Failed Screen\n" 
00053 "      allowed                 : Presentation Allowed, Network Number\n"
00054 "      prohib_not_screened     : Presentation Prohibited, Not Screened\n" 
00055 "      prohib_passed_screen    : Presentation Prohibited, Passed Screen\n"
00056 "      prohib_failed_screen    : Presentation Prohibited, Failed Screen\n"
00057 "      prohib                  : Presentation Prohibited, Network Number\n"
00058 "      unavailable             : Number Unavailable\n"
00059 "\n"
00060 ;
00061 
00062 static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
00063 {
00064    int pres = -1;
00065    static int deprecated = 0;
00066 
00067    if (!deprecated) {
00068       deprecated = 1;
00069       ast_log(LOG_WARNING, "SetCallerPres is deprecated.  Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
00070    }
00071 
00072    /* For interface consistency, permit the argument to be specified as a number */
00073    if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
00074       pres = ast_parse_caller_presentation(data);
00075    }
00076 
00077    if (pres < 0) {
00078       ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
00079          (char *) data);
00080       return 0;
00081    }
00082    
00083    chan->cid.cid_pres = pres;
00084    return 0;
00085 }
00086 
00087 static int unload_module(void)
00088 {
00089    return ast_unregister_application(app2);
00090 }
00091 
00092 static int load_module(void)
00093 {
00094    return ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2);
00095 }
00096 
00097 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");

Generated on Wed Aug 18 22:33:43 2010 for Asterisk - the Open Source PBX by  doxygen 1.4.7