From ec05153ac4e80313e89a0326bfefe17a4ae21f9c Mon Sep 17 00:00:00 2001 From: Russell Bryant <russell@russellbryant.com> Date: Sun, 4 Dec 2005 20:40:46 +0000 Subject: [PATCH] convert most of the option_*'s to a single ast_flags structure. Also, fix some formatting, remove some unnecessary casts, and other little code cleanups. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7331 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- app.c | 2 +- apps/app_chanisavail.c | 2 +- apps/app_controlplayback.c | 2 +- apps/app_db.c | 2 +- apps/app_dial.c | 4 +- apps/app_enumlookup.c | 4 +- apps/app_groupcount.c | 2 +- apps/app_hasnewvoicemail.c | 2 +- apps/app_image.c | 2 +- apps/app_lookupblacklist.c | 2 +- apps/app_md5.c | 2 +- apps/app_osplookup.c | 6 +- apps/app_playback.c | 2 +- apps/app_privacy.c | 2 +- apps/app_queue.c | 8 +- apps/app_record.c | 2 +- apps/app_sendtext.c | 2 +- apps/app_system.c | 2 +- apps/app_transfer.c | 2 +- apps/app_txtcidname.c | 2 +- apps/app_url.c | 4 +- apps/app_voicemail.c | 6 +- asterisk.c | 181 +++++++++++++++++-------------------- channel.c | 4 +- config.c | 2 +- file.c | 2 +- frame.c | 2 +- include/asterisk/logger.h | 5 + include/asterisk/options.h | 86 ++++++++++++++---- loader.c | 6 +- logger.c | 6 +- pbx/pbx_config.c | 22 ++--- pbx/pbx_dundi.c | 2 +- res/res_crypto.c | 4 +- term.c | 2 +- 35 files changed, 208 insertions(+), 180 deletions(-) diff --git a/app.c b/app.c index 60f60cec9a..cd3c23fcba 100644 --- a/app.c +++ b/app.c @@ -636,7 +636,7 @@ int ast_play_and_record(struct ast_channel *chan, const char *playfile, const ch /* Request a video update */ ast_indicate(chan, AST_CONTROL_VIDUPDATE); - if (option_transmit_silence_during_record) + if (ast_opt_transmit_silence) silgen = ast_channel_start_silence_generator(chan); if (x == fmtcnt) { diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c index 3ac603f718..7f8633a656 100644 --- a/apps/app_chanisavail.c +++ b/apps/app_chanisavail.c @@ -143,7 +143,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data) if (res < 1) { pbx_builtin_setvar_helper(chan, "AVAILCHAN", ""); pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ""); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { LOCAL_USER_REMOVE(u); return -1; diff --git a/apps/app_controlplayback.c b/apps/app_controlplayback.c index 55a46ceb57..262ba7a94c 100644 --- a/apps/app_controlplayback.c +++ b/apps/app_controlplayback.c @@ -139,7 +139,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data) pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "USERSTOPPED"); } else { if (res < 0) { - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { ast_log(LOG_WARNING, "ControlPlayback tried to jump to priority n+101 as requested, but priority didn't exist\n"); } diff --git a/apps/app_db.c b/apps/app_db.c index 245c8d3caf..e633cbfce8 100644 --- a/apps/app_db.c +++ b/apps/app_db.c @@ -264,7 +264,7 @@ static int get_exec(struct ast_channel *chan, void *data) } else { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "DBget: Value not found in database.\n"); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { /* Send the call to n+101 priority, where n is the current priority */ ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); } diff --git a/apps/app_dial.c b/apps/app_dial.c index 641e07e258..c224a9a95c 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -418,7 +418,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu strcpy(status, "CONGESTION"); else if (numnochan) strcpy(status, "CHANUNAVAIL"); - if (option_priority_jumping || priority_jump) + if (ast_opt_priority_jumping || priority_jump) ast_goto_if_exists(in, in->context, in->exten, in->priority + 101); } else { if (option_verbose > 2) @@ -1453,7 +1453,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags if ((macro_result = pbx_builtin_getvar_helper(peer, "MACRO_RESULT"))) { if (!strcasecmp(macro_result, "BUSY")) { ast_copy_string(status, macro_result, sizeof(status)); - if (option_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) { + if (ast_opt_priority_jumping || ast_test_flag(&opts, OPT_PRIORITY_JUMP)) { if (!ast_goto_if_exists(chan, NULL, NULL, chan->priority + 101)) { ast_set_flag(peerflags, OPT_GO_ON); } diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c index bd209c47b2..98e66e1a82 100644 --- a/apps/app_enumlookup.c +++ b/apps/app_enumlookup.c @@ -122,7 +122,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data) res = ast_get_enum(chan, args.d, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL); if (!res) { /* Failed to do a lookup */ - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { /* Look for a "busy" place */ ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); } @@ -180,7 +180,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data) *t = 0; pbx_builtin_setvar_helper(chan, "ENUM", tmp); ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51)) res = 0; } diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c index 0d35ca3945..a852860234 100644 --- a/apps/app_groupcount.c +++ b/apps/app_groupcount.c @@ -177,7 +177,7 @@ static int group_check_exec(struct ast_channel *chan, void *data) count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category); if (count > max) { pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OVERMAX"); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) res = -1; } diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c index 7ce8a91321..60a4611511 100644 --- a/apps/app_hasnewvoicemail.c +++ b/apps/app_hasnewvoicemail.c @@ -162,7 +162,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data) if (vmcount > 0) { /* Branch to the next extension */ - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101); } diff --git a/apps/app_image.c b/apps/app_image.c index e23b274a99..3ae9810175 100644 --- a/apps/app_image.c +++ b/apps/app_image.c @@ -96,7 +96,7 @@ static int sendimage_exec(struct ast_channel *chan, void *data) if (!ast_supports_images(chan)) { /* Does not support transport */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT"); LOCAL_USER_REMOVE(u); diff --git a/apps/app_lookupblacklist.c b/apps/app_lookupblacklist.c index 1f7e30fd8d..d7890be966 100644 --- a/apps/app_lookupblacklist.c +++ b/apps/app_lookupblacklist.c @@ -96,7 +96,7 @@ lookupblacklist_exec (struct ast_channel *chan, void *data) } if (bl) { - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND"); } else diff --git a/apps/app_md5.c b/apps/app_md5.c index 24f3b74e47..127b3d7e8e 100644 --- a/apps/app_md5.c +++ b/apps/app_md5.c @@ -156,7 +156,7 @@ static int md5check_exec(struct ast_channel *chan, void *data) if (option_debug > 2) ast_log(LOG_DEBUG, "ERROR: MD5 not verified: %s -- %s\n", args.md5hash, args.string); pbx_builtin_setvar_helper(chan, "CHECKMD5STATUS", "NOMATCH"); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) if (option_debug > 2) ast_log(LOG_DEBUG, "ERROR: Can't jump to exten+101 (e%s,p%d), sorry\n", chan->exten,chan->priority+101); diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c index 2fe2d016ac..e56038fdda 100644 --- a/apps/app_osplookup.c +++ b/apps/app_osplookup.c @@ -171,7 +171,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data) } if (!res) { /* Look for a "busy" place */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); } else if (res > 0) res = 0; @@ -244,7 +244,7 @@ static int ospnext_exec(struct ast_channel *chan, void *data) } if (!res) { /* Look for a "busy" place */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); } else if (res > 0) res = 0; @@ -317,7 +317,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data) } if (!res) { /* Look for a "busy" place */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); } else if (res > 0) res = 0; diff --git a/apps/app_playback.c b/apps/app_playback.c index ed33097ab3..6271fba77e 100644 --- a/apps/app_playback.c +++ b/apps/app_playback.c @@ -130,7 +130,7 @@ static int playback_exec(struct ast_channel *chan, void *data) ast_stopstream(chan); } else { ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data); - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); res = 0; mres = 1; diff --git a/apps/app_privacy.c b/apps/app_privacy.c index 799f31bd23..b94fd69d8f 100644 --- a/apps/app_privacy.c +++ b/apps/app_privacy.c @@ -202,7 +202,7 @@ static int privacy_exec (struct ast_channel *chan, void *data) ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",phone); pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS"); } else { - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED"); } diff --git a/apps/app_queue.c b/apps/app_queue.c index 5564d0fcd1..d997d25a13 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -2617,7 +2617,7 @@ static int pqm_exec(struct ast_channel *chan, void *data) if (set_member_paused(args.queuename, args.interface, 1)) { ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", args.interface); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { pbx_builtin_setvar_helper(chan, "PQMSTATUS", "NOTFOUND"); LOCAL_USER_REMOVE(u); @@ -2673,7 +2673,7 @@ static int upqm_exec(struct ast_channel *chan, void *data) if (set_member_paused(args.queuename, args.interface, 0)) { ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", args.interface); - if (priority_jump || option_priority_jumping) { + if (priority_jump || ast_opt_priority_jumping) { if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "NOTFOUND"); LOCAL_USER_REMOVE(u); @@ -2738,7 +2738,7 @@ static int rqm_exec(struct ast_channel *chan, void *data) break; case RES_EXISTS: ast_log(LOG_WARNING, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename); - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE"); res = 0; @@ -2814,7 +2814,7 @@ static int aqm_exec(struct ast_channel *chan, void *data) break; case RES_EXISTS: ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", args.interface, args.queuename); - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "AQMSTATUS", "MEMBERALREADY"); res = 0; diff --git a/apps/app_record.c b/apps/app_record.c index 85310ea708..669afc7a0d 100644 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -249,7 +249,7 @@ static int record_exec(struct ast_channel *chan, void *data) goto out; } - if (option_transmit_silence_during_record) + if (ast_opt_transmit_silence) silgen = ast_channel_start_silence_generator(chan); /* Request a video update */ diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c index 7830ee8600..c08a793f39 100644 --- a/apps/app_sendtext.c +++ b/apps/app_sendtext.c @@ -105,7 +105,7 @@ static int sendtext_exec(struct ast_channel *chan, void *data) if (!chan->tech->send_text) { ast_mutex_unlock(&chan->lock); /* Does not support transport */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); LOCAL_USER_REMOVE(u); return 0; diff --git a/apps/app_system.c b/apps/app_system.c index 63e9baacb6..f3e09ebbaf 100644 --- a/apps/app_system.c +++ b/apps/app_system.c @@ -111,7 +111,7 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode } else { if (res < 0) res = 0; - if (option_priority_jumping && res) + if (ast_opt_priority_jumping && res) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); if (res != 0) diff --git a/apps/app_transfer.c b/apps/app_transfer.c index aaff52be0d..78d5697c02 100644 --- a/apps/app_transfer.c +++ b/apps/app_transfer.c @@ -131,7 +131,7 @@ static int transfer_exec(struct ast_channel *chan, void *data) if (res < 0) { status = "FAILURE"; - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); res = 0; } else { diff --git a/apps/app_txtcidname.c b/apps/app_txtcidname.c index b6e365b548..f2a65dcb6e 100644 --- a/apps/app_txtcidname.c +++ b/apps/app_txtcidname.c @@ -119,7 +119,7 @@ static int txtcidname_exec(struct ast_channel *chan, void *data) } if (!res) { /* Look for a "busy" place */ - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "FAILED"); } else if (res > 0) diff --git a/apps/app_url.c b/apps/app_url.c index 7f274b46a9..a856fb1a42 100644 --- a/apps/app_url.c +++ b/apps/app_url.c @@ -108,7 +108,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data) if (!ast_channel_supports_html(chan)) { /* Does not support transport */ - if (local_option_jump || option_priority_jumping) + if (local_option_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED"); LOCAL_USER_REMOVE(u); @@ -144,7 +144,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data) case AST_HTML_NOSUPPORT: /* Does not support transport */ status ="UNSUPPORTED"; - if (local_option_jump || option_priority_jumping) + if (local_option_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); res = 0; goto out; diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 85ea1c8ff1..03ddc7bb20 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2382,7 +2382,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ if (!(vmu = find_user(&svm, context, ext))) { ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext); - if (ast_test_flag(options, OPT_PRIORITY_JUMP) || option_priority_jumping) + if (ast_test_flag(options, OPT_PRIORITY_JUMP) || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); return res; @@ -5543,7 +5543,7 @@ static int vm_exec(struct ast_channel *chan, void *data) if (res == ERROR_LOCK_PATH) { ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n"); /*Send the call to n+101 priority, where n is the current priority*/ - if (ast_test_flag(&leave_options, OPT_PRIORITY_JUMP) || option_priority_jumping) + if (ast_test_flag(&leave_options, OPT_PRIORITY_JUMP) || ast_opt_priority_jumping) if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) ast_log(LOG_WARNING, "Extension %s, priority %d doesn't exist.\n", chan->exten, chan->priority + 101); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); @@ -5633,7 +5633,7 @@ static int vm_box_exists(struct ast_channel *chan, void *data) if (find_user(&svm, context, args.mbox)) { pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "SUCCESS"); - if (priority_jump || option_priority_jumping) + if (priority_jump || ast_opt_priority_jumping) if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) ast_log(LOG_WARNING, "VM box %s@%s exists, but extension %s, priority %d doesn't exist\n", box, context, chan->exten, chan->priority + 101); } else diff --git a/asterisk.c b/asterisk.c index 93831ac0f9..025b5aeea7 100644 --- a/asterisk.c +++ b/asterisk.c @@ -136,32 +136,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Some of them can be changed in the CLI */ /*! @{ */ -int option_verbose=0; /*!< Verbosity level */ -int option_debug=0; /*!< Debug level */ -int option_exec_includes=0; /*!< Allow \#exec in config files? */ -int option_nofork=0; /*!< Do not fork */ -int option_quiet=0; /*!< Keep quiet */ -int option_console=0; /*!< Console mode, no background */ -int option_highpriority=0; /*!< Run in realtime Linux priority */ -int option_remote=0; /*!< Remote CLI */ -int option_exec=0; /*!< */ -int option_initcrypto=0; /*!< Initialize crypto keys for RSA auth */ -int option_nocolor; /*!< Don't use termcap colors */ -int option_dumpcore = 0; /*!< Dump core when failing */ -int option_cache_record_files = 0; /*!< Cache sound files */ -int option_timestamp = 0; /*!< Timestamp in logging */ -int option_overrideconfig = 0; /*!< */ -int option_reconnect = 0; /*!< */ -int option_transcode_slin = 1; /*!< */ -int option_maxcalls = 0; /*!< */ + +struct ast_flags ast_options = { AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_PRIORITY_JUMPING }; + +int option_verbose = 0; /*!< Verbosity level */ +int option_debug = 0; /*!< Debug level */ + double option_maxload = 0.0; /*!< Max load avg on system */ -int option_dontwarn = 0; /*!< */ -int option_priority_jumping = 1; /*!< Enable priority jumping as result value for apps */ -int option_transmit_silence_during_record = 0; /*!< Transmit silence during record() app */ +int option_maxcalls = 0; /*!< Max number of active calls */ /*! @} */ -int fully_booted = 0; char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR; char debug_filename[AST_FILENAME_MAX] = ""; @@ -831,7 +816,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) if (!nice) { /* Begin shutdown routine, hanging up active channels */ ast_begin_shutdown(1); - if (option_verbose && option_console) + if (option_verbose && ast_opt_console) ast_verbose("Beginning asterisk %s....\n", restart ? "restart" : "shutdown"); time(&s); for(;;) { @@ -849,7 +834,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) } else { if (nice < 2) ast_begin_shutdown(0); - if (option_verbose && option_console) + if (option_verbose && ast_opt_console) ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt"); for(;;) { if (!ast_active_channels()) @@ -861,12 +846,12 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) } if (!shuttingdown) { - if (option_verbose && option_console) + if (option_verbose && ast_opt_console) ast_verbose("Asterisk %s cancelled.\n", restart ? "restart" : "shutdown"); return; } } - if (option_console || option_remote) { + if (ast_opt_console || ast_opt_remote) { if (getenv("HOME")) snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); if (!ast_strlen_zero(filename)) @@ -880,7 +865,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) ast_verbose("Executing last minute cleanups\n"); ast_run_atexits(); /* Called on exit */ - if (option_verbose && option_console) + if (option_verbose && ast_opt_console) ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num); else if (option_debug) ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num); @@ -892,17 +877,18 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) if (ast_consock > -1) close(ast_consock); if (ast_socket > -1) - unlink((char *)ast_config_AST_SOCKET); - if (!option_remote) unlink((char *)ast_config_AST_PID); + unlink(ast_config_AST_SOCKET); + if (!ast_opt_remote) + unlink(ast_config_AST_PID); printf(term_quit()); if (restart) { - if (option_verbose || option_console) + if (option_verbose || ast_opt_console) ast_verbose("Preparing for Asterisk restart...\n"); /* Mark all FD's for closing on exec */ for (x=3;x<32768;x++) { fcntl(x, F_SETFD, FD_CLOEXEC); } - if (option_verbose || option_console) + if (option_verbose || ast_opt_console) ast_verbose("Restarting Asterisk NOW...\n"); restartnow = 1; @@ -961,7 +947,7 @@ static void console_verboser(const char *s, int pos, int replace, int complete) fflush(stdout); if (complete) { /* Wake up a poll()ing console */ - if (option_console && consolethread != AST_PTHREADT_NULL) + if (ast_opt_console && consolethread != AST_PTHREADT_NULL) pthread_kill(consolethread, SIGURG); } } @@ -1172,7 +1158,7 @@ static int ast_el_read_char(EditLine *el, char *cp) max = 1; fds[0].fd = ast_consock; fds[0].events = POLLIN; - if (!option_exec) { + if (!ast_opt_exec) { fds[1].fd = STDIN_FILENO; fds[1].events = POLLIN; max++; @@ -1185,7 +1171,7 @@ static int ast_el_read_char(EditLine *el, char *cp) break; } - if (!option_exec && fds[1].revents) { + if (!ast_opt_exec && fds[1].revents) { num_read = read(STDIN_FILENO, cp, 1); if (num_read < 1) { break; @@ -1197,7 +1183,7 @@ static int ast_el_read_char(EditLine *el, char *cp) /* if the remote side disappears exit */ if (res < 1) { fprintf(stderr, "\nDisconnected from Asterisk server\n"); - if (!option_reconnect) { + if (!ast_opt_reconnect) { quit_handler(0, 0, 0, 0); } else { int tries; @@ -1222,7 +1208,7 @@ static int ast_el_read_char(EditLine *el, char *cp) buf[res] = '\0'; - if (!option_exec && !lastpos) + if (!ast_opt_exec && !lastpos) write(STDOUT_FILENO, "\r", 1); write(STDOUT_FILENO, buf, res); if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) { @@ -1343,7 +1329,7 @@ static char *cli_prompt(EditLine *el) } break; case '#': /* process console or remote? */ - if (! option_remote) { + if (!ast_opt_remote) { strncat(p, "#", sizeof(prompt) - strlen(prompt) - 1); } else { strncat(p, ">", sizeof(prompt) - strlen(prompt) - 1); @@ -1497,7 +1483,7 @@ static char *cli_complete(EditLine *el, int ch) len = lf->cursor - ptr; - if (option_remote) { + if (ast_opt_remote) { snprintf(buf, sizeof(buf),"_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr); fdprint(ast_consock, buf); res = read(ast_consock, buf, sizeof(buf)); @@ -1707,7 +1693,7 @@ static void ast_remotecontrol(char * data) if (!ast_strlen_zero(filename)) ast_el_read_history(filename); - if (option_exec && data) { /* hack to print output then exit if asterisk -rx is used */ + if (ast_opt_exec && data) { /* hack to print output then exit if asterisk -rx is used */ char tempchar; struct pollfd fds[0]; fds[0].fd = ast_consock; @@ -1774,7 +1760,7 @@ static void ast_readconfig(void) { struct ast_variable *v; char *config = AST_CONFIG_FILE; - if (option_overrideconfig == 1) { + if (ast_opt_override_config) { cfg = ast_config_load(ast_config_AST_CONFIG_FILE); if (!cfg) ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE); @@ -1843,10 +1829,10 @@ static void ast_readconfig(void) { option_verbose = atoi(v->value); /* whether or not to force timestamping. (-T at startup) */ } else if (!strcasecmp(v->name, "timestamp")) { - option_timestamp = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP); /* whether or not to support #exec in config files */ } else if (!strcasecmp(v->name, "execincludes")) { - option_exec_includes = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_EXEC_INCLUDES); /* debug level (-d at startup) */ } else if (!strcasecmp(v->name, "debug")) { option_debug = 0; @@ -1855,40 +1841,40 @@ static void ast_readconfig(void) { } /* Disable forking (-f at startup) */ } else if (!strcasecmp(v->name, "nofork")) { - option_nofork = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK); /* Run quietly (-q at startup ) */ } else if (!strcasecmp(v->name, "quiet")) { - option_quiet = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET); /* Run as console (-c at startup, implies nofork) */ } else if (!strcasecmp(v->name, "console")) { - option_console = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CONSOLE); /* Run with highg priority if the O/S permits (-p at startup) */ } else if (!strcasecmp(v->name, "highpriority")) { - option_highpriority = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY); /* Initialize RSA auth keys (IAX2) (-i at startup) */ } else if (!strcasecmp(v->name, "initcrypto")) { - option_initcrypto = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_INIT_KEYS); /* Disable ANSI colors for console (-c at startup) */ } else if (!strcasecmp(v->name, "nocolor")) { - option_nocolor = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_COLOR); /* Disable some usage warnings for picky people :p */ } else if (!strcasecmp(v->name, "dontwarn")) { - option_dontwarn = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DONT_WARN); /* Dump core in case of crash (-g) */ } else if (!strcasecmp(v->name, "dumpcore")) { - option_dumpcore = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_DUMP_CORE); /* Cache recorded sound files to another directory during recording */ } else if (!strcasecmp(v->name, "cache_record_files")) { - option_cache_record_files = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CACHE_RECORD_FILES); /* Specify cache directory */ } else if (!strcasecmp(v->name, "record_cache_dir")) { ast_copy_string(record_cache_dir, v->value, AST_CACHE_DIR_LEN); /* Build transcode paths via SLINEAR, instead of directly */ } else if (!strcasecmp(v->name, "transcode_via_sln")) { - option_transcode_slin = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSCODE_VIA_SLIN); /* Transmit SLINEAR silence while a channel is being recorded */ } else if (!strcasecmp(v->name, "transmit_silence_during_record")) { - option_transmit_silence_during_record = ast_true(v->value); + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TRANSMIT_SILENCE); } else if (!strcasecmp(v->name, "maxcalls")) { if ((sscanf(v->value, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) { option_maxcalls = 0; @@ -1940,8 +1926,7 @@ int main(int argc, char *argv[]) /* if the progname is rasterisk consider it a remote console */ if (argv[0] && (strstr(argv[0], "rasterisk")) != NULL) { - option_remote++; - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE); } if (gethostname(hostname, sizeof(hostname)-1)) ast_copy_string(hostname, "<Unknown>", sizeof(hostname)); @@ -1970,33 +1955,29 @@ int main(int argc, char *argv[]) switch(c) { case 'd': option_debug++; - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK); break; case 'c': - option_console++; - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE); break; case 'f': - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK); break; case 'n': - option_nocolor++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR); break; case 'r': - option_remote++; - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE); break; case 'R': - option_remote++; - option_nofork++; - option_reconnect++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_REMOTE | AST_OPT_FLAG_RECONNECT); break; case 'p': - option_highpriority++; + ast_set_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY); break; case 'v': option_verbose++; - option_nofork++; + ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK); break; case 'M': if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) @@ -2007,27 +1988,27 @@ int main(int argc, char *argv[]) option_maxload = 0.0; break; case 'q': - option_quiet++; + ast_set_flag(&ast_options, AST_OPT_FLAG_QUIET); break; case 't': - option_cache_record_files++; + ast_set_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES); break; case 'T': - option_timestamp++; + ast_set_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP); break; case 'x': - option_exec++; + ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC); xarg = optarg; break; case 'C': - ast_copy_string((char *)ast_config_AST_CONFIG_FILE,optarg,sizeof(ast_config_AST_CONFIG_FILE)); - option_overrideconfig++; + ast_copy_string(ast_config_AST_CONFIG_FILE, optarg, sizeof(ast_config_AST_CONFIG_FILE)); + ast_set_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG); break; case 'i': - option_initcrypto++; + ast_set_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS); break; case'g': - option_dumpcore++; + ast_set_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE); break; case 'h': show_cli_help(); @@ -2049,14 +2030,14 @@ int main(int argc, char *argv[]) /* For remote connections, change the name of the remote connection. * We do this for the benefit of init scripts (which need to know if/when * the main asterisk process has died yet). */ - if (option_remote) { + if (ast_opt_remote) { strcpy(argv[0], "rasterisk"); for (x = 1; x < argc; x++) { argv[x] = argv[0] + 10; } } - if (option_dumpcore) { + if (ast_opt_dump_core) { struct rlimit l; memset(&l, 0, sizeof(l)); l.rlim_cur = RLIM_INFINITY; @@ -2066,7 +2047,7 @@ int main(int argc, char *argv[]) } } - if (option_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose("[ Reading Master Configuration ]"); ast_readconfig(); @@ -2077,7 +2058,7 @@ int main(int argc, char *argv[]) #ifndef __CYGWIN__ if (!is_child_of_nonroot) - ast_set_priority(option_highpriority); + ast_set_priority(ast_opt_high_priority); if (!is_child_of_nonroot && rungroup) { struct group *gr; @@ -2120,14 +2101,14 @@ int main(int argc, char *argv[]) printf(term_end()); fflush(stdout); - if (option_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose("[ Initializing Custom Configuration Options ]"); /* custom config setup */ register_config_cli(); read_config_maps(); - if (option_console) { + if (ast_opt_console) { if (el_hist == NULL || el == NULL) ast_el_initialize(); @@ -2137,8 +2118,8 @@ int main(int argc, char *argv[]) if (ast_tryconnect()) { /* One is already running */ - if (option_remote) { - if (option_exec) { + if (ast_opt_remote) { + if (ast_opt_exec) { ast_remotecontrol(xarg); quit_handler(0, 0, 0, 0); exit(0); @@ -2150,34 +2131,34 @@ int main(int argc, char *argv[]) quit_handler(0, 0, 0, 0); exit(0); } else { - ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", (char *)ast_config_AST_SOCKET); + ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", ast_config_AST_SOCKET); printf(term_quit()); exit(1); } - } else if (option_remote || option_exec) { + } else if (ast_opt_remote || ast_opt_exec) { ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n",ast_config_AST_SOCKET); printf(term_quit()); exit(1); } /* Blindly write pid file since we couldn't connect */ - unlink((char *)ast_config_AST_PID); - f = fopen((char *)ast_config_AST_PID, "w"); + unlink(ast_config_AST_PID); + f = fopen(ast_config_AST_PID, "w"); if (f) { fprintf(f, "%d\n", getpid()); fclose(f); } else - ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno)); + ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno)); - if (!option_verbose && !option_debug && !option_nofork && !option_console) { + if (!option_verbose && !option_debug && !ast_opt_no_fork && !ast_opt_console) { daemon(0,0); /* Blindly re-write pid file since we are forking */ - unlink((char *)ast_config_AST_PID); - f = fopen((char *)ast_config_AST_PID, "w"); + unlink(ast_config_AST_PID); + f = fopen(ast_config_AST_PID, "w"); if (f) { fprintf(f, "%d\n", getpid()); fclose(f); } else - ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno)); + ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno)); } /* Test recursive mutex locking. */ @@ -2192,13 +2173,13 @@ int main(int argc, char *argv[]) sigaddset(&sigs, SIGPIPE); sigaddset(&sigs, SIGWINCH); pthread_sigmask(SIG_BLOCK, &sigs, NULL); - if (option_console || option_verbose || option_remote) + if (ast_opt_console || option_verbose || ast_opt_remote) ast_register_verbose(console_verboser); /* Print a welcome message if desired */ - if (option_verbose || option_console) { + if (option_verbose || ast_opt_console) { WELCOME_MESSAGE; } - if (option_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose("[ Booting..."); signal(SIGURG, urg_handler); @@ -2285,20 +2266,20 @@ int main(int argc, char *argv[]) /* We might have the option of showing a console, but for now just do nothing... */ - if (option_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose(" ]\n"); - if (option_verbose || option_console) + if (option_verbose || ast_opt_console) ast_verbose(term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp))); - if (option_nofork) + if (ast_opt_no_fork) consolethread = pthread_self(); - fully_booted = 1; + ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED); pthread_sigmask(SIG_UNBLOCK, &sigs, NULL); #ifdef __AST_DEBUG_MALLOC __ast_mm_init(); #endif time(&ast_startuptime); ast_cli_register_multiple(core_cli, sizeof(core_cli) / sizeof(core_cli[0])); - if (option_console) { + if (ast_opt_console) { /* Console stuff now... */ /* Register our quit function */ char title[256]; diff --git a/channel.c b/channel.c index b9869df253..e321a36738 100644 --- a/channel.c +++ b/channel.c @@ -2689,7 +2689,7 @@ int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *pe /* if the best path is not 'pass through', then transcoding is needed; if desired, force transcode path to use SLINEAR between channels */ - if ((src != dst) && option_transcode_slin) + if ((src != dst) && ast_opt_transcode_via_slin) dst = AST_FORMAT_SLINEAR; if (ast_set_read_format(chan, dst) < 0) { ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, dst); @@ -2710,7 +2710,7 @@ int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *pe /* if the best path is not 'pass through', then transcoding is needed; if desired, force transcode path to use SLINEAR between channels */ - if ((src != dst) && option_transcode_slin) + if ((src != dst) && ast_opt_transcode_via_slin) dst = AST_FORMAT_SLINEAR; if (ast_set_read_format(peer, dst) < 0) { ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst); diff --git a/config.c b/config.c index 16c1547422..447db67314 100644 --- a/config.c +++ b/config.c @@ -450,7 +450,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat, do_exec = !strcasecmp(cur, "exec"); else do_exec = 0; - if (do_exec && !option_exec_includes) { + if (do_exec && !ast_opt_exec_includes) { ast_log(LOG_WARNING, "Cannot perform #exec unless execincludes option is enabled in asterisk.conf (options section)!\n"); do_exec = 0; } diff --git a/file.c b/file.c index 530ee488e1..49aeca06c9 100644 --- a/file.c +++ b/file.c @@ -909,7 +909,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con } } - if (option_cache_record_files && (fd > -1)) { + if (ast_opt_cache_record_files && (fd > -1)) { char *c; fclose(bfile); diff --git a/frame.c b/frame.c index a5a9cfdf59..41030aaca9 100644 --- a/frame.c +++ b/frame.c @@ -587,7 +587,7 @@ static int show_codecs(int fd, int argc, char *argv[]) if ((argc < 2) || (argc > 3)) return RESULT_SHOWUSAGE; - if (!option_dontwarn) + if (!ast_opt_dont_warn) ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n" "\tIt does not indicate anything about your configuration.\n"); diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index de8268fd3b..863f2881e2 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -39,6 +39,11 @@ extern "C" { a; \ } +#define VERBOSE_PREFIX_1 " " +#define VERBOSE_PREFIX_2 " == " +#define VERBOSE_PREFIX_3 " -- " +#define VERBOSE_PREFIX_4 " > " + /*! Used for sending a log message */ /*! \brief This is the standard logger function. Probably the only way you will invoke it would be something like this: diff --git a/include/asterisk/options.h b/include/asterisk/options.h index fd8f3aadb5..2360083a7e 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -27,38 +27,86 @@ extern "C" { #endif -#define AST_CACHE_DIR_LEN 512 +#define AST_CACHE_DIR_LEN 512 #define AST_FILENAME_MAX 80 +enum ast_option_flags { + /*! Allow \#exec in config files */ + AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0), + /*! Do not fork() */ + AST_OPT_FLAG_NO_FORK = (1 << 1), + /*! Keep quiet */ + AST_OPT_FLAG_QUIET = (1 << 2), + /*! Console mode */ + AST_OPT_FLAG_CONSOLE = (1 << 3), + /*! Run in realtime Linux priority */ + AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4), + /*! Initialize keys for RSA authentication */ + AST_OPT_FLAG_INIT_KEYS = (1 << 5), + /*! Remote console */ + AST_OPT_FLAG_REMOTE = (1 << 6), + /*! Execute an asterisk CLI command upon startup */ + AST_OPT_FLAG_EXEC = (1 << 7), + /*! Don't use termcap colors */ + AST_OPT_FLAG_NO_COLOR = (1 << 8), + /*! Are we fully started yet? */ + AST_OPT_FLAG_FULLY_BOOTED = (1 << 9), + /*! Trascode via signed linear */ + AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10), + /*! Enable priority jumping in applications */ + AST_OPT_FLAG_PRIORITY_JUMPING = (1 << 11), + /*! Dump core on a seg fault */ + AST_OPT_FLAG_DUMP_CORE = (1 << 12), + /*! Cache sound files */ + AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13), + /*! Display timestamp in log messages */ + AST_OPT_FLAG_TIMESTAMP = (1 << 14), + /*! Override config */ + AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15), + /*! Reconnect */ + AST_OPT_FLAG_RECONNECT = (1 << 16), + /*! Transmit Silence during Record() */ + AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17), + /*! Suppress some warnings */ + AST_OPT_FLAG_DONT_WARN = (1 << 18) +}; + +#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) +#define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK) +#define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET) +#define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE) +#define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY) +#define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS) +#define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE) +#define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC) +#define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR) +#define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED) +#define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) +#define ast_opt_priority_jumping ast_test_flag(&ast_options, AST_OPT_FLAG_PRIORITY_JUMPING) +#define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE) +#define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES) +#define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP) +#define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG) +#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT) +#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) +#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN) + +extern struct ast_flags ast_options; + extern int option_verbose; extern int option_debug; -extern int option_nofork; -extern int option_quiet; -extern int option_console; -extern int option_initcrypto; -extern int option_nocolor; -extern int fully_booted; -extern int option_exec_includes; -extern int option_cache_record_files; -extern int option_timestamp; -extern int option_transcode_slin; -extern int option_transmit_silence_during_record; extern int option_maxcalls; extern double option_maxload; -extern int option_dontwarn; -extern int option_priority_jumping; + extern char defaultlanguage[]; + extern time_t ast_startuptime; extern time_t ast_lastreloadtime; extern int ast_mainpid; + extern char record_cache_dir[AST_CACHE_DIR_LEN]; extern char debug_filename[AST_FILENAME_MAX]; -#define VERBOSE_PREFIX_1 " " -#define VERBOSE_PREFIX_2 " == " -#define VERBOSE_PREFIX_3 " -- " -#define VERBOSE_PREFIX_4 " > " - #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/loader.c b/loader.c index aa2a282974..46fad50b39 100644 --- a/loader.c +++ b/loader.c @@ -383,10 +383,10 @@ static int __load_resource(const char *resource_name, const struct ast_config *c ast_mutex_unlock(&modlock); return -1; } - if (!fully_booted) { + if (!ast_fully_booted) { if (option_verbose) ast_verbose( " => (%s)\n", term_color(tmp, m->description(), COLOR_BROWN, COLOR_BLACK, sizeof(tmp))); - if (option_console && !option_verbose) + if (ast_opt_console && !option_verbose) ast_verbose( "."); } else { if (option_verbose) @@ -560,7 +560,7 @@ int load_modules(const int preload_only) } closedir(mods); } else { - if (!option_quiet) + if (!ast_opt_quiet) ast_log(LOG_WARNING, "Unable to open modules directory %s.\n", (char *)ast_config_AST_MODULE_DIR); } } diff --git a/logger.c b/logger.c index bf6799d4a6..aae10c604a 100644 --- a/logger.c +++ b/logger.c @@ -753,7 +753,7 @@ void ast_log(int level, const char *file, int line, const char *function, const if (level != __LOG_VERBOSE) { sprintf(linestr, "%d", line); - snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ", + snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ", date, term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), (long)GETTID(), @@ -770,7 +770,7 @@ void ast_log(int level, const char *file, int line, const char *function, const /* File channels */ } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) { int res; - snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date, + snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date, levels[level], (long)GETTID(), file); res = fprintf(chan->fileptr, buf); if (res <= 0 && buf[0] != '\0') { /* Error, no characters printed */ @@ -830,7 +830,7 @@ void ast_verbose(const char *fmt, ...) va_list ap; va_start(ap, fmt); - if (option_timestamp) { + if (ast_opt_timestamp) { time_t t; struct tm tm; char date[40]; diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 1bcb2f5150..f9267737a8 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1618,23 +1618,17 @@ static int pbx_load_module(void) cfg = ast_config_load(config); if (cfg) { /* Use existing config to populate the PBX table */ - static_config = ast_true(ast_variable_retrieve(cfg, "general", - "static")); - write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", - "writeprotect")); - autofallthrough_config = ast_true(ast_variable_retrieve(cfg, "general", - "autofallthrough")); - clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", - "clearglobalvars")); - option_priority_jumping = !ast_false(ast_variable_retrieve(cfg, "general", - "priorityjumping")); - + static_config = ast_true(ast_variable_retrieve(cfg, "general", "static")); + write_protect_config = ast_true(ast_variable_retrieve(cfg, "general", "writeprotect")); + autofallthrough_config = ast_true(ast_variable_retrieve(cfg, "general", "autofallthrough")); + clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars")); + ast_set2_flag(&ast_options, !ast_false(ast_variable_retrieve(cfg, "general", "priorityjumping")), AST_OPT_FLAG_PRIORITY_JUMPING); + v = ast_variable_browse(cfg, "globals"); - while(v) { + for (; v; v = v->next) { memset(realvalue, 0, sizeof(realvalue)); pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1); pbx_builtin_setvar_helper(NULL, v->name, realvalue); - v = v->next; } cxt = ast_category_browse(cfg, NULL); while(cxt) { @@ -1736,7 +1730,7 @@ static int pbx_load_module(void) if (plus) ipri += atoi(plus); lastpri = ipri; - if(!option_dontwarn) { + if (!ast_opt_dont_warn) { if (!strcmp(realext, "_.")) ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X.' instead at line %d\n", v->lineno); } diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 15b15845b4..1e5f7446f9 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -3912,7 +3912,7 @@ static int dundi_lookup_exec(struct ast_channel *chan, void *data) break; } } - } else if (option_priority_jumping) + } else if (ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); LOCAL_USER_REMOVE(u); diff --git a/res/res_crypto.c b/res/res_crypto.c index 037ff8e790..3ada0d2249 100644 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -268,7 +268,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i ast_log(LOG_NOTICE, "Key '%s' needs passcode.\n", key->name); key->ktype |= KEY_NEEDS_PASSCODE; if (!notice) { - if (!option_initcrypto) + if (!ast_opt_init_keys) ast_log(LOG_NOTICE, "Add the '-i' flag to the asterisk command line if you want to automatically initialize passcodes at launch.\n"); notice++; } @@ -592,7 +592,7 @@ int reload(void) int load_module(void) { crypto_init(); - if (option_initcrypto) + if (ast_opt_init_keys) crypto_load(STDIN_FILENO, STDOUT_FILENO); else crypto_load(-1, -1); diff --git a/term.c b/term.c index 582adb0af8..cce5155735 100644 --- a/term.c +++ b/term.c @@ -80,7 +80,7 @@ int term_init(void) if (!term) return 0; - if (!option_console || option_nocolor || !option_nofork) + if (!ast_opt_console || ast_opt_no_color || !ast_opt_no_fork) return 0; for (i=0 ;; i++) { -- GitLab