Index: pbx.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx.c,v retrieving revision 1.195 diff -u -r1.195 pbx.c --- pbx.c 9 Jan 2005 20:28:47 -0000 1.195 +++ pbx.c 10 Jan 2005 20:26:22 -0000 @@ -5068,6 +5068,105 @@ else headp = &globals; + /* Builtin variables should set the corresponding structure (or warn appropriately) */ + if (!strncmp(name, "CALL", 4)) { + if (!strncmp(name + 4, "ER", 2)) { + char name2[256], num[256]; + ast_callerid_split(value, name2, sizeof(name2), num, sizeof(num)); + if (!strncmp(name + 6, "ID", 2)) { + if (!strcmp(name + 8, "NUM")) { + ast_set_callerid(chan, num, NULL, NULL); + return; + } else if (!strcmp(name + 8, "NAME")) { + ast_set_callerid(chan, NULL, name2, NULL); + return; + } else if (!strcmp(name + 8, "")) { + ast_set_callerid(chan, num, name2, NULL); + return; + } + } else if (!strcmp(name + 6, "ANI")) { + ast_set_callerid(chan, NULL, NULL, num); + return; + } + } else if (!strncmp(name + 4, "ING", 3)) { + if (!strcmp(name + 7, "PRES")) { + int pres=0; + if (strncasecmp(value, "allowed", 7)) { + if (strcasecmp(value + 7, "_not_screened")) { + pres = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; + } else if (strcasecmp(value + 7, "_passed_screen")) { + pres = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN; + } else if (strcasecmp(value + 7, "_failed_screen")) { + pres = AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN; + } else { + ast_log(LOG_WARNING, "Unknown presentation setting: '%s'\n", value); + } + } else if (strncasecmp(value, "prohib", 6)) { + if (strcasecmp(value + 6, "_not_screened")) { + pres = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED; + } else if (strcasecmp(value + 6, "_passed_screen")) { + pres = AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN; + } else if (strcasecmp(value + 6, "_failed_screen")) { + pres = AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN; + } else { + ast_log(LOG_WARNING, "Unknown presentation setting: '%s'\n", value); + } + } else if (strcasecmp(value, "unavailable")) { + pres = AST_PRES_NUMBER_NOT_AVAILABLE; + } else { + ast_log(LOG_WARNING, "Unknown presentation setting: '%s'\n", value); + } + if (pres) { + chan->cid.cid_pres = pres; + } + return; + } else if (!strcmp(name + 7, "ANI2")) { + sscanf(value, "%d", &(chan->cid.cid_ani2)); + return; + } else if (!strcmp(name + 7, "TON")) { + sscanf(value, "%d", &(chan->cid.cid_ton)); + return; + } else if (!strcmp(name + 7, "TNS")) { + sscanf(value, "%d", &(chan->cid.cid_tns)); + return; + } + } + } else if (!strcmp(name, "DNID") || !strcmp(name, "RDNIS") || !strcmp(name, "HINT") || !strcmp(name, "CHANNEL") || !strcmp(name, "UNIQUEID")) { + ast_log(LOG_WARNING, "Cannot set readonly variable %s\n", name); + return; + } else if (!strcmp(name, "CONTEXT") || !strcmp(name, "EXTEN") || !strcmp(name, "PRIORITY")) { + ast_log(LOG_WARNING, "Cannot set readonly variable %s; use Goto() instead\n", name); + return; + } else if (!strcmp(name, "HANGUPCAUSE")) { + sscanf(value, "%d", &(chan->hangupcause)); + return; + } else if (!strcmp(name, "ACCOUNTCODE")) { + pbx_builtin_setaccount(chan, value); + return; + } else if (!strcmp(name, "LANGUAGE")) { + pbx_builtin_setlanguage(chan, value); + return; + } else if (!strcmp(name, "EPOCH") || !strcmp(name, "DATETIME") || !strcmp(name, "TIMESTAMP")) { + ast_log(LOG_WARNING, "Cannot set readonly variable %s\n", name); + return; + } else if (!strncasecmp(name, "LEN(", 4)) { + ast_log(LOG_WARNING, "Cannot set the length of this variable; set the underlying variable instead\n"); + return; + } else if (!strncasecmp(name, "ENV(", 4)) { + char *name2 = ast_strdupa(name + 4); + char *tmp; + if (name2) { + tmp = strrchr(name2, ')'); + if (tmp) { + *tmp = '\0'; + } + setenv(name2, value, 1); + } else { + ast_log(LOG_ERROR, "Out of memory\n"); + } + return; + } + AST_LIST_TRAVERSE (headp, newvariable, entries) { if (strcasecmp(ast_var_name(newvariable), name) == 0) { /* there is already such a variable, delete it */