More RSW merges. Everything from apps/ except for the big offenders

app_voicemail and app_queue.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@137055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Sean Bright 17 years ago
parent 357bf3e90b
commit 3ffb39833b

@ -776,7 +776,7 @@ static int digitcollect(char *buf, char *name, int id, char *args, struct adsi_s
static int subscript(char *buf, char *name, int id, char *args, struct adsi_script *state, char *script, int lineno) static int subscript(char *buf, char *name, int id, char *args, struct adsi_script *state, char *script, int lineno)
{ {
char *tok = get_token(&args, script, lineno); char *tok = get_token(&args, script, lineno);
char subscript[80]; char subscr[80];
struct adsi_subscript *sub; struct adsi_subscript *sub;
if (!tok) { if (!tok) {
@ -784,12 +784,12 @@ static int subscript(char *buf, char *name, int id, char *args, struct adsi_scri
return 0; return 0;
} }
if (process_token(subscript, tok, sizeof(subscript) - 1, ARG_STRING)) { if (process_token(subscr, tok, sizeof(subscr) - 1, ARG_STRING)) {
ast_log(LOG_WARNING, "Invalid number of seconds '%s' at line %d of %s\n", tok, lineno, script); ast_log(LOG_WARNING, "Invalid number of seconds '%s' at line %d of %s\n", tok, lineno, script);
return 0; return 0;
} }
if (!(sub = getsubbyname(state, subscript, script, lineno))) if (!(sub = getsubbyname(state, subscr, script, lineno)))
return 0; return 0;
buf[0] = 0x9d; buf[0] = 0x9d;
@ -801,7 +801,7 @@ static int subscript(char *buf, char *name, int id, char *args, struct adsi_scri
static int onevent(char *buf, char *name, int id, char *args, struct adsi_script *state, char *script, int lineno) static int onevent(char *buf, char *name, int id, char *args, struct adsi_script *state, char *script, int lineno)
{ {
char *tok = get_token(&args, script, lineno); char *tok = get_token(&args, script, lineno);
char subscript[80], sname[80]; char subscr[80], sname[80];
int sawin = 0, event, snums[8], scnt = 0, x; int sawin = 0, event, snums[8], scnt = 0, x;
struct adsi_subscript *sub; struct adsi_subscript *sub;
@ -848,11 +848,11 @@ static int onevent(char *buf, char *name, int id, char *args, struct adsi_script
ast_log(LOG_WARNING, "Missing subscript to call at line %d of %s\n", lineno, script); ast_log(LOG_WARNING, "Missing subscript to call at line %d of %s\n", lineno, script);
return 0; return 0;
} }
if (process_token(subscript, tok, sizeof(subscript) - 1, ARG_STRING)) { if (process_token(subscr, tok, sizeof(subscr) - 1, ARG_STRING)) {
ast_log(LOG_WARNING, "Invalid subscript '%s' at line %d of %s\n", tok, lineno, script); ast_log(LOG_WARNING, "Invalid subscript '%s' at line %d of %s\n", tok, lineno, script);
return 0; return 0;
} }
if (!(sub = getsubbyname(state, subscript, script, lineno))) if (!(sub = getsubbyname(state, subscr, script, lineno)))
return 0; return 0;
buf[0] = 8; buf[0] = 8;
buf[1] = event; buf[1] = event;

@ -251,11 +251,11 @@ outrun:
static int conf_exec(struct ast_channel *chan, void *data) static int conf_exec(struct ast_channel *chan, void *data)
{ {
int res=-1; int res = -1;
int retrycnt = 0; int retrycnt = 0;
int confflags = 0; int confflags = 0;
int confno = 0; int confno = 0;
char confstr[80] = ""; char confnostr[80] = "";
if (!ast_strlen_zero(data)) { if (!ast_strlen_zero(data)) {
if ((sscanf(data, "DAHDI/%d", &confno) != 1) && if ((sscanf(data, "DAHDI/%d", &confno) != 1) &&
@ -270,10 +270,10 @@ static int conf_exec(struct ast_channel *chan, void *data)
while(!confno && (++retrycnt < 4)) { while(!confno && (++retrycnt < 4)) {
/* Prompt user for conference number */ /* Prompt user for conference number */
confstr[0] = '\0'; confnostr[0] = '\0';
res = ast_app_getdata(chan, "conf-getchannel",confstr, sizeof(confstr) - 1, 0); res = ast_app_getdata(chan, "conf-getchannel",confnostr, sizeof(confnostr) - 1, 0);
if (res <0) goto out; if (res <0) goto out;
if (sscanf(confstr, "%d", &confno) != 1) if (sscanf(confnostr, "%d", &confno) != 1)
confno = 0; confno = 0;
} }
if (confno) { if (confno) {

@ -284,7 +284,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
int res=-1; int res=-1;
int confflags = 0; int confflags = 0;
int confno = 0; int confno = 0;
char confstr[80] = "", *tmp = NULL; char confnostr[80] = "", *tmp = NULL;
struct ast_channel *tempchan = NULL, *lastchan = NULL, *ichan = NULL; struct ast_channel *tempchan = NULL, *lastchan = NULL, *ichan = NULL;
struct ast_frame *f; struct ast_frame *f;
char *desired_group; char *desired_group;
@ -335,12 +335,12 @@ static int conf_exec(struct ast_channel *chan, void *data)
} }
if (tempchan && (!strcmp(tempchan->tech->type, "DAHDI")) && (tempchan != chan)) { if (tempchan && (!strcmp(tempchan->tech->type, "DAHDI")) && (tempchan != chan)) {
ast_verb(3, "DAHDI channel %s is in-use, monitoring...\n", tempchan->name); ast_verb(3, "DAHDI channel %s is in-use, monitoring...\n", tempchan->name);
ast_copy_string(confstr, tempchan->name, sizeof(confstr)); ast_copy_string(confnostr, tempchan->name, sizeof(confnostr));
ast_channel_unlock(tempchan); ast_channel_unlock(tempchan);
if ((tmp = strchr(confstr, '-'))) { if ((tmp = strchr(confnostr, '-'))) {
*tmp = '\0'; *tmp = '\0';
} }
confno = atoi(strchr(confstr, '/') + 1); confno = atoi(strchr(confnostr, '/') + 1);
ast_stopstream(chan); ast_stopstream(chan);
ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language, (char *) NULL); ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language, (char *) NULL);
res = conf_run(chan, confno, confflags); res = conf_run(chan, confno, confflags);

@ -2018,7 +2018,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
{ {
char *parse; char *parse;
const char *context = NULL; const char *context = NULL;
int sleep = 0, loops = 0, res = -1; int sleepms = 0, loops = 0, res = -1;
struct ast_flags64 peerflags = { 0, }; struct ast_flags64 peerflags = { 0, };
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(announce); AST_APP_ARG(announce);
@ -2035,8 +2035,8 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
parse = ast_strdupa(data); parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse); AST_STANDARD_APP_ARGS(args, parse);
if ((sleep = atoi(args.sleep))) if ((sleepms = atoi(args.sleep)))
sleep *= 1000; sleepms *= 1000;
loops = atoi(args.retries); loops = atoi(args.retries);
@ -2045,8 +2045,8 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
goto done; goto done;
} }
if (sleep < 1000) if (sleepms < 1000)
sleep = 10000; sleepms = 10000;
if (!loops) if (!loops)
loops = -1; /* run forever */ loops = -1; /* run forever */
@ -2077,10 +2077,10 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
} else } else
ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
} }
if (!res && sleep) { if (!res && sleepms) {
if (!ast_test_flag(chan, AST_FLAG_MOH)) if (!ast_test_flag(chan, AST_FLAG_MOH))
ast_moh_start(chan, NULL, NULL); ast_moh_start(chan, NULL, NULL);
res = ast_waitfordigit(chan, sleep); res = ast_waitfordigit(chan, sleepms);
} }
} else { } else {
if (!ast_strlen_zero(args.announce)) { if (!ast_strlen_zero(args.announce)) {
@ -2090,11 +2090,11 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
} else } else
ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
} }
if (sleep) { if (sleepms) {
if (!ast_test_flag(chan, AST_FLAG_MOH)) if (!ast_test_flag(chan, AST_FLAG_MOH))
ast_moh_start(chan, NULL, NULL); ast_moh_start(chan, NULL, NULL);
if (!res) if (!res)
res = ast_waitfordigit(chan, sleep); res = ast_waitfordigit(chan, sleepms);
} }
} }
} }

@ -484,23 +484,23 @@ static int search_directory(const char *context, struct ast_config *vmcfg, struc
if (ucfg) { if (ucfg) {
for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) { for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
const char *pos; const char *position;
if (!strcasecmp(cat, "general")) if (!strcasecmp(cat, "general"))
continue; continue;
if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory"))) if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory")))
continue; continue;
/* Find all candidate extensions */ /* Find all candidate extensions */
pos = ast_variable_retrieve(ucfg, cat, "fullname"); position = ast_variable_retrieve(ucfg, cat, "fullname");
if (!pos) if (!position)
continue; continue;
res = 0; res = 0;
if (ast_test_flag(&flags, OPT_LISTBYLASTNAME)) { if (ast_test_flag(&flags, OPT_LISTBYLASTNAME)) {
res = check_match(&item, pos, cat, ext, 0 /* use_first_name */); res = check_match(&item, position, cat, ext, 0 /* use_first_name */);
} }
if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) { if (!res && ast_test_flag(&flags, OPT_LISTBYFIRSTNAME)) {
res = check_match(&item, pos, cat, ext, 1 /* use_first_name */); res = check_match(&item, position, cat, ext, 1 /* use_first_name */);
} }
if (!res) if (!res)

@ -318,7 +318,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
if (k == 3) { if (k == 3) {
int recheck = 0; int recheck = 0;
struct ast_flags flags = { AST_CDR_FLAG_POSTED }; struct ast_flags cdr_flags = { AST_CDR_FLAG_POSTED };
if (!ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) { if (!ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten); pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten);
@ -337,8 +337,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
if (!ast_strlen_zero(acctcode)) if (!ast_strlen_zero(acctcode))
ast_string_field_set(chan, accountcode, acctcode); ast_string_field_set(chan, accountcode, acctcode);
if (special_noanswer) flags.flags = 0; if (special_noanswer) cdr_flags.flags = 0;
ast_cdr_reset(chan->cdr, &flags); ast_cdr_reset(chan->cdr, &cdr_flags);
ast_explicit_goto(chan, args.context, exten, 1); ast_explicit_goto(chan, args.context, exten, 1);
return 0; return 0;
} }

@ -330,22 +330,22 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd); snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd);
festivalcommand = newfestivalcommand; festivalcommand = newfestivalcommand;
} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */ } else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
int i, j; int x, j;
newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1); newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1);
for (i = 0, j = 0; i < strlen(festivalcommand); i++) { for (x = 0, j = 0; x < strlen(festivalcommand); x++) {
if (festivalcommand[i] == '\\' && festivalcommand[i + 1] == 'n') { if (festivalcommand[x] == '\\' && festivalcommand[x + 1] == 'n') {
newfestivalcommand[j++] = '\n'; newfestivalcommand[j++] = '\n';
i++; x++;
} else if (festivalcommand[i] == '\\') { } else if (festivalcommand[x] == '\\') {
newfestivalcommand[j++] = festivalcommand[i + 1]; newfestivalcommand[j++] = festivalcommand[x + 1];
i++; x++;
} else if (festivalcommand[i] == '%' && festivalcommand[i + 1] == 's') { } else if (festivalcommand[x] == '%' && festivalcommand[x + 1] == 's') {
sprintf(&newfestivalcommand[j], "%s", args.text); /* we know it is big enough */ sprintf(&newfestivalcommand[j], "%s", args.text); /* we know it is big enough */
j += strlen(args.text); j += strlen(args.text);
i++; x++;
} else } else
newfestivalcommand[j++] = festivalcommand[i]; newfestivalcommand[j++] = festivalcommand[x];
} }
newfestivalcommand[j] = '\0'; newfestivalcommand[j] = '\0';
festivalcommand = newfestivalcommand; festivalcommand = newfestivalcommand;

@ -230,8 +230,10 @@ static int forkcdr_exec(struct ast_channel *chan, void *data)
if (!ast_strlen_zero(arglist.options)) if (!ast_strlen_zero(arglist.options))
ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options); ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options);
if (!ast_strlen_zero(data)) if (!ast_strlen_zero(data)) {
ast_set2_flag(chan->cdr, ast_test_flag(&flags, OPT_KEEPVARS), AST_CDR_FLAG_KEEP_VARS); int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0;
ast_set2_flag(chan->cdr, keepvars, AST_CDR_FLAG_KEEP_VARS);
}
ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]); ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);

@ -253,12 +253,12 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
ast_channel_lock(chan); ast_channel_lock(chan);
while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) { while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) {
const char *s; const char *argp;
/* Save copy of old arguments if we're overwriting some, otherwise /* Save copy of old arguments if we're overwriting some, otherwise
let them pass through to the other macro */ let them pass through to the other macro */
snprintf(varname, sizeof(varname), "ARG%d", argc); snprintf(varname, sizeof(varname), "ARG%d", argc);
if ((s = pbx_builtin_getvar_helper(chan, varname))) { if ((argp = pbx_builtin_getvar_helper(chan, varname))) {
oldargs[argc] = ast_strdup(s); oldargs[argc] = ast_strdup(argp);
} }
pbx_builtin_setvar_helper(chan, varname, cur); pbx_builtin_setvar_helper(chan, varname, cur);
argc++; argc++;
@ -329,12 +329,12 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
gosub_level++; gosub_level++;
ast_debug(1, "Incrementing gosub_level\n"); ast_debug(1, "Incrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "GOSUBIF")) { } else if (!strcasecmp(runningapp, "GOSUBIF")) {
char tmp2[1024], *cond, *app, *app2 = tmp2; char tmp2[1024], *cond, *app_arg, *app2 = tmp2;
pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1); pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
cond = strsep(&app2, "?"); cond = strsep(&app2, "?");
app = strsep(&app2, ":"); app_arg = strsep(&app2, ":");
if (pbx_checkcondition(cond)) { if (pbx_checkcondition(cond)) {
if (!ast_strlen_zero(app)) { if (!ast_strlen_zero(app_arg)) {
gosub_level++; gosub_level++;
ast_debug(1, "Incrementing gosub_level\n"); ast_debug(1, "Incrementing gosub_level\n");
} }

@ -1536,9 +1536,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
int announcement_played = 0; int announcement_played = 0;
struct timeval now; struct timeval now;
struct ast_dsp *dsp = NULL; struct ast_dsp *dsp = NULL;
struct ast_app *app; struct ast_app *agi_app;
char *agifile; char *agifile;
const char *agifiledefault = "conf-background.agi", *tmp; const char *agifiledefault = "conf-background.agi", *tmpvar;
char meetmesecs[30] = ""; char meetmesecs[30] = "";
char exitcontext[AST_MAX_CONTEXT] = ""; char exitcontext[AST_MAX_CONTEXT] = "";
char recordingtmp[AST_MAX_EXTENSION] = ""; char recordingtmp[AST_MAX_EXTENSION] = "";
@ -1787,8 +1787,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if (confflags & CONFFLAG_EXIT_CONTEXT) { if (confflags & CONFFLAG_EXIT_CONTEXT) {
ast_channel_lock(chan); ast_channel_lock(chan);
if ((tmp = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) { if ((tmpvar = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) {
ast_copy_string(exitcontext, tmp, sizeof(exitcontext)); ast_copy_string(exitcontext, tmpvar, sizeof(exitcontext));
} else if (!ast_strlen_zero(chan->macrocontext)) { } else if (!ast_strlen_zero(chan->macrocontext)) {
ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext)); ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
} else { } else {
@ -1986,8 +1986,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
or use default filename of conf-background.agi */ or use default filename of conf-background.agi */
ast_channel_lock(chan); ast_channel_lock(chan);
if ((tmp = pbx_builtin_getvar_helper(chan, "MEETME_AGI_BACKGROUND"))) { if ((tmpvar = pbx_builtin_getvar_helper(chan, "MEETME_AGI_BACKGROUND"))) {
agifile = ast_strdupa(tmp); agifile = ast_strdupa(tmpvar);
} else { } else {
agifile = ast_strdupa(agifiledefault); agifile = ast_strdupa(agifiledefault);
} }
@ -1999,9 +1999,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
} }
/* Find a pointer to the agi app and execute the script */ /* Find a pointer to the agi app and execute the script */
app = pbx_findapp("agi"); agi_app = pbx_findapp("agi");
if (app) { if (agi_app) {
ret = pbx_exec(chan, app, agifile); ret = pbx_exec(chan, agi_app, agifile);
} else { } else {
ast_log(LOG_WARNING, "Could not find application (agi)\n"); ast_log(LOG_WARNING, "Could not find application (agi)\n");
ret = -2; ret = -2;
@ -2600,27 +2600,27 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
((confflags & CONFFLAG_MONITOR) || ((confflags & CONFFLAG_MONITOR) ||
(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) ||
(!user->talking)) ) { (!user->talking)) ) {
int index; int idx;
for (index = 0; index < AST_FRAME_BITS; index++) for (idx = 0; idx < AST_FRAME_BITS; idx++)
if (chan->rawwriteformat & (1 << index)) if (chan->rawwriteformat & (1 << idx))
break; break;
if (index >= AST_FRAME_BITS) if (idx >= AST_FRAME_BITS)
goto bailoutandtrynormal; goto bailoutandtrynormal;
ast_mutex_lock(&conf->listenlock); ast_mutex_lock(&conf->listenlock);
if (!conf->transframe[index]) { if (!conf->transframe[idx]) {
if (conf->origframe) { if (conf->origframe) {
if (!conf->transpath[index]) if (!conf->transpath[idx])
conf->transpath[index] = ast_translator_build_path((1 << index), AST_FORMAT_SLINEAR); conf->transpath[idx] = ast_translator_build_path((1 << idx), AST_FORMAT_SLINEAR);
if (conf->transpath[index]) { if (conf->transpath[idx]) {
conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0); conf->transframe[idx] = ast_translate(conf->transpath[idx], conf->origframe, 0);
if (!conf->transframe[index]) if (!conf->transframe[idx])
conf->transframe[index] = &ast_null_frame; conf->transframe[idx] = &ast_null_frame;
} }
} }
} }
if (conf->transframe[index]) { if (conf->transframe[idx]) {
if (conf->transframe[index]->frametype != AST_FRAME_NULL) { if (conf->transframe[idx]->frametype != AST_FRAME_NULL) {
if (ast_write(chan, conf->transframe[index])) if (ast_write(chan, conf->transframe[idx]))
ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name); ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name);
} }
} else { } else {
@ -4059,7 +4059,7 @@ static int sla_check_timed_out_station(const struct sla_ringing_trunk *ringing_t
* \note Assumes that sla.lock is locked * \note Assumes that sla.lock is locked
*/ */
static struct sla_ringing_trunk *sla_choose_ringing_trunk(struct sla_station *station, static struct sla_ringing_trunk *sla_choose_ringing_trunk(struct sla_station *station,
struct sla_trunk_ref **trunk_ref, int remove) struct sla_trunk_ref **trunk_ref, int rm)
{ {
struct sla_trunk_ref *s_trunk_ref; struct sla_trunk_ref *s_trunk_ref;
struct sla_ringing_trunk *ringing_trunk = NULL; struct sla_ringing_trunk *ringing_trunk = NULL;
@ -4075,7 +4075,7 @@ static struct sla_ringing_trunk *sla_choose_ringing_trunk(struct sla_station *st
if (sla_check_timed_out_station(ringing_trunk, station)) if (sla_check_timed_out_station(ringing_trunk, station))
continue; continue;
if (remove) if (rm)
AST_LIST_REMOVE_CURRENT(entry); AST_LIST_REMOVE_CURRENT(entry);
if (trunk_ref) if (trunk_ref)
@ -4590,7 +4590,7 @@ static int sla_calc_station_delays(unsigned int *timeout)
static int sla_process_timers(struct timespec *ts) static int sla_process_timers(struct timespec *ts)
{ {
unsigned int timeout = UINT_MAX; unsigned int timeout = UINT_MAX;
struct timeval tv; struct timeval wait;
unsigned int change_made = 0; unsigned int change_made = 0;
/* Check for ring timeouts on ringing trunks */ /* Check for ring timeouts on ringing trunks */
@ -4614,9 +4614,9 @@ static int sla_process_timers(struct timespec *ts)
return 0; return 0;
if (ts) { if (ts) {
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(timeout, 1000)); wait = ast_tvadd(ast_tvnow(), ast_samp2tv(timeout, 1000));
ts->tv_sec = tv.tv_sec; ts->tv_sec = wait.tv_sec;
ts->tv_nsec = tv.tv_usec * 1000; ts->tv_nsec = wait.tv_usec * 1000;
} }
return 1; return 1;

@ -706,9 +706,9 @@ static int base_encode(char *filename, FILE *so)
static int get_date(char *s, int len) static int get_date(char *s, int len)
{ {
struct ast_tm tm; struct ast_tm tm;
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
ast_localtime(&tv, &tm, NULL); ast_localtime(&now, &tm, NULL);
return ast_strftime(s, len, "%a %b %e %r %Z %Y", &tm); return ast_strftime(s, len, "%a %b %e %r %Z %Y", &tm);
} }
@ -1040,18 +1040,18 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
fprintf(p, "To: %s <%s@%s>\n", mailheader_quote(vmu->fullname, passdata2, len_passdata), vmu->username, vmu->domain); fprintf(p, "To: %s <%s@%s>\n", mailheader_quote(vmu->fullname, passdata2, len_passdata), vmu->username, vmu->domain);
if (!ast_strlen_zero(template->subject)) { if (!ast_strlen_zero(template->subject)) {
char *passdata; char *pass_data;
int vmlen = strlen(template->subject) * 3 + 200; int vmlen = strlen(template->subject) * 3 + 200;
if ((passdata = alloca(vmlen))) { if ((pass_data = alloca(vmlen))) {
pbx_substitute_variables_helper(ast, template->subject, passdata, vmlen); pbx_substitute_variables_helper(ast, template->subject, pass_data, vmlen);
fprintf(p, "Subject: %s\n", passdata); fprintf(p, "Subject: %s\n", pass_data);
} else { } else {
ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
fclose(p); fclose(p);
return -1; return -1;
} }
ast_debug(4, "-_-_- Subject now: %s\n", passdata); ast_debug(4, "-_-_- Subject now: %s\n", pass_data);
} else { } else {
fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain); fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain);
@ -1071,12 +1071,12 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
fprintf(p, "--%s\n", bound); fprintf(p, "--%s\n", bound);
fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", global_charset); fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", global_charset);
if (!ast_strlen_zero(template->body)) { if (!ast_strlen_zero(template->body)) {
char *passdata; char *pass_data;
int vmlen = strlen(template->body)*3 + 200; int vmlen = strlen(template->body)*3 + 200;
if ((passdata = alloca(vmlen))) { if ((pass_data = alloca(vmlen))) {
pbx_substitute_variables_helper(ast, template->body, passdata, vmlen); pbx_substitute_variables_helper(ast, template->body, pass_data, vmlen);
ast_debug(3, "Message now: %s\n-----\n", passdata); ast_debug(3, "Message now: %s\n-----\n", pass_data);
fprintf(p, "%s\n", passdata); fprintf(p, "%s\n", pass_data);
} else } else
ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
} else { } else {
@ -1400,11 +1400,11 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename
strsep(&stringp, "|"); strsep(&stringp, "|");
if (!ast_strlen_zero(etemplate->locale)) { if (!ast_strlen_zero(etemplate->locale)) {
char *newlocale; char *new_locale;
ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale)); ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale));
ast_debug(2, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale); ast_debug(2, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale);
newlocale = setlocale(LC_TIME, etemplate->locale); new_locale = setlocale(LC_TIME, etemplate->locale);
if (newlocale == NULL) { if (new_locale == NULL) {
ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale); ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale);
} }
} }
@ -2192,9 +2192,8 @@ static void timezone_destroy_list(void)
/*! \brief Add time zone to memory list */ /*! \brief Add time zone to memory list */
static int timezone_add(const char *zonename, const char *config) static int timezone_add(const char *zonename, const char *config)
{ {
struct minivm_zone *newzone; struct minivm_zone *newzone;
char *msg_format, *timezone; char *msg_format, *timezone_str;
newzone = ast_calloc(1, sizeof(*newzone)); newzone = ast_calloc(1, sizeof(*newzone));
if (newzone == NULL) if (newzone == NULL)
@ -2207,7 +2206,7 @@ static int timezone_add(const char *zonename, const char *config)
return 0; return 0;
} }
timezone = strsep(&msg_format, "|"); timezone_str = strsep(&msg_format, "|");
if (!msg_format) { if (!msg_format) {
ast_log(LOG_WARNING, "Invalid timezone definition : %s\n", zonename); ast_log(LOG_WARNING, "Invalid timezone definition : %s\n", zonename);
ast_free(newzone); ast_free(newzone);
@ -2215,7 +2214,7 @@ static int timezone_add(const char *zonename, const char *config)
} }
ast_copy_string(newzone->name, zonename, sizeof(newzone->name)); ast_copy_string(newzone->name, zonename, sizeof(newzone->name));
ast_copy_string(newzone->timezone, timezone, sizeof(newzone->timezone)); ast_copy_string(newzone->timezone, timezone_str, sizeof(newzone->timezone));
ast_copy_string(newzone->msg_format, msg_format, sizeof(newzone->msg_format)); ast_copy_string(newzone->msg_format, msg_format, sizeof(newzone->msg_format));
AST_LIST_LOCK(&minivm_zones); AST_LIST_LOCK(&minivm_zones);
@ -2675,7 +2674,7 @@ static char *handle_minivm_show_settings(struct ast_cli_entry *e, int cmd, struc
/*! \brief Show stats */ /*! \brief Show stats */
static char *handle_minivm_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_minivm_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct ast_tm time; struct ast_tm timebuf;
char buf[BUFSIZ]; char buf[BUFSIZ];
switch (cmd) { switch (cmd) {
@ -2700,12 +2699,12 @@ static char *handle_minivm_show_stats(struct ast_cli_entry *e, int cmd, struct a
ast_cli(a->fd, " Received messages since last reset: <none>\n"); ast_cli(a->fd, " Received messages since last reset: <none>\n");
} else { } else {
ast_cli(a->fd, " Received messages since last reset: %d\n", global_stats.receivedmessages); ast_cli(a->fd, " Received messages since last reset: %d\n", global_stats.receivedmessages);
ast_localtime(&global_stats.lastreceived, &time, NULL); ast_localtime(&global_stats.lastreceived, &timebuf, NULL);
ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &time); ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &timebuf);
ast_cli(a->fd, " Last received voicemail: %s\n", buf); ast_cli(a->fd, " Last received voicemail: %s\n", buf);
} }
ast_localtime(&global_stats.reset, &time, NULL); ast_localtime(&global_stats.reset, &timebuf, NULL);
ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &time); ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &timebuf);
ast_cli(a->fd, " Last reset: %s\n", buf); ast_cli(a->fd, " Last reset: %s\n", buf);
ast_cli(a->fd, "\n"); ast_cli(a->fd, "\n");

@ -1193,7 +1193,7 @@ static int osp_finish(
int recorded, int recorded,
int cause, int cause,
time_t start, time_t start,
time_t connect, time_t connect_time,
time_t end, time_t end,
unsigned int release) unsigned int release)
{ {
@ -1216,11 +1216,11 @@ static int osp_finish(
error = OSPPTransactionReportUsage( error = OSPPTransactionReportUsage(
handle, handle,
difftime(end, connect), difftime(end, connect_time),
start, start,
end, end,
alert, alert,
connect, connect_time,
isPddInfoPresent, isPddInfoPresent,
pdd, pdd,
release, release,
@ -1664,7 +1664,7 @@ static int ospfinished_exec(
int inhandle = OSP_INVALID_HANDLE; int inhandle = OSP_INVALID_HANDLE;
int outhandle = OSP_INVALID_HANDLE; int outhandle = OSP_INVALID_HANDLE;
int recorded = 0; int recorded = 0;
time_t start, connect, end; time_t start, connect_time, end;
unsigned int release; unsigned int release;
char buffer[OSP_INTSTR_SIZE]; char buffer[OSP_INTSTR_SIZE];
const char* status; const char* status;
@ -1713,24 +1713,24 @@ static int ospfinished_exec(
if (chan->cdr) { if (chan->cdr) {
start = chan->cdr->start.tv_sec; start = chan->cdr->start.tv_sec;
connect = chan->cdr->answer.tv_sec; connect_time = chan->cdr->answer.tv_sec;
if (connect) { if (connect_time) {
end = time(NULL); end = time(NULL);
} else { } else {
end = connect; end = connect_time;
} }
} else { } else {
start = 0; start = 0;
connect = 0; connect_time = 0;
end = 0; end = 0;
} }
ast_debug(1, "OSPFinish: start '%ld'\n", start); ast_debug(1, "OSPFinish: start '%ld'\n", start);
ast_debug(1, "OSPFinish: connect '%ld'\n", connect); ast_debug(1, "OSPFinish: connect '%ld'\n", connect_time);
ast_debug(1, "OSPFinish: end '%ld'\n", end); ast_debug(1, "OSPFinish: end '%ld'\n", end);
release = ast_check_hangup(chan) ? 0 : 1; release = ast_check_hangup(chan) ? 0 : 1;
if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) { if (osp_finish(outhandle, recorded, cause, start, connect_time, end, release) <= 0) {
ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n"); ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n");
} }
switch (cause) { switch (cause) {
@ -1740,7 +1740,7 @@ static int ospfinished_exec(
cause = AST_CAUSE_NO_ROUTE_DESTINATION; cause = AST_CAUSE_NO_ROUTE_DESTINATION;
break; break;
} }
if (osp_finish(inhandle, recorded, cause, start, connect, end, release) <= 0) { if (osp_finish(inhandle, recorded, cause, start, connect_time, end, release) <= 0) {
ast_debug(1, "OSPFinish: Unable to report usage for inbound call\n"); ast_debug(1, "OSPFinish: Unable to report usage for inbound call\n");
} }
snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE); snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE);

@ -275,16 +275,16 @@ static int say_enumeration_full(struct ast_channel *chan, int num,
} }
static int say_date_generic(struct ast_channel *chan, time_t t, static int say_date_generic(struct ast_channel *chan, time_t t,
const char *ints, const char *lang, const char *format, const char *timezone, const char *prefix) const char *ints, const char *lang, const char *format, const char *timezonename, const char *prefix)
{ {
char buf[128]; char buf[128];
struct ast_tm tm; struct ast_tm tm;
struct timeval tv = { t, 0 }; struct timeval when = { t, 0 };
say_args_t a = { chan, ints, lang, -1, -1 }; say_args_t a = { chan, ints, lang, -1, -1 };
if (format == NULL) if (format == NULL)
format = ""; format = "";
ast_localtime(&tv, &tm, NULL); ast_localtime(&when, &tm, NULL);
snprintf(buf, sizeof(buf), "%s:%s:%04d%02d%02d%02d%02d.%02d-%d-%3d", snprintf(buf, sizeof(buf), "%s:%s:%04d%02d%02d%02d%02d.%02d-%d-%3d",
prefix, prefix,
format, format,
@ -300,9 +300,9 @@ static int say_date_generic(struct ast_channel *chan, time_t t,
} }
static int say_date_with_format(struct ast_channel *chan, time_t t, static int say_date_with_format(struct ast_channel *chan, time_t t,
const char *ints, const char *lang, const char *format, const char *timezone) const char *ints, const char *lang, const char *format, const char *timezonename)
{ {
return say_date_generic(chan, t, ints, lang, format, timezone, "datetime"); return say_date_generic(chan, t, ints, lang, format, timezonename, "datetime");
} }
static int say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang) static int say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang)

@ -173,7 +173,7 @@ static int record_exec(struct ast_channel *chan, void *data)
); );
char *tmp2 = ast_strdupa(args.filename); char *tmp2 = ast_strdupa(args.filename);
char countstring[15]; char countstring[15];
int i; int idx;
/* Separate each piece out by the format specifier */ /* Separate each piece out by the format specifier */
AST_NONSTANDARD_APP_ARGS(fname, tmp2, '%'); AST_NONSTANDARD_APP_ARGS(fname, tmp2, '%');
@ -182,8 +182,8 @@ static int record_exec(struct ast_channel *chan, void *data)
/* First piece has no leading percent, so it's copied verbatim */ /* First piece has no leading percent, so it's copied verbatim */
ast_copy_string(tmp, fname.piece[0], sizeof(tmp)); ast_copy_string(tmp, fname.piece[0], sizeof(tmp));
tmplen = strlen(tmp); tmplen = strlen(tmp);
for (i = 1; i < fname.argc; i++) { for (idx = 1; idx < fname.argc; idx++) {
if (fname.piece[i][0] == 'd') { if (fname.piece[idx][0] == 'd') {
/* Substitute the count */ /* Substitute the count */
snprintf(countstring, sizeof(countstring), "%d", count); snprintf(countstring, sizeof(countstring), "%d", count);
ast_copy_string(tmp + tmplen, countstring, sizeof(tmp) - tmplen); ast_copy_string(tmp + tmplen, countstring, sizeof(tmp) - tmplen);
@ -191,10 +191,10 @@ static int record_exec(struct ast_channel *chan, void *data)
} else if (tmplen + 2 < sizeof(tmp)) { } else if (tmplen + 2 < sizeof(tmp)) {
/* Unknown format specifier - just copy it verbatim */ /* Unknown format specifier - just copy it verbatim */
tmp[tmplen++] = '%'; tmp[tmplen++] = '%';
tmp[tmplen++] = fname.piece[i][0]; tmp[tmplen++] = fname.piece[idx][0];
} }
/* Copy the remaining portion of the piece */ /* Copy the remaining portion of the piece */
ast_copy_string(tmp + tmplen, &(fname.piece[i][1]), sizeof(tmp) - tmplen); ast_copy_string(tmp + tmplen, &(fname.piece[idx][1]), sizeof(tmp) - tmplen);
} }
count++; count++;
} while (ast_fileexists(tmp, ext, chan->language) > 0); } while (ast_fileexists(tmp, ext, chan->language) > 0);

@ -2165,12 +2165,11 @@ struct rptfilter *f;
#ifdef NEW_ASTERISK #ifdef NEW_ASTERISK
static void rpt_localtime( time_t * t, struct ast_tm *lt) static void rpt_localtime( time_t * t, struct ast_tm *lt)
{ {
struct timeval tv; struct timeval when;
tv.tv_sec = *t;
tv.tv_usec = 0;
ast_localtime(&tv, lt, NULL);
when.tv_sec = *t;
when.tv_usec = 0;
ast_localtime(&when, lt, NULL);
} }
#else #else
@ -5110,7 +5109,7 @@ struct dahdi_params par;
/* Parts of this section taken from app_parkandannounce */ /* Parts of this section taken from app_parkandannounce */
char *tpl_working, *tpl_current; char *tpl_working, *tpl_current;
char *tmp[100], *myparm; char *tmp[100], *myparm;
int looptemp=0,i=0, dres = 0; int looptemp=0,idx=0, dres = 0;
tpl_working = ast_strdup(mytele->param); tpl_working = ast_strdup(mytele->param);
@ -5123,17 +5122,17 @@ struct dahdi_params par;
tpl_current=strsep(&tpl_working,":"); tpl_current=strsep(&tpl_working,":");
} }
for(i=0; i<looptemp; i++) { for(idx=0; idx<looptemp; idx++) {
if(!strcmp(tmp[i], "PARKED")) { if(!strcmp(tmp[idx], "PARKED")) {
ast_say_digits(mychannel, atoi(myparm), "", mychannel->language); ast_say_digits(mychannel, atoi(myparm), "", mychannel->language);
} else if(!strcmp(tmp[i], "NODE")) { } else if(!strcmp(tmp[idx], "NODE")) {
ast_say_digits(mychannel, atoi(myrpt->name), "", mychannel->language); ast_say_digits(mychannel, atoi(myrpt->name), "", mychannel->language);
} else { } else {
dres = ast_streamfile(mychannel, tmp[i], mychannel->language); dres = ast_streamfile(mychannel, tmp[idx], mychannel->language);
if(!dres) { if(!dres) {
dres = ast_waitstream(mychannel, ""); dres = ast_waitstream(mychannel, "");
} else { } else {
ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], mychannel->name); ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[idx], mychannel->name);
dres = 0; dres = 0;
} }
} }
@ -6144,7 +6143,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm
static int function_autopatchup(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink) static int function_autopatchup(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
{ {
pthread_attr_t attr; pthread_attr_t attr;
int i, index, paramlength; int i, idx, paramlength;
char *lparam; char *lparam;
char *value = NULL; char *value = NULL;
char *paramlist[20]; char *paramlist[20];
@ -6181,10 +6180,10 @@ static int function_autopatchup(struct rpt *myrpt, char *param, char *digitbuf,
} }
paramlength = finddelim(lparam, paramlist, 20); paramlength = finddelim(lparam, paramlist, 20);
for(i = 0; i < paramlength; i++){ for(i = 0; i < paramlength; i++){
index = matchkeyword(paramlist[i], &value, keywords); idx = matchkeyword(paramlist[i], &value, keywords);
if(value) if(value)
value = skipchars(value, "= "); value = skipchars(value, "= ");
switch(index){ switch(idx){
case 1: /* context */ case 1: /* context */
strncpy(myrpt->patchcontext, value, MAXPATCHCONTEXT - 1) ; strncpy(myrpt->patchcontext, value, MAXPATCHCONTEXT - 1) ;
@ -6904,10 +6903,10 @@ struct ast_frame wf;
} }
if (myrpt->p.archivedir) if (myrpt->p.archivedir)
{ {
char str[100]; char dtmfstr[100];
sprintf(str,"DTMF,%s,%c",mylink->name,c); sprintf(dtmfstr,"DTMF,%s,%c",mylink->name,c);
donodelog(myrpt,str); donodelog(myrpt,dtmfstr);
} }
c = func_xlat(myrpt,c,&myrpt->p.outxlat); c = func_xlat(myrpt,c,&myrpt->p.outxlat);
if (!c) return; if (!c) return;
@ -7402,7 +7401,7 @@ struct dahdi_radio_param r;
static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes, static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes,
unsigned char *rxbuf, int rxmaxbytes, int asciiflag) unsigned char *rxbuf, int rxmaxbytes, int asciiflag)
{ {
int i,j,index,oldmode,olddata; int i,j,idx,oldmode,olddata;
struct dahdi_radio_param prm; struct dahdi_radio_param prm;
char c; char c;
@ -7477,7 +7476,7 @@ static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes
*rxbuf = 0; *rxbuf = 0;
memcpy(rxbuf,prm.buf,prm.index); memcpy(rxbuf,prm.buf,prm.index);
} }
index = prm.index; idx = prm.index;
prm.radpar = DAHDI_RADPAR_REMMODE; prm.radpar = DAHDI_RADPAR_REMMODE;
prm.data = DAHDI_RADPAR_REM_NONE; prm.data = DAHDI_RADPAR_REM_NONE;
if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1; if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
@ -7492,7 +7491,7 @@ static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes
prm.radpar = DAHDI_RADPAR_UIODATA; prm.radpar = DAHDI_RADPAR_UIODATA;
prm.data = olddata; prm.data = olddata;
if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1; if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
return(index); return(idx);
} }
static int civ_cmd(struct rpt *myrpt,unsigned char *cmd, int cmdlen) static int civ_cmd(struct rpt *myrpt,unsigned char *cmd, int cmdlen)
@ -10264,10 +10263,10 @@ int seq,res;
if (strcmp(dest,myrpt->name)) return 0; if (strcmp(dest,myrpt->name)) return 0;
if (myrpt->p.archivedir) if (myrpt->p.archivedir)
{ {
char str[100]; char dtmfstr[100];
sprintf(str,"DTMF,%c",c); sprintf(dtmfstr,"DTMF,%c",c);
donodelog(myrpt,str); donodelog(myrpt,dtmfstr);
} }
c = func_xlat(myrpt,c,&myrpt->p.outxlat); c = func_xlat(myrpt,c,&myrpt->p.outxlat);
if (!c) return(0); if (!c) return(0);
@ -11228,14 +11227,14 @@ char tmpstr[300],lstr[MAXLINKLIST];
if (myrpt->reload) if (myrpt->reload)
{ {
struct rpt_tele *telem; struct rpt_tele *inner_telem;
rpt_mutex_lock(&myrpt->lock); rpt_mutex_lock(&myrpt->lock);
telem = myrpt->tele.next; inner_telem = myrpt->tele.next;
while(telem != &myrpt->tele) while(inner_telem != &myrpt->tele)
{ {
ast_softhangup(telem->chan,AST_SOFTHANGUP_DEV); ast_softhangup(inner_telem->chan,AST_SOFTHANGUP_DEV);
telem = telem->next; inner_telem = inner_telem->next;
} }
myrpt->reload = 0; myrpt->reload = 0;
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
@ -11901,16 +11900,16 @@ char tmpstr[300],lstr[MAXLINKLIST];
if (myrpt->keyposttimer <= 0) if (myrpt->keyposttimer <= 0)
{ {
char str[100]; char str[100];
int n = 0; int diff = 0;
time_t now; time_t now;
myrpt->keyposttimer = KEYPOSTTIME; myrpt->keyposttimer = KEYPOSTTIME;
time(&now); time(&now);
if (myrpt->lastkeyedtime) if (myrpt->lastkeyedtime)
{ {
n = (int)(now - myrpt->lastkeyedtime); diff = (int)(now - myrpt->lastkeyedtime);
} }
sprintf(str,"keyed=%d&keytime=%d",myrpt->keyed,n); sprintf(str,"keyed=%d&keytime=%d",myrpt->keyed,diff);
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
statpost(myrpt,str); statpost(myrpt,str);
rpt_mutex_lock(&myrpt->lock); rpt_mutex_lock(&myrpt->lock);
@ -12163,41 +12162,41 @@ char tmpstr[300],lstr[MAXLINKLIST];
} }
if (f->datalen && f->data.ptr) if (f->datalen && f->data.ptr)
{ {
char *val, busy = 0; char busy = 0;
if (debug) ast_log(LOG_NOTICE,"Got PL %s on node %s\n",(char *)f->data.ptr,myrpt->name); if (debug) ast_log(LOG_NOTICE,"Got PL %s on node %s\n",(char *)f->data.ptr,myrpt->name);
// ctcss code autopatch initiate // ctcss code autopatch initiate
if (strstr((char *)f->data.ptr,"/M/")&& !myrpt->macropatch) if (strstr((char *)f->data.ptr,"/M/")&& !myrpt->macropatch)
{ {
char val[16]; char value[16];
strcat(val,"*6"); strcat(value,"*6");
myrpt->macropatch=1; myrpt->macropatch=1;
rpt_mutex_lock(&myrpt->lock); rpt_mutex_lock(&myrpt->lock);
if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(val)){ if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(value)){
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
busy=1; busy=1;
} }
if(!busy){ if(!busy){
myrpt->macrotimer = MACROTIME; myrpt->macrotimer = MACROTIME;
strncat(myrpt->macrobuf,val,MAXMACRO - 1); strncat(myrpt->macrobuf,value,MAXMACRO - 1);
if (!busy) strcpy(myrpt->lasttone,(char*)f->data.ptr); if (!busy) strcpy(myrpt->lasttone,(char*)f->data.ptr);
} }
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
} }
else if (strcmp((char *)f->data.ptr,myrpt->lasttone)) else if (strcmp((char *)f->data.ptr,myrpt->lasttone))
{ {
val = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.tonemacro, (char *)f->data.ptr); char *value = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.tonemacro, (char *)f->data.ptr);
if (val) if (value)
{ {
if (debug) ast_log(LOG_NOTICE,"Tone %s doing %s on node %s\n",(char *) f->data.ptr,val,myrpt->name); if (debug) ast_log(LOG_NOTICE,"Tone %s doing %s on node %s\n",(char *) f->data.ptr,value,myrpt->name);
rpt_mutex_lock(&myrpt->lock); rpt_mutex_lock(&myrpt->lock);
if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(val)){ if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(value)){
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
busy=1; busy=1;
} }
if(!busy){ if(!busy){
myrpt->macrotimer = MACROTIME; myrpt->macrotimer = MACROTIME;
strncat(myrpt->macrobuf,val,MAXMACRO - 1); strncat(myrpt->macrobuf,value,MAXMACRO - 1);
} }
rpt_mutex_unlock(&myrpt->lock); rpt_mutex_unlock(&myrpt->lock);
} }
@ -12281,7 +12280,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
} }
if (f->frametype == AST_FRAME_VOICE) if (f->frametype == AST_FRAME_VOICE)
{ {
struct ast_frame *f1; struct ast_frame *vframe;
if (myrpt->p.duplex < 2) if (myrpt->p.duplex < 2)
{ {
@ -12290,22 +12289,22 @@ char tmpstr[300],lstr[MAXLINKLIST];
if ((!myfirst) && myrpt->callmode) if ((!myfirst) && myrpt->callmode)
{ {
x = 0; x = 0;
AST_LIST_TRAVERSE(&myrpt->txq, f1, AST_LIST_TRAVERSE(&myrpt->txq, vframe,
frame_list) x++; frame_list) x++;
for(;x < myrpt->p.simplexpatchdelay; x++) for(;x < myrpt->p.simplexpatchdelay; x++)
{ {
f1 = ast_frdup(f); vframe = ast_frdup(f);
memset(f1->data.ptr,0,f1->datalen); memset(vframe->data.ptr,0,vframe->datalen);
AST_LIST_INSERT_TAIL(&myrpt->txq,f1,frame_list); AST_LIST_INSERT_TAIL(&myrpt->txq,vframe,frame_list);
} }
myfirst = 1; myfirst = 1;
} }
f1 = ast_frdup(f); vframe = ast_frdup(f);
AST_LIST_INSERT_TAIL(&myrpt->txq, AST_LIST_INSERT_TAIL(&myrpt->txq,
f1,frame_list); vframe,frame_list);
} else myfirst = 0; } else myfirst = 0;
x = 0; x = 0;
AST_LIST_TRAVERSE(&myrpt->txq, f1, AST_LIST_TRAVERSE(&myrpt->txq, vframe,
frame_list) x++; frame_list) x++;
if (!x) if (!x)
{ {
@ -12320,8 +12319,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
} }
else else
{ {
while((f1 = AST_LIST_REMOVE_HEAD(&myrpt->txq, while((vframe = AST_LIST_REMOVE_HEAD(&myrpt->txq,
frame_list))) ast_frfree(f1); frame_list))) ast_frfree(vframe);
} }
ast_write(myrpt->txchannel,f); ast_write(myrpt->txchannel,f);
} }
@ -13192,7 +13191,6 @@ static int rpt_exec(struct ast_channel *chan, void *data)
if(options && *options == 'q') if(options && *options == 'q')
{ {
int res=0;
char buf2[128]; char buf2[128];
if(myrpt->keyed) if(myrpt->keyed)
@ -13226,8 +13224,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
snprintf(buf2,sizeof(buf2),"%s=%s", "RPT_STAT_LASTTONE", myrpt->lasttone); snprintf(buf2,sizeof(buf2),"%s=%s", "RPT_STAT_LASTTONE", myrpt->lasttone);
pbx_builtin_setvar(chan, buf2); pbx_builtin_setvar(chan, buf2);
res=priority_jump(myrpt,chan); return priority_jump(myrpt,chan);
return res;
} }
if(options && *options == 'o') if(options && *options == 'o')
@ -13307,8 +13304,8 @@ static int rpt_exec(struct ast_channel *chan, void *data)
{ {
/* Parts of this section taken from app_parkandannounce */ /* Parts of this section taken from app_parkandannounce */
char *return_context; char *return_context;
int l, m, lot, timeout = 0; int length, m, lot, timeout = 0;
char tmp[256],*template; char buffer[256],*template;
char *working, *context, *exten, *priority; char *working, *context, *exten, *priority;
char *s,*orig_s; char *s,*orig_s;
@ -13332,14 +13329,14 @@ static int rpt_exec(struct ast_channel *chan, void *data)
if (!phone_mode) send_newkey(chan); if (!phone_mode) send_newkey(chan);
} }
l=strlen(options)+2; length=strlen(options)+2;
orig_s=ast_malloc(l); orig_s=ast_malloc(length);
if(!orig_s) { if(!orig_s) {
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
return -1; return -1;
} }
s=orig_s; s=orig_s;
strncpy(s,options,l); strncpy(s,options,length);
template=strsep(&s,"|"); template=strsep(&s,"|");
if(!template) { if(!template) {
@ -13408,9 +13405,9 @@ static int rpt_exec(struct ast_channel *chan, void *data)
if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context); if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
snprintf(tmp,sizeof(tmp) - 1,"%d,%s",lot,template + 1); snprintf(buffer, sizeof(buffer) - 1, "%d,%s", lot, template + 1);
rpt_telemetry(myrpt,REV_PATCH,tmp); rpt_telemetry(myrpt,REV_PATCH,buffer);
ast_free(orig_s); ast_free(orig_s);
@ -14982,7 +14979,7 @@ static int rpt_manager_do_stats(struct mansession *s, const struct message *m, c
static int manager_rpt_status(struct mansession *s, const struct message *m) static int manager_rpt_status(struct mansession *s, const struct message *m)
{ {
int i,res,len,index; int i,res,len,idx;
int uptime,hours,minutes; int uptime,hours,minutes;
time_t now; time_t now;
const char *cmd = astman_get_header(m, "Command"); const char *cmd = astman_get_header(m, "Command");
@ -15022,9 +15019,9 @@ static int manager_rpt_status(struct mansession *s, const struct message *m)
return 0; return 0;
} }
else else
index = mct[i].index; idx = mct[i].index;
switch(index){ /* Use the index to go to the correct command */ switch(idx){ /* Use the index to go to the correct command */
case MGRCMD_RPTSTAT: case MGRCMD_RPTSTAT:
/* Return Nodes: and a comma separated list of nodes */ /* Return Nodes: and a comma separated list of nodes */

@ -272,8 +272,8 @@ static void numcpy(char *d, char *s)
static char *isodate(time_t t, char *buf, int len) static char *isodate(time_t t, char *buf, int len)
{ {
struct ast_tm tm; struct ast_tm tm;
struct timeval tv = { t, 0 }; struct timeval local = { t, 0 };
ast_localtime(&tv, &tm, NULL); ast_localtime(&local, &tm, NULL);
ast_strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm); ast_strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm);
return buf; return buf;
} }
@ -507,10 +507,10 @@ static int packsms(unsigned char dcs, unsigned char *base, unsigned int udhl, un
static void packdate(unsigned char *o, time_t w) static void packdate(unsigned char *o, time_t w)
{ {
struct ast_tm t; struct ast_tm t;
struct timeval tv = { w, 0 }; struct timeval topack = { w, 0 };
int z; int z;
ast_localtime(&tv, &t, NULL); ast_localtime(&topack, &t, NULL);
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
z = -t.tm_gmtoff / 60 / 15; z = -t.tm_gmtoff / 60 / 15;
#else #else
@ -980,8 +980,8 @@ static void sms_writefile(sms_t * h)
} }
} }
if (h->scts.tv_sec) { if (h->scts.tv_sec) {
char buf[30]; char datebuf[30];
fprintf(o, "scts=%s\n", isodate(h->scts.tv_sec, buf, sizeof(buf))); fprintf(o, "scts=%s\n", isodate(h->scts.tv_sec, datebuf, sizeof(datebuf)));
} }
if (h->pid) if (h->pid)
fprintf(o, "pid=%d\n", h->pid); fprintf(o, "pid=%d\n", h->pid);
@ -1113,7 +1113,7 @@ static void putdummydata_proto2(sms_t *h)
static void sms_compose2(sms_t *h, int more) static void sms_compose2(sms_t *h, int more)
{ {
struct ast_tm tm; struct ast_tm tm;
struct timeval tv = h->scts; struct timeval now = h->scts;
char stm[9]; char stm[9];
h->omsg[0] = 0x00; /* set later... */ h->omsg[0] = 0x00; /* set later... */
@ -1122,7 +1122,7 @@ static void sms_compose2(sms_t *h, int more)
if (h->smsc) { /* deliver */ if (h->smsc) { /* deliver */
h->omsg[0] = 0x11; /* SMS_DELIVERY */ h->omsg[0] = 0x11; /* SMS_DELIVERY */
/* Required: 10 11 12 13 14 15 17 (seems they must be ordered!) */ /* Required: 10 11 12 13 14 15 17 (seems they must be ordered!) */
ast_localtime(&tv, &tm, NULL); ast_localtime(&now, &tm, NULL);
sprintf(stm, "%02d%02d%02d%02d", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min); /* Date mmddHHMM */ sprintf(stm, "%02d%02d%02d%02d", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min); /* Date mmddHHMM */
adddata_proto2(h, 0x14, stm, 8); /* Date */ adddata_proto2(h, 0x14, stm, 8); /* Date */
if (*h->oa == 0) if (*h->oa == 0)
@ -1161,14 +1161,14 @@ static int sms_handleincoming_proto2(sms_t *h)
int f, i, sz = 0; int f, i, sz = 0;
int msg, msgsz; int msg, msgsz;
struct ast_tm tm; struct ast_tm tm;
struct timeval tv = { 0, 0 }; struct timeval now = { 0, 0 };
char debug_buf[MAX_DEBUG_LEN * 3 + 1]; char debug_buf[MAX_DEBUG_LEN * 3 + 1];
sz = h->imsg[1] + 2; sz = h->imsg[1] + 2;
/* ast_verb(3, "SMS-P2 Frame: %s\n", sms_hexdump(h->imsg, sz, debug_buf)); */ /* ast_verb(3, "SMS-P2 Frame: %s\n", sms_hexdump(h->imsg, sz, debug_buf)); */
/* Parse message body (called payload) */ /* Parse message body (called payload) */
tv = h->scts = ast_tvnow(); now = h->scts = ast_tvnow();
for (f = 4; f < sz; ) { for (f = 4; f < sz; ) {
msg = h->imsg[f++]; msg = h->imsg[f++];
msgsz = h->imsg[f++]; msgsz = h->imsg[f++];
@ -1183,8 +1183,8 @@ static int sms_handleincoming_proto2(sms_t *h)
h->udl = msgsz; h->udl = msgsz;
break; break;
case 0x14: /* Date SCTS */ case 0x14: /* Date SCTS */
tv = h->scts = ast_tvnow(); now = h->scts = ast_tvnow();
ast_localtime(&tv, &tm, NULL); ast_localtime(&now, &tm, NULL);
tm.tm_mon = ( (h->imsg[f] * 10) + h->imsg[f + 1] ) - 1; tm.tm_mon = ( (h->imsg[f] * 10) + h->imsg[f + 1] ) - 1;
tm.tm_mday = ( (h->imsg[f + 2] * 10) + h->imsg[f + 3] ); tm.tm_mday = ( (h->imsg[f + 2] * 10) + h->imsg[f + 3] );
tm.tm_hour = ( (h->imsg[f + 4] * 10) + h->imsg[f + 5] ); tm.tm_hour = ( (h->imsg[f + 4] * 10) + h->imsg[f + 5] );
@ -1743,7 +1743,7 @@ static int sms_exec(struct ast_channel *chan, void *data)
int res = -1; int res = -1;
sms_t h = { 0 }; sms_t h = { 0 };
/* argument parsing support */ /* argument parsing support */
struct ast_flags sms_flags; struct ast_flags flags;
char *parse, *sms_opts[OPTION_ARG_ARRAY_SIZE]; char *parse, *sms_opts[OPTION_ARG_ARRAY_SIZE];
char *p; char *p;
AST_DECLARE_APP_ARGS(sms_args, AST_DECLARE_APP_ARGS(sms_args,
@ -1761,7 +1761,7 @@ static int sms_exec(struct ast_channel *chan, void *data)
parse = ast_strdupa(data); /* create a local copy */ parse = ast_strdupa(data); /* create a local copy */
AST_STANDARD_APP_ARGS(sms_args, parse); AST_STANDARD_APP_ARGS(sms_args, parse);
if (sms_args.argc > 1) if (sms_args.argc > 1)
ast_app_parse_options(sms_options, &sms_flags, sms_opts, sms_args.options); ast_app_parse_options(sms_options, &flags, sms_opts, sms_args.options);
ast_verb(1, "sms argc %d queue <%s> opts <%s> addr <%s> body <%s>\n", ast_verb(1, "sms argc %d queue <%s> opts <%s> addr <%s> body <%s>\n",
sms_args.argc, S_OR(sms_args.queue, ""), sms_args.argc, S_OR(sms_args.queue, ""),
@ -1789,8 +1789,8 @@ static int sms_exec(struct ast_channel *chan, void *data)
if (!isalnum(*p)) if (!isalnum(*p))
*p = '-'; /* make very safe for filenames */ *p = '-'; /* make very safe for filenames */
h.smsc = ast_test_flag(&sms_flags, OPTION_BE_SMSC); h.smsc = ast_test_flag(&flags, OPTION_BE_SMSC);
h.protocol = ast_test_flag(&sms_flags, OPTION_TWO) ? 2 : 1; h.protocol = ast_test_flag(&flags, OPTION_TWO) ? 2 : 1;
if (!ast_strlen_zero(sms_opts[OPTION_ARG_PAUSE])) if (!ast_strlen_zero(sms_opts[OPTION_ARG_PAUSE]))
h.opause_0 = atoi(sms_opts[OPTION_ARG_PAUSE]); h.opause_0 = atoi(sms_opts[OPTION_ARG_PAUSE]);
if (h.opause_0 < 25 || h.opause_0 > 2000) if (h.opause_0 < 25 || h.opause_0 > 2000)
@ -1799,9 +1799,9 @@ static int sms_exec(struct ast_channel *chan, void *data)
/* the following apply if there is an arg3/4 and apply to the created message file */ /* the following apply if there is an arg3/4 and apply to the created message file */
if (ast_test_flag(&sms_flags, OPTION_SRR)) if (ast_test_flag(&flags, OPTION_SRR))
h.srr = 1; h.srr = 1;
if (ast_test_flag(&sms_flags, OPTION_DCS)) if (ast_test_flag(&flags, OPTION_DCS))
h.dcs = 1; h.dcs = 1;
#if 0 #if 0
case '1': case '1':
@ -1858,7 +1858,7 @@ static int sms_exec(struct ast_channel *chan, void *data)
goto done; goto done;
} }
if (ast_test_flag(&sms_flags, OPTION_ANSWER)) { if (ast_test_flag(&flags, OPTION_ANSWER)) {
h.framenumber = 1; /* Proto 2 */ h.framenumber = 1; /* Proto 2 */
/* set up SMS_EST initial message */ /* set up SMS_EST initial message */
if (h.protocol == 2) { if (h.protocol == 2) {

@ -50,7 +50,7 @@ static int waituntil_exec(struct ast_channel *chan, void *data)
double fraction; double fraction;
long seconds; long seconds;
struct timeval future = { 0, }; struct timeval future = { 0, };
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
int msec; int msec;
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
@ -68,8 +68,8 @@ static int waituntil_exec(struct ast_channel *chan, void *data)
future.tv_sec = seconds; future.tv_sec = seconds;
future.tv_usec = fraction * 1000000; future.tv_usec = fraction * 1000000;
if ((msec = ast_tvdiff_ms(future, tv)) < 0) { if ((msec = ast_tvdiff_ms(future, now)) < 0) {
ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)tv.tv_sec, (long)future.tv_sec); ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)now.tv_sec, (long)future.tv_sec);
pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST"); pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST");
return 0; return 0;
} }

@ -60,10 +60,10 @@ static char *continue_synopsis = "Restart a While loop";
#define VAR_SIZE 64 #define VAR_SIZE 64
static const char *get_index(struct ast_channel *chan, const char *prefix, int index) { static const char *get_index(struct ast_channel *chan, const char *prefix, int idx) {
char varname[VAR_SIZE]; char varname[VAR_SIZE];
snprintf(varname, VAR_SIZE, "%s_%d", prefix, index); snprintf(varname, VAR_SIZE, "%s_%d", prefix, idx);
return pbx_builtin_getvar_helper(chan, varname); return pbx_builtin_getvar_helper(chan, varname);
} }

Loading…
Cancel
Save