Merged revisions 146799 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r146799 | tilghman | 2008-10-06 15:52:04 -0500 (Mon, 06 Oct 2008) | 8 lines
  
  Dialplan functions should not actually return 0, unless they have modified the
  workspace.  To signal an error (and no change to the workspace), -1 should be
  returned instead.
  (closes issue #13340)
   Reported by: kryptolus
   Patches: 
         20080827__bug13340__2.diff.txt uploaded by Corydon76 (license 14)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@146802 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-10-06 21:09:05 +00:00
parent 9b0a2e5231
commit 63b165dbb9
11 changed files with 51 additions and 13 deletions

View File

@@ -51,6 +51,7 @@ static int callerpres_write(struct ast_channel *chan, const char *cmd, char *dat
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
char *buf, size_t len)
{
int res = -1;
char *opt = data;
if (!chan)
@@ -64,10 +65,13 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
if (!strncasecmp("all", data, 3)) {
snprintf(buf, len, "\"%s\" <%s>", name, num);
res = 0;
} else if (!strncasecmp("name", data, 4)) {
ast_copy_string(buf, name, len);
res = 0;
} else if (!strncasecmp("num", data, 3)) {
ast_copy_string(buf, num, len);
res = 0;
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
@@ -78,32 +82,40 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
snprintf(buf, len, "\"%s\" <%s>",
S_OR(chan->cid.cid_name, ""),
S_OR(chan->cid.cid_num, ""));
res = 0;
} else if (!strncasecmp("name", data, 4)) {
if (chan->cid.cid_name) {
ast_copy_string(buf, chan->cid.cid_name, len);
res = 0;
}
} else if (!strncasecmp("num", data, 3)) {
if (chan->cid.cid_num) {
ast_copy_string(buf, chan->cid.cid_num, len);
res = 0;
}
} else if (!strncasecmp("ani", data, 3)) {
if (!strncasecmp(data + 3, "2", 1)) {
snprintf(buf, len, "%d", chan->cid.cid_ani2);
} else if (chan->cid.cid_ani) {
ast_copy_string(buf, chan->cid.cid_ani, len);
res = 0;
}
} else if (!strncasecmp("dnid", data, 4)) {
if (chan->cid.cid_dnid) {
ast_copy_string(buf, chan->cid.cid_dnid, len);
res = 0;
}
} else if (!strncasecmp("rdnis", data, 5)) {
if (chan->cid.cid_rdnis) {
ast_copy_string(buf, chan->cid.cid_rdnis, len);
res = 0;
}
} else if (!strncasecmp("pres", data, 4)) {
ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len);
res = 0;
} else if (!strncasecmp("ton", data, 3)) {
snprintf(buf, len, "%d", chan->cid.cid_ton);
res = 0;
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
@@ -111,7 +123,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
ast_channel_unlock(chan);
}
return 0;
return res;
}
static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,