Index: app.c =================================================================== --- app.c (revision 22820) +++ app.c (working copy) @@ -246,10 +246,7 @@ if (ast_has_voicemail_func) return ast_has_voicemail_func(mailbox, folder); - if ((option_verbose > 2) && !warned) { - ast_verbose(VERBOSE_PREFIX_3 "Message check requested for mailbox %s/folder %s but voicemail not loaded.\n", mailbox, folder ? folder : "INBOX"); - warned++; - } + AST_VERBOSE_IF(3, !warned++, VERBOSE_PREFIX_3 "Message check requested for mailbox %s/folder %s but voicemail not loaded.", mailbox, folder ? folder : "INBOX"); return 0; } @@ -264,10 +261,7 @@ if (ast_messagecount_func) return ast_messagecount_func(mailbox, newmsgs, oldmsgs); - if (!warned && (option_verbose > 2)) { - warned++; - ast_verbose(VERBOSE_PREFIX_3 "Message count requested for mailbox %s but voicemail not loaded.\n", mailbox); - } + AST_VERBOSE_IF(3, !warned++, VERBOSE_PREFIX_3 "Message count requested for mailbox %s but voicemail not loaded.", mailbox); return 0; } @@ -594,7 +588,7 @@ end=start; /* pre-initialize end to be same as start in case we never get into loop */ for (x=0;x maxsilence) { /* Ended happily with silence */ - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds\n", totalsilence/1000); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds", totalsilence/1000); ast_frfree(f); res = 'S'; outmsg=2; @@ -685,8 +678,7 @@ ast_writestream(others[0], f); } else if (f->frametype == AST_FRAME_DTMF) { if (f->subclass == '#') { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "User ended message by pressing %c\n", f->subclass); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "User ended message by pressing %c", f->subclass); res = '#'; outmsg = 2; ast_frfree(f); @@ -694,8 +686,7 @@ } if (f->subclass == '0') { /* Check for a '0' during message recording also, in case caller wants operator */ - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "User cancelled by pressing %c\n", f->subclass); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "User cancelled by pressing %c", f->subclass); res = '0'; outmsg = 0; ast_frfree(f); @@ -705,8 +696,7 @@ if (maxtime) { time(&end); if (maxtime < (end - start)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Took too long, cutting it short...\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Took too long, cutting it short..."); outmsg = 2; res = 't'; ast_frfree(f); @@ -717,8 +707,7 @@ } if (end == start) time(&end); if (!f) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "User hung up\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "User hung up"); res = -1; outmsg=1; } @@ -814,7 +803,7 @@ end=start; /* pre-initialize end to be same as start in case we never get into loop */ for (x=0;x maxsilence) { /* Ended happily with silence */ - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds\n", totalsilence/1000); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds", totalsilence/1000); ast_frfree(f); res = 'S'; outmsg=2; @@ -898,8 +886,7 @@ ast_writestream(others[0], f); } else if (f->frametype == AST_FRAME_DTMF) { /* stop recording with any digit */ - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "User ended message by pressing %c\n", f->subclass); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "User ended message by pressing %c", f->subclass); res = 't'; outmsg = 2; ast_frfree(f); @@ -908,8 +895,7 @@ if (maxtime) { time(&end); if (maxtime < (end - start)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Took too long, cutting it short...\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Took too long, cutting it short..."); res = 't'; outmsg=2; ast_frfree(f); @@ -920,8 +906,7 @@ } if (end == start) time(&end); if (!f) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "User hung up\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "User hung up"); res = -1; outmsg=1; #if 0 @@ -963,7 +948,7 @@ ast_closestream(realfiles[x]); ast_filerename(prependfile, recordfile, sfmt[x]); #if 0 - ast_verbose("Recording Format: sfmts=%s, prependfile %s, recordfile %s\n", sfmt[x],prependfile,recordfile); + AST_VERBOSE(3, "Recording Format: sfmts=%s, prependfile %s, recordfile %s", sfmt[x],prependfile,recordfile); #endif ast_filedelete(prependfile, sfmt[x]); } @@ -1202,16 +1187,13 @@ } case '2': /* Review */ - ast_verbose(VERBOSE_PREFIX_3 "Reviewing the recording\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Reviewing the recording"); cmd = ast_stream_and_wait(chan, recordfile, chan->language, AST_DIGIT_ANY); break; case '3': message_exists = 0; /* Record */ - if (recorded == 1) - ast_verbose(VERBOSE_PREFIX_3 "Re-recording\n"); - else - ast_verbose(VERBOSE_PREFIX_3 "Recording\n"); + AST_VERBOSE(3, (recorded == 1) ? VERBOSE_PREFIX_3 "Re-recording" : VERBOSE_PREFIX_3 "Recording"); recorded = 1; cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, path); if (cmd == -1) { Index: asterisk.c =================================================================== --- asterisk.c (revision 22820) +++ asterisk.c (working copy) @@ -750,8 +750,7 @@ break; } } - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Remote UNIX connection disconnected\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Remote UNIX connection disconnected"); close(con->fd); close(con->p[0]); close(con->p[1]); @@ -816,8 +815,7 @@ ast_log(LOG_WARNING, "No more connections allowed\n"); close(s); } else if (consoles[x].fd > -1) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Remote UNIX connection\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Remote UNIX connection"); } } } @@ -983,8 +981,7 @@ ast_log(LOG_WARNING, "Unable to set high priority\n"); return -1; } else - if (option_verbose) - ast_verbose("Set to realtime thread\n"); + AST_VERBOSE(1, "Set to realtime thread"); } else { sched.sched_priority = 0; if (sched_setscheduler(0, SCHED_OTHER, &sched)) { @@ -998,8 +995,7 @@ ast_log(LOG_WARNING, "Unable to set high priority\n"); return -1; } else - if (option_verbose) - ast_verbose("Set to high priority\n"); + AST_VERBOSE(1, "Set to high priority"); } else { if (setpriority(PRIO_PROCESS, 0, 0) == -1) { ast_log(LOG_WARNING, "Unable to set normal priority\n"); @@ -1033,8 +1029,7 @@ if (!nice) { /* Begin shutdown routine, hanging up active channels */ ast_begin_shutdown(1); - if (option_verbose && ast_opt_console) - ast_verbose("Beginning asterisk %s....\n", restart ? "restart" : "shutdown"); + AST_VERBOSE_IF(1, ast_opt_console, "Beginning asterisk %s....", restart ? "restart" : "shutdown"); time(&s); for (;;) { time(&e); @@ -1051,8 +1046,7 @@ } else { if (nice < 2) ast_begin_shutdown(0); - if (option_verbose && ast_opt_console) - ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt"); + AST_VERBOSE_IF(1, ast_opt_console, "Waiting for inactivity to perform %s...", restart ? "restart" : "halt"); for (;;) { if (!ast_active_channels()) break; @@ -1063,8 +1057,7 @@ } if (!shuttingdown) { - if (option_verbose && ast_opt_console) - ast_verbose("Asterisk %s cancelled.\n", restart ? "restart" : "shutdown"); + AST_VERBOSE_IF(1, ast_opt_console, "Asterisk %s cancelled.", restart ? "restart" : "shutdown"); return; } } @@ -1078,13 +1071,11 @@ if (el_hist != NULL) history_end(el_hist); } - if (option_verbose) - ast_verbose("Executing last minute cleanups\n"); + AST_VERBOSE(1, "Executing last minute cleanups"); ast_run_atexits(); /* Called on exit */ - if (option_verbose && ast_opt_console) - ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num); - else if (option_debug) + AST_VERBOSE_IF(1, ast_opt_console, "Asterisk %s ending (%d).", ast_active_channels() ? "uncleanly" : "cleanly", num); + if (option_debug) ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num); manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False"); if (ast_socket > -1) { @@ -2394,8 +2385,7 @@ ast_log(LOG_WARNING, "Unable to drop unneeded groups\n"); exit(1); } - if (option_verbose) - ast_verbose("Running as group '%s'\n", rungroup); + AST_VERBOSE(1, "Running as group '%s'", rungroup); } if (!is_child_of_nonroot && runuser) { @@ -2420,8 +2410,7 @@ exit(1); } setenv("ASTERISK_ALREADY_NONROOT", "yes", 1); - if (option_verbose) - ast_verbose("Running as user '%s'\n", runuser); + AST_VERBOSE(1, "Running as user '%s'", runuser); } #endif /* __CYGWIN__ */ Index: astmm.c =================================================================== --- astmm.c (revision 22820) +++ astmm.c (working copy) @@ -432,8 +432,7 @@ snprintf(filename, sizeof(filename), "%s/mmlog", (char *)ast_config_AST_LOG_DIR); mmlog = fopen(filename, "a+"); - if (option_verbose) - ast_verbose("Asterisk Malloc Debugger Started (see %s))\n", filename); + AST_VERBOSE(1, "Asterisk Malloc Debugger Started (see %s))", filename); if (mmlog) { fprintf(mmlog, "%ld - New session\n", time(NULL)); fflush(mmlog); Index: cdr.c =================================================================== --- cdr.c (revision 22820) +++ cdr.c (working copy) @@ -152,8 +152,7 @@ AST_LIST_TRAVERSE_SAFE_BEGIN(&be_list, i, list) { if (!strcasecmp(name, i->name)) { AST_LIST_REMOVE_CURRENT(&be_list, list); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend\n", name); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend", name); free(i); break; } Index: channel.c =================================================================== --- channel.c (revision 22820) +++ channel.c (working copy) @@ -411,9 +411,8 @@ if (option_debug) ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type, - chan->tech->description); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)", chan->tech->type, + chan->tech->description); AST_LIST_UNLOCK(&channels); return 0; @@ -432,8 +431,7 @@ if (chan->tech == tech) { AST_LIST_REMOVE_CURRENT(&backends, list); free(chan); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered channel type '%s'\n", tech->type); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Unregistered channel type '%s'", tech->type); break; } } @@ -3535,9 +3533,8 @@ case AST_BRIDGE_RETRY: continue; default: - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Native bridging %s and %s ended\n", - c0->name, c1->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Native bridging %s and %s ended", + c0->name, c1->name); /* fallthrough */ case AST_BRIDGE_FAILED_NOWARN: nativefailed++; @@ -3795,8 +3792,7 @@ if (ast_moh_start_ptr) return ast_moh_start_ptr(chan, mclass); - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : "default"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Music class %s requested but no musiconhold loaded.", mclass ? mclass : "default"); return 0; } Index: config.c =================================================================== --- config.c (revision 22820) +++ config.c (working copy) @@ -568,15 +568,15 @@ if (!(f = fopen(fn, "r"))) { if (option_debug) ast_log(LOG_DEBUG, "No file to parse: %s\n", fn); - else if (option_verbose > 1) - ast_verbose( "Not found (%s)\n", strerror(errno)); + else + AST_VERBOSE(2, "Not found (%s)", strerror(errno)); continue; } count++; if (option_debug) ast_log(LOG_DEBUG, "Parsing %s\n", fn); - else if (option_verbose > 1) - ast_verbose("Found\n"); + else + AST_VERBOSE(2, "Found"); while(!feof(f)) { lineno++; if (fgets(buf, sizeof(buf), f)) { @@ -764,9 +764,8 @@ } map->next = config_maps; - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s\n", - map->name, map->driver, map->database, map->table ? map->table : map->name); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Binding %s to %s/%s/%s", + map->name, map->driver, map->database, map->table ? map->table : map->name); config_maps = map; return 0; Index: dnsmgr.c =================================================================== --- dnsmgr.c (revision 22820) +++ dnsmgr.c (working copy) @@ -115,8 +115,7 @@ if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) return 0; - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_3 "doing lookup for '%s'\n", name); + AST_VERBOSE(4, VERBOSE_PREFIX_3 "doing lookup for '%s'", name); /* if it's actually an IP address and not a name, there's no need for a managed lookup */ @@ -133,8 +132,7 @@ memcpy(result, hp->h_addr, sizeof(result)); return 0; } else { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "adding manager for '%s'\n", name); + AST_VERBOSE(3, VERBOSE_PREFIX_2 "adding manager for '%s'", name); *dnsmgr = ast_dnsmgr_get(name, result); return !*dnsmgr; } @@ -165,15 +163,13 @@ return -1; } - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "Refreshing DNS lookups.\n"); + AST_VERBOSE(3, VERBOSE_PREFIX_2 "Refreshing DNS lookups."); AST_LIST_LOCK(info->entries); AST_LIST_TRAVERSE(info->entries, entry, list) { if (info->regex_present && regexec(&info->filter, entry->name, 0, NULL, 0)) continue; - if (info->verbose && (option_verbose > 2)) - ast_verbose(VERBOSE_PREFIX_2 "refreshing '%s'\n", entry->name); + AST_VERBOSE_IF(3, info->verbose, VERBOSE_PREFIX_2 "refreshing '%s'", entry->name); if ((hp = ast_gethostbyname(entry->name, &ahp))) { /* check to see if it has changed, do callback if requested */ Index: file.c =================================================================== --- file.c (revision 22820) +++ file.c (working copy) @@ -105,8 +105,7 @@ AST_LIST_INSERT_HEAD(&formats, tmp, list); AST_LIST_UNLOCK(&formats); - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", f->name, f->exts); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s", f->name, f->exts); return 0; } @@ -130,8 +129,7 @@ AST_LIST_UNLOCK(&formats); if (!res) { - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Unregistered format %s", name); } else ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name); @@ -801,8 +799,7 @@ if (vfs && ast_playstream(vfs)) return -1; #if 1 - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (language '%s')\n", filename, preflang ? preflang : "default"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Playing '%s' (language '%s')", filename, preflang ? preflang : "default"); #endif return 0; } Index: image.c =================================================================== --- image.c (revision 22820) +++ image.c (working copy) @@ -50,8 +50,7 @@ int ast_image_register(struct ast_imager *img) { - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Registered format '%s' (%s)", img->name, img->desc); AST_LIST_LOCK(&imagers); AST_LIST_INSERT_HEAD(&imagers, img, list); AST_LIST_UNLOCK(&imagers); @@ -71,8 +70,7 @@ } AST_LIST_TRAVERSE_SAFE_END AST_LIST_UNLOCK(&imagers); - if (i && (option_verbose > 1)) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered format '%s' (%s)\n", img->name, img->desc); + AST_VERBOSE_IF(2, i, VERBOSE_PREFIX_2 "Unregistered format '%s' (%s)", img->name, img->desc); } int ast_supports_images(struct ast_channel *chan) Index: indications.c =================================================================== --- indications.c (revision 22820) +++ indications.c (working copy) @@ -359,8 +359,7 @@ if (country) { struct tone_zone *z = ast_get_indication_zone(country); if (z) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Setting default indication country to '%s'\n",country); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Setting default indication country to '%s'",country); current_tonezone = z; return 0; } @@ -486,8 +485,7 @@ tone_zones = zone; ast_mutex_unlock(&tzlock); - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Registered indication country '%s'\n",zone->country); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Registered indication country '%s'",zone->country); return 0; } @@ -518,8 +516,7 @@ ast_log(LOG_NOTICE,"Removed default indication country '%s'\n",tz->country); current_tonezone = NULL; } - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Unregistered indication country '%s'\n",tz->country); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Unregistered indication country '%s'",tz->country); free_zone(tz); if (tone_zones == tz) tone_zones = tmp; Index: loader.c =================================================================== --- loader.c (revision 22820) +++ loader.c (working copy) @@ -613,8 +613,7 @@ /* drop the lock and try a reload. if successful, break */ AST_LIST_UNLOCK(&module_list); res = 2; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", cur->resource, m->description()); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Reloading module '%s' (%s)", cur->resource, m->description()); m->reload(m); AST_LIST_LOCK(&module_list); if (oldversion != modlistver) /* something changed, abort */ @@ -761,13 +760,11 @@ cur->cb->lu_head = NULL; if (!ast_fully_booted) { - if (option_verbose) - ast_verbose( " => (%s)\n", term_color(tmp, m->description(), COLOR_BROWN, COLOR_BLACK, sizeof(tmp))); + AST_VERBOSE(1, " => (%s)", term_color(tmp, m->description(), COLOR_BROWN, COLOR_BLACK, sizeof(tmp))); if (ast_opt_console && !option_verbose) ast_verbose( "."); } else { - if (option_verbose) - ast_verbose(VERBOSE_PREFIX_1 "Loaded %s => (%s)\n", fn, m->description()); + AST_VERBOSE(1, VERBOSE_PREFIX_1 "Loaded %s => (%s)", fn, m->description()); } AST_LIST_INSERT_TAIL(&module_list, cur, next); @@ -864,11 +861,9 @@ struct ast_config *cfg; int x; - if (option_verbose) { - ast_verbose(preload_only ? - "Asterisk Dynamic Loader loading preload modules:\n" : - "Asterisk Dynamic Loader Starting:\n"); - } + AST_VERBOSE(1, preload_only ? + "Asterisk Dynamic Loader loading preload modules:" : + "Asterisk Dynamic Loader Starting:"); if (0) check_symbols(); Index: logger.c =================================================================== --- logger.c (revision 22820) +++ logger.c (working copy) @@ -81,7 +81,6 @@ #define GETTID() getpid() #endif - static char dateformat[256] = "%b %e %T"; /* Original Asterisk Format */ AST_MUTEX_DEFINE_STATIC(msglist_lock); @@ -148,11 +147,11 @@ { char *w; int res = 0; - char *stringp=NULL; - stringp=s; + char *stringp = NULL; + stringp = s; w = strsep(&stringp, ","); - while(w) { - while(*w && (*w < 33)) + while (w) { + while (*w && (*w < 33)) w++; if (!strcasecmp(w, "error")) res |= (1 << __LOG_ERROR); @@ -195,7 +194,7 @@ * syslog.facility => level,level,level */ facility = strchr(channel, '.'); - if(!facility++ || !facility) { + if (!facility++ || !facility) { facility = "local0"; } @@ -326,8 +325,8 @@ ast_mutex_lock(&loglock); if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) { - if(ast_true(s)) { - if(gethostname(hostname, sizeof(hostname)-1)) { + if (ast_true(s)) { + if (gethostname(hostname, sizeof(hostname) - 1)) { ast_copy_string(hostname, "unknown", sizeof(hostname)); ast_log(LOG_WARNING, "What box has no hostname???\n"); } @@ -347,7 +346,7 @@ } var = ast_variable_browse(cfg, "logfiles"); - while(var) { + while (var) { chan = make_logchannel(var->name, var->value, var->lineno); if (chan) { chan->next = logchannels; @@ -401,7 +400,7 @@ mkdir((char *)ast_config_AST_LOG_DIR, 0755); f = logchannels; - while(f) { + while (f) { if (f->disabled) { f->disabled = 0; /* Re-enable logging at reload */ manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename); @@ -409,10 +408,10 @@ if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { fclose(f->fileptr); /* Close file */ f->fileptr = NULL; - if(rotate) { + if (rotate) { ast_copy_string(old, f->filename, sizeof(old)); - - for(x=0;;x++) { + + for(x = 0; ; x++) { snprintf(new, sizeof(new), "%s.%d", f->filename, x); myf = fopen((char *)new, "r"); if (myf) { @@ -423,7 +422,7 @@ } /* do it */ - if (rename(old,new)) + if (rename(old, new)) fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); } } @@ -437,7 +436,7 @@ if (logfiles.event_log) { snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); if (event_rotate) { - for (x=0;;x++) { + for (x = 0; ; x++) { snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); myf = fopen((char *)new, "r"); if (myf) /* File exists */ @@ -447,15 +446,14 @@ } /* do it */ - if (rename(old,new)) + if (rename(old, new)) ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new); } eventlog = fopen(old, "a"); if (eventlog) { ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n"); - if (option_verbose) - ast_verbose("Asterisk Event Logger restarted\n"); + AST_VERBOSE(1, "Asterisk Event Logger restarted"); } else { ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); res = -1; @@ -483,8 +481,7 @@ if (qlog) { ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", ""); ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n"); - if (option_verbose) - ast_verbose("Asterisk Queue Logger restarted\n"); + AST_VERBOSE(1, "Asterisk Queue Logger restarted"); } else { ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno)); res = -1; @@ -497,7 +494,7 @@ static int handle_logger_reload(int fd, int argc, char *argv[]) { - if(reload_logger(0)) { + if (reload_logger(0)) { ast_cli(fd, "Failed to reload the logger\n"); return RESULT_FAILURE; } else @@ -506,7 +503,7 @@ static int handle_logger_rotate(int fd, int argc, char *argv[]) { - if(reload_logger(1)) { + if (reload_logger(1)) { ast_cli(fd, "Failed to reload the logger and rotate log files\n"); return RESULT_FAILURE; } else @@ -529,7 +526,6 @@ while (chan) { ast_cli(fd, FORMATL, chan->filename, chan->type==LOGTYPE_CONSOLE ? "Console" : (chan->type==LOGTYPE_SYSLOG ? "Syslog" : "File"), chan->disabled ? "Disabled" : "Enabled"); - ast_cli(fd, " - "); if (chan->logmask & (1 << __LOG_DEBUG)) ast_cli(fd, "Debug "); if (chan->logmask & (1 << __LOG_DTMF)) @@ -547,11 +543,11 @@ ast_cli(fd, "\n"); chan = chan->next; } - ast_cli(fd, "\n"); ast_mutex_unlock(&loglock); return RESULT_SUCCESS; +#undef FORMATL } static struct verb { @@ -562,7 +558,7 @@ static char logger_reload_help[] = "Usage: logger reload\n" -" Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n"; +" Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n"; static char logger_rotate_help[] = "Usage: logger rotate\n" @@ -574,7 +570,7 @@ static struct ast_cli_entry logger_show_channels_cli = { { "logger", "show", "channels", NULL }, - handle_logger_show_channels, "List configured log channels", + handle_logger_show_channels, "Lists configured log channels", logger_show_channels_help }; static struct ast_cli_entry reload_logger_cli = @@ -619,8 +615,7 @@ eventlog = fopen((char *)tmp, "a"); if (eventlog) { ast_log(LOG_EVENT, "Started Asterisk Event Logger\n"); - if (option_verbose) - ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp); + AST_VERBOSE(1, "Asterisk Event Logger Started %s", (char *)tmp); } else { ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno)); res = -1; @@ -641,7 +636,7 @@ ast_mutex_lock(&msglist_lock); m = list; - while(m) { + while (m) { if (m->msg) { free(m->msg); } @@ -733,7 +728,7 @@ if (logchannels) { chan = logchannels; - while(chan && !chan->disabled) { + while (chan && !chan->disabled) { /* Check syslog channels */ if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << level))) { va_start(ap, fmt); @@ -804,15 +799,14 @@ if (filesize_reload_needed) { reload_logger(1); ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n"); - if (option_verbose) - ast_verbose("Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n"); + AST_VERBOSE(1, "Rotated Logs Per SIGXFSZ (Exceeded file size limit)"); } } void ast_backtrace(void) { #ifdef STACK_BACKTRACES - int count=0, i=0; + int count = 0, i = 0; void **addresses; char **strings; @@ -820,7 +814,7 @@ count = backtrace(addresses, MAX_BACKTRACE_FRAMES); if ((strings = backtrace_symbols(addresses, count))) { ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); - for (i=0; i < count ; i++) { + for (i = 0; i < count; i++) { ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); } free(strings); @@ -958,7 +952,7 @@ tmp->next = verboser; verboser = tmp; m = list; - while(m) { + while (m) { /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */ v(m->msg, 0, 0, 1); m = m->next; @@ -972,10 +966,10 @@ int ast_unregister_verbose(void (*v)(const char *string, int opos, int replacelast, int complete)) { int res = -1; - struct verb *tmp, *tmpl=NULL; + struct verb *tmp, *tmpl = NULL; ast_mutex_lock(&msglist_lock); tmp = verboser; - while(tmp) { + while (tmp) { if (tmp->verboser == v) { if (tmpl) tmpl->next = tmp->next; Index: manager.c =================================================================== --- manager.c (revision 22820) +++ manager.c (working copy) @@ -1699,11 +1699,7 @@ return -1; } else { s->authenticated = 1; - if (option_verbose > 1) { - if (displayconnects) { - ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } - } + AST_VERBOSE_IF(2, displayconnects, VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); astman_send_ack(s, m, "Authentication accepted"); } @@ -1825,16 +1821,10 @@ } } if (s->authenticated) { - if (option_verbose > 1) { - if (displayconnects) - ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } + AST_VERBOSE_IF(2, displayconnects, VERBOSE_PREFIX_2 "Manager '%s' logged off from %s", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); } else { - if (option_verbose > 1) { - if (displayconnects) - ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } + AST_VERBOSE_IF(2, displayconnects, VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); } destroy_session(s); @@ -1872,10 +1862,8 @@ prev->next = next; else sessions = next; - if (s->authenticated && (option_verbose > 1) && displayconnects) { - ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' timed out from %s\n", - s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } + AST_VERBOSE_IF(2, (s->authenticated && displayconnects), VERBOSE_PREFIX_2 "HTTP Manager '%s' timed out from %s", + s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); free_session(s); } else prev = s; @@ -2022,8 +2010,7 @@ if (!strcasecmp(action, cur->action)) { prev->next = cur->next; free(cur); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Manager unregistered action %s\n", action); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Manager unregistered action %s", action); ast_mutex_unlock(&actionlock); return 0; } @@ -2076,8 +2063,7 @@ act->next = NULL; } - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Manager registered action %s\n", act->action); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Manager registered action %s", act->action); ast_mutex_unlock(&actionlock); return 0; } @@ -2125,7 +2111,6 @@ return s; } - static void vars2msg(struct message *m, struct ast_variable *vars) { int x; @@ -2217,16 +2202,10 @@ } if (process_message(s, &m)) { if (s->authenticated) { - if (option_verbose > 1) { - if (displayconnects) - ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } + AST_VERBOSE_IF(2, displayconnects, VERBOSE_PREFIX_2 "HTTP Manager '%s' logged off from %s", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); ast_log(LOG_EVENT, "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); } else { - if (option_verbose > 1) { - if (displayconnects) - ast_verbose(VERBOSE_PREFIX_2 "HTTP Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); - } + AST_VERBOSE_IF(2, displayconnects, VERBOSE_PREFIX_2 "HTTP Connect attempt from '%s' unable to authenticate", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); ast_log(LOG_EVENT, "HTTP Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr)); } s->needdestroy = 1; @@ -2321,9 +2300,10 @@ .callback = mxml_http_callback, }; -static int registered = 0; static int webregged = 0; +static int registered = 0; + int init_manager(void) { struct ast_config *cfg; @@ -2465,8 +2445,7 @@ } flags = fcntl(asock, F_GETFL); fcntl(asock, F_SETFL, flags | O_NONBLOCK); - if (option_verbose) - ast_verbose("Asterisk Management interface listening on port %d\n", portno); + AST_VERBOSE(1, "Asterisk Management interface listening on port %d", portno); ast_pthread_create(&t, NULL, accept_thread, NULL); } return 0; Index: netsock.c =================================================================== --- netsock.c (revision 22820) +++ netsock.c (working copy) @@ -143,8 +143,7 @@ close(netsocket); return NULL; } - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Using TOS bits %d", tos); if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos); Index: pbx.c =================================================================== --- pbx.c (revision 22820) +++ pbx.c (working copy) @@ -1174,8 +1174,7 @@ ast_mutex_unlock(&acflock); - if (!res && option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name); + AST_VERBOSE_IF(2, !res, VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name); return res; } @@ -1226,8 +1225,7 @@ ast_mutex_unlock(&acflock); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Registered custom function %s\n", acf->name); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Registered custom function %s", acf->name); return 0; } @@ -1545,12 +1543,10 @@ snprintf(atmp2, EXT_DATA_SIZE+100, "%s(\"%s\", \"%s\") %s", app->name, c->name, passdata, "in new stack"); pbx_builtin_setvar_helper(c, atmp, atmp2); } - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Executing %s(\"%s\", \"%s\") %s\n", - term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)), - term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), - term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3)), - "in new stack"); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Executing %s(\"%s\", \"%s\") in new stack", + term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)), + term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), + term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3))); manager_event(EVENT_FLAG_CALL, "Newexten", "Channel: %s\r\n" "Context: %s\r\n" @@ -2095,8 +2091,7 @@ /* Start by trying whatever the channel is set to */ if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { /* If not successful fall back to 's' */ - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d failed so falling back to exten 's'", c->name, c->context, c->exten, c->priority); /* XXX the original code used the existing priority in the call to * ast_exists_extension(), and reset it to 1 afterwards. * I believe the correct thing is to set it to 1 immediately. @@ -2104,8 +2099,7 @@ set_ext_pri(c, "s", 1); if (!ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { /* JK02: And finally back to default if everything else failed */ - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'\n", c->name, c->context, c->exten, c->priority); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Starting %s at %s,%s,%d still failed so falling back to context 'default'", c->name, c->context, c->exten, c->priority); ast_copy_string(c->context, "default", sizeof(c->context)); } } @@ -2130,15 +2124,15 @@ case AST_PBX_KEEPALIVE: if (option_debug) ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name); - else if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name); + else + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'", c->context, c->exten, c->priority, c->name); goto out; break; default: if (option_debug) ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); - else if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); + else + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'", c->context, c->exten, c->priority, c->name); if (c->_softhangup == AST_SOFTHANGUP_ASYNCGOTO) { c->_softhangup =0; break; @@ -2172,8 +2166,7 @@ * Try to continue at "i", 1 or exit if the latter does not exist. */ if (ast_exists_extension(c, c->context, "i", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Sent into invalid extension '%s' in context '%s' on %s", c->exten, c->context, c->name); pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten); set_ext_pri(c, "i", 1); } else { @@ -2217,8 +2210,7 @@ if (!ast_strlen_zero(exten)) { /* An invalid extension */ if (ast_exists_extension(c, c->context, "i", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Invalid extension '%s' in context '%s' on %s\n", exten, c->context, c->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Invalid extension '%s' in context '%s' on %s", exten, c->context, c->name); pbx_builtin_setvar_helper(c, "INVALID_EXTEN", exten); set_ext_pri(c, "i", 1); } else { @@ -2228,8 +2220,7 @@ } else { /* A simple timeout */ if (ast_exists_extension(c, c->context, "t", 1, c->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Timeout on %s\n", c->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Timeout on %s", c->name); set_ext_pri(c, "t", 1); } else { ast_log(LOG_WARNING, "Timeout, but no rule 't' in context '%s'\n", c->context); @@ -2238,8 +2229,7 @@ } } if (c->cdr) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "CDR updated on %s\n",c->name); + AST_VERBOSE(3, VERBOSE_PREFIX_2 "CDR updated on %s", c->name); ast_cdr_update(c); } } else { @@ -2248,8 +2238,7 @@ status = pbx_builtin_getvar_helper(c, "DIALSTATUS"); if (!status) status = "UNKNOWN"; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_2 "Auto fallthrough, channel '%s' status is '%s'\n", c->name, status); + AST_VERBOSE(3, VERBOSE_PREFIX_2 "Auto fallthrough, channel '%s' status is '%s'", c->name, status); if (!strcasecmp(status, "CONGESTION")) res = pbx_builtin_congestion(c, "10"); else if (!strcasecmp(status, "CHANUNAVAIL")) @@ -2272,8 +2261,8 @@ /* Something bad happened, or a hangup has been requested. */ if (option_debug) ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); - else if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name); + else + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'", c->context, c->exten, c->priority, c->name); break; } c->priority++; @@ -2693,8 +2682,7 @@ apps = tmp; } - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Registered application '%s'\n", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Registered application '%s'", term_color(tmps, tmp->name, COLOR_BRCYAN, 0, sizeof(tmps))); ast_mutex_unlock(&applock); return 0; } @@ -3403,8 +3391,7 @@ tmpl->next = tmp->next; else apps = tmp->next; - if (option_verbose > 1) - ast_verbose( VERBOSE_PREFIX_2 "Unregistered application '%s'\n", tmp->name); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Unregistered application '%s'", tmp->name); free(tmp); ast_mutex_unlock(&applock); return 0; @@ -3446,8 +3433,8 @@ *local_contexts = tmp; if (option_debug) ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name); - else if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name); + else + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Registered extension context '%s'", tmp->name); } if (!extcontexts) @@ -3889,8 +3876,7 @@ il->next = new_include; else con->includes = new_include; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Including context '%s' in context '%s'\n", new_include->name, ast_get_context_name(con)); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Including context '%s' in context '%s'", new_include->name, ast_get_context_name(con)); ast_mutex_unlock(&con->lock); return 0; @@ -3985,8 +3971,7 @@ il->next = new_sw; else con->alts = new_sw; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'\n", new_sw->name, new_sw->data, ast_get_context_name(con)); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Including switch '%s/%s' in context '%s'", new_sw->name, new_sw->data, ast_get_context_name(con)); ast_mutex_unlock(&con->lock); return 0; @@ -4502,8 +4487,7 @@ if (!ast_strlen_zero(as->app)) { app = pbx_findapp(as->app); if (app) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Launching %s(%s) on %s\n", as->app, as->appdata, chan->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Launching %s(%s) on %s", as->app, as->appdata, chan->name); pbx_exec(chan, app, as->appdata); } else ast_log(LOG_WARNING, "No such application '%s'\n", as->app); @@ -4595,8 +4579,7 @@ } if (chan->_state == AST_STATE_UP) { res = 0; - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); + AST_VERBOSE(4, VERBOSE_PREFIX_4 "Channel %s was answered.", chan->name); if (sync > 1) { if (channel) @@ -4620,8 +4603,7 @@ } } } else { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); + AST_VERBOSE(4, VERBOSE_PREFIX_4 "Channel %s was never answered.", chan->name); if(chan->cdr) { /* update the cdr */ /* here we update the status of the call, which sould be busy. @@ -4721,8 +4703,7 @@ struct ast_app *app; app = pbx_findapp(tmp->app); if (app) { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Launching %s(%s) on %s\n", tmp->app, tmp->data, tmp->chan->name); + AST_VERBOSE(4, VERBOSE_PREFIX_4 "Launching %s(%s) on %s", tmp->app, tmp->data, tmp->chan->name); pbx_exec(tmp->chan, app, tmp->data); } else ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app); @@ -4771,8 +4752,7 @@ ast_cdr_setaccount(chan, account); if (chan->_state == AST_STATE_UP) { res = 0; - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name); + AST_VERBOSE(4, VERBOSE_PREFIX_4 "Channel %s was answered.", chan->name); tmp = ast_calloc(1, sizeof(*tmp)); if (!tmp) res = -1; @@ -4804,8 +4784,7 @@ } } } else { - if (option_verbose > 3) - ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", chan->name); + AST_VERBOSE(4, VERBOSE_PREFIX_4 "Channel %s was never answered.", chan->name); if (chan->cdr) { /* update the cdr */ /* here we update the status of the call, which sould be busy. * if that fails then we set the status to failed */ @@ -5210,11 +5189,9 @@ res = ast_waitfordigit(chan, ms); if (!res) { if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, continuing...\n", chan->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Timeout on %s, continuing...", chan->name); } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Timeout on %s, going to 't'", chan->name); set_ext_pri(chan, "t", 0); /* XXX is the 0 correct ? */ } else { ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context); @@ -5311,8 +5288,7 @@ static int pbx_builtin_goto(struct ast_channel *chan, void *data) { int res = ast_parseable_goto(chan, data); - if (!res && (option_verbose > 2)) - ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1); + AST_VERBOSE_IF(3, !res, VERBOSE_PREFIX_3 "Goto (%s,%s,%d)", chan->context,chan->exten, chan->priority+1); return res; } @@ -5392,8 +5368,7 @@ headp = (chan) ? &chan->varshead : &globals; if (value) { - if ((option_verbose > 1) && (headp == &globals)) - ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); + AST_VERBOSE_IF(2, (headp == &globals), VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'", name, value); newvariable = ast_var_assign(name, value); if (headp == &globals) ast_mutex_lock(&globalslock); @@ -5437,8 +5412,7 @@ } if (value) { - if ((option_verbose > 1) && (headp == &globals)) - ast_verbose(VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'\n", name, value); + AST_VERBOSE_IF(2, (headp == &globals), VERBOSE_PREFIX_2 "Setting global variable '%s' to '%s'", name, value); newvariable = ast_var_assign(name, value); AST_LIST_INSERT_HEAD(headp, newvariable, entries); } @@ -5638,17 +5612,14 @@ int x; /* Initialize the PBX */ - if (option_verbose) { - ast_verbose( "Asterisk PBX Core Initializing\n"); - ast_verbose( "Registering builtin applications:\n"); - } + AST_VERBOSE(1, "Asterisk PBX Core Initializing"); + AST_VERBOSE(1, "Registering builtin applications:"); AST_LIST_HEAD_INIT_NOLOCK(&globals); ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(pbx_cli[0])); /* Register builtin applications */ - for (x=0; x 2) - ast_verbose(VERBOSE_PREFIX_3 "Native bridging %s and %s\n", c0->name, c1->name); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "Native bridging %s and %s", c0->name, c1->name); /* Ok, we should be able to redirect the media. Start with one channel */ if (pr0->set_rtp_peer(c0, p1, vp1, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) @@ -1882,8 +1881,7 @@ rtpstart = 5000; rtpend = 31000; } - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "RTP Allocating from port range %d -> %d\n", rtpstart, rtpend); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "RTP Allocating from port range %d -> %d", rtpstart, rtpend); return 0; } Index: say.c =================================================================== --- say.c (revision 22820) +++ say.c (working copy) @@ -1191,10 +1191,8 @@ int state = 0; /* no need to save anything */ int mf = 1; /* +1 = Masculin; -1 = Feminin */ char fn[SAY_NUM_BUF_SIZE] = ""; - ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. " - "num: %d, options=\"%s\"\n", - num, options - ); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "ast_say_digits_full: started. " + "num: %d, options=\"%s\"", num, options); if (!num) return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); @@ -1210,10 +1208,8 @@ * state==0 is the normal mode and it means that we continue * to check if the number num has yet anything left. */ - ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, " - "state=%d, options=\"%s\", mf=%d\n", - num, state, options, mf - ); + AST_VERBOSE(3, VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, " + "state=%d, options=\"%s\", mf=%d", num, state, options, mf); if (state==1) { snprintf(fn, sizeof(fn), "digits/hundred"); state = 0; Index: srv.c =================================================================== --- srv.c (revision 22820) +++ srv.c (working copy) @@ -80,8 +80,7 @@ return -1; } if (res && strcmp(repl, ".")) { - if (option_verbose > 3) - ast_verbose( VERBOSE_PREFIX_3 "parse_srv: SRV mapped to host %s, port %d\n", repl, ntohs(srv->portnum)); + AST_VERBOSE(4, VERBOSE_PREFIX_3 "parse_srv: SRV mapped to host %s, port %d", repl, ntohs(srv->portnum)); if (host) { ast_copy_string(host, repl, hostlen); host[hostlen-1] = '\0'; Index: translate.c =================================================================== --- translate.c (revision 22820) +++ translate.c (working copy) @@ -597,8 +597,9 @@ AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { if (u == t) { AST_LIST_REMOVE_CURRENT(&translators, list); - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt)); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "Unregistered translator '%s' from format %s to %s", + term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), + ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt)); break; } } Index: udptl.c =================================================================== --- udptl.c (revision 22820) +++ udptl.c (working copy) @@ -1246,8 +1246,7 @@ udptlstart = 4500; udptlend = 4999; } - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend); + AST_VERBOSE(2, VERBOSE_PREFIX_2 "UDPTL allocating from port range %d -> %d", udptlstart, udptlend); } void ast_udptl_init(void)