if(option_verbose >= 4)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: DTMF Digit Timeout on %s\n", chan->name);
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
+ ast_debug(1,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
res = 1;
break;
}
if ((r = ast_waitfor(chan, -1) < 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
+ ast_debug(1, "Waitfor returned %d\n", r);
continue;
}
if (option_verbose >= 3 )
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n");
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
+ ast_debug(1,"AlarmReceiver: can't write metadata\n");
}
else
res = 0;
if(fd == -1) {
if (option_verbose >= 3)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n");
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n");
+ ast_debug(1,"AlarmReceiver: can't make temporary file\n");
res = -1;
}
if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event);
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event);
+ ast_debug(1, "AlarmReceiver: Received event: %s\n", event);
/* Calculate checksum */
database_increment("checksum-errors");
if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Nonzero checksum\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
+ ast_debug(1, "AlarmReceiver: Nonzero checksum\n");
continue;
}
database_increment("format-errors");
if(option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Wrong message type\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
+ ast_debug(1, "AlarmReceiver: Wrong message type\n");
continue;
}
}
*/
if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){
- if (option_debug)
- ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
+ ast_debug(1,"Alarmreceiver: executing: %s\n", event_app);
ast_safe_system(event_app);
}
maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
if (!ast_strlen_zero(args.argSilenceThreshold))
silenceThreshold = atoi(args.argSilenceThreshold);
- } else if (option_debug)
- ast_log(LOG_DEBUG, "AMD using the default parameters.\n");
+ } else {
+ ast_debug(1, "AMD using the default parameters.\n");
+ }
/* Now we're ready to roll! */
if (option_verbose > 2)
if (!(f = ast_read(chan))) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup\n");
+ ast_debug(1, "Got hangup\n");
strcpy(amdStatus, "HANGUP");
break;
}
goto chanquit;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio);
+ ast_debug(2, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio);
if (ast_async_goto_if_exists(chan2, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio))
ast_log(LOG_WARNING, "%s failed for %s\n", app, args.channel);
tmp[0] = res;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
pbx_builtin_setvar_helper(chan, "SPY_CHANNEL", name);
running = -2;
break;
- } else if (option_debug > 1) {
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ } else {
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
} else if (res >= '0' && res <= '9') {
inp[x++] = res;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
goto exit;
- else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ else
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
}
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
goto exit;
- else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ else
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
/* reset for the next loop around, unless overridden later */
family = strsep(&argv, "/");
keytree = strsep(&argv, "\0");
if (!family || !keytree) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ ast_debug(1, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
family = strsep(&argv, "/");
key = strsep(&argv, "\0");
if (!family || !key) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ ast_debug(1, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
+ ast_debug(1, "Ignoring, no parameters\n");
}
ast_module_user_remove(u);
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
}
} else if (single) {
/* XXX are we sure the logic is correct ? or we should just switch on f->frametype ? */
/* check the results of ast_call */
if (res) {
/* Again, keep going even if there's an error */
- if (option_debug)
- ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
+ ast_debug(1, "ast call on peer returned %d\n", res);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst);
ast_hangup(tc);
number = numsubst;
pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url);
+ ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
ast_channel_sendurl( peer, args.url );
}
if ( (ast_test_flag(&opts, OPT_PRIVACY) || ast_test_flag(&opts, OPT_SCREENING)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) {
if (theapp && !res) { /* XXX why check res here ? */
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ ast_debug(1, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
hanguptree(outgoing, NULL);
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
senddialendevent(chan, pa.status);
- if (option_debug)
- ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", pa.status);
+ ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) {
if (calldurationlimit)
{
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
+ ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
if ((res = ast_answer(chan))) {
ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
return -1;
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
- ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
- }
+ ast_debug(1, "Digittimeout: %d\n", digittimeout);
+ ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout);
tmp = ast_strdupa(data);
if (!ast_strlen_zero(args.options))
ast_app_parse_options(app_opts, &flags, NULL, args.options);
- if (option_debug)
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ ast_debug(1, "Mailbox: %s\n",args.mailbox);
special_noanswer = 0;
if (ast_test_flag(&flags, NOANSWER_FLAG)) {
acctcode[0] = 0;
/* can we access DISA without password? */
- if (option_debug)
- ast_log(LOG_DEBUG, "Context: %s\n",args.context);
+ ast_debug(1, "Context: %s\n",args.context);
if (!strcasecmp(args.passcode, "no-password")) {
k |= 1; /* We have the password */
- if (option_debug)
- ast_log(LOG_DEBUG, "DISA no-password login success\n");
+ ast_debug(1, "DISA no-password login success\n");
}
lastdigittime = ast_tvnow();
/* if outa time, give em reorder */
if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) >
((k&2) ? digittimeout : firstdigittimeout)) {
- if (option_debug)
- ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
- ((k&1) ? "extension" : "password"),chan->name);
+ ast_debug(1,"DISA %s entry timeout on chan %s\n",
+ ((k&1) ? "extension" : "password"),chan->name);
break;
}
if ((res = ast_waitfor(chan, -1) < 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
+ ast_debug(1, "Waitfor returned %d\n", res);
continue;
}
AST_STANDARD_APP_ARGS(args, pwline);
- if (option_debug)
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ ast_debug(1, "Mailbox: %s\n",args.mailbox);
/* password must be in valid format (numeric) */
if (sscanf(args.passcode,"%d", &j) < 1)
}
/* password good, set to dial state */
- if (option_debug)
- ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
+ ast_debug(1,"DISA on chan %s password is good\n",chan->name);
play_dialtone(chan, args.mailbox);
k|=1; /* In number mode */
exten[sizeof(acctcode)] = 0;
ast_copy_string(acctcode, exten, sizeof(acctcode));
exten[0] = 0;
- if (option_debug)
- ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
+ ast_debug(1,"Successful DISA log-in on chan %s\n", chan->name);
continue;
}
}
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
if (intkeys && strchr(intkeys, f->subclass)) {
res = f->subclass;
ast_frfree(f);
break;
}
if (res < needed) { /* last frame */
- if (option_debug)
- ast_log(LOG_DEBUG, "Last frame\n");
+ ast_debug(1, "Last frame\n");
res=0;
ast_frfree(f);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more waveform\n");
+ ast_debug(1, "No more waveform\n");
res = 0;
}
}
intstr = AST_DIGIT_ANY;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
+ ast_debug(1, "Text passed to festival server : %s\n",(char *)data);
/* Connect to local festival server */
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fdesc!=-1) {
writecache=1;
strln=strlen((char *)data);
- if (option_debug)
- ast_log(LOG_DEBUG,"line length : %d\n",strln);
+ ast_debug(1,"line length : %d\n",strln);
write(fdesc,&strln,sizeof(int));
write(fdesc,data,strln);
seekpos=lseek(fdesc,0,SEEK_CUR);
- if (option_debug)
- ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
+ ast_debug(1,"Seek position : %d\n",seekpos);
}
} else {
read(fdesc,&strln,sizeof(int));
- if (option_debug)
- ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
+ ast_debug(1,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
if (strlen((char *)data)==strln) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Size OK\n");
+ ast_debug(1,"Size OK\n");
read(fdesc,&bigstring,strln);
bigstring[strln] = 0;
if (strcmp(bigstring,data)==0) {
if (readcache==1) {
close(fd);
fd=fdesc;
- if (option_debug)
- ast_log(LOG_DEBUG,"Reading from cache...\n");
+ ast_debug(1,"Reading from cache...\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"Passing text to festival...\n");
+ ast_debug(1,"Passing text to festival...\n");
fs=fdopen(dup(fd),"wb");
fprintf(fs,festivalcommand,(char *)data);
fflush(fs);
/* Write to cache and then pass it down */
if (writecache==1) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Writing result to cache...\n");
+ ast_debug(1,"Writing result to cache...\n");
while ((strln=read(fd,buffer,16384))!=0) {
write(fdesc,buffer,strln);
}
lseek(fd,seekpos,SEEK_SET);
}
- if (option_debug)
- ast_log(LOG_DEBUG,"Passing data to channel...\n");
+ ast_debug(1,"Passing data to channel...\n");
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
}
ack[3] = '\0';
if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
- if (option_debug)
- ast_log(LOG_DEBUG,"Festival WV command\n");
+ ast_debug(1,"Festival WV command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
ast_free(waveform);
break;
}
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
- if (option_debug)
- ast_log(LOG_DEBUG,"Festival LP command\n");
+ ast_debug(1,"Festival LP command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
waveform[filesize]='\0';
ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform);
*tmp = '\0';
ast_copy_string(cur->number, number, sizeof(cur->number));
cur->order = numorder;
- if (option_debug)
- ast_log(LOG_DEBUG, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
+ ast_debug(1, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
return cur;
}
if (!strcasecmp(f->name, cat))
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "New profile %s.\n", cat);
+ ast_debug(1, "New profile %s.\n", cat);
if (!f) {
/* Make one then */
f = alloc_profile(cat);
AST_LIST_INSERT_TAIL(&f->numbers, cur, entry);
} else {
profile_set_param(f, var->name, var->value, var->lineno, 1);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
+ ast_debug(2, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
}
var = var->next;
} /* End while(var) loop */
ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
break;
}
}
if (winner->stream)
ast_stopstream(winner);
tmpuser->digts = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF received: %c\n",(char) f->subclass);
+ ast_debug(1, "DTMF received: %c\n",(char) f->subclass);
tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
tmpuser->ynidx++;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF string: %s\n", tmpuser->yn);
+ ast_debug(1, "DTMF string: %s\n", tmpuser->yn);
if (tmpuser->ynidx >= ynlongest) {
- if (option_debug)
- ast_log(LOG_DEBUG, "reached longest possible match - doing evals\n");
+ ast_debug(1, "reached longest possible match - doing evals\n");
if (!strcmp(tmpuser->yn, tpargs->takecall)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Match to take the call!\n");
+ ast_debug(1, "Match to take the call!\n");
ast_frfree(f);
return tmpuser->ochan;
}
if (!strcmp(tmpuser->yn, tpargs->nextindp)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Next in dial plan step requested.\n");
+ ast_debug(1, "Next in dial plan step requested.\n");
*status = 1;
ast_frfree(f);
return NULL;
ast_frfree(f);
} else {
if (winner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "we didn't get a frame. hanging up. dg is %d\n",dg);
+ ast_debug(1, "we didn't get a frame. hanging up. dg is %d\n",dg);
if (!dg) {
clear_calling_tree(findme_user_list);
return NULL;
tmpuser->state = -1;
ast_hangup(winner);
livechannels--;
- if (option_debug)
- ast_log(LOG_DEBUG, "live channels left %d\n", livechannels);
+ ast_debug(1, "live channels left %d\n", livechannels);
if (!livechannels) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "no live channels left. exiting.\n");
}
} else
- if (option_debug)
- ast_log(LOG_DEBUG, "timed out waiting for action\n");
+ ast_debug(1, "timed out waiting for action\n");
}
} else {
while (nm) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Number %s timeout %ld\n", nm->number,nm->timeout);
+ ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout);
time(&start_time);
number = ast_strdupa(nm->number);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "examining %s\n", number);
+ ast_debug(3, "examining %s\n", number);
do {
rest = strchr(number, '&');
if (rest) {
}
AST_LIST_UNLOCK(&followmes);
- if (option_debug)
- ast_log(LOG_DEBUG, "New profile %s.\n", args.followmeid);
+ ast_debug(1, "New profile %s.\n", args.followmeid);
if (!f) {
ast_log(LOG_WARNING, "Profile requested, %s, not found in the configuration.\n", args.followmeid);
res = 0;
/* Wait for audio, and stream */
ms = ast_waitfor(chan, -1);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
/* If we are to run the macro exclusively, take the mutex */
if (exclusive) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Locking macrolock for '%s'\n", fullmacro);
+ ast_debug(1, "Locking macrolock for '%s'\n", fullmacro);
ast_autoservice_start(chan);
if (ast_context_lockmacro(fullmacro)) {
ast_log(LOG_WARNING, "Failed to lock macro '%s' as in-use\n", fullmacro);
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
(res == '*') || (res == '#')) {
/* Just return result as to the previous application as if it had been dialed */
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+ ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res);
break;
}
switch(res) {
res = 0;
goto out;
case AST_PBX_KEEPALIVE:
- if (option_debug)
- ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
- else if (option_verbose > 1)
+ ast_debug(2, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
+ if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE in macro '%s' on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
goto out;
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
- else if (option_verbose > 1)
+ ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+ if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
dead = 1;
goto out;
}
}
- ast_log(LOG_DEBUG, "Executed application: %s\n", runningapp);
+ ast_debug(1, "Executed application: %s\n", runningapp);
if (!strcasecmp(runningapp, "GOSUB")) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "GOSUBIF")) {
char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
if (pbx_checkcondition(cond)) {
if (!ast_strlen_zero(app)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
}
} else {
if (!ast_strlen_zero(app2)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
}
}
} else if (!strcasecmp(runningapp, "RETURN")) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "STACKPOP")) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (!strncasecmp(runningapp, "EXEC", 4)) {
/* Must evaluate args to find actual app */
char tmp2[1024] = "", *tmp3 = NULL;
tmp3 = tmp2;
if (tmp3)
- ast_log(LOG_DEBUG, "Last app: %s\n", tmp3);
+ ast_debug(1, "Last app: %s\n", tmp3);
if (tmp3 && !strncasecmp(tmp3, "GOSUB", 5)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
} else if (tmp3 && !strncasecmp(tmp3, "RETURN", 6)) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (tmp3 && !strncasecmp(tmp3, "STACKPOP", 8)) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
}
}
/* don't stop executing extensions when we're in "h" */
if (chan->_softhangup && !inhangup) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n",
- chan->exten, chan->macroexten, chan->priority);
+ ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", chan->exten, chan->macroexten, chan->priority);
goto out;
}
chan->priority++;
/* Unlock the macro */
if (exclusive) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlocking macrolock for '%s'\n", fullmacro);
+ ast_debug(1, "Unlocking macrolock for '%s'\n", fullmacro);
if (ast_context_unlockmacro(fullmacro)) {
ast_log(LOG_ERROR, "Failed to unlock macro '%s' - that isn't good\n", fullmacro);
res = 0;
} else
return RESULT_SHOWUSAGE;
- if (option_debug)
- ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+ ast_debug(1, "Cmdline: %s\n", cmdline);
admin_exec(NULL, cmdline);
AST_RWLIST_UNLOCK(&sla_stations);
if (!trunk_ref) {
- ast_log(LOG_DEBUG, "Trunk not found for event!\n");
+ ast_debug(1, "Trunk not found for event!\n");
return;
}
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
ast_mutex_unlock(&conf->playlock);
goto outrun;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
+ ast_debug(1, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
if (!sent_event) {
manager_event(EVENT_FLAG_CALL, "MeetmeJoin",
close(fd);
using_pseudo = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ ast_debug(1, "Ooh, something swapped out under us, starting over\n");
retryzap = strcasecmp(c->tech->type, "Zap");
user->zapchannel = !retryzap;
goto zapretry;
tmp[0] = f->subclass;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
ret = 0;
ast_frfree(f);
break;
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ } else {
+ ast_debug(2, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ }
} else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) {
ret = 0;
ast_frfree(f);
if (!cnf) {
if (dynamic) {
/* No need to parse meetme.conf */
- if (option_debug)
- ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno);
+ ast_debug(1, "Building dynamic conference '%s'\n", confno);
if (dynamic_pin) {
if (dynamic_pin[0] == 'q') {
/* Query the user to enter a PIN */
}
}
if (!var) {
- ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno);
+ ast_debug(1, "%s isn't a valid conference\n", confno);
}
ast_config_destroy(cfg);
}
ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
ast_mutex_unlock(&sla.lock);
if (!ringing_trunk) {
- ast_log(LOG_DEBUG, "Found no ringing trunk for station '%s' to answer!\n",
- ringing_station->station->name);
+ ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name);
break;
}
/* Track the channel that answered this trunk */
ast_cond_destroy(&cond);
ast_autoservice_stop(chan);
if (!trunk_ref->trunk->chan) {
- ast_log(LOG_DEBUG, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan);
+ ast_debug(1, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan);
pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION");
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
trunk_ref->chan = NULL;
}
while (var) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name);
+ ast_debug(3, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "fromaddress")) {
ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress));
} else if (!strcasecmp(var->name, "fromemail")) {
ast_log(LOG_NOTICE, "No username or domain? \n");
return NULL;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain);
+ ast_debug(3, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain);
AST_LIST_LOCK(&minivm_accounts);
AST_LIST_TRAVERSE(&minivm_accounts, cur, list) {
AST_LIST_UNLOCK(&minivm_accounts);
if (cur) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Found account for %s@%s\n", username, domain);
+ ast_debug(3, "-_-_- Found account for %s@%s\n", username, domain);
vmu = cur;
} else
if (vmu) {
ast_copy_string(vmu->username, username, sizeof(vmu->username));
ast_copy_string(vmu->domain, domain, sizeof(vmu->domain));
- if (option_debug)
- ast_log(LOG_DEBUG, "--- Created temporary account\n");
+ ast_debug(1, "--- Created temporary account\n");
}
}
return -1;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
+ ast_debug(3, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
if (!strcmp(format, "wav49"))
format = "WAV";
int tmpfd;
snprintf(newtmp, sizeof(newtmp), "/tmp/XXXXXX");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ ast_debug(3, "newtmp: %s\n", newtmp);
tmpfd = mkstemp(newtmp);
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
ast_safe_system(tmpcmd);
/* Create file name */
snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format);
- if (option_debug && template->attachment)
- ast_log(LOG_DEBUG, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail);
+ if (template->attachment)
+ ast_debug(1, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail);
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
close(pfd);
pfd = -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Opening temp file for e-mail: %s\n", tmp);
+ ast_debug(1, "-_-_- Opening temp file for e-mail: %s\n", tmp);
}
if (!p) {
ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp);
if (ast_strlen_zero(fromaddress)) {
fprintf(p, "From: Asterisk PBX <%s>\n", who);
} else {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Fromaddress template: %s\n", fromaddress);
+ ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress);
/* Allocate a buffer big enough for variable substitution */
int vmlen = strlen(fromaddress) * 3 + 200;
return -1;
}
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata);
+ ast_debug(4, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata);
fprintf(p, "Message-ID: <Asterisk-%d-%s-%d-%s>\n", (unsigned int)rand(), vmu->username, getpid(), who);
len_passdata = strlen(vmu->fullname) * 2 + 3;
fclose(p);
return -1;
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Subject now: %s\n", passdata);
+
+ ast_debug(4, "-_-_- Subject now: %s\n", passdata);
+
} else {
fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain);
- ast_log(LOG_DEBUG, "-_-_- Using default subject for this email \n");
+ ast_debug(1, "-_-_- Using default subject for this email \n");
}
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
pbx_substitute_variables_helper(ast, template->body, passdata, vmlen);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Message now: %s\n-----\n", passdata);
+ ast_debug(3, "Message now: %s\n-----\n", passdata);
fprintf(p, "%s\n", passdata);
} else
ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
"in mailbox %s from %s, on %s so you might\n"
"want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname,
dur, vmu->username, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Using default message body (no template)\n-----\n");
+ ast_debug(3, "Using default message body (no template)\n-----\n");
}
/* Eww. We want formats to tell us their own MIME type */
if (template->attachment) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Attaching file to message: %s\n", fname);
+ ast_debug(3, "-_-_- Attaching file to message: %s\n", fname);
char *ctype = "audio/x-";
if (!strcasecmp(format, "ogg"))
ctype = "application/";
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug) {
- ast_log(LOG_DEBUG, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Actual command used: %s\n", tmp2);
- }
+ ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
+ ast_debug(3, "-_-_- Actual command used: %s\n", tmp2);
if (ast)
ast_channel_free(ast);
return 0;
return -1;
}
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest);
+ ast_debug(2, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest);
return 0;
}
int res;
char fn[PATH_MAX];
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Still preparing to play message ...\n");
+ ast_debug(2, "-_-_- Still preparing to play message ...\n");
snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username);
int numericusername = 1;
char *i = username;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- No personal prompts. Using default prompt set for language\n");
+ ast_debug(2, "-_-_- No personal prompts. Using default prompt set for language\n");
while (*i) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Numeric? Checking %c\n", *i);
+ ast_debug(2, "-_-_- Numeric? Checking %c\n", *i);
if (!isdigit(*i)) {
numericusername = FALSE;
break;
{
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Deleting voicemail file %s\n", file);
+ ast_debug(1, "-_-_- Deleting voicemail file %s\n", file);
res = unlink(file); /* Remove the meta data file */
res |= ast_filedelete(file, NULL); /* remove the media file */
vmu->username, vmu->domain,
chan->cid.cid_name, chan->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing: %s\n", arguments);
-
+ ast_debug(1, "Executing: %s\n", arguments);
ast_safe_system(arguments);
}
if (!ast_strlen_zero(etemplate->locale)) {
char *newlocale;
ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale));
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- 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);
if (newlocale == NULL) {
ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale);
/* Read counter if available */
counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER");
- if (option_debug > 1) {
- if (ast_strlen_zero(counter))
- ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER not found\n");
- else
- ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter);
+ if (ast_strlen_zero(counter)) {
+ ast_debug(2, "-_-_- MVM_COUNTER not found\n");
+ } else {
+ ast_debug(2, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter);
}
res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter);
/* If we have no user directory, use generic temporary directory */
if (!userdir) {
create_dirpath(tmpdir, sizeof(tmpdir), "0000_minivm_temp", "mediafiles", "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating temporary directory %s\n", tmpdir);
+ ast_debug(3, "Creating temporary directory %s\n", tmpdir);
}
/* OEJ XXX Maybe this can be turned into a log file? Hmm. */
/* Store information */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Open file for metadata: %s\n", tmptxtfile);
+ ast_debug(2, "Open file for metadata: %s\n", tmptxtfile);
res = play_record_review(chan, NULL, tmptxtfile, global_vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain);
}
fclose(txt); /* Close log file */
if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
+ ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n");
unlink(tmptxtfile);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED))
// /* Go ahead and delete audio files from system, they're not needed any more */
// if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
// ast_filedelete(tmptxtfile, NULL);
-// if (option_debug > 1)
-// ast_log(LOG_DEBUG, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile);
+// /* Even not being used at the moment, it's better to convert ast_log to ast_debug anyway */
+// ast_debug(2, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile);
// }
if (res > 0)
ast_module_user_remove(u);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain);
+ ast_debug(1, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain);
if (!(vmu = find_account(domain, username, TRUE))) {
ast_log(LOG_ERROR, "Could not allocate memory. \n");
/* Check for temporary greeting - it overrides busy and unavail */
snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", MVM_SPOOL_DIR, vmu->domain, username);
if (!(res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "temp"))) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Temporary message directory does not exist, using default (%s)\n", tempfile);
+ ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile);
ast_copy_string(prefile, tempfile, sizeof(prefile));
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Preparing to play message ...\n");
+ ast_debug(2, "-_-_- Preparing to play message ...\n");
/* Check current or macro-calling context for special extensions */
if (ast_test_flag(vmu, MVM_OPERATOR)) {
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ ast_debug(2, "%s doesn't exist, doing what we can\n", prefile);
res = invent_message(chan, vmu->domain, username, ast_test_flag(&leave_options, OPT_BUSY_GREETING), ecodes);
}
if (res < 0) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ ast_debug(2, "Hang up during prefile playback\n");
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu);
if (ast_fileexists(filename, NULL, NULL) > 0) {
res = vm_delete(filename);
if (res) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Can't delete file: %s\n", filename);
+ ast_debug(2, "-_-_- Can't delete file: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED");
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Deleted voicemail file :: %s \n", filename);
+ ast_debug(2, "-_-_- Deleted voicemail file :: %s \n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "SUCCESS");
}
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Filename does not exist: %s\n", filename);
+ ast_debug(2, "-_-_- Filename does not exist: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED");
}
/* Maybe we should check the result of play_record_review ? */
cmd = play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, FALSE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recorded new %s message in %s (duration %d)\n", message, filename, duration);
+ ast_debug(1, "Recorded new %s message in %s (duration %d)\n", message, filename, duration);
if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu);
char *username;
char accbuf[BUFSIZ];
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name);
+ ast_debug(3, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name);
ast_copy_string(accbuf, name, sizeof(accbuf));
username = accbuf;
return 0;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating static account for user %s domain %s\n", username, domain);
+ ast_debug(3, "Creating static account for user %s domain %s\n", username, domain);
/* Allocate user account */
vmu = ast_calloc(1, sizeof(*vmu));
populate_defaults(vmu);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "...Configuring account %s\n", name);
+ ast_debug(3, "...Configuring account %s\n", name);
while (var) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name);
+ ast_debug(3, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "serveremail")) {
ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail));
} else if (!strcasecmp(var->name, "email")) {
}
var = var->next;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "...Linking account %s\n", name);
+ ast_debug(3, "...Linking account %s\n", name);
AST_LIST_LOCK(&minivm_accounts);
AST_LIST_INSERT_TAIL(&minivm_accounts, vmu, list);
global_stats.voicemailaccounts++;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : "");
+ ast_debug(2, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : "");
return 0;
}
fclose(fi);
messagebody = ast_calloc(1, strlen(buf + 1));
ast_copy_string(messagebody, buf, strlen(buf) + 1);
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "---> Size of allocation %d\n", (int) strlen(buf + 1) );
- ast_log(LOG_DEBUG, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody);
- }
+ ast_debug(4, "---> Size of allocation %d\n", (int) strlen(buf + 1) );
+ ast_debug(4, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody);
return messagebody;
}
message_destroy_list(); /* Destroy list of voicemail message templates */
timezone_destroy_list(); /* Destroy list of timezones */
vmaccounts_destroy_list(); /* Destroy list of voicemail accounts */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Destroyed memory objects...\n");
+ ast_debug(2, "Destroyed memory objects...\n");
/* First, set some default settings */
global_externnotify[0] = '\0';
return 0;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Loaded configuration file, now parsing\n");
+ ast_debug(2, "-_-_- Loaded configuration file, now parsing\n");
/* General settings */
cat = ast_category_browse(cfg, NULL);
while (cat) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Found configuration section [%s]\n", cat);
+ ast_debug(3, "-_-_- Found configuration section [%s]\n", cat);
if (!strcasecmp(cat, "general")) {
/* Nothing right now */
error += apply_general_options(ast_variable_browse(cfg, cat));
minivmlogfile = fopen(global_logfile, "a");
if(!minivmlogfile)
ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno));
- if (option_debug > 2 && minivmlogfile)
- ast_log(LOG_DEBUG, "-_-_- Opened log file %s \n", global_logfile);
+ if (minivmlogfile)
+ ast_debug(3, "-_-_- Opened log file %s \n", global_logfile);
}
return 0;
counterfile = fopen(filename, "r");
if (counterfile) {
if(fgets(readbuf, sizeof(readbuf), counterfile)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Read this string from counter file: %s\n", readbuf);
+ ast_debug(3, "Read this string from counter file: %s\n", readbuf);
old = counter = atoi(readbuf);
}
fclose(counterfile);
switch (operand) {
case 0: /* Read only */
ast_unlock_path(directory);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter);
+ ast_debug(2, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter);
return counter;
break;
case 1: /* Set new value */
fprintf(counterfile, "%d\n\n", counter);
fclose(counterfile);
ast_unlock_path(directory);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter);
+ ast_debug(2, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter);
return counter;
}
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more mp3\n");
+ ast_debug(1, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more mp3\n");
+ ast_debug(1, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
} else {
snprintf(p->privatekey, sizeof(p->privatekey), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: privatekey '%s'\n", p->privatekey);
+ ast_debug(1, "OSP: privatekey '%s'\n", p->privatekey);
} else if (!strcasecmp(v->name, "localcert")) {
if (v->value[0] == '/') {
ast_copy_string(p->localcert, v->value, sizeof(p->localcert));
} else {
snprintf(p->localcert, sizeof(p->localcert), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert);
+ ast_debug(1, "OSP: localcert '%s'\n", p->localcert);
} else if (!strcasecmp(v->name, "cacert")) {
if (p->cacount < OSP_MAX_CERTS) {
if (v->value[0] == '/') {
} else {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
} else {
ast_log(LOG_WARNING, "OSP: Too many CA Certificates at line %d\n", v->lineno);
} else if (!strcasecmp(v->name, "servicepoint")) {
if (p->spcount < OSP_MAX_SRVS) {
ast_copy_string(p->srvpoints[p->spcount], v->value, sizeof(p->srvpoints[0]));
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
+ ast_debug(1, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
p->spcount++;
} else {
ast_log(LOG_WARNING, "OSP: Too many Service Points at line %d\n", v->lineno);
} else if (!strcasecmp(v->name, "maxconnections")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_MAXCONNECTIONS) && (t <= OSP_MAX_MAXCONNECTIONS)) {
p->maxconnections = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: maxconnections '%d'\n", t);
+ ast_debug(1, "OSP: maxconnections '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: maxconnections should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_MAXCONNECTIONS, OSP_MAX_MAXCONNECTIONS, v->value, v->lineno);
} else if (!strcasecmp(v->name, "retrydelay")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYDELAY) && (t <= OSP_MAX_RETRYDELAY)) {
p->retrydelay = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: retrydelay '%d'\n", t);
+ ast_debug(1, "OSP: retrydelay '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_RETRYDELAY, OSP_MAX_RETRYDELAY, v->value, v->lineno);
} else if (!strcasecmp(v->name, "retrylimit")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYLIMIT) && (t <= OSP_MAX_RETRYLIMIT)) {
p->retrylimit = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: retrylimit '%d'\n", t);
+ ast_debug(1, "OSP: retrylimit '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_RETRYLIMIT, OSP_MAX_RETRYLIMIT, v->value, v->lineno);
} else if (!strcasecmp(v->name, "timeout")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_TIMEOUT) && (t <= OSP_MAX_TIMEOUT)) {
p->timeout = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: timeout '%d'\n", t);
+ ast_debug(1, "OSP: timeout '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_TIMEOUT, OSP_MAX_TIMEOUT, v->value, v->lineno);
}
} else if (!strcasecmp(v->name, "source")) {
ast_copy_string(p->source, v->value, sizeof(p->source));
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", p->source);
+ ast_debug(1, "OSP: source '%s'\n", p->source);
} else if (!strcasecmp(v->name, "authpolicy")) {
if ((sscanf(v->value, "%d", &t) == 1) && ((t == OSP_AUTH_NO) || (t == OSP_AUTH_YES) || (t == OSP_AUTH_EXCLUSIVE))) {
p->authpolicy = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", t);
+ ast_debug(1, "OSP: authpolicy '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: authpolicy should be %d, %d or %d, not '%s' at line %d\n",
OSP_AUTH_NO, OSP_AUTH_YES, OSP_AUTH_EXCLUSIVE, v->value, v->lineno);
} else if (!strcasecmp(v->name, "defaultprotocol")) {
if (!strcasecmp(v->value, OSP_PROT_SIP)) {
p->defaultprotocol = OSP_PROT_SIP;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else if (!strcasecmp(v->value, OSP_PROT_H323)) {
p->defaultprotocol = OSP_PROT_H323;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else if (!strcasecmp(v->value, OSP_PROT_IAX)) {
p->defaultprotocol = OSP_PROT_IAX;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else {
ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s, or %s not '%s' at line %d\n",
OSP_PROT_SIP, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_OTHER, v->value, v->lineno);
if (p->cacount < 1) {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s-cacert.pem", ast_config_AST_KEY_DIR, provider);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
}
for (i = 0; i < p->cacount; i++) {
ast_free(p);
res = -1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
+ ast_debug(1, "OSP: provider '%s'\n", provider);
ast_mutex_lock(&osplock);
p->next = ospproviders;
ospproviders = p;
while(p) {
if (!strcasecmp(p->name, name)) {
*provider = p;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: find provider '%s'\n", name);
+ ast_debug(1, "OSP: find provider '%s'\n", name);
res = 1;
break;
}
if (!strcasecmp(p->name, provider)) {
error = OSPPTransactionNew(p->handle, transaction);
if (error == OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
+ ast_debug(1, "OSP: transaction '%d'\n", *transaction);
ast_copy_string(source, p->source, sourcesize);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
+ ast_debug(1, "OSP: source '%s'\n", source);
res = 1;
} else {
*transaction = OSP_INVALID_HANDLE;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to create transaction handle, error '%d'\n", error);
res = -1;
}
break;
NULL,
osp_tokenformat);
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
+ ast_debug(1, "OSP: Unable to validate inbound token\n");
res = -1;
} else if (authorised) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Authorised\n");
+ ast_debug(1, "OSP: Authorised\n");
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
+ ast_debug(1, "OSP: Unauthorised\n");
res = 0;
}
int error;
if (strlen(destination) <= 2) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
+ ast_debug(1, "OSP: Wrong destination format '%s'\n", destination);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
if ((error = OSPPTransactionIsDestOSPEnabled(result->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination OSP version, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
}
if ((error = OSPPTransactionGetDestNetworkId(result->outhandle, result->networkid)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination network ID, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination network ID, error '%d'\n", error);
result->networkid[0] = '\0';
}
if ((error = OSPPTransactionGetDestProtocol(result->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination protocol, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
result->token[0] = '\0';
result->networkid[0] = '\0';
destination[strlen(destination) - 1] = '\0';
switch(protocol) {
case OSPE_DEST_PROT_H323_SETUP:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_H323);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_H323);
ast_copy_string(result->tech, OSP_TECH_H323, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_SIP:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_SIP);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_SIP);
ast_copy_string(result->tech, OSP_TECH_SIP, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_IAX:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_IAX);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_IAX);
ast_copy_string(result->tech, OSP_TECH_IAX, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
break;
case OSPE_DEST_PROT_UNDEFINED:
case OSPE_DEST_PROT_UNKNOWN:
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: unknown/undefined protocol '%d'\n", protocol);
- ast_log(LOG_DEBUG, "OSP: use default protocol '%s'\n", provider->defaultprotocol);
- }
+ ast_debug(1, "OSP: unknown/undefined protocol '%d'\n", protocol);
+ ast_debug(1, "OSP: use default protocol '%s'\n", provider->defaultprotocol);
+
ast_copy_string(result->tech, provider->defaultprotocol, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
*timelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if (ast_strlen_zero(token)) {
res = 0;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
*transaction = OSP_INVALID_HANDLE;
res = 0;
} else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) {
if (ast_strlen_zero(token)) {
res = 1;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
*transaction = OSP_INVALID_HANDLE;
res = 0;
} else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) {
result->outtimelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if ((res = osp_create_transaction(provider, &result->outhandle, sizeof(source), source)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
result->outhandle = OSP_INVALID_HANDLE;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
}
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");
+ ast_debug(1, "OSP: Unable to request authorization\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
}
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
}
&tokenlen,
token);
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get first route\n");
+ ast_debug(1, "OSP: Unable to get first route\n");
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
return 1;
}
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
result->outtimelimit = OSP_DEF_TIMELIMIT;
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
+
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
break;
} else if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
result->outtimelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if (result->outhandle == OSP_INVALID_HANDLE) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n");
+ ast_debug(1, "OSP: Transaction handle undefined\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
reason = asterisk2osp(cause);
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
+
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
res = 1;
break;
} else if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
result->token[0] = '\0';
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
&dummy,
NULL);
if (error == OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Usage reported\n");
+ ast_debug(1, "OSP: Usage reported\n");
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to report usage, error '%d'\n", error);
res = -1;
}
OSPPTransactionDelete(handle);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
-
- }
+ ast_debug(1, "OSPAuth: provider '%s'\n", provider);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
- ast_log(LOG_DEBUG, "OSPAuth: token size '%zd'\n", strlen(token));
- }
+ ast_debug(1, "OSPAuth: source '%s'\n", source);
+ ast_debug(1, "OSPAuth: token size '%zd'\n", strlen(token));
if ((res = osp_auth(provider, &handle, source, chan->cid.cid_num, chan->exten, token, &timelimit)) > 0) {
status = AST_OSP_SUCCESS;
snprintf(buffer, sizeof(buffer), "%d", handle);
pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
+ ast_debug(1, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", timelimit);
pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
+ ast_debug(1, "OSPAuth: %s\n", status);
if(res <= 0) {
res = -1;
AST_STANDARD_APP_ARGS(args, tmp);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
+ ast_debug(1, "OSPLookup: exten '%s'\n", args.exten);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ ast_debug(1, "OSPlookup: provider '%s'\n", provider);
if (args.options) {
if (strchr(args.options, 'h')) {
callidtypes |= OSP_CALLID_IAX;
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPLookup: call id types '%d'\n", callidtypes);
- }
+ ast_debug(1, "OSPLookup: call id types '%d'\n", callidtypes);
result.inhandle = OSP_INVALID_HANDLE;
result.intimelimit = OSP_DEF_TIMELIMIT;
srcdev = ast_var_value(current);
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle);
- ast_log(LOG_DEBUG, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit);
- ast_log(LOG_DEBUG, "OSPLookup: OSPINNETWORKID '%s'\n", netid);
- ast_log(LOG_DEBUG, "OSPLookup: source device '%s'\n", srcdev);
- }
+ ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle);
+ ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit);
+ ast_debug(1, "OSPLookup: OSPINNETWORKID '%s'\n", netid);
+ ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
if ((cres = ast_autoservice_start(chan)) < 0) {
ast_module_user_remove(u);
snprintf(buffer, sizeof(buffer), "%d", result.outhandle);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
+ ast_debug(1, "OSPLookup: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
+ ast_debug(1, "OSPLookup: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLED '%s'\n", result.called);
+ ast_debug(1, "OSPLookup: OSPCALLED '%s'\n", result.called);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
+ ast_debug(1, "OSPLookup: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ ast_debug(1, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", callidtypes);
pbx_builtin_setvar_helper(chan, "OSPOUTCALLIDTYPES", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
+ ast_debug(1, "OSPLookup: %s\n", status);
if (!strcasecmp(result.tech, OSP_TECH_H323)) {
if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, OSP_TECH_IAX)) {
snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called);
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
+ ast_debug(1, "OSPNext: cause '%d'\n", cause);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ ast_debug(1, "OSPlookup: provider '%s'\n", provider);
result.inhandle = OSP_INVALID_HANDLE;
result.outhandle = OSP_INVALID_HANDLE;
}
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle);
- ast_log(LOG_DEBUG, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%d'\n", result.numresults);
- }
+ ast_debug(1, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle);
+ ast_debug(1, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle);
+ ast_debug(1, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit);
+ ast_debug(1, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
+ ast_debug(1, "OSPNext: OSPRESULTS '%d'\n", result.numresults);
if ((res = osp_next(provider, cause, &result)) > 0) {
status = AST_OSP_SUCCESS;
}
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
+ ast_debug(1, "OSPNext: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
+ ast_debug(1, "OSPNext: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLED'%s'\n", result.called);
+ ast_debug(1, "OSPNext: OSPCALLED'%s'\n", result.called);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
+ ast_debug(1, "OSPNext: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ ast_debug(1, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
+ ast_debug(1, "OSPNext: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
+ ast_debug(1, "OSPNext: %s\n", status);
if (!strcasecmp(result.tech, OSP_TECH_H323)) {
if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, OSP_TECH_IAX)) {
snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called);
}
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
- ast_log(LOG_DEBUG, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
- ast_log(LOG_DEBUG, "OSPFinish: recorded '%d'\n", recorded);
- }
+ ast_debug(1, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
+ ast_debug(1, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
+ ast_debug(1, "OSPFinish: recorded '%d'\n", recorded);
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
+ ast_debug(1, "OSPFinish: cause '%d'\n", cause);
if (chan->cdr) {
start = chan->cdr->start.tv_sec;
connect = 0;
end = 0;
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPFinish: start '%ld'\n", start);
- ast_log(LOG_DEBUG, "OSPFinish: connect '%ld'\n", connect);
- ast_log(LOG_DEBUG, "OSPFinish: end '%ld'\n", end);
- }
+ ast_debug(1, "OSPFinish: start '%ld'\n", start);
+ ast_debug(1, "OSPFinish: connect '%ld'\n", connect);
+ ast_debug(1, "OSPFinish: end '%ld'\n", end);
release = chan->_softhangup ? 0 : 1;
if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n");
+ ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n");
}
switch (cause) {
case AST_CAUSE_NORMAL_CLEARING:
break;
}
if (osp_finish(inhandle, recorded, cause, start, connect, end, release) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "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);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
} else {
OSPPInit(0);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware);
+ ast_debug(1, "OSP: osp_hardware '%d'\n", osp_hardware);
t = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "tokenformat");
if (t) {
TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, t);
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
+ ast_debug(1, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
t = ast_category_browse(cfg, NULL);
while(t) {
ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
return 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
+ ast_debug(1, "OSP: osp_initialized '%d'\n", osp_initialized);
return 1;
}
AST_LIST_UNLOCK(&interfaces);
if (!curint) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_debug(3, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_debug(1, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
return 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
+ ast_debug(1, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
if ((curint = ast_calloc(1, sizeof(*curint)))) {
ast_copy_string(curint->interface, interface, sizeof(curint->interface));
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
if (!strcasecmp(curint->interface, interface)) {
if (!interface_exists_global(interface)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
+ ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
AST_LIST_REMOVE_CURRENT(&interfaces, list);
ast_free(curint);
}
q->announcefrequency = atoi(val);
} else if (!strcasecmp(param, "min-announce-frequency")) {
q->minannouncefrequency = atoi(val);
- ast_log(LOG_DEBUG, "%s=%s for queue '%s'\n", param, val, q->name);
+ ast_debug(1, "%s=%s for queue '%s'\n", param, val, q->name);
} else if (!strcasecmp(param, "announce-round-seconds")) {
q->roundingseconds = atoi(val);
/* Rounding to any other values just doesn't make sense... */
/*! \note Hmm, can't seem to distinguish a DB failure from a not
found condition... So we might delete an in-core queue
in case of DB failure. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
+ ast_debug(1, "Queue %s not found in realtime.\n", queuename);
q->dead = 1;
/* Delete if unused (else will be deleted when last caller leaves). */
S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */
S_OR(qe->chan->cid.cid_name, "unknown"),
q->name, qe->pos, q->count, qe->chan->uniqueid );
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
+ ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
}
ast_mutex_unlock(&q->lock);
AST_LIST_UNLOCK(&queues);
manager_event(EVENT_FLAG_CALL, "Leave",
"Channel: %s\r\nQueue: %s\r\nCount: %d\r\nUniqueid: %s\r\n",
qe->chan->name, q->name, q->count, qe->chan->uniqueid);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name );
+ ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name );
/* Take us out of the queue */
if (prev)
prev->next = cur->next;
if (strcmp(mem->interface, member->interface))
continue;
- if (option_debug)
- ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
+ ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
if (q->weight > rq->weight) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
+ ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
found = 1;
break;
}
/* on entry here, we know that tmp->chan == NULL */
if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wrapuptime not yet expired for %s\n", tmp->interface);
+ ast_debug(1, "Wrapuptime not yet expired for %s\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
}
if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s in use, can't receive call\n", tmp->interface);
+ ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
}
if (tmp->member->paused) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s paused, can't receive call\n", tmp->interface);
+ ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
return 0;
}
if (use_weight && compare_weight(qe->parent,tmp->member)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
+ ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
/* Place the call, but don't wait on the answer */
if ((res = ast_call(tmp->chan, location, 0))) {
/* Again, keep going even if there's an error */
- if (option_debug)
- ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
+ ast_debug(1, "ast call on peer returned %d\n", res);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", tmp->interface);
do_hang(tmp);
while (ret == 0) {
struct callattempt *best = find_best(outgoing);
if (!best) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Nobody left to try ringing in queue\n");
+ ast_debug(1, "Nobody left to try ringing in queue\n");
break;
}
if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
/* Ring everyone who shares this best metric (for ringall) */
for (cur = outgoing; cur; cur = cur->q_next) {
if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) {
- if (option_debug)
- ast_log(LOG_DEBUG, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric);
+ ast_debug(1, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric);
ring_entry(qe, cur, busies);
}
}
} else {
/* Ring just the best channel */
- if (option_debug)
- ast_log(LOG_DEBUG, "Trying '%s' with metric %d\n", best->interface, best->metric);
+ ast_debug(1, "Trying '%s' with metric %d\n", best->interface, best->metric);
ring_entry(qe, best, busies);
}
if (best->chan) /* break out with result = 1 */
if (best) {
/* Ring just the best channel */
- if (option_debug)
- ast_log(LOG_DEBUG, "Next is '%s' with metric %d\n", best->interface, best->metric);
+ ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric);
qe->parent->rrpos = best->metric % 1000;
} else {
/* Just increment rrpos */
}
if (pos == 1 /* not found */) {
if (numlines == (numbusies + numnochan)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Everyone is busy at this time\n");
+ ast_debug(1, "Everyone is busy at this time\n");
} else {
ast_log(LOG_NOTICE, "No one is answering queue '%s' (%d/%d/%d)\n", queue, numlines, numbusies, numnochan);
}
/* Ignore going off hook */
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
}
}
ast_frfree(f);
ch = qe->parent->head;
/* If we are now at the top of the head, break out */
if (ch == qe) {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's our turn (%s).\n", qe->chan->name);
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's not our turn (%s).\n", qe->chan->name);
res = 0;
}
ch = qe->parent->head;
if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl);
+ ast_debug(1, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl);
avl = 1;
} else {
for (cur = qe->parent->members; cur; cur = cur->next) {
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "There are %d available members.\n", avl);
+ ast_debug(1, "There are %d available members.\n", avl);
while ((idx < avl) && (ch) && (ch != qe)) {
idx++;
/* If the queue entry is within avl [the number of available members] calls from the top ... */
if (ch && idx < avl) {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's our turn (%s).\n", qe->chan->name);
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's not our turn (%s).\n", qe->chan->name);
res = 0;
}
if (use_weight)
AST_LIST_LOCK(&queues);
ast_mutex_lock(&qe->parent->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "%s is trying to call a queue member.\n",
+ ast_debug(1, "%s is trying to call a queue member.\n",
qe->chan->name);
ast_copy_string(queuename, qe->parent->name, sizeof(queuename));
cur = qe->parent->members;
} else {
res = digit;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Nobody answered.\n", qe->chan->name);
+ ast_debug(1, "%s: Nobody answered.\n", qe->chan->name);
} else { /* peer is valid */
/* Ah ha! Someone answered within the desired timeframe. Of course after this
we will always return with -1 so that it is hung up properly after the
/* Begin Monitoring */
if (qe->parent->monfmt && *qe->parent->monfmt) {
if (!qe->parent->montype) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting Monitor as requested.\n");
+ ast_debug(1, "Starting Monitor as requested.\n");
monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))
which = qe->chan;
if (qe->parent->monjoin)
ast_monitor_setjoinfiles(which, 1);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting MixMonitor as requested.\n");
+ ast_debug(1, "Starting MixMonitor as requested.\n");
monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
if (!monitorfilename) {
if (qe->chan->cdr)
else
snprintf(mixmonargs, sizeof(mixmonargs)-1, "%s|b%s", tmpid2, monitor_options);
- if (option_debug)
- ast_log(LOG_DEBUG, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
+ ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
ret = pbx_exec(qe->chan, mixmonapp, mixmonargs);
/* Drop out of the queue at this point, to prepare for next caller */
leave_queue(qe);
if (!ast_strlen_zero(url) && ast_channel_supports_html(peer)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
+ ast_debug(1, "app_queue: sendurl=%s.\n", url);
ast_channel_sendurl(peer, url);
}
}
if (!ast_strlen_zero(macroexec)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: macro=%s.\n", macroexec);
+ ast_debug(1, "app_queue: macro=%s.\n", macroexec);
res = ast_autoservice_start(qe->chan);
if (res) {
if (app) {
res = pbx_exec(qe->chan, app, macroexec);
- if (option_debug)
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ ast_debug(1, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
}
if (!ast_strlen_zero(agi)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: agi=%s.\n", agi);
+ ast_debug(1, "app_queue: agi=%s.\n", agi);
app = pbx_findapp("agi");
if (app) {
agiexec = ast_strdupa(agi);
if ((mem = interface_exists(q, interface))) {
found++;
if (mem->paused == paused) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
+ ast_debug(1, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
}
mem->paused = paused;
if (ast_strlen_zero(membername))
membername = interface;
- if (option_debug)
- ast_log(LOG_DEBUG, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused);
+ ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused);
if (add_to_queue(queue_name, interface, membername, penalty, paused, 0) == RES_OUTOFMEMORY) {
ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n");
res = 0;
break;
case RES_EXISTS:
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
+ ast_debug(1, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE");
res = 0;
break;
user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO");
if (user_priority) {
if (sscanf(user_priority, "%d", &prio) == 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Got priority %d from ${QUEUE_PRIO}.\n",
- chan->name, prio);
+ ast_debug(1, "%s: Got priority %d from ${QUEUE_PRIO}.\n", chan->name, prio);
} else {
ast_log(LOG_WARNING, "${QUEUE_PRIO}: Invalid value (%s), channel %s.\n",
user_priority, chan->name);
prio = 0;
}
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "NO QUEUE_PRIO variable found. Using default.\n");
+ ast_debug(3, "NO QUEUE_PRIO variable found. Using default.\n");
prio = 0;
}
/* Get the maximum penalty from the variable ${QUEUE_MAX_PENALTY} */
if ((max_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MAX_PENALTY"))) {
if (sscanf(max_penalty_str, "%d", &max_penalty) == 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n",
- chan->name, max_penalty);
+ ast_debug(1, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", chan->name, max_penalty);
} else {
ast_log(LOG_WARNING, "${QUEUE_MAX_PENALTY}: Invalid value (%s), channel %s.\n",
max_penalty_str, chan->name);
if (args.options && (strchr(args.options, 'c')))
qcontinue = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
- args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
+ ast_debug(1, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
+ args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
qe.chan = chan;
qe.prio = prio;
* of the queue, go and check for our turn again.
*/
if (!is_our_turn(&qe)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Darn priorities, going back in queue (%s)!\n",
- qe.chan->name);
+ ast_debug(1, "Darn priorities, going back in queue (%s)!\n", qe.chan->name);
goto check_turns;
}
}
if (!q->count)
destroy_queue(q);
else
- ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
+ ast_debug(1, "XXX Leaking a little memory :( XXX\n");
} else {
ast_mutex_lock(&q->lock);
for (cur = q->members; cur; cur = cur->next)
ast_frfree(f);
}
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup\n");
+ ast_debug(1, "Got hangup\n");
res = -1;
}
return DC_ERROR;
ast_copy_string(digitbuf, digits, sizeof(digitbuf));
-
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf);
+ ast_debug(1, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf);
switch (myatoi(param)) {
case 1: /* Link off */
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Autopatch up\n");
+ ast_debug(1, "@@@@ Autopatch up\n");
if (!myrpt->callmode) {
/* Set defaults */
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Autopatch down\n");
+ ast_debug(1, "@@@@ Autopatch down\n");
rpt_mutex_lock(&myrpt->lock);
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
+ ast_debug(1, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
switch (myatoi(param)) {
case 1: /* System ID */
if ((!myrpt->remote) && (!myrpt->enable))
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
+ ast_debug(1, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
mychannel = myrpt->remchannel;
AST_APP_ARG(param);
);
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Digits collected: %s, source: %d\n", digits, command_source);
+ ast_debug(1, "@@@@ Digits collected: %s, source: %d\n", digits, command_source);
if (command_source == SOURCE_DPHONE) {
if (!myrpt->p.dphone_functions)
stringp = ast_strdupa(vp->value);
AST_NONSTANDARD_APP_ARGS(args, stringp, ',');
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)"));
+ ast_debug(1, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)"));
/* Look up the action */
for (i = 0; i < (sizeof(function_table) / sizeof(struct function_table_tag)); i++) {
if (!strncasecmp(args.action, function_table[i].action, strlen(args.action)))
break;
}
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ table index i = %d\n", i);
+ ast_debug(1, "@@@@ table index i = %d\n", i);
if (i == (sizeof(function_table) / sizeof(struct function_table_tag))) {
/* Error, action not in table */
return DC_ERROR;
}
if (function_table[i].function == NULL) {
/* Error, function undefined */
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ NULL for action: %s\n", args.action);
+ ast_debug(1, "@@@@ NULL for action: %s\n", args.action);
return DC_ERROR;
}
functiondigits = digits + strlen(vp->name);
int i;
struct zt_radio_param prm;
- if (debug) {
- char *buf = alloca(30 + txbytes * 3);
- int len;
- ast_copy_string(buf, "String output was: ", 30 + txbytes * 3);
- len = strlen(buf);
- for (i = 0; i < txbytes; i++)
- len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]);
- strcat(buf + len, "\n");
- ast_log(LOG_DEBUG, "%s", buf);
- }
+ char *buf = alloca(30 + txbytes * 3);
+ int len;
+ ast_copy_string(buf, "String output was: ", 30 + txbytes * 3);
+ len = strlen(buf);
+ for (i = 0; i < txbytes; i++)
+ len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]);
+ strcat(buf + len, "\n");
+ ast_debug(1, "%s", buf);
prm.radpar = ZT_RADPAR_REMMODE;
if (asciiflag)
/* if no decimal, is invalid */
if (s == NULL) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Frequency needs a decimal\n");
+ ast_debug(1, "@@@@ Frequency needs a decimal\n");
return -1;
}
*s++ = 0;
if (strlen(tmp) < 2) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad MHz digits: %s\n", tmp);
+ ast_debug(1, "@@@@ Bad MHz digits: %s\n", tmp);
return -1;
}
if (strlen(s) < 3) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad KHz digits: %s\n", s);
+ ast_debug(1, "@@@@ Bad KHz digits: %s\n", s);
return -1;
}
if ((s[2] != '0') && (s[2] != '5')) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ KHz must end in 0 or 5: %c\n", s[2]);
+ ast_debug(1, "@@@@ KHz must end in 0 or 5: %c\n", s[2]);
return -1;
}
band = rbi_mhztoband(tmp);
if (band == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad Band: %s\n", tmp);
+ ast_debug(1, "@@@@ Bad Band: %s\n", tmp);
return -1;
}
txpl = rbi_pltocode(myrpt->txpl);
if (txpl == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad TX PL: %s\n", myrpt->txpl);
+ ast_debug(1, "@@@@ Bad TX PL: %s\n", myrpt->txpl);
return -1;
}
int fd, m, d;
fd = 0;
- if (debug)
- ast_log(LOG_DEBUG, "New frequency: %s\n", newfreq);
+ ast_debug(1, "New frequency: %s\n", newfreq);
if (split_freq(&m, &d, newfreq))
return -1;
{
int res;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ lock on\n");
+ ast_debug(1, "@@@@ lock on\n");
res = simple_command_ft897(myrpt, 0x00); /* LOCK on */
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ ptt off\n");
+ ast_debug(1, "@@@@ ptt off\n");
if (!res)
res = simple_command_ft897(myrpt, 0x88); /* PTT off */
- if (debug)
- ast_log(LOG_DEBUG, "Modulation mode\n");
+ ast_debug(1, "Modulation mode\n");
if (!res)
res = set_mode_ft897(myrpt, myrpt->remmode); /* Modulation mode */
- if (debug)
- ast_log(LOG_DEBUG, "Split off\n");
+ ast_debug(1, "Split off\n");
if (!res)
simple_command_ft897(myrpt, 0x82); /* Split off */
- if (debug)
- ast_log(LOG_DEBUG, "Frequency\n");
+ ast_debug(1, "Frequency\n");
if (!res)
res = set_freq_ft897(myrpt, myrpt->freq); /* Frequency */
if ((myrpt->remmode == REM_MODE_FM)) {
- if (debug)
- ast_log(LOG_DEBUG, "Offset\n");
+ ast_debug(1, "Offset\n");
if (!res)
res = set_offset_ft897(myrpt, myrpt->offset); /* Offset if FM */
if ((!res)&&(myrpt->rxplon || myrpt->txplon)) {
- if (debug)
- ast_log(LOG_DEBUG, "CTCSS tone freqs.\n");
+ ast_debug(1, "CTCSS tone freqs.\n");
res = set_ctcss_freq_ft897(myrpt, myrpt->txpl, myrpt->rxpl); /* CTCSS freqs if CTCSS is enabled */
}
if (!res) {
- if (debug)
- ast_log(LOG_DEBUG, "CTCSS mode\n");
+ ast_debug(1, "CTCSS mode\n");
res = set_ctcss_mode_ft897(myrpt, myrpt->txplon, myrpt->rxplon); /* CTCSS mode */
}
}
if ((myrpt->remmode == REM_MODE_USB)||(myrpt->remmode == REM_MODE_LSB)) {
- if (debug)
- ast_log(LOG_DEBUG, "Clarifier off\n");
+ ast_debug(1, "Clarifier off\n");
simple_command_ft897(myrpt, 0x85); /* Clarifier off if LSB or USB */
}
return res;
{
int m, d;
- if (debug)
- ast_log(LOG_DEBUG, "Before bump: %s\n", myrpt->freq);
+ ast_debug(1, "Before bump: %s\n", myrpt->freq);
if (split_freq(&m, &d, myrpt->freq))
return -1;
}
if (check_freq_ft897(m, d, NULL)) {
- if (debug)
- ast_log(LOG_DEBUG, "Bump freq invalid\n");
+ ast_debug(1, "Bump freq invalid\n");
return -1;
}
snprintf(myrpt->freq, MAXREMSTR, "%d.%05d", m, d);
-
- if (debug)
- ast_log(LOG_DEBUG, "After bump: %s\n", myrpt->freq);
+ ast_debug(1, "After bump: %s\n", myrpt->freq);
return set_freq_ft897(myrpt, myrpt->freq);
}
/* Check frequency for validity and establish a default mode */
snprintf(freq, sizeof(freq), "%s.%03d%02d", args.s1, k, ht);
-
- if (debug)
- ast_log(LOG_DEBUG, "New frequency: %s\n", freq);
+ ast_debug(1, "New frequency: %s\n", freq);
split_freq(&mhz, &decimals, freq);
i = strlen(digitbuf) - 1;
if ((j != 1) || (k < 2)|| (l != 1))
break; /* Not yet */
- if (debug)
- ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf);
+ ast_debug(1, "PL digits entered %s\n", digitbuf);
ast_copy_string(tmp, digitbuf, sizeof(tmp));
/* see if we have at least 1 */
i = strlen(digitbuf) - 1;
if ((j != 1) || (k < 2)|| (l != 1))
break; /* Not yet */
- if (debug)
- ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf);
+ ast_debug(1, "PL digits entered %s\n", digitbuf);
ast_copy_string(tmp, digitbuf, sizeof(tmp));
/* see if we have at least 1 */
if (who == myrpt->rxchannel) { /* if it was a read from rx */
f = ast_read(myrpt->rxchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
continue;
} else if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
if ((!lasttx) || (myrpt->p.duplex > 1)) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
myrpt->keyed = 1;
}
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
if ((!lasttx) || (myrpt->p.duplex > 1)) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
if (myrpt->keyed) {
rpt_telemetry(myrpt, UNKEY, NULL);
}
if (who == myrpt->pchannel) { /* if it was a read from pseudo */
f = ast_read(myrpt->pchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
if (who == myrpt->txchannel) { /* if it was a read from tx */
f = ast_read(myrpt->txchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7 )
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
l->lastrx = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
l->lastrx = 0;
}
if (f->subclass == AST_CONTROL_HANGUP) {
rpt_mutex_unlock(&myrpt->lock);
f = ast_read(l->pchan);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
toexit = 1;
rpt_mutex_lock(&myrpt->lock);
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
toexit = 1;
rpt_mutex_lock(&myrpt->lock);
if (who == myrpt->txpchannel) { /* if it was a read from remote tx */
f = ast_read(myrpt->txpchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
ast_free(ll);
}
rpt_mutex_unlock(&myrpt->lock);
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung up channel\n");
+ ast_debug(1, "@@@@ rpt:Hung up channel\n");
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
return NULL;
if (who == chan) { /* if it was a read from incoming */
f = ast_read(chan);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
if (f->frametype == AST_FRAME_DTMF) {
myrpt->remchannel = chan; /* Save copy of channel */
if (handle_remote_phone_dtmf(myrpt, f->subclass, &keyed, phone_mode) == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
if (f->frametype == AST_FRAME_TEXT) {
myrpt->remchannel = chan; /* Save copy of channel */
if (handle_remote_data(myrpt, f->data) == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
keyed = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
keyed = 0;
}
}
if (who == myrpt->rxchannel) { /* if it was a read from radio */
f = ast_read(myrpt->rxchannel);
if (!f) {
- if (debug) ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
ast_write(chan, f);
} else if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ remote rx key\n");
+ ast_debug(8, "@@@@ remote rx key\n");
if (!myrpt->remotetx) {
ast_indicate(chan, AST_CONTROL_RADIO_KEY);
myrpt->remoterx = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ remote rx un-key\n");
+ ast_debug(8, "@@@@ remote rx un-key\n");
if (!myrpt->remotetx) {
ast_indicate(chan, AST_CONTROL_RADIO_UNKEY);
myrpt->remoterx = 0;
/* do this cuz you have to */
f = ast_read(myrpt->txchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
oldframe = AST_LIST_REMOVE_HEAD(oldlist, entries);
AST_LIST_UNLOCK(oldlist);
- if (oldframe)
+ if (oldframe) {
gosub_release_frame(chan, oldframe);
- else if (option_debug)
- ast_log(LOG_DEBUG, "%s called with an empty gosub stack\n", app_pop);
-
+ } else {
+ ast_debug(1, "%s called with an empty gosub stack\n", app_pop);
+ }
return 0;
}
u = ast_module_user_add(chan);
if (!stack_store) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
+ ast_debug(1, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
stack_store = ast_channel_datastore_alloc(&stack_info, NULL);
if (!stack_store) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Gosub will fail.\n");
for (i = 0; i < args2.argc; i++) {
snprintf(argname, sizeof(argname), "ARG%d", i + 1);
pbx_builtin_pushvar_helper(chan, argname, args2.argval[i]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting '%s' to '%s'\n", argname, args2.argval[i]);
+ ast_debug(1, "Setting '%s' to '%s'\n", argname, args2.argval[i]);
}
/* And finally, save our return address */
}
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n",
- tmp, sil, min, max);
+ ast_debug(1, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", tmp, sil, min, max);
if (chan->_state != AST_STATE_UP) {
/* Otherwise answer unless we're supposed to send this while on-hook */
res = ast_answer(chan);
ms = 0;
if ((ms > min) && ((max < 0) || (ms < max))) {
char ms_str[10];
- if (option_debug)
- ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
+ ast_debug(1, "Found qualified token of %d ms\n", ms);
/* Save detected talk time (in milliseconds) */
sprintf(ms_str, "%d", ms );
ast_frfree(fr);
break;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ ast_debug(1, "Found unqualified token of %d ms\n", ms);
}
notsilent = 0;
}
if (!notsilent) {
/* Heard some audio, mark the begining of the token */
start = ast_tvnow();
- if (option_debug)
- ast_log(LOG_DEBUG, "Start of voice token!\n");
+ ast_debug(1, "Start of voice token!\n");
notsilent = 1;
}
}
ast_log(LOG_NOTICE, "No samples were received from the other side!\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
+ ast_debug(1, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
return (noise / samples);
}
/* Transmit client version */
if (!res)
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "Transmit client version\n");
+ ast_debug(1, "Transmit client version\n");
/* Read server version */
- if (option_debug)
- ast_log(LOG_DEBUG, "Read server version\n");
+ ast_debug(1, "Read server version\n");
if (!res)
res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0);
if (res > 0)
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "server version: %s\n", serverver);
+ ast_debug(1, "server version: %s\n", serverver);
if (res > 0)
res = 0;
res = ast_dtmf_stream(chan, NULL, testid, 0);
if (!res)
res = ast_dtmf_stream(chan, NULL, "#", 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "send test identifier: %s\n", testid);
+ ast_debug(1, "send test identifier: %s\n", testid);
if ((res >=0) && (!ast_strlen_zero(testid))) {
/* Make the directory to hold the test results in case it's not there */
if (!res) {
/* Step 1: Wait for "1" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n");
+ ast_debug(1, "TestClient: 2. Wait DTMF 1\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS");
if (res == '1')
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 2: Send "2" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n");
+ ast_debug(1, "TestClient: 2. Send DTMF 2\n");
res = ast_dtmf_stream(chan, NULL, "2", 0);
fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 3: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n");
+ ast_debug(1, "TestClient: 3. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 4: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n");
+ ast_debug(1, "TestClient: 4. Measure noise\n");
res = measurenoise(chan, 5000, "TestClient");
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 5: Wait for "4" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n");
+ ast_debug(1, "TestClient: 5. Wait DTMF 4\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS");
if (res == '4')
}
if (!res) {
/* Step 6: Transmit tone noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n");
+ ast_debug(1, "TestClient: 6. Transmit tone\n");
res = sendnoise(chan, 6000);
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
}
if (!res || (res == '5')) {
/* Step 7: Wait for "5" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n");
+ ast_debug(1, "TestClient: 7. Wait DTMF 5\n");
if (!res)
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS");
}
if (!res) {
/* Step 8: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n");
+ ast_debug(1, "TestClient: 8. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 9: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n");
+ ast_debug(1, "TestClient: 6. Measure tone\n");
res = measurenoise(chan, 4000, "TestClient");
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 10: Send "7" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n");
+ ast_debug(1, "TestClient: 7. Send DTMF 7\n");
res = ast_dtmf_stream(chan, NULL, "7", 0);
fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 11: Wait for "8" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n");
+ ast_debug(1, "TestClient: 11. Wait DTMF 8\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS");
if (res == '8')
}
if (option_debug && !res ) {
/* Step 12: Hangup! */
- ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n");
+ ast_debug(1, "TestClient: 12. Hangup\n");
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n");
+ ast_debug(1, "-- TEST COMPLETE--\n");
fprintf(f, "-- END TEST--\n");
fclose(f);
res = -1;
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
/* Read version */
- if (option_debug)
- ast_log(LOG_DEBUG, "Read client version\n");
+ ast_debug(1, "Read client version\n");
if (!res)
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
if (res > 0)
res = 0;
- if (option_debug) {
- ast_log(LOG_DEBUG, "client version: %s\n", testid);
- ast_log(LOG_DEBUG, "Transmit server version\n");
- }
+
+ ast_debug(1, "client version: %s\n", testid);
+ ast_debug(1, "Transmit server version\n");
+
res = ast_safe_sleep(chan, 1000);
if (!res)
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
if (!res)
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "read test identifier: %s\n", testid);
+ ast_debug(1, "read test identifier: %s\n", testid);
/* Check for sneakyness */
if (strchr(testid, '/'))
res = -1;
fprintf(f, "SERVERCHAN: %s\n", chan->name);
fprintf(f, "SERVERTEST ID: %s\n", testid);
fprintf(f, "ANSWER: PASS\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
+ ast_debug(1, "Processing Test ID '%s'\n", testid);
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 1: Send "1" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n");
+ ast_debug(1, "TestServer: 1. Send DTMF 1\n");
res = ast_dtmf_stream(chan, NULL, "1", 0);
fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 2: Wait for "2" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n");
+ ast_debug(1, "TestServer: 2. Wait DTMF 2\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS");
if (res == '2')
}
if (!res) {
/* Step 3: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n");
+ ast_debug(1, "TestServer: 3. Measure noise\n");
res = measurenoise(chan, 6000, "TestServer");
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 4: Send "4" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n");
+ ast_debug(1, "TestServer: 4. Send DTMF 4\n");
res = ast_dtmf_stream(chan, NULL, "4", 0);
fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 5: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n");
+ ast_debug(1, "TestServer: 5. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 6: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n");
+ ast_debug(1, "TestServer: 6. Measure tone\n");
res = measurenoise(chan, 4000, "TestServer");
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
if (!res) {
/* Step 7: Send "5" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n");
+ ast_debug(1, "TestServer: 7. Send DTMF 5\n");
res = ast_dtmf_stream(chan, NULL, "5", 0);
fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 8: Transmit tone noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 8. Transmit tone\n");
+ ast_debug(1, "TestServer: 8. Transmit tone\n");
res = sendnoise(chan, 6000);
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
}
if (!res || (res == '7')) {
/* Step 9: Wait for "7" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n");
+ ast_debug(1, "TestServer: 9. Wait DTMF 7\n");
if (!res)
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS");
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 10: Send "8" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n");
+ ast_debug(1, "TestServer: 10. Send DTMF 8\n");
res = ast_dtmf_stream(chan, NULL, "8", 0);
fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 11: Wait for hangup to arrive! */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n");
+ ast_debug(1, "TestServer: 11. Waiting for hangup\n");
res = ast_safe_sleep(chan, 10000);
fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL");
}
/* check users.conf and update the password stored for the mailbox*/
/* if no vmsecret entry exists create one. */
if ((cfg = ast_config_load_with_comments("users.conf"))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "we are looking for %s\n", vmu->mailbox);
+ ast_debug(4, "we are looking for %s\n", vmu->mailbox);
while ((category = ast_category_browse(cfg, category))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "users.conf: %s\n", category);
+ ast_debug(4, "users.conf: %s\n", category);
if (!strcasecmp(category, vmu->mailbox)) {
if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "looks like we need to make vmsecret!\n");
+ ast_debug(3, "looks like we need to make vmsecret!\n");
var = ast_variable_new("vmsecret", newpassword);
}
new = alloca(strlen(newpassword)+1);
sprintf(new, "%s", newpassword);
if (!(cat = ast_category_get(cfg, category))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "failed to get category!\n");
+ ast_debug(4, "failed to get category!\n");
break;
}
if (!var)
ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum);
return;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
+ ast_debug(3, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
/* delete message */
sprintf (arg,"%lu",messageNum);
mail_setflag (vms->mailstream,arg,"\\DELETED");
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
tmpfd = mkstemp(newtmp);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ ast_debug(3, "newtmp: %s\n", newtmp);
if (vmu->volgain < -.001 || vmu->volgain > .001) {
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
ast_safe_system(tmpcmd);
attach = newtmp;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
}
fprintf(p, "--%s" ENDL, bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
}
if (!strcmp(format, "wav49"))
format = "WAV";
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
+ ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
if ((p = vm_mkftemp(tmp)) == NULL) {
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+ ast_debug(1, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
}
return 0;
}
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
+ ast_debug(1, "Sent page to %s with command '%s'\n", pager, mailcmd);
return 0;
}
if (!strcmp(fmt, "wav49"))
fmt = "WAV";
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Storing file '%s', format '%s'\n", fn, fmt);
+ ast_debug(3, "Storing file '%s', format '%s'\n", fn, fmt);
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
fclose(p);
unlink(tmp);
ast_free(buf);
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "%s stored\n", fn);
+ ast_debug(3, "%s stored\n", fn);
return 0;
}
if (oldmsgs)
*oldmsgs = 0;
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Mailbox is set to %s\n",mailbox);
+ ast_debug(3,"Mailbox is set to %s\n",mailbox);
/* If no mailbox, return immediately */
if (ast_strlen_zero(mailbox))
}
/* We have to get the user before we can open the stream! */
- /*ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
+ /*ast_debug(1,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
if (!(vmu = find_user(NULL, context, mailboxnc))) {
ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailboxnc, context);
return -1;
/* check if someone is accessing this box right now... */
if ((vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1)) || (vms_p = get_vm_state_by_mailbox(mailboxnc, 1))) {
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Returning before search - user is logged in\n");
+ ast_debug(3,"Returning before search - user is logged in\n");
*newmsgs = vms_p->newmessages;
*oldmsgs = vms_p->oldmessages;
free_user(vmu);
/* add one if not there... */
if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) {
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
+ ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser);
if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
free_user(vmu);
return -1;
ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */
vms_p->mailstream = NIL; /* save for access from interactive entry point */
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
+ ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
vms_p->updated = 1;
/* set mailbox to INBOX! */
ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ ast_debug(1, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
}
}
ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
} else {
snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails);
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing %s\n", arguments);
+ ast_debug(1, "Executing %s\n", arguments);
ast_safe_system(arguments);
}
}
category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Before find_user\n");
+ ast_debug(3, "Before find_user\n");
if (!(vmu = find_user(&svm, context, ext))) {
ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ ast_debug(1, "%s doesn't exist, doing what we can\n", prefile);
res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
}
DISPOSE(prefile, -1);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ ast_debug(1, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
return -1;
/* must open stream for this user to get info! */
vms = get_vm_state_by_mailbox(ext,0);
if (vms) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Using vm_state, interactive set to %d.\n",vms->interactive);
+ ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive);
newmsgs = vms->newmessages++;
oldmsgs = vms->oldmessages;
} else {
}
/* here is a big difference! We add one to it later */
msgnum = newmsgs + oldmsgs;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum);
+ ast_debug(3, "Messagecount set to %d\n",msgnum);
snprintf(fn, sizeof(fn), "%s/imap/msg%s%04d", VM_SPOOL_DIR, vmu->mailbox, msgnum);
/* set variable for compatibility */
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE");
/* Check if mailbox is full */
if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) {
- if (option_debug)
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
+ ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
ast_play_and_wait(chan, "vm-mailboxfull");
return -1;
}
/* here is a big difference! We add one to it later */
msgnum = newmsgs + oldmsgs;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum);
+ ast_debug(3, "Messagecount set to %d\n",msgnum);
#else
if (count_messages(vmu, dir) >= vmu->maxmsg) {
ast_filedelete(tmptxtfile, NULL);
unlink(tmptxtfile);
} else if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
+ ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n");
unlink(tmptxtfile);
ast_unlock_path(dir);
if (ast_check_realtime("voicemail_data")) {
/* get the real IMAP message number for this message */
sprintf(sequence,"%ld",vms->msgArray[msg]);
imap_mailbox_name(dbox, vms, box, 1);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Copying sequence %s to mailbox %s\n",sequence,dbox);
+ ast_debug(3, "Copying sequence %s to mailbox %s\n",sequence,dbox);
res = mail_copy(vms->mailstream, sequence, dbox);
if (res == 1) return 0;
return 1;
bytes += ast_adsi_voice_mode(buf + bytes, 0);
ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done downloading scripts...\n");
+ ast_debug(1, "Done downloading scripts...\n");
#ifdef DISPLAY
/* Add last dot */
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Restarting session...\n");
+ ast_debug(1, "Restarting session...\n");
bytes = 0;
/* Load the session now */
AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
#ifdef IMAP_STORAGE
/* Need to get message content */
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
+ ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
if (!vms->msgArray[vms->curmsg]) {
ast_log (LOG_WARNING,"Trying to access unknown message\n");
return -1;
}
if (!strcasecmp(fmt, "wav49"))
fmt = "WAV";
- if (option_debug > 2)
- ast_log (LOG_DEBUG,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts);
+ ast_debug(3,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts);
/* ast_copy_string(fmt, vmfmts, sizeof(fmt));*/
/* if (!ast_strlen_zero(fmt)) { */
snprintf(todir, sizeof(todir), "%s%s/%s/tmp", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
make_gsm_file(vms->fn, vms->imapuser, todir, vms->curmsg);
- if (option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn);
+ ast_debug(3,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn);
/*mail_fetchstructure (mailstream, vmArray[0], &body); */
mail_fetchstructure (vms->mailstream, vms->msgArray[vms->curmsg], &body);
save_body(body,vms,"3","gsm");
return res;
/* Strip off caller ID number from name */
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
+ ast_debug(1, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
ast_callerid_parse(cid, &name, &callerid);
if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) {
/* Check for internal contexts and only */
/* say extension when the call didn't come from an internal context in the list */
for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
+ ast_debug(1, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
if ((strcmp(cidinternalcontexts[i], context) == 0))
break;
}
}
else if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n", callerid);
+ ast_debug(1, "VM-CID: Numeric caller id: (%s)\n", callerid);
/* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
if (!callback)
res = wait_file2(chan, vms, "vm-from-phonenumber");
}
} else {
/* Number unknown */
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
+ ast_debug(1, "VM-CID: From an unknown number\n");
/* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */
res = wait_file2(chan, vms, "vm-unknown-caller");
}
durations=atoi(duration);
durationm=(durations / 60);
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
+ ast_debug(1, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
if ((!res) && (durationm >= minduration)) {
res = wait_file2(chan, vms, "vm-duration");
char buf[1024];
vms->starting = 0;
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
+ ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
if (!vms->msgArray[vms->curmsg]) {
ast_log (LOG_WARNING,"Trying to access unknown message\n");
ast_log (LOG_ERROR,"vm_state is NULL!\n");
return -1;
}
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser);
+ ast_debug(3,"vm_state user is:%s\n",vms->imapuser);
if (vms->mailstream == NIL || !vms->mailstream) {
- if (option_debug)
- ast_log (LOG_DEBUG,"mailstream not set.\n");
+ ast_debug(1,"mailstream not set.\n");
} else {
stream = vms->mailstream;
}
}
/* Now connect to the target folder */
imap_mailbox_name(tmp, vms, box, 1);
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_open, server: %s, box:%d\n", tmp, box);
+ ast_debug(3,"Before mail_open, server: %s, box:%d\n", tmp, box);
vms->mailstream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
if (vms->mailstream == NIL) {
return -1;
char dbox[256];
ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser));
-
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"Before init_mailstream, user is %s\n",vmu->imapuser);
+ ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser);
if ((ret = init_mailstream(vms, box)) || !vms->mailstream) {
ast_log (LOG_ERROR,"Could not initialize mailstream\n");
pgm->unseen = 0;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"Before mail_search_full, user is %s\n",vmu->imapuser);
+ ast_debug(3,"Before mail_search_full, user is %s\n",vmu->imapuser);
vms->vmArrayIndex = 0;
mail_search_full (vms->mailstream, NULL, pgm, NIL);
if (vms->deleted) {
for (x=0;x < vmu->maxmsg;x++) {
if (vms->deleted[x]) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"IMAP delete of %d\n",x);
+ ast_debug(3,"IMAP delete of %d\n",x);
IMAP_DELETE(vms->curdir, x, vms->fn, vms);
}
}
if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd))
vm_change_password_shell(vmu, newpassword);
- if (option_debug)
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan, vm_passchanged);
/* If forcename is set, have the user record their name */
if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd))
vm_change_password_shell(vmu, newpassword);
- if (option_debug)
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan, vm_passchanged);
break;
case '*':
ast_copy_string(mailbox, fullusername, mailbox_size);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
+ ast_debug(1, "Before find user for mailbox %s\n",mailbox);
vmu = find_user(&vmus, context, mailbox);
if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) {
/* saved password is blank, so don't bother asking */
memset(&vmus, 0, sizeof(vmus));
if (chan->_state != AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Before ast_answer\n");
+ ast_debug(1, "Before ast_answer\n");
ast_answer(chan);
}
if (!valid)
res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "After vm_authenticate\n");
+ ast_debug(1, "After vm_authenticate\n");
if (!res) {
valid = 1;
if (!skipuser)
create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
#endif
/* Retrieve old and new message counts */
- if (option_debug)
- ast_log(LOG_DEBUG, "Before open_mailbox\n");
+ ast_debug(1, "Before open_mailbox\n");
res = open_mailbox(&vms, vmu, 1);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
+ ast_debug(1, "Number of old messages: %d\n",vms.oldmessages);
/* Start in INBOX */
res = open_mailbox(&vms, vmu, 0);
if (res == ERROR_LOCK_PATH)
goto out;
vms.newmessages = vms.lastmsg + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
+ ast_debug(1, "Number of new messages: %d\n",vms.newmessages);
/* Select proper mailbox FIRST!! */
if (play_auto) {
}
}
#ifdef IMAP_STORAGE
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
+ ast_debug(3, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) {
- if (option_debug)
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
+ ast_debug(1, "*** QUOTA EXCEEDED!!\n");
cmd = ast_play_and_wait(chan, "vm-mailboxfull");
}
#endif
}
#ifdef IMAP_STORAGE
/* expunge message - use UID Expunge if supported on IMAP server*/
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup);
+ ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup);
if (vmu && deleted == 1 && expungeonhangup == 1) {
#ifdef HAVE_IMAP_TK2006
if (LEVELUIDPLUS (vms.mailstream)) {
/* External voicemail notify application */
if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
ast_copy_string(externnotify, val, sizeof(externnotify));
- if (option_debug)
- ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
+ ast_debug(1, "found externnotify: %s\n", externnotify);
} else {
externnotify[0] = '\0';
}
/* SMDI voicemail notification */
if ((s = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(s)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabled SMDI voicemail notification\n");
+ ast_debug(1, "Enabled SMDI voicemail notification\n");
if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
smdi_iface = ast_smdi_interface_find(val);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
+ ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
}
if (!smdi_iface) {
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
+ ast_debug(1, "Using SMDI port %s\n", smdi_iface->name);
}
}
ast_set2_flag((&globalflags), ast_true(val), VM_FORCEGREET);
if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
+ ast_debug(1,"VM_CID Internal context string: %s\n",s);
stringp = ast_strdupa(s);
for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
if (!ast_strlen_zero(stringp)) {
while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
q++;
ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
- if (option_debug)
- ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
+ ast_debug(1,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
} else {
cidinternalcontexts[x][0] = '\0';
}
}
}
if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
+ ast_debug(1,"VM Review Option disabled globally\n");
val = "no";
}
&n