00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029 #include <string.h>
00030
00031 #include "asterisk.h"
00032
00033 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00034
00035 #include "asterisk/lock.h"
00036 #include "asterisk/file.h"
00037 #include "asterisk/logger.h"
00038 #include "asterisk/channel.h"
00039 #include "asterisk/pbx.h"
00040 #include "asterisk/module.h"
00041 #include "asterisk/translate.h"
00042 #include "asterisk/image.h"
00043 #include "asterisk/callerid.h"
00044 #include "asterisk/utils.h"
00045
00046 static char *tdesc = "Set CallerID Number";
00047
00048 static char *app = "SetCIDNum";
00049
00050 static char *synopsis = "Set CallerID Number";
00051
00052 static char *descrip =
00053 " SetCIDNum(cnum[|a]): Set Caller*ID Number on a call to a new\n"
00054 "value, while preserving the original Caller*ID name. This is\n"
00055 "useful for providing additional information to the called\n"
00056 "party. Sets ANI as well if a flag is used.\n"
00057 "SetCIDNum has been deprecated in favor of the function\n"
00058 "CALLERID(number)\n";
00059
00060 STANDARD_LOCAL_USER;
00061
00062 LOCAL_USER_DECL;
00063
00064 static int setcallerid_exec(struct ast_channel *chan, void *data)
00065 {
00066 int res = 0;
00067 struct localuser *u;
00068 char *opt;
00069 int anitoo = 0;
00070 char *tmp = NULL;
00071 static int deprecation_warning = 0;
00072
00073 LOCAL_USER_ADD(u);
00074
00075 if (!deprecation_warning) {
00076 ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use Set(CALLERID(number)=value) instead.\n");
00077 deprecation_warning = 1;
00078 }
00079
00080 if (data)
00081 tmp = ast_strdupa(data);
00082 else
00083 tmp = "";
00084
00085 opt = strchr(tmp, '|');
00086 if (opt) {
00087 *opt = '\0';
00088 opt++;
00089 if (*opt == 'a')
00090 anitoo = 1;
00091 }
00092
00093 ast_set_callerid(chan, tmp, NULL, anitoo ? tmp : NULL);
00094
00095 LOCAL_USER_REMOVE(u);
00096
00097 return res;
00098 }
00099
00100 int unload_module(void)
00101 {
00102 int res;
00103
00104 res = ast_unregister_application(app);
00105
00106 STANDARD_HANGUP_LOCALUSERS;
00107
00108 return res;
00109 }
00110
00111 int load_module(void)
00112 {
00113 return ast_register_application(app, setcallerid_exec, synopsis, descrip);
00114 }
00115
00116 char *description(void)
00117 {
00118 return tdesc;
00119 }
00120
00121 int usecount(void)
00122 {
00123 int res;
00124 STANDARD_USECOUNT(res);
00125 return res;
00126 }
00127
00128 char *key()
00129 {
00130 return ASTERISK_GPL_KEY;
00131 }