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