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 RDNIS Number";
00047
00048 static char *app = "SetRDNIS";
00049
00050 static char *synopsis = "Set RDNIS Number";
00051
00052 static char *descrip =
00053 " SetRDNIS(cnum): Set RDNIS Number on a call to a new\n"
00054 "value.\n"
00055 "SetRDNIS has been deprecated in favor of the function\n"
00056 "CALLERID(rdnis)\n";
00057
00058 STANDARD_LOCAL_USER;
00059
00060 LOCAL_USER_DECL;
00061
00062 static int setrdnis_exec(struct ast_channel *chan, void *data)
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 }
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, setrdnis_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 }