Version 0.2.0 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2002-07-26 11:06:49 +00:00
parent c89f206a7a
commit 39055ab5d7

View File

@@ -64,7 +64,13 @@ static char *descrip =
"The file that contains the passcodes (if used) allows specification\n" "The file that contains the passcodes (if used) allows specification\n"
"of either just a passcode (defaulting to the \"disa\" context, or\n" "of either just a passcode (defaulting to the \"disa\" context, or\n"
"passcode|context on each line of the file. The file may contain blank\n" "passcode|context on each line of the file. The file may contain blank\n"
"lines, or comments starting with \"#\" or \";\".\n\n" "lines, or comments starting with \"#\" or \";\". In addition, the\n"
"above arguments may have |new-callerid-string appended to them, to\n"
"specify a new (different) callerid to be used for this call, for\n"
"example: numeric-passcode|context|\"My Phone\" <(234) 123-4567> or \n"
"full-pathname-of-passcode-file|\"My Phone\" <(234) 123-4567>. Note that\n"
"in the case of specifying the numeric-passcode, the context must be\n"
"specified if the callerid is specified also.\n\n"
"If login is successful, the application parses the dialed number in\n" "If login is successful, the application parses the dialed number in\n"
"the specified (or default) context, and returns 0 with the new extension\n" "the specified (or default) context, and returns 0 with the new extension\n"
"context filled-in and the priority set to 1, so that the PBX may\n" "context filled-in and the priority set to 1, so that the PBX may\n"
@@ -109,9 +115,9 @@ static int disa_exec(struct ast_channel *chan, void *data)
{ {
int i,j,k,x; int i,j,k,x;
struct localuser *u; struct localuser *u;
char tmp[256],exten[AST_MAX_EXTENSION],acctcode[20]; char tmp[256],arg2[256],exten[AST_MAX_EXTENSION],acctcode[20];
unsigned char tone_block[640],sil_block[640]; unsigned char tone_block[640],sil_block[640];
char *ourcontext; char *ourcontext,*ourcallerid;
struct ast_frame *f,wf; struct ast_frame *f,wf;
struct timeval lastout, now, lastdigittime; struct timeval lastout, now, lastdigittime;
int res; int res;
@@ -137,10 +143,19 @@ static int disa_exec(struct ast_channel *chan, void *data)
strncpy(tmp, (char *)data, sizeof(tmp)-1); strncpy(tmp, (char *)data, sizeof(tmp)-1);
strtok(tmp, "|"); strtok(tmp, "|");
ourcontext = strtok(NULL, "|"); ourcontext = strtok(NULL, "|");
/* if context specified, save 2nd arg and parse third */
if (ourcontext) {
strcpy(arg2,ourcontext);
ourcallerid = strtok(NULL,"|");
}
/* if context not specified, use "disa" */ /* if context not specified, use "disa" */
if (!ourcontext) ourcontext = "disa"; else {
arg2[0] = 0;
ourcallerid = NULL;
ourcontext = "disa";
}
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
if (chan->state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
{ {
/* answer */ /* answer */
ast_answer(chan); ast_answer(chan);
@@ -243,6 +258,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
if (tmp[0] == '#') continue; if (tmp[0] == '#') continue;
if (tmp[0] == ';') continue; if (tmp[0] == ';') continue;
strtok(tmp, "|"); strtok(tmp, "|");
/* save 2nd arg as clid */
ourcallerid = arg2;
ourcontext = strtok(NULL, "|"); ourcontext = strtok(NULL, "|");
/* password must be in valid format (numeric) */ /* password must be in valid format (numeric) */
if (sscanf(tmp,"%d",&j) < 1) continue; if (sscanf(tmp,"%d",&j) < 1) continue;
@@ -275,6 +292,11 @@ static int disa_exec(struct ast_channel *chan, void *data)
/* if this exists */ /* if this exists */
if (ast_exists_extension(chan,ourcontext,exten,1, chan->callerid)) if (ast_exists_extension(chan,ourcontext,exten,1, chan->callerid))
{ {
if (ourcallerid && *ourcallerid)
{
if (chan->callerid) free(chan->callerid);
chan->callerid = strdup(ourcallerid);
}
strcpy(chan->exten,exten); strcpy(chan->exten,exten);
strcpy(chan->context,ourcontext); strcpy(chan->context,ourcontext);
strcpy(chan->accountcode,acctcode); strcpy(chan->accountcode,acctcode);