diff options
154 files changed, 1933 insertions, 1933 deletions
@@ -17,6 +17,13 @@ app_fax * The app_fax module is now deprecated, users should migrate to the replacement module res_fax. +Build System +------------------ + * MALLOC_DEBUG no longer has an effect on Asterisk's ABI. Asterisk built + with MALLOC_DEBUG can now successfully load binary modules built without + MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer + need to have a special build with it enabled. + app_macro ------------------ * The app_macro module is now deprecated and by default it is no longer @@ -217,7 +217,9 @@ ifeq ($(AST_DEVMODE),yes) endif endif -ifneq ($(findstring BSD,$(OSARCH)),) +ifeq ($(OSARCH),NetBSD) + _ASTCFLAGS+=-isystem /usr/pkg/include +else ifneq ($(findstring BSD,$(OSARCH)),) _ASTCFLAGS+=-isystem /usr/local/include endif @@ -239,7 +241,9 @@ ifeq ($(OSARCH),SunOS) _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__ endif -ifneq ($(GREP),:) +ifeq ($(GREP),) +else ifeq ($(GREP),:) +else ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .) endif ifneq ($(AWK),) @@ -282,7 +286,9 @@ else # These are used for all but Darwin SOLINK=-shared DYLINK=$(SOLINK) - ifneq ($(findstring BSD,$(OSARCH)),) + ifeq ($(OSARCH),NetBSD) + _ASTLDFLAGS+=-L/usr/pkg/lib + else ifneq ($(findstring BSD,$(OSARCH)),) _ASTLDFLAGS+=-L/usr/local/lib endif endif @@ -467,7 +473,9 @@ endif $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \ done -ifneq ($(GREP),:) +ifeq ($(GREP),) +else ifeq ($(GREP),:) +else XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null)) endif @@ -486,7 +494,9 @@ doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US) @echo @echo "</docs>" >> $@ -ifneq ($(GREP),:) +ifeq ($(GREP),) +else ifeq ($(GREP),:) +else XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null)) endif @@ -630,7 +640,9 @@ oldmodcheck: fi ld-cache-update: -ifneq ($(LDCONFIG),:) +ifeq ($(LDCONFIG),) +else ifeq ($(LDCONFIG),:) +else ifeq ($(DESTDIR),) # DESTDIR means binary archive creation; ldconfig should be run on postinst @if [ $$(id -u) -eq 0 ] ; then \ $(LDCONFIG) "$(ASTLIBDIR)/" ; \ @@ -984,7 +996,9 @@ ifeq ($(HAVE_DAHDI),1) rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk endif $(MAKE) -C sounds uninstall -ifneq ($(LDCONFIG),:) +ifeq ($(LDCONFIG),) +else ifeq ($(LDCONFIG),:) +else $(LDCONFIG) "$(ASTLIBDIR)/" || : endif diff --git a/UPGRADE.txt b/UPGRADE.txt index 366825863..108c10a01 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -44,6 +44,12 @@ ARI: - The ContactInfo event's contact_status field is now set to "NonQualified" when a contact exists but has not been qualified. +Build System: + - MALLOC_DEBUG no longer has an effect on Asterisk's ABI. Asterisk built + with MALLOC_DEBUG can now successfully load binary modules built without + MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer + need to have a special build with it enabled. + cdr_syslog: - The cdr_syslog module is now deprecated and by default it is no longer built. diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c index 00c75dd68..2fefe4ed1 100644 --- a/addons/cdr_mysql.c +++ b/addons/cdr_mysql.c @@ -724,4 +724,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MySQL CDR Backend", .load = load_module, .unload = unload_module, .reload = reload, + .requires = "cdr", ); diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c index 8c4ff2c4a..ffdbf6721 100644 --- a/addons/chan_ooh323.c +++ b/addons/chan_ooh323.c @@ -1174,8 +1174,7 @@ static int ooh323_answer(struct ast_channel *ast) p->alertsent = 1; } ast_setstate(ast, AST_STATE_UP); - if (option_debug) - ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast)); + ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast)); ast_channel_unlock(ast); ooAnswerCall(p->callToken); } @@ -5244,5 +5243,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Objective Systems H32 .load = load_module, .unload = unload_module, .reload = reload_module, - .load_pri = AST_MODPRI_CHANNEL_DRIVER + .load_pri = AST_MODPRI_CHANNEL_DRIVER, + .requires = "udptl", ); diff --git a/addons/res_config_mysql.c b/addons/res_config_mysql.c index ae4348500..edd938506 100644 --- a/addons/res_config_mysql.c +++ b/addons/res_config_mysql.c @@ -1559,4 +1559,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "MySQL RealTime Config .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig", ); diff --git a/apps/app_celgenuserevent.c b/apps/app_celgenuserevent.c index 67c7fbcbd..11b11b07c 100644 --- a/apps/app_celgenuserevent.c +++ b/apps/app_celgenuserevent.c @@ -103,4 +103,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, + .requires = "cel", ); diff --git a/apps/app_dial.c b/apps/app_dial.c index 257ff472a..3d16fb6a1 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1605,6 +1605,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, break; } break; + case AST_FRAME_VIDEO: case AST_FRAME_VOICE: case AST_FRAME_IMAGE: if (caller_entertained) { @@ -1703,6 +1704,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, ast_log(LOG_WARNING, "Unable to send URL\n"); } break; + case AST_FRAME_VIDEO: case AST_FRAME_VOICE: case AST_FRAME_IMAGE: if (!single || caller_entertained) { @@ -3378,4 +3380,9 @@ static int load_module(void) return res; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialing Application"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Dialing Application", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .requires = "ccss", +); diff --git a/apps/app_directory.c b/apps/app_directory.c index 48533f592..a47fe3b66 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -815,10 +815,10 @@ static int do_directory(struct ast_channel *chan, struct ast_config *vmcfg, stru /* Sort items */ sort_items(sorted, count); - if (option_debug) { - ast_debug(2, "Listing matching entries:\n"); + if (DEBUG_ATLEAST(2)) { + ast_log(LOG_DEBUG, "Listing matching entries:\n"); for (ptr = sorted, i = 0; i < count; i++, ptr++) { - ast_debug(2, "%s: %s\n", ptr[0]->exten, ptr[0]->name); + ast_log(LOG_DEBUG, "%s: %s\n", ptr[0]->exten, ptr[0]->name); } } diff --git a/apps/app_fax.c b/apps/app_fax.c index 293925ac1..c5d0f514b 100644 --- a/apps/app_fax.c +++ b/apps/app_fax.c @@ -995,7 +995,7 @@ static int load_module(void) AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Simple FAX Application", - .support_level = AST_MODULE_SUPPORT_EXTENDED, + .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, ); diff --git a/apps/app_forkcdr.c b/apps/app_forkcdr.c index 73963f3e1..25b56cb5a 100644 --- a/apps/app_forkcdr.c +++ b/apps/app_forkcdr.c @@ -215,4 +215,9 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fork The CDR into 2 separate entities"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Fork The CDR into 2 separate entities", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .requires = "cdr", +); diff --git a/apps/app_minivm.c b/apps/app_minivm.c index e9fa2118c..c09fba173 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -1438,7 +1438,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu ast_debug(1, "Using default subject for this email \n"); } - if (option_debug > 2) + if (DEBUG_ATLEAST(3)) fprintf(p, "X-Asterisk-debug: template %s user account %s@%s\n", template->name, vmu->username, vmu->domain); fprintf(p, "MIME-Version: 1.0\n"); diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c index c42e1873e..78f573a6c 100644 --- a/apps/app_osplookup.c +++ b/apps/app_osplookup.c @@ -50,7 +50,6 @@ #include "asterisk/module.h" #include "asterisk/pbx.h" #include "asterisk/cli.h" -#include "asterisk/astosp.h" /*** DOCUMENTATION <application name="OSPAuth" language="en_US"> @@ -436,6 +435,11 @@ </application> ***/ +/* OSP Return statuses */ +#define AST_OSP_SUCCESS ((char*)"SUCCESS") /* Return status, success */ +#define AST_OSP_FAILED ((char*)"FAILED") /* Return status, failed */ +#define AST_OSP_ERROR ((char*)"ERROR") /* Return status, error */ + /* OSP Buffer Sizes */ #define OSP_SIZE_INTSTR ((unsigned int)16) /* OSP signed/unsigned int string buffer size */ #define OSP_SIZE_NORSTR ((unsigned int)256) /* OSP normal string buffer size */ diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 72e3e59c1..c4df4dcbb 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -63,7 +63,6 @@ </member> <member name="ODBC_STORAGE" displayname="Storage of Voicemail using ODBC"> <depend>generic_odbc</depend> - <depend>ltdl</depend> <conflict>IMAP_STORAGE</conflict> <conflict>FILE_STORAGE</conflict> <defaultenabled>no</defaultenabled> @@ -3657,7 +3656,7 @@ static void set_update(MAILSTREAM * stream) char buf[1024] = ""; if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))) || !(vms = get_vm_state_by_imapuser(user, 0))) { - if (user && option_debug > 2) + if (user && DEBUG_ATLEAST(3)) ast_log(AST_LOG_WARNING, "User %s mailbox not found for update.\n", user); return; } @@ -6089,22 +6088,33 @@ static int has_voicemail(const char *mailbox, const char *folder) return 0; } - +/*! + * \brief Check the given mailbox's message count. + * \param mailbox The @ delimited string for user@context. If no context is found, uses 'default' for the context. + * \param urgentmsgs urgent message count. + * \param newmsgs new message count. + * \param oldmsgs old message count pointer + * \return -1 if error occurred, 0 otherwise. + */ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs) { char tmp[256]; char *context; /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + if (ast_strlen_zero(mailbox)) { return 0; + } - if (newmsgs) + if (newmsgs) { *newmsgs = 0; - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs = 0; - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs = 0; + } if (strchr(mailbox, ',')) { int tmpnew, tmpold, tmpurgent; @@ -6114,15 +6124,18 @@ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int * mb = tmp; while ((cur = strsep(&mb, ", "))) { if (!ast_strlen_zero(cur)) { - if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) + if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) { return -1; - else { - if (newmsgs) + } else { + if (newmsgs) { *newmsgs += tmpnew; - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs += tmpold; - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs += tmpurgent; + } } } } @@ -6131,17 +6144,21 @@ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int * ast_copy_string(tmp, mailbox, sizeof(tmp)); - if ((context = strchr(tmp, '@'))) + if ((context = strchr(tmp, '@'))) { *context++ = '\0'; - else + } else { context = "default"; + } - if (newmsgs) + if (newmsgs) { *newmsgs = __has_voicemail(context, tmp, "INBOX", 0); - if (oldmsgs) + } + if (oldmsgs) { *oldmsgs = __has_voicemail(context, tmp, "Old", 0); - if (urgentmsgs) + } + if (urgentmsgs) { *urgentmsgs = __has_voicemail(context, tmp, "Urgent", 0); + } return 0; } @@ -7854,7 +7871,8 @@ static int get_folder2(struct ast_channel *chan, char *fn, int start) ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", '#', '#'); return '#'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); return res; } @@ -8017,7 +8035,8 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, if (retries > 3) { cmd = '*'; /* Let's cancel this beast */ } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } @@ -8245,7 +8264,8 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st cmd = 't'; done = 1; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd < 0 || cmd == 't') @@ -8910,7 +8930,8 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn); res = 0; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); } DISPOSE(vms->curdir, vms->curmsg); return res; @@ -10765,7 +10786,8 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct if (retries > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd == 't') @@ -10845,7 +10867,8 @@ static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, st if (retries > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } DISPOSE(prefile, -1); @@ -11667,7 +11690,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) } else { cmd = vm_intro(chan, vmu, &vms); } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); vms.repeats = 0; vms.starting = 1; @@ -11687,7 +11711,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) adsi_folders(chan, 0, "Change to folder..."); cmd = get_folder2(chan, "vm-changeto", 0); - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); if (cmd == '#') { cmd = 0; } else if (cmd > 0) { @@ -11819,7 +11844,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) if (vms.repeats > 3) { cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } } if (cmd == 't') { @@ -11997,7 +12023,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) if (useadsi) adsi_folders(chan, 1, "Save to folder..."); cmd = get_folder2(chan, "vm-savefolder", 1); - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); box = 0; /* Shut up compiler */ if (cmd == '#') { cmd = 0; @@ -13241,7 +13268,10 @@ static void stop_poll_thread(void) poll_thread = AST_PTHREADT_NULL; } -/*! \brief Append vmu info string into given astman with event_name. */ +/*! + * \brief Append vmu info string into given astman with event_name. + * \return 0 failed. 1 otherwise. +*/ static int append_vmu_info_astman( struct mansession *s, struct ast_vm_user *vmu, @@ -13251,14 +13281,33 @@ static int append_vmu_info_astman( { int new; int old; + char *mailbox; + int ret; if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) { ast_log(LOG_ERROR, "Wrong input parameter."); return 0; } + /* create mailbox string */ + if (!ast_strlen_zero(vmu->context)) { + ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context); + } else { + ret = ast_asprintf(&mailbox, "%s", vmu->mailbox); + } + if (ret == -1) { + ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno)); + return 0; + } + /* get mailbox count */ - inboxcount(vmu->mailbox, &new, &old); + ret = inboxcount(mailbox, &new, &old); + ast_free(mailbox); + if (ret == -1) { + ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n", + vmu->mailbox ?: "", vmu->context ?: ""); + return 0; + } astman_append(s, "Event: %s\r\n" @@ -15141,7 +15190,8 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, else cmd = 't'; } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?'); } if (retries >= 3) { return 0; @@ -15306,7 +15356,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s res = 't'; } } - ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res); + ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", + isprint(res) ? res : '?', isprint(res) ? res : '?'); break; } diff --git a/build_tools/make_buildopts_h b/build_tools/make_buildopts_h index 3ba4cb9dd..c47d5082c 100755 --- a/build_tools/make_buildopts_h +++ b/build_tools/make_buildopts_h @@ -20,18 +20,19 @@ fi TMP=`${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'` for x in ${TMP}; do echo "#define ${x} 1" - if test "${x}" = "DONT_OPTIMIZE" \ + if test "${x}" = "AO2_DEBUG" \ -o "${x}" = "BETTER_BACKTRACES" \ - -o "${x}" = "LOTS_OF_SPANS" \ -o "${x}" = "BUILD_NATIVE" \ - -o "${x}" = "LOW_MEMORY" \ - -o "${x}" = "REF_DEBUG" \ - -o "${x}" = "AO2_DEBUG" \ - -o "${x}" = "REBUILD_PARSERS" \ - -o "${x}" = "RADIO_RELAX" \ -o "${x}" = "DEBUG_SCHEDULER" \ -o "${x}" = "DETECT_DEADLOCKS" \ - -o "${x}" = "DUMP_SCHEDULER" ; then + -o "${x}" = "DONT_OPTIMIZE" \ + -o "${x}" = "DUMP_SCHEDULER" \ + -o "${x}" = "LOTS_OF_SPANS" \ + -o "${x}" = "LOW_MEMORY" \ + -o "${x}" = "MALLOC_DEBUG" \ + -o "${x}" = "RADIO_RELAX" \ + -o "${x}" = "REBUILD_PARSERS" \ + -o "${x}" = "REF_DEBUG" ; then # These aren't ABI affecting options, keep them out of AST_BUILDOPTS continue fi diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in index afea01f59..e62c183b7 100644 --- a/build_tools/menuselect-deps.in +++ b/build_tools/menuselect-deps.in @@ -34,7 +34,6 @@ LIBEDIT=@PBX_LIBEDIT@ LIBXML2=@PBX_LIBXML2@ XMLSTARLET=@PBX_XMLSTARLET@ BASH=@PBX_BASH@ -LTDL=@PBX_LTDL@ LUA=@PBX_LUA@ MISDN=@PBX_MISDN@ MYSQLCLIENT=@PBX_MYSQLCLIENT@ diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c index d4da850ce..feb62e9fb 100644 --- a/cdr/cdr_adaptive_odbc.c +++ b/cdr/cdr_adaptive_odbc.c @@ -35,6 +35,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <depend>generic_odbc</depend> <support_level>core</support_level> ***/ @@ -830,4 +831,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Adaptive ODBC CDR bac .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr,res_odbc", ); diff --git a/cdr/cdr_beanstalkd.c b/cdr/cdr_beanstalkd.c index 8f4863aa5..524274ffb 100644 --- a/cdr/cdr_beanstalkd.c +++ b/cdr/cdr_beanstalkd.c @@ -261,9 +261,10 @@ static int reload(void) { } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Beanstalkd CDR Backend", -.support_level = AST_MODULE_SUPPORT_EXTENDED, -.load = load_module, -.unload = unload_module, -.reload = reload, -.load_pri = AST_MODPRI_CDR_DRIVER, + .support_level = AST_MODULE_SUPPORT_EXTENDED, + .load = load_module, + .unload = unload_module, + .reload = reload, + .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c index 5666a3d4e..e4c74ff1e 100644 --- a/cdr/cdr_csv.c +++ b/cdr/cdr_csv.c @@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Comma Separated Value .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c index 5a5eb9ed0..72a475c8c 100644 --- a/cdr/cdr_custom.c +++ b/cdr/cdr_custom.c @@ -231,4 +231,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable Comma Se .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c index 3f0cc6b6d..74f37d207 100644 --- a/cdr/cdr_manager.c +++ b/cdr/cdr_manager.c @@ -371,4 +371,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Inte .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c index b44bbf52a..54ca1b9e3 100644 --- a/cdr/cdr_odbc.c +++ b/cdr/cdr_odbc.c @@ -39,6 +39,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <depend>generic_odbc</depend> <support_level>extended</support_level> ***/ @@ -327,4 +328,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ODBC CDR Backend", .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index b482fe6c8..a4919d57f 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -644,20 +644,20 @@ static int config_module(int reload) return -1; } - if (option_debug) { + if (DEBUG_ATLEAST(1)) { if (ast_strlen_zero(pghostname)) { - ast_debug(1, "using default unix socket\n"); + ast_log(LOG_DEBUG, "using default unix socket\n"); } else { - ast_debug(1, "got hostname of %s\n", pghostname); + ast_log(LOG_DEBUG, "got hostname of %s\n", pghostname); } - ast_debug(1, "got port of %s\n", pgdbport); - ast_debug(1, "got user of %s\n", pgdbuser); - ast_debug(1, "got dbname of %s\n", pgdbname); - ast_debug(1, "got password of %s\n", pgpassword); - ast_debug(1, "got application name of %s\n", pgappname); - ast_debug(1, "got sql table name of %s\n", table); - ast_debug(1, "got encoding of %s\n", encoding); - ast_debug(1, "got timezone of %s\n", tz); + ast_log(LOG_DEBUG, "got port of %s\n", pgdbport); + ast_log(LOG_DEBUG, "got user of %s\n", pgdbuser); + ast_log(LOG_DEBUG, "got dbname of %s\n", pgdbname); + ast_log(LOG_DEBUG, "got password of %s\n", pgpassword); + ast_log(LOG_DEBUG, "got application name of %s\n", pgappname); + ast_log(LOG_DEBUG, "got sql table name of %s\n", table); + ast_log(LOG_DEBUG, "got encoding of %s\n", encoding); + ast_log(LOG_DEBUG, "got timezone of %s\n", tz); } pgsql_reconnect(); @@ -794,4 +794,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL CDR Backen .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c index a43e96cd8..0a5fa6371 100644 --- a/cdr/cdr_radius.c +++ b/cdr/cdr_radius.c @@ -287,4 +287,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CDR Backend", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_sqlite.c b/cdr/cdr_sqlite.c index b91296073..aceff0f57 100644 --- a/cdr/cdr_sqlite.c +++ b/cdr/cdr_sqlite.c @@ -248,4 +248,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite CDR Backend", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c index 2212d0499..9f71c8481 100644 --- a/cdr/cdr_sqlite3_custom.c +++ b/cdr/cdr_sqlite3_custom.c @@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite3 Custom CDR Mo .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_syslog.c b/cdr/cdr_syslog.c index bbc44064f..4f0a78ccb 100644 --- a/cdr/cdr_syslog.c +++ b/cdr/cdr_syslog.c @@ -292,4 +292,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable syslog C .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c index f3d0628ec..2de4e426a 100644 --- a/cdr/cdr_tds.c +++ b/cdr/cdr_tds.c @@ -635,4 +635,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "FreeTDS CDR Backend", .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cdr", ); diff --git a/cel/cel_beanstalkd.c b/cel/cel_beanstalkd.c index e6f23808c..fe4f430e9 100644 --- a/cel/cel_beanstalkd.c +++ b/cel/cel_beanstalkd.c @@ -272,4 +272,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Beanstalkd CEL Backen .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_custom.c b/cel/cel_custom.c index 9c81ee1d4..73423a362 100644 --- a/cel/cel_custom.c +++ b/cel/cel_custom.c @@ -223,4 +223,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Customizable Comma Se .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_manager.c b/cel/cel_manager.c index 365bb70c2..e485aab49 100644 --- a/cel/cel_manager.c +++ b/cel/cel_manager.c @@ -380,4 +380,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Inte .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_odbc.c b/cel/cel_odbc.c index 05c1095cb..04d37346d 100644 --- a/cel/cel_odbc.c +++ b/cel/cel_odbc.c @@ -28,6 +28,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <depend>generic_odbc</depend> <support_level>core</support_level> ***/ @@ -855,4 +856,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ODBC CEL backend", .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel,res_odbc", ); diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c index 5fe66784b..77dd46ae7 100644 --- a/cel/cel_pgsql.c +++ b/cel/cel_pgsql.c @@ -556,18 +556,18 @@ static int process_my_load_module(struct ast_config *cfg) ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying schema info\n"); return AST_MODULE_LOAD_DECLINE; } - if (option_debug) { + if (DEBUG_ATLEAST(3)) { if (ast_strlen_zero(pghostname)) { - ast_debug(3, "cel_pgsql: using default unix socket\n"); + ast_log(LOG_DEBUG, "cel_pgsql: using default unix socket\n"); } else { - ast_debug(3, "cel_pgsql: got hostname of %s\n", pghostname); + ast_log(LOG_DEBUG, "cel_pgsql: got hostname of %s\n", pghostname); } - ast_debug(3, "cel_pgsql: got port of %s\n", pgdbport); - ast_debug(3, "cel_pgsql: got user of %s\n", pgdbuser); - ast_debug(3, "cel_pgsql: got dbname of %s\n", pgdbname); - ast_debug(3, "cel_pgsql: got password of %s\n", pgpassword); - ast_debug(3, "cel_pgsql: got sql table name of %s\n", table); - ast_debug(3, "cel_pgsql: got show_user_defined of %s\n", + ast_log(LOG_DEBUG, "cel_pgsql: got port of %s\n", pgdbport); + ast_log(LOG_DEBUG, "cel_pgsql: got user of %s\n", pgdbuser); + ast_log(LOG_DEBUG, "cel_pgsql: got dbname of %s\n", pgdbname); + ast_log(LOG_DEBUG, "cel_pgsql: got password of %s\n", pgpassword); + ast_log(LOG_DEBUG, "cel_pgsql: got sql table name of %s\n", table); + ast_log(LOG_DEBUG, "cel_pgsql: got show_user_defined of %s\n", cel_show_user_def ? "Yes" : "No"); } @@ -709,4 +709,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL CEL Backen .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_radius.c b/cel/cel_radius.c index 250d6a778..4e87f86d5 100644 --- a/cel/cel_radius.c +++ b/cel/cel_radius.c @@ -259,4 +259,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CEL Backend", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_sqlite3_custom.c b/cel/cel_sqlite3_custom.c index 5675da6b3..db38eaf3e 100644 --- a/cel/cel_sqlite3_custom.c +++ b/cel/cel_sqlite3_custom.c @@ -360,4 +360,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite3 Custom CEL Mo .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/cel/cel_tds.c b/cel/cel_tds.c index 0859fab7a..0aa73e522 100644 --- a/cel/cel_tds.c +++ b/cel/cel_tds.c @@ -580,4 +580,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "FreeTDS CEL Backend", .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, + .requires = "cel", ); diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index ed7d5cfe3..a5dead1a2 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -39,6 +39,10 @@ #include "asterisk.h" +#include <errno.h> +#ifndef ESTRPIPE +#define ESTRPIPE EPIPE +#endif #include <fcntl.h> #include <sys/ioctl.h> #include <sys/time.h> diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index de2c15279..37e277432 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -15058,14 +15058,14 @@ retry: ast_mutex_lock(&p->lock); if (p->owner && !p->restartpending) { if (ast_channel_trylock(p->owner)) { - if (option_debug > 2) + if (DEBUG_ATLEAST(3)) ast_verbose("Avoiding deadlock\n"); /* Avoid deadlock since you're not supposed to lock iflock or pvt before a channel */ ast_mutex_unlock(&p->lock); ast_mutex_unlock(&iflock); goto retry; } - if (option_debug > 2) + if (DEBUG_ATLEAST(3)) ast_verbose("Softhanging up on %s\n", ast_channel_name(p->owner)); ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_EXPLICIT); p->restartpending = 1; @@ -19542,5 +19542,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, tdesc, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, + .requires = "ccss", .optional_modules = "res_smdi", ); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index eade5d13c..dec9dfda1 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -14902,5 +14902,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Inter Asterisk eXchan .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, + .requires = "dnsmgr", .optional_modules = "res_crypto", ); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 85701634c..5030af453 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -10964,22 +10964,25 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action if (portno != -1 || vportno != -1 || tportno != -1) { /* We are now ready to change the sip session and RTP structures with the offered codecs, since they are acceptable */ + unsigned int framing; ast_format_cap_remove_by_type(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN); ast_format_cap_append_from_cap(p->jointcaps, newjointcapability, AST_MEDIA_TYPE_UNKNOWN); /* Our joint codec profile for this call */ ast_format_cap_remove_by_type(p->peercaps, AST_MEDIA_TYPE_UNKNOWN); ast_format_cap_append_from_cap(p->peercaps, newpeercapability, AST_MEDIA_TYPE_UNKNOWN); /* The other side's capability in latest offer */ p->jointnoncodeccapability = newnoncodeccapability; /* DTMF capabilities */ + tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0); + framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt); /* respond with single most preferred joint codec, limiting the other side's choice */ if (ast_test_flag(&p->flags[1], SIP_PAGE2_PREFERRED_CODEC)) { - unsigned int framing; - - tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0); - framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt); ast_format_cap_remove_by_type(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN); ast_format_cap_append(p->jointcaps, tmp_fmt, framing); - ao2_ref(tmp_fmt, -1); } + if (!ast_rtp_codecs_get_framing(&newaudiortp)) { + /* Peer did not force us to use a specific framing, so use our own */ + ast_rtp_codecs_set_framing(&newaudiortp, framing); + } + ao2_ref(tmp_fmt, -1); } /* Setup audio address and port */ @@ -11488,6 +11491,7 @@ static int process_sdp_a_audio(const char *a, struct sip_pvt *p, struct ast_rtp_ if (framing && p->autoframing) { ast_debug(1, "Setting framing to %ld\n", framing); ast_format_cap_set_framing(p->caps, framing); + ast_rtp_codecs_set_framing(newaudiortp, framing); } found = TRUE; } else if (sscanf(a, "rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) { @@ -22475,7 +22479,7 @@ static void sip_dump_history(struct sip_pvt *dialog) return; } - if (!option_debug && !sipdebug) { + if (!sipdebug && !DEBUG_ATLEAST(1)) { if (!errmsg) { ast_log(LOG_NOTICE, "You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n"); errmsg = 1; @@ -22483,20 +22487,20 @@ static void sip_dump_history(struct sip_pvt *dialog) return; } - ast_debug(1, "\n---------- SIP HISTORY for '%s' \n", dialog->callid); + ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid); if (dialog->subscribed) { - ast_debug(1, " * Subscription\n"); + ast_log(LOG_DEBUG, " * Subscription\n"); } else { - ast_debug(1, " * SIP Call\n"); + ast_log(LOG_DEBUG, " * SIP Call\n"); } if (dialog->history) { AST_LIST_TRAVERSE(dialog->history, hist, list) - ast_debug(1, " %-3.3d. %s\n", ++x, hist->event); + ast_log(LOG_DEBUG, " %-3.3d. %s\n", ++x, hist->event); } if (!x) { - ast_debug(1, "Call '%s' has no history\n", dialog->callid); + ast_log(LOG_DEBUG, "Call '%s' has no history\n", dialog->callid); } - ast_debug(1, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid); + ast_log(LOG_DEBUG, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid); } @@ -35740,5 +35744,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Session Initiation Pr .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, + .requires = "ccss,dnsmgr,udptl", .optional_modules = "res_crypto,res_http_websocket", ); @@ -657,6 +657,8 @@ GMIME_LIBS GMIME_CFLAGS PBX_SSL_OP_NO_TLSV1_2 PBX_SSL_OP_NO_TLSV1_1 +PORTAUDIO_LIBS +PORTAUDIO_CFLAGS PYTHONDEV_LIBS PYTHONDEV_CFLAGS PYTHONDEV_INCLUDE @@ -1044,10 +1046,6 @@ PBX_LUA LUA_DIR LUA_INCLUDE LUA_LIB -PBX_LTDL -LTDL_DIR -LTDL_INCLUDE -LTDL_LIB PBX_LIBXSLT_CLEANUP LIBXSLT_CLEANUP_DIR LIBXSLT_CLEANUP_INCLUDE @@ -1406,7 +1404,6 @@ with_libcurl with_libedit with_libxml2 with_libxslt -with_ltdl with_lua with_misdn with_mysqlclient @@ -1485,6 +1482,8 @@ PJPROJECT_CFLAGS PJPROJECT_LIBS PYTHONDEV_CFLAGS PYTHONDEV_LIBS +PORTAUDIO_CFLAGS +PORTAUDIO_LIBS GMIME_CFLAGS GMIME_LIBS GTK2_CFLAGS @@ -2161,7 +2160,6 @@ Optional Packages: --with-libedit=PATH use NetBSD Editline library files in PATH --with-libxml2=PATH use LibXML2 files in PATH --with-libxslt=PATH use LibXSLT files in PATH - --with-ltdl=PATH use libtool files in PATH --with-lua=PATH use Lua files in PATH --with-misdn=PATH use mISDN user files in PATH --with-mysqlclient=PATH use MySQL client files in PATH @@ -2244,6 +2242,10 @@ Some influential environment variables: C compiler flags for PYTHONDEV, overriding pkg-config PYTHONDEV_LIBS linker flags for PYTHONDEV, overriding pkg-config + PORTAUDIO_CFLAGS + C compiler flags for PORTAUDIO, overriding pkg-config + PORTAUDIO_LIBS + linker flags for PORTAUDIO, overriding pkg-config GMIME_CFLAGS C compiler flags for GMIME, overriding pkg-config GMIME_LIBS linker flags for GMIME, overriding pkg-config @@ -4671,6 +4673,11 @@ case "${host_os}" in esac case "${host_os}" in + netbsd*) + ac_default_prefix=/usr/pkg + CPPFLAGS=-I/usr/pkg/include + LDFLAGS=-L/usr/pkg/lib + ;; freebsd*) ac_default_prefix=/usr/local CPPFLAGS=-I/usr/local/include @@ -7803,6 +7810,9 @@ fi +DOWNLOAD=":" +DOWNLOAD_TO_STDOUT= +DOWNLOAD_TIMEOUT= if test "${WGET}" != ":" ; then DOWNLOAD=${WGET} DOWNLOAD_TO_STDOUT="${WGET} -q -O-" @@ -7853,16 +7863,17 @@ $as_echo "no" >&6; } fi - DOWNLOAD=${FETCH} - DOWNLOAD_TO_STDOUT="${FETCH} -o-" - DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)' + if test "${FETCH}" != ":" ; then + DOWNLOAD=${FETCH} + DOWNLOAD_TO_STDOUT="${FETCH} -o-" + DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)' + fi fi fi - # Extract the first word of "ldconfig", so it can be a program name with args. set dummy ldconfig; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -9191,7 +9202,7 @@ $as_echo_n "checking for embedded pjproject (may have to download)... " >&6; } $as_echo "configuring" >&6; } if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then - as_fn_error $? "A download utility (wget, curl or fetch) is required to download bundled pjproject" "$LINENO" 5 + as_fn_error $? "A download utility (wget, curl, or fetch) is required to download bundled pjproject" "$LINENO" 5 fi if test "${BZIP2}" = ":" ; then as_fn_error $? "bzip2 is required to extract the pjproject tar file" "$LINENO" 5 @@ -10789,38 +10800,6 @@ PBX_LIBXSLT_CLEANUP=0 - LTDL_DESCRIP="libtool" - LTDL_OPTION="ltdl" - PBX_LTDL=0 - -# Check whether --with-ltdl was given. -if test "${with_ltdl+set}" = set; then : - withval=$with_ltdl; - case ${withval} in - n|no) - USE_LTDL=no - # -1 is a magic value used by menuselect to know that the package - # was disabled, other than 'not found' - PBX_LTDL=-1 - ;; - y|ye|yes) - ac_mandatory_list="${ac_mandatory_list} LTDL" - ;; - *) - LTDL_DIR="${withval}" - ac_mandatory_list="${ac_mandatory_list} LTDL" - ;; - esac - -fi - - - - - - - - LUA_DESCRIP="Lua" LUA_OPTION="lua" PBX_LUA=0 @@ -13882,6 +13861,10 @@ _ACEOF fi +if test "x$LIBUUID_LIB" != "x" ; then + UUID_INCLUDE="$LIBUUID_INCLUDE" + UUID_LIB="$LIBUUID_LIB" +else if test "x${PBX_E2FSUUID}" != "x1" -a "${USE_E2FSUUID}" != "no"; then pbxlibdir="" @@ -13978,7 +13961,11 @@ _ACEOF fi -for ac_func in uuid_generate_random + if test "x$E2FSUUID_LIB" != "x" ; then + UUID_INCLUDE="$E2FSUUID_INCLUDE" + UUID_LIB="$E2FSUUID_LIB" + else + for ac_func in uuid_generate_random do : ac_fn_c_check_func "$LINENO" "uuid_generate_random" "ac_cv_func_uuid_generate_random" if test "x$ac_cv_func_uuid_generate_random" = xyes; then : @@ -13991,18 +13978,13 @@ else fi done - -if test "x$LIBUUID_LIB" != "x" ; then - UUID_INCLUDE="$LIBUUID_INCLUDE" - UUID_LIB="$LIBUUID_LIB" -elif test "x$E2FSUUID_LIB" != "x" ; then - UUID_INCLUDE="$E2FSUUID_INCLUDE" - UUID_LIB="$E2FSUUID_LIB" -elif test "x$SYSUUID" != "x" ; then - UUID_INCLUDE="" - UUID_LIB="" -else - as_fn_error $? "*** uuid support not found (this typically means the uuid development package is missing)" "$LINENO" 5 + if test "x$SYSUUID" != "x" ; then + UUID_INCLUDE="" + UUID_LIB="" + else + as_fn_error $? "*** uuid support not found (this typically means the uuid development package is missing)" "$LINENO" 5 + fi + fi fi @@ -18623,6 +18605,9 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use rpath" >&5 $as_echo_n "checking whether to use rpath... " >&6; } AST_RPATH= +if test "${OSARCH}" = "NetBSD"; then + AST_RPATH="-Wl,-rpath,/usr/pkg/lib" +fi if test "${check_rpath}" != yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 $as_echo "skipped" >&6; } @@ -19444,6 +19429,41 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=${old_LIBS} +# re-check without -ldl +# Non-Linux platforms like FreeBSD and NetBSD do not need a library libdl.so. +if test "${PBX_DLADDR}" = "0"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dladdr in dlfcn.h without -ldl" >&5 +$as_echo_n "checking for dladdr in dlfcn.h without -ldl... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _GNU_SOURCE 1 +#include <dlfcn.h> +int +main () +{ +dladdr((void *)0, (void *)0) + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + PBX_DLADDR=1 + + +$as_echo "#define HAVE_DLADDR 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + # PKGCONFIG is used in later tests @@ -19583,13 +19603,13 @@ if test "x${PBX_ALSA}" != "x1" -a "${USE_ALSA}" != "no"; then ast_ext_lib_check_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snd_spcm_init in -lasound" >&5 -$as_echo_n "checking for snd_spcm_init in -lasound... " >&6; } -if ${ac_cv_lib_asound_snd_spcm_init+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snd_pcm_open in -lasound" >&5 +$as_echo_n "checking for snd_pcm_open in -lasound... " >&6; } +if ${ac_cv_lib_asound_snd_pcm_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lasound ${pbxlibdir} -lm -ldl $LIBS" +LIBS="-lasound ${pbxlibdir} $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -19599,27 +19619,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char snd_spcm_init (); +char snd_pcm_open (); int main () { -return snd_spcm_init (); +return snd_pcm_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_asound_snd_spcm_init=yes + ac_cv_lib_asound_snd_pcm_open=yes else - ac_cv_lib_asound_snd_spcm_init=no + ac_cv_lib_asound_snd_pcm_open=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asound_snd_spcm_init" >&5 -$as_echo "$ac_cv_lib_asound_snd_spcm_init" >&6; } -if test "x$ac_cv_lib_asound_snd_spcm_init" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asound_snd_pcm_open" >&5 +$as_echo "$ac_cv_lib_asound_snd_pcm_open" >&6; } +if test "x$ac_cv_lib_asound_snd_pcm_open" = xyes; then : AST_ALSA_FOUND=yes else AST_ALSA_FOUND=no @@ -19630,7 +19650,7 @@ fi # now check for the header. if test "${AST_ALSA_FOUND}" = "yes"; then - ALSA_LIB="${pbxlibdir} -lasound -lm -ldl" + ALSA_LIB="${pbxlibdir} -lasound " # if --with-ALSA=DIR has been specified, use it. if test "x${ALSA_DIR}" != "x"; then ALSA_INCLUDE="-I${ALSA_DIR}/include" @@ -19762,9 +19782,7 @@ _ACEOF fi - -if test "${PBX_BFD}" = "0"; then - # Fedora/RedHat/CentOS require extra libraries +# Fedora/RedHat/CentOS require extra libraries if test "x${PBX_BFD}" != "x1" -a "${USE_BFD}" != "no"; then pbxlibdir="" @@ -19779,9 +19797,9 @@ if test "x${PBX_BFD}" != "x1" -a "${USE_BFD}" != "no"; then ast_ext_lib_check_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_check_format in -lbfd" >&5 -$as_echo_n "checking for bfd_check_format in -lbfd... " >&6; } -if ${ac_cv_lib_bfd_bfd_check_format+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5 +$as_echo_n "checking for bfd_openr in -lbfd... " >&6; } +if ${ac_cv_lib_bfd_bfd_openr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -19795,27 +19813,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char bfd_check_format (); +char bfd_openr (); int main () { -return bfd_check_format (); +return bfd_openr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_bfd_bfd_check_format=yes + ac_cv_lib_bfd_bfd_openr=yes else - ac_cv_lib_bfd_bfd_check_format=no + ac_cv_lib_bfd_bfd_openr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_check_format" >&5 -$as_echo "$ac_cv_lib_bfd_bfd_check_format" >&6; } -if test "x$ac_cv_lib_bfd_bfd_check_format" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5 +$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; } +if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then : AST_BFD_FOUND=yes else AST_BFD_FOUND=no @@ -19861,10 +19879,7 @@ _ACEOF fi -fi - -if test "${PBX_BFD}" = "0"; then - # openSUSE requires -lz +# openSUSE requires -lz if test "x${PBX_BFD}" != "x1" -a "${USE_BFD}" != "no"; then pbxlibdir="" @@ -19879,9 +19894,9 @@ if test "x${PBX_BFD}" != "x1" -a "${USE_BFD}" != "no"; then ast_ext_lib_check_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_check_format in -lbfd" >&5 -$as_echo_n "checking for bfd_check_format in -lbfd... " >&6; } -if ${ac_cv_lib_bfd_bfd_check_format+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5 +$as_echo_n "checking for bfd_openr in -lbfd... " >&6; } +if ${ac_cv_lib_bfd_bfd_openr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -19895,27 +19910,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char bfd_check_format (); +char bfd_openr (); int main () { -return bfd_check_format (); +return bfd_openr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_bfd_bfd_check_format=yes + ac_cv_lib_bfd_bfd_openr=yes else - ac_cv_lib_bfd_bfd_check_format=no + ac_cv_lib_bfd_bfd_openr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_check_format" >&5 -$as_echo "$ac_cv_lib_bfd_bfd_check_format" >&6; } -if test "x$ac_cv_lib_bfd_bfd_check_format" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5 +$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; } +if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then : AST_BFD_FOUND=yes else AST_BFD_FOUND=no @@ -19961,7 +19976,6 @@ _ACEOF fi -fi case "${OSARCH}" in linux*) @@ -20768,8 +20782,7 @@ $as_echo "#define HAVE_LIBEDIT 1" >>confdefs.h fi fi -if test "${PBX_LIBEDIT}" != 1; then - # some platforms do not list libedit via pkg-config, for example OpenBSD 6.2 +# some platforms do not list libedit via pkg-config, for example OpenBSD 6.2 if test "x${PBX_LIBEDIT}" != "x1" -a "${USE_LIBEDIT}" != "no"; then pbxlibdir="" @@ -20866,7 +20879,6 @@ _ACEOF fi -fi if test "${PBX_LIBEDIT}" != 1; then as_fn_error $? "*** Please install the 'libedit' development package." "$LINENO" 5 exit 1 @@ -21715,7 +21727,7 @@ $as_echo_n "checking for system c-client library...... " >&6; } CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" imap_ldflags="" - imap_libs="-lc-client" + imap_libs="-lcrypto -lssl -lc-client" imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` @@ -22428,104 +22440,6 @@ fi done -# Needed by unixodbc - -if test "x${PBX_LTDL}" != "x1" -a "${USE_LTDL}" != "no"; then - pbxlibdir="" - # if --with-LTDL=DIR has been specified, use it. - if test "x${LTDL_DIR}" != "x"; then - if test -d ${LTDL_DIR}/lib; then - pbxlibdir="-L${LTDL_DIR}/lib" - else - pbxlibdir="-L${LTDL_DIR}" - fi - fi - - ast_ext_lib_check_save_CFLAGS="${CFLAGS}" - CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lt_dlinit in -lltdl" >&5 -$as_echo_n "checking for lt_dlinit in -lltdl... " >&6; } -if ${ac_cv_lib_ltdl_lt_dlinit+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lltdl ${pbxlibdir} $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char lt_dlinit (); -int -main () -{ -return lt_dlinit (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ltdl_lt_dlinit=yes -else - ac_cv_lib_ltdl_lt_dlinit=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ltdl_lt_dlinit" >&5 -$as_echo "$ac_cv_lib_ltdl_lt_dlinit" >&6; } -if test "x$ac_cv_lib_ltdl_lt_dlinit" = xyes; then : - AST_LTDL_FOUND=yes -else - AST_LTDL_FOUND=no -fi - - CFLAGS="${ast_ext_lib_check_save_CFLAGS}" - - - # now check for the header. - if test "${AST_LTDL_FOUND}" = "yes"; then - LTDL_LIB="${pbxlibdir} -lltdl " - # if --with-LTDL=DIR has been specified, use it. - if test "x${LTDL_DIR}" != "x"; then - LTDL_INCLUDE="-I${LTDL_DIR}/include" - fi - LTDL_INCLUDE="${LTDL_INCLUDE} " - - # check for the header - ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${CPPFLAGS} ${LTDL_INCLUDE}" - ac_fn_c_check_header_mongrel "$LINENO" "ltdl.h" "ac_cv_header_ltdl_h" "$ac_includes_default" -if test "x$ac_cv_header_ltdl_h" = xyes; then : - LTDL_HEADER_FOUND=1 -else - LTDL_HEADER_FOUND=0 -fi - - - CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" - - if test "x${LTDL_HEADER_FOUND}" = "x0" ; then - LTDL_LIB="" - LTDL_INCLUDE="" - else - - PBX_LTDL=1 - cat >>confdefs.h <<_ACEOF -#define HAVE_LTDL 1 -_ACEOF - - fi - fi -fi - - - if test "x${PBX_LDAP}" != "x1" -a "${USE_LDAP}" != "no"; then pbxlibdir="" @@ -24005,9 +23919,9 @@ if test "x${PBX_OGG}" != "x1" -a "${USE_OGG}" != "no"; then ast_ext_lib_check_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ogg_sync_init in -logg" >&5 -$as_echo_n "checking for ogg_sync_init in -logg... " >&6; } -if ${ac_cv_lib_ogg_ogg_sync_init+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ogg_stream_init in -logg" >&5 +$as_echo_n "checking for ogg_stream_init in -logg... " >&6; } +if ${ac_cv_lib_ogg_ogg_stream_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -24021,27 +23935,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char ogg_sync_init (); +char ogg_stream_init (); int main () { -return ogg_sync_init (); +return ogg_stream_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ogg_ogg_sync_init=yes + ac_cv_lib_ogg_ogg_stream_init=yes else - ac_cv_lib_ogg_ogg_sync_init=no + ac_cv_lib_ogg_ogg_stream_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ogg_ogg_sync_init" >&5 -$as_echo "$ac_cv_lib_ogg_ogg_sync_init" >&6; } -if test "x$ac_cv_lib_ogg_ogg_sync_init" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ogg_ogg_stream_init" >&5 +$as_echo "$ac_cv_lib_ogg_ogg_stream_init" >&6; } +if test "x$ac_cv_lib_ogg_ogg_stream_init" = xyes; then : AST_OGG_FOUND=yes else AST_OGG_FOUND=no @@ -24059,8 +23973,18 @@ fi fi OGG_INCLUDE="${OGG_INCLUDE} " - # no header, assume found - OGG_HEADER_FOUND="1" + # check for the header + ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${CPPFLAGS} ${OGG_INCLUDE}" + ac_fn_c_check_header_mongrel "$LINENO" "ogg/ogg.h" "ac_cv_header_ogg_ogg_h" "$ac_includes_default" +if test "x$ac_cv_header_ogg_ogg_h" = xyes; then : + OGG_HEADER_FOUND=1 +else + OGG_HEADER_FOUND=0 +fi + + + CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" if test "x${OGG_HEADER_FOUND}" = "x0" ; then OGG_LIB="" @@ -26345,6 +26269,94 @@ fi + if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PORTAUDIO" >&5 +$as_echo_n "checking for PORTAUDIO... " >&6; } + +if test -n "$PORTAUDIO_CFLAGS"; then + pkg_cv_PORTAUDIO_CFLAGS="$PORTAUDIO_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PORTAUDIO_CFLAGS=`$PKG_CONFIG --cflags "portaudio-2.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PORTAUDIO_LIBS"; then + pkg_cv_PORTAUDIO_LIBS="$PORTAUDIO_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PORTAUDIO_LIBS=`$PKG_CONFIG --libs "portaudio-2.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "portaudio-2.0" 2>&1` + else + PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "portaudio-2.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PORTAUDIO_PKG_ERRORS" >&5 + + + PBX_PORTAUDIO=0 + + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + PBX_PORTAUDIO=0 + + +else + PORTAUDIO_CFLAGS=$pkg_cv_PORTAUDIO_CFLAGS + PORTAUDIO_LIBS=$pkg_cv_PORTAUDIO_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + PBX_PORTAUDIO=1 + PORTAUDIO_INCLUDE="$PORTAUDIO_CFLAGS" + PORTAUDIO_LIB="$PORTAUDIO_LIBS" + +$as_echo "#define HAVE_PORTAUDIO 1" >>confdefs.h + + +fi + fi + + if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then pbxlibdir="" # if --with-PORTAUDIO=DIR has been specified, use it. @@ -29706,7 +29718,7 @@ if test "x${PBX_LUA}" = "x1" ; then fi fi -# Some distributions (like SuSE) remove the 5.1 suffix. +# Some distributions (like openSUSE and NetBSD) remove the 5.x suffix. if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then pbxlibdir="" @@ -29721,9 +29733,9 @@ if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then ast_ext_lib_check_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_openlib in -llua" >&5 -$as_echo_n "checking for luaL_openlib in -llua... " >&6; } -if ${ac_cv_lib_lua_luaL_openlib+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for luaL_newstate in -llua" >&5 +$as_echo_n "checking for luaL_newstate in -llua... " >&6; } +if ${ac_cv_lib_lua_luaL_newstate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29737,27 +29749,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char luaL_openlib (); +char luaL_newstate (); int main () { -return luaL_openlib (); +return luaL_newstate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_lua_luaL_openlib=yes + ac_cv_lib_lua_luaL_newstate=yes else - ac_cv_lib_lua_luaL_openlib=no + ac_cv_lib_lua_luaL_newstate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_luaL_openlib" >&5 -$as_echo "$ac_cv_lib_lua_luaL_openlib" >&6; } -if test "x$ac_cv_lib_lua_luaL_openlib" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_luaL_newstate" >&5 +$as_echo "$ac_cv_lib_lua_luaL_newstate" >&6; } +if test "x$ac_cv_lib_lua_luaL_newstate" = xyes; then : AST_LUA_FOUND=yes else AST_LUA_FOUND=no @@ -33183,105 +33195,6 @@ fi -if test "${OSARCH}" = "OpenBSD"; -then - -if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then - pbxlibdir="" - # if --with-VORBIS=DIR has been specified, use it. - if test "x${VORBIS_DIR}" != "x"; then - if test -d ${VORBIS_DIR}/lib; then - pbxlibdir="-L${VORBIS_DIR}/lib" - else - pbxlibdir="-L${VORBIS_DIR}" - fi - fi - - ast_ext_lib_check_save_CFLAGS="${CFLAGS}" - CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vorbis_info_init in -lvorbis" >&5 -$as_echo_n "checking for vorbis_info_init in -lvorbis... " >&6; } -if ${ac_cv_lib_vorbis_vorbis_info_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lvorbis ${pbxlibdir} -lm -lvorbisenc -lvorbisfile -logg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char vorbis_info_init (); -int -main () -{ -return vorbis_info_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_vorbis_vorbis_info_init=yes -else - ac_cv_lib_vorbis_vorbis_info_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbis_vorbis_info_init" >&5 -$as_echo "$ac_cv_lib_vorbis_vorbis_info_init" >&6; } -if test "x$ac_cv_lib_vorbis_vorbis_info_init" = xyes; then : - AST_VORBIS_FOUND=yes -else - AST_VORBIS_FOUND=no -fi - - CFLAGS="${ast_ext_lib_check_save_CFLAGS}" - - - # now check for the header. - if test "${AST_VORBIS_FOUND}" = "yes"; then - VORBIS_LIB="${pbxlibdir} -lvorbis -lm -lvorbisenc -lvorbisfile -logg" - # if --with-VORBIS=DIR has been specified, use it. - if test "x${VORBIS_DIR}" != "x"; then - VORBIS_INCLUDE="-I${VORBIS_DIR}/include" - fi - VORBIS_INCLUDE="${VORBIS_INCLUDE} " - - # check for the header - ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${CPPFLAGS} ${VORBIS_INCLUDE}" - ac_fn_c_check_header_mongrel "$LINENO" "vorbis/codec.h" "ac_cv_header_vorbis_codec_h" "$ac_includes_default" -if test "x$ac_cv_header_vorbis_codec_h" = xyes; then : - VORBIS_HEADER_FOUND=1 -else - VORBIS_HEADER_FOUND=0 -fi - - - CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" - - if test "x${VORBIS_HEADER_FOUND}" = "x0" ; then - VORBIS_LIB="" - VORBIS_INCLUDE="" - else - - PBX_VORBIS=1 - cat >>confdefs.h <<_ACEOF -#define HAVE_VORBIS 1 -_ACEOF - - fi - fi -fi - - -else if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then pbxlibdir="" @@ -33378,7 +33291,6 @@ _ACEOF fi -fi if test "x${PBX_VORBIS_OPEN_CALLBACKS}" != "x1" -a "${USE_VORBIS_OPEN_CALLBACKS}" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OV_CALLBACKS_NOCLOSE declared in vorbis/vorbisfile.h" >&5 diff --git a/configure.ac b/configure.ac index 8558aedf1..81f1d46c4 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,11 @@ case "${host_os}" in esac case "${host_os}" in + netbsd*) + ac_default_prefix=/usr/pkg + CPPFLAGS=-I/usr/pkg/include + LDFLAGS=-L/usr/pkg/lib + ;; freebsd*) ac_default_prefix=/usr/local CPPFLAGS=-I/usr/local/include @@ -281,6 +286,9 @@ AC_PATH_PROG([PATCH], [patch], :) AC_PATH_PROG([SED], [sed], :) AC_PATH_PROG([NM], [nm], :) +DOWNLOAD=":" +DOWNLOAD_TO_STDOUT= +DOWNLOAD_TIMEOUT= if test "${WGET}" != ":" ; then DOWNLOAD=${WGET} DOWNLOAD_TO_STDOUT="${WGET} -q -O-" @@ -290,13 +298,14 @@ else if test "${CURL}" != ":" ; then DOWNLOAD_TO_STDOUT="${CURL} -Ls" DOWNLOAD_TIMEOUT='--max-time $(or $2,$1)' else - AC_PATH_PROG([FETCH], [fetch], [:]) - DOWNLOAD=${FETCH} - DOWNLOAD_TO_STDOUT="${FETCH} -o-" - DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)' + AC_PATH_PROG([FETCH], [fetch], :) + if test "${FETCH}" != ":" ; then + DOWNLOAD=${FETCH} + DOWNLOAD_TO_STDOUT="${FETCH} -o-" + DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)' + fi fi fi - AC_SUBST(DOWNLOAD) AC_SUBST(DOWNLOAD_TO_STDOUT) AC_SUBST(DOWNLOAD_TIMEOUT) @@ -479,7 +488,6 @@ AST_EXT_LIB_SETUP_OPTIONAL([LIBEDIT_IS_UNICODE], [Libedit compiled for unicode], AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2]) AST_EXT_LIB_SETUP([LIBXSLT], [LibXSLT], [libxslt]) AST_EXT_LIB_SETUP_OPTIONAL([LIBXSLT_CLEANUP], [LibXSLT Library Cleanup Function], [LIBXSLT], [libxslt]) -AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl]) AST_EXT_LIB_SETUP([LUA], [Lua], [lua]) AST_EXT_LIB_SETUP([MISDN], [mISDN user], [misdn]) AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient]) @@ -638,20 +646,23 @@ AC_SUBST(EDITLINE_LIB) # * -le2fs-uuid on OpenBSD # * in libsystem on OS X AST_EXT_LIB_CHECK([LIBUUID], [uuid], [uuid_generate_random], [uuid/uuid.h], []) -AST_EXT_LIB_CHECK([E2FSUUID], [e2fs-uuid], [uuid_generate_random], [uuid/uuid.h], []) -AC_CHECK_FUNCS([uuid_generate_random], [SYSUUID=true], [SYSUUID=""]) - if test "x$LIBUUID_LIB" != "x" ; then UUID_INCLUDE="$LIBUUID_INCLUDE" UUID_LIB="$LIBUUID_LIB" -elif test "x$E2FSUUID_LIB" != "x" ; then - UUID_INCLUDE="$E2FSUUID_INCLUDE" - UUID_LIB="$E2FSUUID_LIB" -elif test "x$SYSUUID" != "x" ; then - UUID_INCLUDE="" - UUID_LIB="" else - AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)]) + AST_EXT_LIB_CHECK([E2FSUUID], [e2fs-uuid], [uuid_generate_random], [uuid/uuid.h], []) + if test "x$E2FSUUID_LIB" != "x" ; then + UUID_INCLUDE="$E2FSUUID_INCLUDE" + UUID_LIB="$E2FSUUID_LIB" + else + AC_CHECK_FUNCS([uuid_generate_random], [SYSUUID=true], [SYSUUID=""]) + if test "x$SYSUUID" != "x" ; then + UUID_INCLUDE="" + UUID_LIB="" + else + AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)]) + fi + fi fi AC_SUBST(UUID_INCLUDE) AC_SUBST(UUID_LIB) @@ -1313,6 +1324,9 @@ AC_ARG_ENABLE(rpath, AC_MSG_CHECKING(whether to use rpath) AST_RPATH= +if test "${OSARCH}" = "NetBSD"; then + AST_RPATH="-Wl,-rpath,/usr/pkg/lib" +fi if test "${check_rpath}" != yes; then AC_MSG_RESULT(skipped) elif test "${prefix}" = /usr || test "${prefix}" = NONE; then @@ -1449,25 +1463,36 @@ AC_LINK_IFELSE( ) LIBS=${old_LIBS} +# re-check without -ldl +# Non-Linux platforms like FreeBSD and NetBSD do not need a library libdl.so. +if test "${PBX_DLADDR}" = "0"; then + AC_MSG_CHECKING(for dladdr in dlfcn.h without -ldl) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#define _GNU_SOURCE 1 +#include <dlfcn.h>], + [dladdr((void *)0, (void *)0)] + )], + AC_MSG_RESULT(yes) + PBX_DLADDR=1 + AC_SUBST([PBX_DLADDR]) + AC_DEFINE([HAVE_DLADDR], 1, [Define to 1 if your system has the dladdr() GNU extension]), + AC_MSG_RESULT(no) + ) +fi + # PKGCONFIG is used in later tests PKG_PROG_PKG_CONFIG() # do the package library checks now -AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl]) +AST_EXT_LIB_CHECK([ALSA], [asound], [snd_pcm_open], [alsa/asoundlib.h]) AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h]) - -if test "${PBX_BFD}" = "0"; then - # Fedora/RedHat/CentOS require extra libraries - AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_check_format], [bfd.h], [-ldl -liberty]) -fi - -if test "${PBX_BFD}" = "0"; then - # openSUSE requires -lz - AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_check_format], [bfd.h], [-ldl -liberty -lz]) -fi +# Fedora/RedHat/CentOS require extra libraries +AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h], [-ldl -liberty]) +# openSUSE requires -lz +AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h], [-ldl -liberty -lz]) case "${OSARCH}" in linux*) @@ -1575,10 +1600,8 @@ if test "${USE_ILBC}" != "no"; then fi AST_PKG_CONFIG_CHECK(LIBEDIT, libedit) -if test "${PBX_LIBEDIT}" != 1; then - # some platforms do not list libedit via pkg-config, for example OpenBSD 6.2 - AST_EXT_LIB_CHECK([LIBEDIT], [edit], [history_init], [histedit.h], [-ltermcap]) -fi +# some platforms do not list libedit via pkg-config, for example OpenBSD 6.2 +AST_EXT_LIB_CHECK([LIBEDIT], [edit], [history_init], [histedit.h], [-ltermcap]) if test "${PBX_LIBEDIT}" != 1; then AC_MSG_ERROR(*** Please install the 'libedit' development package.) exit 1 @@ -1861,7 +1884,7 @@ if test "${USE_IMAP_TK}" != "no"; then CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" imap_ldflags="" - imap_libs="-lc-client" + imap_libs="-lcrypto -lssl -lc-client" imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` @@ -2130,9 +2153,6 @@ AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h]) # 64-bit version of kevent (from kqueue) on OS X AC_CHECK_FUNCS([kevent64]) -# Needed by unixodbc -AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], []) - AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_initialize], [ldap.h]) AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h]) @@ -2178,7 +2198,7 @@ AST_C_DECLARE_CHECK([UNBOUND_CONST_PARAMS], [UNBOUND_VERSION_MAJOR], [unbound.h] AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], []) -AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], []) +AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_stream_init], [ogg/ogg.h]) # Non-glibc platforms require libexecinfo for backtrace support AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h]) @@ -2294,6 +2314,7 @@ AST_PKG_CONFIG_CHECK([PYTHONDEV], [python]) AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h]) +AST_PKG_CONFIG_CHECK([PORTAUDIO], [portaudio-2.0]) AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h]) AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h]) @@ -2387,8 +2408,8 @@ if test "x${PBX_LUA}" = "x1" ; then fi fi -# Some distributions (like SuSE) remove the 5.1 suffix. -AST_EXT_LIB_CHECK([LUA], [lua], [luaL_openlib], [lua.h], [-lm]) +# Some distributions (like openSUSE and NetBSD) remove the 5.x suffix. +AST_EXT_LIB_CHECK([LUA], [lua], [luaL_newstate], [lua.h], [-lm]) # Accept either RADIUS client library, their APIs are fully compatible, # just different header filenames and different SONAMEs @@ -2563,12 +2584,7 @@ fi AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [dahdi/tonezone.h], [${tonezone_extra} ${DAHDI_INCLUDE}]) -if test "${OSARCH}" = "OpenBSD"; -then - AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile -logg]) -else - AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile]) -fi +AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile]) AST_C_DECLARE_CHECK([VORBIS_OPEN_CALLBACKS], [OV_CALLBACKS_NOCLOSE], [vorbis/vorbisfile.h]) AC_LANG_PUSH(C++) diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq index 23a247a13..887c5e21d 100755 --- a/contrib/scripts/install_prereq +++ b/contrib/scripts/install_prereq @@ -24,7 +24,7 @@ PACKAGES_DEBIAN="build-essential pkg-config" PACKAGES_DEBIAN="$PACKAGES_DEBIAN libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev" # Asterisk: for addons: PACKAGES_DEBIAN="$PACKAGES_DEBIAN libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev xmlstarlet bison flex" -PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libltdl-dev libneon27-dev libgmime-2.6-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev" +PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libneon27-dev libgmime-2.6-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev" PACKAGES_DEBIAN="$PACKAGES_DEBIAN libvpb-dev libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libosptk-dev libjack-jackd2-dev bash" PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-common-dev libcpg-dev libcfg-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev" PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample1-dev libc-client2007e-dev binutils-dev libsrtp0-dev libsrtp2-dev libgsm1-dev doxygen graphviz zlib1g-dev libldap2-dev" @@ -40,7 +40,7 @@ PACKAGES_RH="make gcc gcc-c++ pkgconfig" PACKAGES_RH="$PACKAGES_RH libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel" # Asterisk: for addons: PACKAGES_RH="$PACKAGES_RH speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex" -PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel libtool-ltdl-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel" +PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel" PACKAGES_RH="$PACKAGES_RH mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel bash" PACKAGES_RH="$PACKAGES_RH net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel" PACKAGES_RH="$PACKAGES_RH libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard" @@ -51,12 +51,60 @@ PACKAGES_RH="$PACKAGES_RH wget subversion" PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel" # Basic build system: +PACKAGES_SUSE="make gcc gcc-c++ pkg-config" +# Asterisk: basic requirements: +PACKAGES_SUSE="$PACKAGES_SUSE libedit-devel libjansson-devel libuuid-devel sqlite3-devel libxml2-devel" +# Asterisk: for addons: +PACKAGES_SUSE="$PACKAGES_SUSE speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-devel portaudio-devel libcurl-devel xmlstarlet bison flex" +PACKAGES_SUSE="$PACKAGES_SUSE postgresql-devel unixODBC-devel libneon-devel gmime-devel lua-devel liburiparser-devel libxslt-devel libopenssl-devel" +PACKAGES_SUSE="$PACKAGES_SUSE libmysqlclient-devel bluez-devel freeradius-client-devel freetds-devel bash" +PACKAGES_SUSE="$PACKAGES_SUSE net-snmp-devel iksemel-devel libcorosync-devel newt-devel popt-devel libical-devel spandsp-devel" +PACKAGES_SUSE="$PACKAGES_SUSE imap-devel libsrtp2-devel libgsm-devel doxygen graphviz zlib-devel openldap2-devel" +PACKAGES_SUSE="$PACKAGES_SUSE codec2-devel fftw3-devel libsndfile-devel unbound-devel" +# Asterisk: for the unpackaged below: +PACKAGES_SUSE="$PACKAGES_SUSE wget subversion" +# Asterisk: for ./configure --with-pjproject-bundled: +PACKAGES_SUSE="$PACKAGES_SUSE bzip2 patch python-devel" + +# Basic build system: +PACKAGES_ARCH="make gcc pkg-config" +# Asterisk: basic requirements: +PACKAGES_ARCH="$PACKAGES_ARCH libedit jansson libutil-linux libxml2 sqlite" +# Asterisk: for addons: +PACKAGES_ARCH="$PACKAGES_ARCH speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex" +PACKAGES_ARCH="$PACKAGES_ARCH postgresql-libs unixodbc neon gmime lua uriparser libxslt openssl" +PACKAGES_ARCH="$PACKAGES_ARCH libmariadbclient bluez-libs radcli freetds bash" +PACKAGES_ARCH="$PACKAGES_ARCH net-snmp libnewt popt libical spandsp" +PACKAGES_ARCH="$PACKAGES_ARCH c-client binutils libsrtp gsm doxygen graphviz zlib libldap" +PACKAGES_ARCH="$PACKAGES_ARCH fftw libsndfile unbound" +# Asterisk: for the unpackaged below: +PACKAGES_ARCH="$PACKAGES_ARCH wget subversion" +# Asterisk: for ./configure --with-pjproject-bundled: +PACKAGES_ARCH="$PACKAGES_ARCH bzip2 patch python2" + +# Basic build system: +PACKAGES_NBSD="gmake pkg-config" +# Asterisk: basic requirements: +PACKAGES_NBSD="$PACKAGES_NBSD editline jansson sqlite3 libuuid libxml2" +# Asterisk: for addons: +PACKAGES_NBSD="$PACKAGES_NBSD speex speexdsp libogg libvorbis alsa-lib portaudio-devel curl bison flex" +PACKAGES_NBSD="$PACKAGES_NBSD postgresql10-client unixodbc neon gmime lua52 uriparser libxslt openssl" +PACKAGES_NBSD="$PACKAGES_NBSD mysql-client radiusclient-ng freetds bash" +PACKAGES_NBSD="$PACKAGES_NBSD net-snmp iksemel popt libical spandsp" +PACKAGES_NBSD="$PACKAGES_NBSD imap-uw srtp gsm doxygen graphviz libzip openldap-client" +PACKAGES_NBSD="$PACKAGES_NBSD codec2 fftw libsndfile unbound" +# Asterisk: for the unpackaged below: +PACKAGES_NBSD="$PACKAGES_NBSD wget subversion-base" +# Asterisk: for ./configure --with-pjproject-bundled: +PACKAGES_NBSD="$PACKAGES_NBSD bzip2 patch python27" + +# Basic build system: PACKAGES_OBSD="gmake" # Asterisk: basic requirements: PACKAGES_OBSD="$PACKAGES_OBSD libxml sqlite3 e2fsprogs jansson" # Asterisk: for addons: PACKAGES_OBSD="$PACKAGES_OBSD speex speexdsp libogg libvorbis portaudio-svn curl xmlstarlet bison" -PACKAGES_OBSD="$PACKAGES_OBSD postgresql-client iodbc libltdl neon gmime lua%5.2 uriparser libxslt" +PACKAGES_OBSD="$PACKAGES_OBSD postgresql-client iodbc neon gmime lua%5.2 uriparser libxslt" PACKAGES_OBSD="$PACKAGES_OBSD mariadb-client radcli freetds" PACKAGES_OBSD="$PACKAGES_OBSD net-snmp iksemel popt libical spandsp" PACKAGES_OBSD="$PACKAGES_OBSD c-client libsrtp gsm doxygen graphviz" @@ -72,10 +120,11 @@ PACKAGES_FBSD="gmake pkgconf" PACKAGES_FBSD="$PACKAGES_FBSD libedit jansson e2fsprogs-libuuid sqlite3 libxml2" # Asterisk: for addons: PACKAGES_FBSD="$PACKAGES_FBSD speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex" -PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC libltdl neon gmime26 lua52 uriparser libxslt openssl" +PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC neon gmime26 lua52 uriparser libxslt openssl" PACKAGES_FBSD="$PACKAGES_FBSD mysql57-client radcli freetds" PACKAGES_FBSD="$PACKAGES_FBSD net-snmp iksemel corosync newt popt libical spandsp" PACKAGES_FBSD="$PACKAGES_FBSD cclient libbfd libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard" +PACKAGES_FBSD="$PACKAGES_FBSD codec2 fftw3 libsndfile unbound" # Asterisk: for the unpackaged below: PACKAGES_FBSD="$PACKAGES_FBSD wget subversion" # Asterisk: for ./configure --with-pjproject-bundled: @@ -130,6 +179,15 @@ check_installed_rpms() { done } +check_installed_pacman() { + for pack in "$@" + do + if ! pacman -Q --explicit $pack >/dev/null 2>/dev/null + then echo $pack + fi + done +} + check_installed_pkgs() { for pack in "$@" do @@ -148,6 +206,15 @@ check_installed_fpkgs() { done } +check_installed_zypper() { + for pack in "$@" + do + if ! zypper se -ixnC $pack >/dev/null 2>/dev/null + then echo $pack + fi + done +} + handle_debian() { if ! [ -x "$(command -v aptitude)" ]; then apt-get install aptitude @@ -166,6 +233,24 @@ handle_rh() { fi } +handle_arch() { + extra_packs=`check_installed_pacman $PACKAGES_ARCH` + if [ x"$extra_packs" != "x" ] ; then + $testcmd pacman -S --asexplicit --noconfirm $extra_packs + fi +} + +handle_nbsd() { + extra_packs=`check_installed_pkgs $PACKAGES_NBSD` + if [ x"$extra_packs" != "x" ] ; then + if [ -z "$PKG_PATH" ] ; then + # see NetBSD Problem Report #48177 + export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -p)/$(uname -r)/All" + fi + $testcmd pkg_add $extra_packs + fi +} + handle_obsd() { extra_packs=`check_installed_pkgs $PACKAGES_OBSD` if [ x"$extra_packs" != "x" ] ; then @@ -180,6 +265,13 @@ handle_fbsd() { fi } +handle_SUSE() { + extra_packs=`check_installed_zypper $PACKAGES_SUSE` + if [ x"$extra_packs" != "x" ] ; then + $testcmd zypper install --no-confirm $extra_packs + fi +} + install_unpackaged() { echo "*** Installing NBS (Network Broadcast Sound) ***" svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk @@ -243,7 +335,7 @@ OS=`uname -s` unsupported_distro='' # A number of distributions we don't (yet?) support. -if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then +if [ "$OS" != 'Linux' -a "$OS" != 'NetBSD' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting." exit 1 fi @@ -256,10 +348,6 @@ if [ -f /etc/mandrake-release ]; then unsupported_distro='Mandriva' fi -if [ -f /etc/SuSE-release ]; then - unsupported_distro='SUSE' -fi - if [ -f /etc/slackware-version ]; then unsupported_distro='Slackware' fi @@ -274,6 +362,16 @@ if [ -r /etc/debian_version ]; then handle_debian elif [ -r /etc/redhat-release ]; then handle_rh +elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then + handle_SUSE +elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "opensuse" ]; then + handle_SUSE +elif [ -r /etc/arch-release ]; then + handle_arch +elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID_LIKE" = "archlinux" ]; then + handle_arch # $ID=arch +elif [ "$OS" = 'NetBSD' ]; then + handle_nbsd elif [ "$OS" = 'OpenBSD' ]; then handle_obsd elif [ "$OS" = 'FreeBSD' ]; then diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c index be5bb2bf9..ba86842f7 100644 --- a/formats/format_ogg_vorbis.c +++ b/formats/format_ogg_vorbis.c @@ -33,6 +33,7 @@ #include "asterisk.h" +#include <ogg/ogg.h> #include <vorbis/codec.h> #include <vorbis/vorbisenc.h> #include <vorbis/vorbisfile.h> diff --git a/funcs/func_callcompletion.c b/funcs/func_callcompletion.c index ed5238c1f..37ba38ce4 100644 --- a/funcs/func_callcompletion.c +++ b/funcs/func_callcompletion.c @@ -126,4 +126,9 @@ static int load_module(void) return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Control Configuration Function", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .requires = "ccss", +); diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index 2dd9f1578..d7bc21145 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -704,4 +704,9 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Detail Record (CDR) dialplan functions"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Detail Record (CDR) dialplan functions", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .requires = "cdr", +); diff --git a/funcs/func_enum.c b/funcs/func_enum.c index 6929e3ccd..f649e0f29 100644 --- a/funcs/func_enum.c +++ b/funcs/func_enum.c @@ -472,4 +472,9 @@ static int load_module(void) return res; } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ENUM related dialplan functions"); +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ENUM related dialplan functions", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .requires = "enum", +); diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index 0f6b65e7d..0d053f614 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -29,6 +29,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <depend>generic_odbc</depend> <support_level>core</support_level> ***/ diff --git a/include/asterisk.h b/include/asterisk.h index 371860278..27d66b776 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -21,7 +21,7 @@ #include "asterisk/autoconfig.h" #include "asterisk/compat.h" -#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) && defined(MALLOC_DEBUG) +#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) #include "asterisk/astmm.h" #endif diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index e989b16fd..431f96108 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -33,32 +33,24 @@ int astdb_init(void); /*!< Provided by db.c */ int ast_channels_init(void); /*!< Provided by channel.c */ void ast_builtins_init(void); /*!< Provided by cli.c */ int ast_cli_perms_init(int reload); /*!< Provided by cli.c */ -int dnsmgr_init(void); /*!< Provided by dnsmgr.c */ void dnsmgr_start_refresh(void); /*!< Provided by dnsmgr.c */ -int dnsmgr_reload(void); /*!< Provided by dnsmgr.c */ int ast_dns_system_resolver_init(void); /*!< Provided by dns_system_resolver.c */ void threadstorage_init(void); /*!< Provided by threadstorage.c */ int ast_device_state_engine_init(void); /*!< Provided by devicestate.c */ int astobj2_init(void); /*!< Provided by astobj2.c */ int ast_named_locks_init(void); /*!< Provided by named_locks.c */ int ast_file_init(void); /*!< Provided by file.c */ -int ast_features_init(void); /*!< Provided by features.c */ void ast_autoservice_init(void); /*!< Provided by autoservice.c */ -int ast_http_init(void); /*!< Provided by http.c */ -int ast_http_reload(void); /*!< Provided by http.c */ int ast_tps_init(void); /*!< Provided by taskprocessor.c */ int ast_timing_init(void); /*!< Provided by timing.c */ -int ast_indications_init(void); /*!< Provided by indications.c */ -int ast_indications_reload(void);/*!< Provided by indications.c */ void ast_stun_init(void); /*!< Provided by stun.c */ -int ast_cel_engine_init(void); /*!< Provided by cel.c */ -int ast_cel_engine_reload(void); /*!< Provided by cel.c */ int ast_ssl_init(void); /*!< Provided by ssl.c */ int ast_pj_init(void); /*!< Provided by libasteriskpj.c */ int ast_test_init(void); /*!< Provided by test.c */ int ast_msg_init(void); /*!< Provided by message.c */ void ast_msg_shutdown(void); /*!< Provided by message.c */ int aco_init(void); /*!< Provided by config_options.c */ +int dns_core_init(void); /*!< Provided by dns_core.c */ /*! * \brief Initialize the bridging system. @@ -96,13 +88,6 @@ void ast_process_pending_reloads(void); */ int ast_xmldoc_load_documentation(void); -/*! - * \brief Reload genericplc configuration value from codecs.conf - * - * Implementation is in main/channel.c - */ -int ast_plc_reload(void); - /*! \brief initializes the rtp engine arrays */ int ast_rtp_engine_init(void); @@ -112,9 +97,6 @@ int ast_rtp_engine_init(void); */ int ast_parking_stasis_init(void); -/*! \brief initialize the sounds index */ -int ast_sounds_index_init(void); - /*! * \brief Endpoint support initialization. * \return 0 on success. diff --git a/include/asterisk/acl.h b/include/asterisk/acl.h index bda1c7606..09adc527d 100644 --- a/include/asterisk/acl.h +++ b/include/asterisk/acl.h @@ -382,24 +382,6 @@ const char *ast_tos2str(unsigned int tos); struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined); /*! - * \brief Initialize and configure the named ACL system. - * - * \details - * This function will prepare the named ACL system for use. - * For this reason, it needs to be called before other things that use ACLs are initialized. - */ -int ast_named_acl_init(void); - -/*! - * \brief reload/reconfigure the named ACL system. - * - * \details - * This function is designed to trigger an event upon a successful reload that may update - * ACL consumers. - */ -int ast_named_acl_reload(void); - -/*! * \brief a \ref stasis_message_type for changes against a named ACL or the set of all named ACLs * \since 12 * diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index 06300c861..4e4a65b31 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -32,27 +32,30 @@ extern "C" { #define _ASTERISK_ASTMM_H /* IWYU pragma: private, include "asterisk.h" */ +#if defined(MALLOC_DEBUG) #define __AST_DEBUG_MALLOC +void __ast_mm_init_phase_1(void); +void __ast_mm_init_phase_2(void); +#endif + void *ast_std_malloc(size_t size); void *ast_std_calloc(size_t nmemb, size_t size); void *ast_std_realloc(void *ptr, size_t size); void ast_std_free(void *ptr); void ast_free_ptr(void *ptr); -void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); -void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func); -void *__ast_malloc(size_t size, const char *file, int lineno, const char *func); +void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); +void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func); +void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func); void __ast_free(void *ptr, const char *file, int lineno, const char *func); -void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func); -char *__ast_strdup(const char *s, const char *file, int lineno, const char *func); -char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); -int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) +void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func); +char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func); +char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); +int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) __attribute__((format(printf, 5, 6))); -int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) +int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) __attribute__((format(printf, 2, 0))); -void __ast_mm_init_phase_1(void); -void __ast_mm_init_phase_2(void); /*! * \brief ASTMM_LIBC can be defined to control the meaning of standard allocators. @@ -120,42 +123,42 @@ void __ast_mm_init_phase_2(void); #if ASTMM_LIBC == ASTMM_REDIRECT /* Redefine libc functions to our own versions */ -#define calloc(a,b) \ - __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) +#define calloc(a, b) \ + __ast_repl_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define malloc(a) \ - __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_malloc(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define free(a) \ - __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) -#define realloc(a,b) \ - __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define realloc(a, b) \ + __ast_repl_realloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define strdup(a) \ - __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) -#define strndup(a,b) \ - __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_strdup(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define strndup(a, b) \ + __ast_repl_strndup(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define asprintf(a, b, c...) \ - __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) -#define vasprintf(a,b,c) \ - __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) +#define vasprintf(a, b, c) \ + __ast_repl_vasprintf(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__) #elif ASTMM_LIBC == ASTMM_BLOCK /* Redefine libc functions to cause compile errors */ -#define calloc(a,b) \ - Do_not_use_calloc__use_ast_calloc->fail(a,b) +#define calloc(a, b) \ + Do_not_use_calloc__use_ast_calloc->fail(a, b) #define malloc(a) \ Do_not_use_malloc__use_ast_malloc->fail(a) #define free(a) \ Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a) -#define realloc(a,b) \ - Do_not_use_realloc__use_ast_realloc->fail(a,b) +#define realloc(a, b) \ + Do_not_use_realloc__use_ast_realloc->fail(a, b) #define strdup(a) \ Do_not_use_strdup__use_ast_strdup->fail(a) -#define strndup(a,b) \ - Do_not_use_strndup__use_ast_strndup->fail(a,b) +#define strndup(a, b) \ + Do_not_use_strndup__use_ast_strndup->fail(a, b) #define asprintf(a, b, c...) \ - Do_not_use_asprintf__use_ast_asprintf->fail(a,b,c) -#define vasprintf(a,b,c) \ - Do_not_use_vasprintf__use_ast_vasprintf->fail(a,b,c) + Do_not_use_asprintf__use_ast_asprintf->fail(a, b, c) +#define vasprintf(a, b, c) \ + Do_not_use_vasprintf__use_ast_vasprintf->fail(a, b, c) #else #error "Unacceptable value for the macro ASTMM_LIBC" @@ -166,7 +169,7 @@ void __ast_mm_init_phase_2(void); /* Provide our own definition for ast_free */ #define ast_free(a) \ - __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #error "NEVER INCLUDE astmm.h DIRECTLY!!" diff --git a/include/asterisk/astosp.h b/include/asterisk/astosp.h deleted file mode 100644 index 4faa2b4e7..000000000 --- a/include/asterisk/astosp.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 1999 - 2005, Digium, Inc. - * - * Mark Spencer <markster@digium.com> - * - * See http://www.asterisk.org for more information about - * the Asterisk project. Please do not directly contact - * any of the maintainers of this project for assistance; - * the project provides a web site, mailing lists and IRC - * channels for your use. - * - * This program is free software, distributed under the terms of - * the GNU General Public License Version 2. See the LICENSE file - * at the top of the source tree. - */ - -/*! - * \file - * \brief Open Settlement Protocol (OSP) - */ - -#ifndef _ASTERISK_OSP_H -#define _ASTERISK_OSP_H - -#define AST_OSP_SUCCESS ((char*)"SUCCESS") /* Return status, success */ -#define AST_OSP_FAILED ((char*)"FAILED") /* Return status, failed */ -#define AST_OSP_ERROR ((char*)"ERROR") /* Return status, error */ - -#endif /* _ASTERISK_OSP_H */ diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 06114616d..5e9ba6011 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -483,9 +483,6 @@ than `double'. */ #undef HAVE_LONG_DOUBLE_WIDER -/* Define to 1 if you have the libtool library. */ -#undef HAVE_LTDL - /* Define to 1 if you have the Lua library. */ #undef HAVE_LUA @@ -663,7 +660,7 @@ /* Define to 1 if you have the popt library. */ #undef HAVE_POPT -/* Define to 1 if you have the PortAudio library. */ +/* Define if your system has the PORTAUDIO libraries. */ #undef HAVE_PORTAUDIO /* Define to 1 if you have the `pow' function. */ diff --git a/include/asterisk/ccss.h b/include/asterisk/ccss.h index fb17500b6..c006c7639 100644 --- a/include/asterisk/ccss.h +++ b/include/asterisk/ccss.h @@ -1618,15 +1618,4 @@ typedef void (*ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_confi */ int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest, ast_cc_callback_fn callback); -/*! - * \since 1.8 - * \brief Initialize CCSS - * - * Performs startup routines necessary for CC operation. - * - * \retval 0 Success - * \retval nonzero Failure - */ -int ast_cc_init(void); - #endif /* _ASTERISK_CCSS_H */ diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h index e10da8223..c6b241315 100644 --- a/include/asterisk/cdr.h +++ b/include/asterisk/cdr.h @@ -581,12 +581,6 @@ const char *ast_cdr_disp2str(int disposition); */ void ast_cdr_setuserfield(const char *channel_name, const char *userfield); -/*! \brief Reload the configuration file cdr.conf and start/stop CDR scheduling thread */ -int ast_cdr_engine_reload(void); - -/*! \brief Load the configuration file cdr.conf and possibly start the CDR scheduling thread */ -int ast_cdr_engine_init(void); - /*! Submit any remaining CDRs and prepare for shutdown */ void ast_cdr_engine_term(void); diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 3dfbe61d9..8cb03800e 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -1149,7 +1149,7 @@ enum ama_flags { * \deprecated You should use the ast_datastore_alloc() generic function instead. * \version 1.6.1 deprecated */ -struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) +struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) __attribute__((deprecated)); /*! @@ -1208,7 +1208,7 @@ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const * and "default" context. * \note Since 12.0.0 this function returns with the newly created channel locked. */ -struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 16))) +struct ast_channel * __attribute__((format(printf, 15, 16))) __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h index 2040c7b65..1a303c5f7 100644 --- a/include/asterisk/chanvars.h +++ b/include/asterisk/chanvars.h @@ -35,12 +35,10 @@ AST_LIST_HEAD_NOLOCK(varshead, ast_var_t); struct varshead *ast_var_list_create(void); void ast_var_list_destroy(struct varshead *head); -#ifdef __AST_DEBUG_MALLOC + struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function); -#define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_var_t *ast_var_assign(const char *name, const char *value); -#endif +#define ast_var_assign(name, value) _ast_var_assign(name, value, __FILE__, __LINE__, __PRETTY_FUNCTION__) + void ast_var_delete(struct ast_var_t *var); const char *ast_var_name(const struct ast_var_t *var); const char *ast_var_full_name(const struct ast_var_t *var); diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h index 2e89a39eb..85472837c 100644 --- a/include/asterisk/compat.h +++ b/include/asterisk/compat.h @@ -64,7 +64,7 @@ void closefrom(int lowfd); #endif -#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_ASPRINTF) int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...); #endif @@ -96,7 +96,7 @@ int setenv(const char *name, const char *value, int overwrite); char *strcasestr(const char *, const char *); #endif -#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_STRNDUP) char *strndup(const char *, size_t); #endif @@ -116,7 +116,7 @@ uint64_t strtoq(const char *nptr, char **endptr, int base); int unsetenv(const char *name); #endif -#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_VASPRINTF) int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap); #endif diff --git a/include/asterisk/config.h b/include/asterisk/config.h index fd9641e99..c1b7dea8d 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -784,15 +784,6 @@ int ast_realtime_append_mapping(const char *name, const char *driver, const char */ int register_config_cli(void); -/*! - * \brief Exposed re-initialization method for core process - * - * \details - * This method is intended for use only with the core re-initialization and is - * not designed to be called from any user applications. - */ -int read_config_maps(void); - /*! \brief Create a new base configuration structure */ struct ast_config *ast_config_new(void); @@ -919,12 +910,9 @@ void ast_category_destroy(struct ast_category *cat); struct ast_variable *ast_category_detach_variables(struct ast_category *cat); void ast_category_rename(struct ast_category *cat, const char *name); -#ifdef __AST_DEBUG_MALLOC struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno); #define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#else -struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename); -#endif + struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size); struct ast_config_include *ast_include_find(struct ast_config *conf, const char *included_file); void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file); diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h index 8d6516bc1..7a7d99be6 100644 --- a/include/asterisk/datastore.h +++ b/include/asterisk/datastore.h @@ -82,7 +82,7 @@ struct ast_datastore { * \param file, line, function * \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc */ -struct ast_datastore * attribute_malloc __ast_datastore_alloc( +struct ast_datastore *__ast_datastore_alloc( const struct ast_datastore_info *info, const char *uid, struct ast_module *mod, const char *file, int line, const char *function); diff --git a/include/asterisk/dsp.h b/include/asterisk/dsp.h index d092e6b4c..769d3b981 100644 --- a/include/asterisk/dsp.h +++ b/include/asterisk/dsp.h @@ -193,16 +193,4 @@ int ast_dsp_get_tcount(struct ast_dsp *dsp); */ int ast_dsp_get_threshold_from_settings(enum threshold which); -/*! - * \brief Reloads dsp settings from dsp.conf - * \since 1.6.1 - */ -int ast_dsp_reload(void); - -/*! - * \brief Load dsp settings from dsp.conf - * \since 1.6.1 - */ -int ast_dsp_init(void); - #endif /* _ASTERISK_DSP_H */ diff --git a/include/asterisk/enum.h b/include/asterisk/enum.h index 877c0c3cf..2ce85ccb3 100644 --- a/include/asterisk/enum.h +++ b/include/asterisk/enum.h @@ -97,7 +97,4 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *location, i */ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix); -int ast_enum_init(void); -int ast_enum_reload(void); - #endif /* _ASTERISK_ENUM_H */ diff --git a/include/asterisk/features_config.h b/include/asterisk/features_config.h index 1bce50bba..cd1bbbcea 100644 --- a/include/asterisk/features_config.h +++ b/include/asterisk/features_config.h @@ -265,10 +265,4 @@ struct ast_applicationmap_item { */ struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan); -void ast_features_config_shutdown(void); - -int ast_features_config_reload(void); - -int ast_features_config_init(void); - #endif /* _FEATURES_CONFIG_H */ diff --git a/include/asterisk/hashtab.h b/include/asterisk/hashtab.h index cfe035b28..64ed1bf6f 100644 --- a/include/asterisk/hashtab.h +++ b/include/asterisk/hashtab.h @@ -251,22 +251,15 @@ unsigned int ast_hashtab_hash_short(const short num); * \param hash a func ptr to do the hashing * \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now */ -#ifdef __AST_DEBUG_MALLOC -struct ast_hashtab * _ast_hashtab_create(int initial_buckets, - int (*compare)(const void *a, const void *b), - int (*resize)(struct ast_hashtab *), - int (*newsize)(struct ast_hashtab *tab), - unsigned int (*hash)(const void *obj), - int do_locking, const char *file, int lineno, const char *function); -#define ast_hashtab_create(a,b,c,d,e,f) _ast_hashtab_create(a,b,c,d,e,f,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_hashtab * ast_hashtab_create(int initial_buckets, - int (*compare)(const void *a, const void *b), - int (*resize)(struct ast_hashtab *), - int (*newsize)(struct ast_hashtab *tab), - unsigned int (*hash)(const void *obj), - int do_locking ); -#endif +struct ast_hashtab *_ast_hashtab_create(int initial_buckets, + int (*compare)(const void *a, const void *b), + int (*resize)(struct ast_hashtab *), + int (*newsize)(struct ast_hashtab *tab), + unsigned int (*hash)(const void *obj), + int do_locking, + const char *file, int lineno, const char *function); +#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking) \ + _ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief This func will free the hash table and all its memory. @@ -294,12 +287,9 @@ void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void * * \retval 1 on success * \retval 0 if there's a problem */ -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); -#define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#else -int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj); -#endif +#define ast_hashtab_insert_immediate(tab, obj) \ + _ast_hashtab_insert_immediate(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Insert without checking, hashing or locking @@ -311,12 +301,9 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj); * \retval 1 on success * \retval 0 if there's a problem */ -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func); -#define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#else -int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h); -#endif +#define ast_hashtab_insert_immediate_bucket(tab, obj, h) \ + _ast_hashtab_insert_immediate_bucket(tab, obj, h, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Check and insert new object only if it is not there. @@ -324,12 +311,9 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj * \retval 1 on success * \retval 0 if there's a problem, or it's already there. */ -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); -#define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) -#else -int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj); -#endif +#define ast_hashtab_insert_safe(tab, obj) \ + _ast_hashtab_insert_safe(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Lookup this object in the hash table. @@ -362,20 +346,14 @@ int ast_hashtab_size( struct ast_hashtab *tab); int ast_hashtab_capacity( struct ast_hashtab *tab); /*! \brief Return a copy of the hash table */ -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func); -#define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj)); -#endif +#define ast_hashtab_dup(tab, obj_dup_func) \ + _ast_hashtab_dup(tab, obj_dup_func, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Gives an iterator to hastable */ -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); -#define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab); -#endif +#define ast_hashtab_start_traversal(tab) \ + _ast_hashtab_start_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief end the traversal, free the iterator, unlock if necc. */ void ast_hashtab_end_traversal(struct ast_hashtab_iter *it); @@ -395,12 +373,9 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj); /* ------------------ */ /*! \brief Gives an iterator to hastable */ -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); -#define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab); -#endif +#define ast_hashtab_start_write_traversal(tab) \ + _ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Looks up the object, removes the corresponding bucket */ void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj); diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h index 728327936..83c69a8d6 100644 --- a/include/asterisk/heap.h +++ b/include/asterisk/heap.h @@ -97,14 +97,10 @@ typedef int (*ast_heap_cmp_fn)(void *elm1, void *elm2); * \return An instance of a max heap * \since 1.6.1 */ -#ifdef __AST_DEBUG_MALLOC struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset, const char *file, int lineno, const char *func); -#define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, - ssize_t index_offset); -#endif +#define ast_heap_create(init_height, cmp_fn, index_offset) \ + _ast_heap_create(init_height, cmp_fn, index_offset, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Destroy a max heap @@ -126,12 +122,9 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h); * \retval non-zero failure * \since 1.6.1 */ -#ifdef __AST_DEBUG_MALLOC int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func); -#define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -int ast_heap_push(struct ast_heap *h, void *elm); -#endif +#define ast_heap_push(h, elm) \ + _ast_heap_push(h, elm, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Pop the max element off of the heap diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index 8b1e5fe01..df039313c 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -133,9 +133,6 @@ int ast_logger_remove_channel(const char *log_channel); */ void ast_log_backtrace(void); -/*! \brief Reload logger without rotating log files */ -int logger_reload(void); - /*! \brief Reload logger while rotating log files */ int ast_logger_rotate(void); diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index 35dc22763..97d4b9c29 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -356,12 +356,6 @@ void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, c /*! \brief Determinie if a manager session ident is authenticated */ int astman_is_authed(uint32_t ident); -/*! \brief Called by Asterisk initialization */ -int init_manager(void); - -/*! \brief Called by Asterisk module functions and the CLI command */ -int reload_manager(void); - /*! * \brief Add a datastore to a session * diff --git a/include/asterisk/module.h b/include/asterisk/module.h index ebd41c06d..faa4f7f67 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -292,13 +292,14 @@ enum ast_module_load_priority { AST_MODPRI_REALTIME_DEPEND = 10, /*!< Dependency for a realtime driver */ AST_MODPRI_REALTIME_DEPEND2 = 20, /*!< Second level dependency for a realtime driver (func_curl needs res_curl, but is needed by res_config_curl) */ AST_MODPRI_REALTIME_DRIVER = 30, /*!< A realtime driver, which provides configuration services for other modules */ - AST_MODPRI_TIMING = 40, /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */ - AST_MODPRI_CHANNEL_DEPEND = 50, /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */ - AST_MODPRI_CHANNEL_DRIVER = 60, /*!< Channel drivers (provide devicestate) */ - AST_MODPRI_APP_DEPEND = 70, /*!< Dependency for an application */ - AST_MODPRI_DEVSTATE_PROVIDER = 80, /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */ - AST_MODPRI_DEVSTATE_PLUGIN = 90, /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */ - AST_MODPRI_CDR_DRIVER = 100, /*!< CDR or CEL backend */ + AST_MODPRI_CORE = 40, /*!< A core module originally meant to start between preload and load. */ + AST_MODPRI_TIMING = 50, /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */ + AST_MODPRI_CHANNEL_DEPEND = 60, /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */ + AST_MODPRI_CHANNEL_DRIVER = 70, /*!< Channel drivers (provide devicestate) */ + AST_MODPRI_APP_DEPEND = 80, /*!< Dependency for an application */ + AST_MODPRI_DEVSTATE_PROVIDER = 90, /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */ + AST_MODPRI_DEVSTATE_PLUGIN = 100, /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */ + AST_MODPRI_CDR_DRIVER = 110, /*!< CDR or CEL backend */ AST_MODPRI_DEFAULT = 128, /*!< Modules not otherwise defined (such as most apps) will load here */ AST_MODPRI_DEVSTATE_CONSUMER = 150, /*!< Certain modules, which consume devstate, need to load after all others (e.g. app_queue) */ }; diff --git a/include/asterisk/sounds_index.h b/include/asterisk/sounds_index.h index d7eb05332..bbd3965f4 100644 --- a/include/asterisk/sounds_index.h +++ b/include/asterisk/sounds_index.h @@ -33,14 +33,6 @@ extern "C" { struct ast_media_index; /*! - * \brief Reload the sounds index - * - * \retval zero on success - * \retval non-zero on failure - */ -int ast_sounds_reindex(void); - -/*! * \brief Get the sounds index * * \retval sounds index (must be ao2_cleanup()'ed) diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h index 69f2fcca4..ce978901b 100644 --- a/include/asterisk/stringfields.h +++ b/include/asterisk/stringfields.h @@ -228,11 +228,6 @@ struct ast_string_field_mgr { ast_string_field last_alloc; /*!< the last field allocated */ struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */ struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */ -#if defined(__AST_DEBUG_MALLOC) - const char *owner_file; /*!< filename of owner */ - const char *owner_func; /*!< function name of owner */ - int owner_line; /*!< line number of owner */ -#endif }; /*! @@ -266,7 +261,8 @@ int __ast_string_field_ptr_grow(struct ast_string_field_mgr *mgr, an additional pool will be allocated. */ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, size_t needed); + struct ast_string_field_pool **pool_head, size_t needed, + const char *file, int lineno, const char *func); /*! \internal @@ -277,9 +273,9 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr \param format printf-style format string \return nothing */ -void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, - ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 4, 5))); +void __ast_string_field_ptr_build(const char *file, int lineno, const char *func, + struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, + ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 7, 8))); /*! \internal @@ -292,8 +288,9 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, \return nothing */ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, - ast_string_field *ptr, const char *format, va_list ap) __attribute__((format(printf, 4, 0))); + struct ast_string_field_pool **pool_head, + ast_string_field *ptr, const char *format, va_list ap, + const char *file, int lineno, const char *func) __attribute__((format(printf, 4, 0))); /*! \brief Declare a string field @@ -434,7 +431,7 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_ * \internal * \brief internal version of ast_calloc_with_stringfields */ -void * attribute_malloc __ast_calloc_with_stringfields(unsigned int num_structs, +void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file, int lineno, const char *func); @@ -479,7 +476,7 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, __res__; \ }) -#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) \ +#define __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, file, lineno, func) \ ({ \ int __res__ = 0; \ const char *__d__ = (data); \ @@ -491,7 +488,7 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, *__p__ = __ast_string_field_empty; \ } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \ (!__ast_string_field_ptr_grow(&field_mgr, &field_mgr_pool, __dlen__, __p__)) || \ - (target = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__))) { \ + (target = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__, file, lineno, func))) { \ if (target != *__p__) { \ __ast_string_field_release_active(field_mgr_pool, *__p__); \ *__p__ = target; \ @@ -503,6 +500,9 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, __res__; \ }) +#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) \ + __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) + /*! \brief Set a field to a simple string value \param x Pointer to a structure containing fields @@ -532,7 +532,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ + __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ __res__ = 0; \ } \ __res__; \ @@ -550,7 +551,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ + __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ __res__ = 0; \ } \ __res__; \ @@ -568,7 +570,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ + __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ __res__ = 0; \ } \ __res__; \ @@ -586,7 +589,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ + __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ __res__ = 0; \ } \ __res__; \ @@ -626,12 +630,14 @@ int __ast_string_fields_cmp(struct ast_string_field_vector *left, struct ast_str if (((void *)(copy)) != NULL && ((void *)(orig)) != NULL) { \ __res__ = __ast_string_fields_copy(((copy)->__field_mgr_pool), \ (struct ast_string_field_mgr *)&((copy)->__field_mgr), \ - (struct ast_string_field_mgr *)&((orig)->__field_mgr)); \ + (struct ast_string_field_mgr *)&((orig)->__field_mgr), \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ } \ __res__; \ }) int __ast_string_fields_copy(struct ast_string_field_pool *copy_pool, - struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr); + struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr, + const char *file, int lineno, const char *func); #endif /* _ASTERISK_STRINGFIELDS_H */ diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 85393b4f9..e4bef5f0f 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -617,8 +617,8 @@ int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str * * \note The result of this function is dynamically allocated memory, and must * be free()'d after it is no longer needed. */ -#ifdef __AST_DEBUG_MALLOC -#define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) +#define ast_str_create(init_len) \ + _ast_str_create(init_len, __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( struct ast_str * attribute_malloc _ast_str_create(size_t init_len, const char *file, int lineno, const char *func), @@ -636,24 +636,6 @@ struct ast_str * attribute_malloc _ast_str_create(size_t init_len, return buf; } ) -#else -AST_INLINE_API( -struct ast_str * attribute_malloc ast_str_create(size_t init_len), -{ - struct ast_str *buf; - - buf = (struct ast_str *)ast_calloc(1, sizeof(*buf) + init_len); - if (buf == NULL) - return NULL; - - buf->__AST_STR_LEN = init_len; - buf->__AST_STR_USED = 0; - buf->__AST_STR_TS = DS_MALLOC; - - return buf; -} -) -#endif /*! \brief Reset the content of a dynamic string. * Useful before a series of ast_str_append. @@ -772,7 +754,6 @@ char *ast_str_truncate(struct ast_str *buf, ssize_t len), /*! * Make space in a new string (e.g. to read in data from a file) */ -#ifdef __AST_DEBUG_MALLOC AST_INLINE_API( int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function), { @@ -796,32 +777,8 @@ int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, return 0; } ) -#define ast_str_make_space(a,b) _ast_str_make_space(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -AST_INLINE_API( -int ast_str_make_space(struct ast_str **buf, size_t new_len), -{ - struct ast_str *old_buf = *buf; - - if (new_len <= (*buf)->__AST_STR_LEN) - return 0; /* success */ - if ((*buf)->__AST_STR_TS == DS_ALLOCA || (*buf)->__AST_STR_TS == DS_STATIC) - return -1; /* cannot extend */ - *buf = (struct ast_str *)ast_realloc(*buf, new_len + sizeof(struct ast_str)); - if (*buf == NULL) { - *buf = old_buf; - return -1; - } - if ((*buf)->__AST_STR_TS != DS_MALLOC) { - pthread_setspecific((*buf)->__AST_STR_TS->key, *buf); - _DB1(__ast_threadstorage_object_replace(old_buf, *buf, new_len + sizeof(struct ast_str));) - } - - (*buf)->__AST_STR_LEN = new_len; - return 0; -} -) -#endif +#define ast_str_make_space(buf, new_len) \ + _ast_str_make_space(buf, new_len, __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( int ast_str_copy_string(struct ast_str **dst, struct ast_str *src), @@ -965,14 +922,12 @@ enum { * through calling one of the other functions or macros defined in this * file. */ -#ifdef __AST_DEBUG_MALLOC -int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len, - int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func); -#define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__) -#else -int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, ssize_t max_len, - int append, const char *fmt, va_list ap); -#endif +int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, + ssize_t max_len, int append, const char *fmt, va_list ap, + const char *file, int lineno, const char *func); +#define _ast_str_helper(buf, max_len, append, fmt, ap) \ + __ast_str_helper(buf, max_len, append, fmt, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__) + char *__ast_str_helper2(struct ast_str **buf, ssize_t max_len, const char *src, size_t maxsrc, int append, int escapecommas); @@ -1022,7 +977,7 @@ char *__ast_str_helper2(struct ast_str **buf, ssize_t max_len, */ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap), { - return __ast_str_helper(buf, max_len, 0, fmt, ap); + return _ast_str_helper(buf, max_len, 0, fmt, ap); } ) @@ -1040,7 +995,7 @@ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct a */ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap), { - return __ast_str_helper(buf, max_len, 1, fmt, ap); + return _ast_str_helper(buf, max_len, 1, fmt, ap); } ) diff --git a/include/asterisk/udptl.h b/include/asterisk/udptl.h index 7137ff936..0d79d6f66 100644 --- a/include/asterisk/udptl.h +++ b/include/asterisk/udptl.h @@ -126,13 +126,6 @@ void ast_udptl_setnat(struct ast_udptl *udptl, int nat); void ast_udptl_stop(struct ast_udptl *udptl); -void ast_udptl_init(void); - -/*! - * \version 1.6.1 return changed to int - */ -int ast_udptl_reload(void); - #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index c6c34074e..bb9aa2a3c 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -509,11 +509,11 @@ long int ast_random(void); #endif -#ifndef __AST_DEBUG_MALLOC -#define ast_std_malloc malloc -#define ast_std_calloc calloc -#define ast_std_realloc realloc -#define ast_std_free free +#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) +void *ast_std_malloc(size_t size); +void *ast_std_calloc(size_t nmemb, size_t size); +void *ast_std_realloc(void *ptr, size_t size); +void ast_std_free(void *ptr); /*! * \brief free() wrapper @@ -521,8 +521,44 @@ long int ast_random(void); * ast_free_ptr should be used when a function pointer for free() needs to be passed * as the argument to a function. Otherwise, astmm will cause seg faults. */ +void ast_free_ptr(void *ptr); +void __ast_free(void *ptr, const char *file, int lineno, const char *func); + +#else + +/* + * Need to defeat the MALLOC_DEBUG API when building the standalone utilities. + */ + +#define ast_std_malloc malloc +#define ast_std_calloc calloc +#define ast_std_realloc realloc +#define ast_std_free free + +#define ast_free_ptr free #define ast_free free -#define ast_free_ptr ast_free + +#define __ast_repl_calloc(nmemb, size, file, lineno, func) \ + calloc(nmemb, size) + +#define __ast_repl_calloc_cache(nmemb, size, file, lineno, func) \ + calloc(nmemb, size) + +#define __ast_repl_malloc(size, file, lineno, func) \ + malloc(size) + +#define __ast_repl_realloc(ptr, size, file, lineno, func) \ + realloc(ptr, size) + +#define __ast_repl_strdup(s, file, lineno, func) \ + strdup(s) + +#define __ast_repl_strndup(s, n, file, lineno, func) \ + strndup(s, n) + +#define __ast_repl_vasprintf(strp, format, ap, file, lineno, func) \ + vasprintf(strp, format, ap) +#endif #if defined(AST_IN_CORE) #define MALLOC_FAILURE_MSG \ @@ -539,7 +575,8 @@ void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, c DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - if (!(p = malloc(len))) { + p = __ast_repl_malloc(len, file, lineno, func); + if (!p) { MALLOC_FAILURE_MSG; } @@ -554,7 +591,24 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - if (!(p = calloc(num, len))) { + p = __ast_repl_calloc(num, len, file, lineno, func); + if (!p) { + MALLOC_FAILURE_MSG; + } + + return p; +} +) + +AST_INLINE_API( +void * attribute_malloc __ast_calloc_cache(size_t num, size_t len, const char *file, int lineno, const char *func), +{ + void *p; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); + + p = __ast_repl_calloc_cache(num, len, file, lineno, func); + if (!p) { MALLOC_FAILURE_MSG; } @@ -563,13 +617,14 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i ) AST_INLINE_API( -void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), +void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), { void *newp; DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - if (!(newp = realloc(p, len))) { + newp = __ast_repl_realloc(p, len, file, lineno, func); + if (!newp) { MALLOC_FAILURE_MSG; } @@ -585,7 +640,8 @@ char * attribute_malloc __ast_strdup(const char *str, const char *file, int line DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); if (str) { - if (!(newstr = strdup(str))) { + newstr = __ast_repl_strdup(str, file, lineno, func); + if (!newstr) { MALLOC_FAILURE_MSG; } } @@ -602,7 +658,8 @@ char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *f DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); if (str) { - if (!(newstr = strndup(str, len))) { + newstr = __ast_repl_strndup(str, len, file, lineno, func); + if (!newstr) { MALLOC_FAILURE_MSG; } } @@ -611,8 +668,30 @@ char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *f } ) -int __attribute__((format(printf, 5, 6))) - __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...); +AST_INLINE_API( +__attribute__((format(printf, 5, 6))) +int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...), +{ + int res; + va_list ap; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); + + va_start(ap, fmt); + res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func); + if (res < 0) { + /* + * *ret is undefined so set to NULL to ensure it is + * initialized to something useful. + */ + *ret = NULL; + MALLOC_FAILURE_MSG; + } + va_end(ap); + + return res; +} +) AST_INLINE_API( __attribute__((format(printf, 2, 0))) @@ -622,7 +701,7 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); - res = vasprintf(ret, fmt, ap); + res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func); if (res < 0) { /* * *ret is undefined so set to NULL to ensure it is @@ -636,8 +715,6 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i } ) -#endif /* AST_DEBUG_MALLOC */ - /*! * \brief A wrapper for malloc() * @@ -671,7 +748,7 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i * The arguments and return value are the same as calloc() */ #define ast_calloc_cache(num, len) \ - __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for realloc() diff --git a/main/Makefile b/main/Makefile index fb0063b2a..fb985b9b8 100644 --- a/main/Makefile +++ b/main/Makefile @@ -17,9 +17,9 @@ all: asterisk include $(ASTTOPDIR)/Makefile.moddir_rules -# Can the MODSRC list be automated without needing built-in modules to be -# in a different directory? Would a different directory be better? -MOD_SRC:= +MOD_SRC:=cdr.c cel.c config.c ccss.c dnsmgr.c dsp.c enum.c features.c http.c indications.c logger.c manager.c named_acl.c plc.c sounds.c udptl.c +# Allow deletion of built-in modules without needing to modify this source. +MOD_SRC:=$(wildcard $(MOD_SRC)) MOD_OBJS:=$(sort $(MOD_SRC:.c=.o)) # Must include the extra ast_expr2.c, ast_expr2f.c, in case they need to be regenerated (because to force regeneration, we delete them) diff --git a/main/asterisk.c b/main/asterisk.c index e348b2199..7a4424d22 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -199,7 +199,6 @@ int daemon(int, int); /* defined in libresolv of all places */ #include "asterisk/channel.h" #include "asterisk/translate.h" #include "asterisk/pickup.h" -#include "asterisk/features.h" #include "asterisk/acl.h" #include "asterisk/ulaw.h" #include "asterisk/alaw.h" @@ -209,11 +208,7 @@ int daemon(int, int); /* defined in libresolv of all places */ #include "asterisk/term.h" #include "asterisk/manager.h" #include "asterisk/cdr.h" -#include "asterisk/cel.h" #include "asterisk/pbx.h" -#include "asterisk/enum.h" -#include "asterisk/http.h" -#include "asterisk/udptl.h" #include "asterisk/app.h" #include "asterisk/lock.h" #include "asterisk/utils.h" @@ -225,11 +220,9 @@ int daemon(int, int); /* defined in libresolv of all places */ #include "asterisk/devicestate.h" #include "asterisk/presencestate.h" #include "asterisk/module.h" -#include "asterisk/dsp.h" #include "asterisk/buildinfo.h" #include "asterisk/xmldoc.h" #include "asterisk/poll-compat.h" -#include "asterisk/ccss.h" #include "asterisk/test.h" #include "asterisk/rtp_engine.h" #include "asterisk/format.h" @@ -2732,10 +2725,14 @@ static void send_rasterisk_connect_commands(void) } #ifdef HAVE_LIBEDIT_IS_UNICODE -static int ast_el_read_char(EditLine *editline, wchar_t *cp) +#define CHAR_T_LIBEDIT wchar_t +#define CHAR_TO_LIBEDIT(c) btowc(c) #else -static int ast_el_read_char(EditLine *editline, char *cp) +#define CHAR_T_LIBEDIT char +#define CHAR_TO_LIBEDIT(c) c #endif + +static int ast_el_read_char(EditLine *editline, CHAR_T_LIBEDIT *cp) { int num_read = 0; int lastpos = 0; @@ -2756,28 +2753,29 @@ static int ast_el_read_char(EditLine *editline, char *cp) } res = ast_poll(fds, max, -1); if (res < 0) { - if (sig_flags.need_quit || sig_flags.need_quit_handler) + if (sig_flags.need_quit || sig_flags.need_quit_handler) { break; - if (errno == EINTR) + } + if (errno == EINTR) { continue; + } fprintf(stderr, "poll failed: %s\n", strerror(errno)); break; } if (!ast_opt_exec && fds[1].revents) { char c = '\0'; + num_read = read(STDIN_FILENO, &c, 1); if (num_read < 1) { break; - } else { -#ifdef HAVE_LIBEDIT_IS_UNICODE - *cp = btowc(c); -#else - *cp = c; -#endif - return (num_read); } + + *cp = CHAR_TO_LIBEDIT(c); + + return num_read; } + if (fds[0].revents) { res = read(ast_consock, buf, sizeof(buf) - 1); /* if the remote side disappears exit */ @@ -2788,6 +2786,7 @@ static int ast_el_read_char(EditLine *editline, char *cp) } else { int tries; int reconnects_per_second = 20; + fprintf(stderr, "Attempting to reconnect for 30 seconds\n"); for (tries = 0; tries < 30 * reconnects_per_second; tries++) { if (ast_tryconnect()) { @@ -2796,8 +2795,9 @@ static int ast_el_read_char(EditLine *editline, char *cp) WELCOME_MESSAGE; send_rasterisk_connect_commands(); break; - } else - usleep(1000000 / reconnects_per_second); + } + + usleep(1000000 / reconnects_per_second); } if (tries >= 30 * reconnects_per_second) { fprintf(stderr, "Failed to reconnect for 30 seconds. Quitting.\n"); @@ -2818,25 +2818,17 @@ static int ast_el_read_char(EditLine *editline, char *cp) console_print(buf); if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (res >= 2 && buf[res-2] == '\n'))) { -#ifdef HAVE_LIBEDIT_IS_UNICODE - *cp = btowc(CC_REFRESH); -#else - *cp = CC_REFRESH; -#endif - return(1); - } else { - lastpos = 1; + *cp = CHAR_TO_LIBEDIT(CC_REFRESH); + + return 1; } + lastpos = 1; } } -#ifdef HAVE_LIBEDIT_IS_UNICODE - *cp = btowc('\0'); -#else - *cp = '\0'; -#endif + *cp = CHAR_TO_LIBEDIT('\0'); - return (0); + return 0; } static struct ast_str *prompt = NULL; @@ -4445,12 +4437,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou print_intro_message(runuser, rungroup); - if (ast_opt_console) { - ast_verb(0, "[ Initializing Custom Configuration Options ]\n"); - } - /* custom config setup */ register_config_cli(); - read_config_maps(); check_init(astobj2_init(), "AO2"); check_init(ast_named_locks_init(), "Named Locks"); @@ -4548,6 +4535,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou check_init(ast_parking_stasis_init(), "Parking Core"); check_init(ast_device_state_engine_init(), "Device State Engine"); check_init(ast_presence_state_engine_init(), "Presence State Engine"); + check_init(dns_core_init(), "DNS Resolver Core"); check_init(ast_dns_system_resolver_init(), "Default DNS resolver"); check_init(ast_security_stasis_init(), "Security Stasis Topic and Events"); check_init(ast_image_init(), "Image"); @@ -4564,32 +4552,10 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou /* We should avoid most config loads before this point as they can't use realtime. */ check_init(load_modules(1), "Module Preload"); - /* Initialize core modules that have config files. These should be converted to - * built-in modules with load priority after realtime, that way users will not - * need to 'preload' realtime modules. */ - check_init(ast_features_init(), "Call Features"); - check_init(dnsmgr_init(), "DNS manager"); - check_init(ast_named_acl_init(), "Named ACL system"); - ast_http_init(); - check_init(ast_indications_init(), "Indication Tone Handling"); - check_init(ast_cdr_engine_init(), "CDR Engine"); - ast_dsp_init(); - ast_udptl_init(); - check_init(ast_cel_engine_init(), "CEL Engine"); - check_init(init_manager(), "Asterisk Manager Interface"); - check_init(ast_enum_init(), "ENUM Support"); - check_init(ast_cc_init(), "Call Completion Supplementary Services"); - /* Load remaining modules */ check_init(load_modules(0), "Module"); /* - * This is initialized after the dynamic modules load to avoid repeatedly - * reindexing sounds for every format module load. - */ - check_init(ast_sounds_index_init(), "Sounds Indexer"); - - /* * This has to load after the dynamic modules load, as items in the media * cache can't be constructed from items in the AstDB without their * bucket backends. diff --git a/main/astmm.c b/main/astmm.c index accd2ffcf..1fa35d728 100644 --- a/main/astmm.c +++ b/main/astmm.c @@ -149,31 +149,6 @@ AST_MUTEX_DEFINE_STATIC_NOTRACKING(reglock); } \ } while (0) -void *ast_std_malloc(size_t size) -{ - return malloc(size); -} - -void *ast_std_calloc(size_t nmemb, size_t size) -{ - return calloc(nmemb, size); -} - -void *ast_std_realloc(void *ptr, size_t size) -{ - return realloc(ptr, size); -} - -void ast_std_free(void *ptr) -{ - free(ptr); -} - -void ast_free_ptr(void *ptr) -{ - ast_free(ptr); -} - static void print_backtrace(struct ast_bt *bt) { int i = 0; @@ -479,7 +454,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha } } -void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) { void *ptr; @@ -491,7 +466,7 @@ void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, cons return ptr; } -void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) { void *ptr; @@ -503,7 +478,7 @@ void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno return ptr; } -void *__ast_malloc(size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) { void *ptr; @@ -539,7 +514,7 @@ static struct ast_region *region_find(void *ptr) return reg; } -void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func) { size_t len; struct ast_region *found; @@ -588,7 +563,7 @@ void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const return new_mem; } -char *__ast_strdup(const char *s, const char *file, int lineno, const char *func) +char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) { size_t len; void *ptr; @@ -603,7 +578,7 @@ char *__ast_strdup(const char *s, const char *file, int lineno, const char *func return ptr; } -char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) +char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) { size_t len; char *ptr; @@ -621,7 +596,7 @@ char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const return ptr; } -int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *fmt, ...) +int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *fmt, ...) { int size; va_list ap, ap2; @@ -642,7 +617,7 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, return size; } -int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func) +int __ast_repl_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func) { int size; va_list ap2; @@ -1543,4 +1518,83 @@ void __ast_mm_init_phase_2(void) ast_register_cleanup(mm_atexit_ast); } +#else /* !defined(__AST_DEBUG_MALLOC) */ + +void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) +{ + return calloc(nmemb, size); +} + +void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) +{ + return calloc(nmemb, size); +} + +void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) +{ + return malloc(size); +} + +void __ast_free(void *ptr, const char *file, int lineno, const char *func) +{ + free(ptr); +} + +void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func) +{ + return realloc(ptr, size); +} + +char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) +{ + return strdup(s); +} + +char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) +{ + return strndup(s, n); +} + +int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) +{ + va_list ap; + int rc = 0; + + va_start(ap, format); + rc = vasprintf(strp, format, ap); + va_end(ap); + + return rc; +} + +int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) +{ + return vasprintf(strp, format, ap); +} + #endif /* defined(__AST_DEBUG_MALLOC) */ + +void *ast_std_malloc(size_t size) +{ + return malloc(size); +} + +void *ast_std_calloc(size_t nmemb, size_t size) +{ + return calloc(nmemb, size); +} + +void *ast_std_realloc(void *ptr, size_t size) +{ + return realloc(ptr, size); +} + +void ast_std_free(void *ptr) +{ + free(ptr); +} + +void ast_free_ptr(void *ptr) +{ + ast_free(ptr); +} diff --git a/main/astobj2_container.c b/main/astobj2_container.c index ae647d2dd..9bea58f74 100644 --- a/main/astobj2_container.c +++ b/main/astobj2_container.c @@ -935,12 +935,15 @@ void ao2_container_unregister(const char *name) } #if defined(AO2_DEBUG) -static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags) +static int ao2_complete_reg_cb(void *obj, void *arg, int flags) { - struct ao2_reg_match *which = data; + struct ao2_reg_container *reg = obj; - /* ao2_reg_sort_cb() has already filtered the search to matching keys */ - return (which->find_nth < ++which->count) ? (CMP_MATCH | CMP_STOP) : 0; + if (ast_cli_completion_add(ast_strdup(reg->name))) { + return CMP_STOP; + } + + return 0; } #endif /* defined(AO2_DEBUG) */ @@ -948,9 +951,6 @@ static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags) static char *complete_container_names(struct ast_cli_args *a) { struct ao2_reg_partial_key partial_key; - struct ao2_reg_match which; - struct ao2_reg_container *reg; - char *name; if (a->pos != 3) { return NULL; @@ -958,17 +958,10 @@ static char *complete_container_names(struct ast_cli_args *a) partial_key.len = strlen(a->word); partial_key.name = a->word; - which.find_nth = a->n; - which.count = 0; - reg = ao2_t_callback_data(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0, - ao2_complete_reg_cb, &partial_key, &which, "Find partial registered container"); - if (reg) { - name = ast_strdup(reg->name); - ao2_t_ref(reg, -1, "Done with registered container object."); - } else { - name = NULL; - } - return name; + ao2_callback(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0, + ao2_complete_reg_cb, &partial_key); + + return NULL; } #endif /* defined(AO2_DEBUG) */ diff --git a/main/bridge.c b/main/bridge.c index 4f79852cb..1109c4b76 100644 --- a/main/bridge.c +++ b/main/bridge.c @@ -5027,46 +5027,29 @@ struct ast_bridge *ast_bridge_find_by_id(const char *bridge_id) return ao2_find(bridges, bridge_id, OBJ_SEARCH_KEY); } -struct bridge_complete { - /*! Nth match to return. */ - int state; - /*! Which match currently on. */ - int which; -}; - -static int complete_bridge_live_search(void *obj, void *arg, void *data, int flags) +static int complete_bridge_live_search(void *obj, void *arg, int flags) { - struct bridge_complete *search = data; + struct ast_bridge *bridge = obj; - if (++search->which > search->state) { - return CMP_MATCH; + if (ast_cli_completion_add(ast_strdup(bridge->uniqueid))) { + return CMP_STOP; } + return 0; } -static char *complete_bridge_live(const char *word, int state) +static char *complete_bridge_live(const char *word) { - char *ret; - struct ast_bridge *bridge; - struct bridge_complete search = { - .state = state, - }; + ao2_callback(bridges, ast_strlen_zero(word) ? 0 : OBJ_PARTIAL_KEY, + complete_bridge_live_search, (char *) word); - bridge = ao2_callback_data(bridges, ast_strlen_zero(word) ? 0 : OBJ_PARTIAL_KEY, - complete_bridge_live_search, (char *) word, &search); - if (!bridge) { - return NULL; - } - ret = ast_strdup(bridge->uniqueid); - ao2_ref(bridge, -1); - return ret; + return NULL; } -static char *complete_bridge_stasis(const char *word, int state) +static char *complete_bridge_stasis(const char *word) { - char *ret = NULL; - int wordlen = strlen(word), which = 0; - RAII_VAR(struct ao2_container *, cached_bridges, NULL, ao2_cleanup); + int wordlen = strlen(word); + struct ao2_container *cached_bridges; struct ao2_iterator iter; struct stasis_message *msg; @@ -5079,15 +5062,17 @@ static char *complete_bridge_stasis(const char *word, int state) for (; (msg = ao2_iterator_next(&iter)); ao2_ref(msg, -1)) { struct ast_bridge_snapshot *snapshot = stasis_message_data(msg); - if (!strncasecmp(word, snapshot->uniqueid, wordlen) && (++which > state)) { - ret = ast_strdup(snapshot->uniqueid); - ao2_ref(msg, -1); - break; + if (!strncasecmp(word, snapshot->uniqueid, wordlen)) { + if (ast_cli_completion_add(ast_strdup(snapshot->uniqueid))) { + ao2_ref(msg, -1); + break; + } } } ao2_iterator_destroy(&iter); + ao2_ref(cached_bridges, -1); - return ret; + return NULL; } static char *handle_bridge_show_all(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) @@ -5168,7 +5153,7 @@ static char *handle_bridge_show_specific(struct ast_cli_entry *e, int cmd, struc return NULL; case CLI_GENERATE: if (a->pos == 2) { - return complete_bridge_stasis(a->word, a->n); + return complete_bridge_stasis(a->word); } return NULL; } @@ -5207,7 +5192,7 @@ static char *handle_bridge_destroy_specific(struct ast_cli_entry *e, int cmd, st return NULL; case CLI_GENERATE: if (a->pos == 2) { - return complete_bridge_live(a->word, a->n); + return complete_bridge_live(a->word); } return NULL; } @@ -5229,11 +5214,10 @@ static char *handle_bridge_destroy_specific(struct ast_cli_entry *e, int cmd, st } #endif -static char *complete_bridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state) +static char *complete_bridge_participant(const char *bridge_name, const char *word) { struct ast_bridge *bridge; struct ast_bridge_channel *bridge_channel; - int which; int wordlen; bridge = ast_bridge_find_by_id(bridge_name); @@ -5241,19 +5225,17 @@ static char *complete_bridge_participant(const char *bridge_name, const char *li return NULL; } - { - SCOPED_LOCK(bridge_lock, bridge, ast_bridge_lock, ast_bridge_unlock); + wordlen = strlen(word); - which = 0; - wordlen = strlen(word); - AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) { - if (!strncasecmp(ast_channel_name(bridge_channel->chan), word, wordlen) - && ++which > state) { - ao2_ref(bridge, -1); - return ast_strdup(ast_channel_name(bridge_channel->chan)); + ast_bridge_lock(bridge); + AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) { + if (!strncasecmp(ast_channel_name(bridge_channel->chan), word, wordlen)) { + if (ast_cli_completion_add(ast_strdup(ast_channel_name(bridge_channel->chan)))) { + break; } } } + ast_bridge_unlock(bridge); ao2_ref(bridge, -1); @@ -5263,7 +5245,6 @@ static char *complete_bridge_participant(const char *bridge_name, const char *li static char *handle_bridge_kick_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { static const char * const completions[] = { "all", NULL }; - char *complete; struct ast_bridge *bridge; switch (cmd) { @@ -5277,14 +5258,11 @@ static char *handle_bridge_kick_channel(struct ast_cli_entry *e, int cmd, struct return NULL; case CLI_GENERATE: if (a->pos == 2) { - return complete_bridge_live(a->word, a->n); + return complete_bridge_live(a->word); } if (a->pos == 3) { - complete = ast_cli_complete(a->word, completions, a->n); - if (!complete) { - complete = complete_bridge_participant(a->argv[2], a->line, a->word, a->pos, a->n - 1); - } - return complete; + ast_cli_complete(a->word, completions, -1); + return complete_bridge_participant(a->argv[2], a->word); } return NULL; } @@ -5385,24 +5363,22 @@ static char *handle_bridge_technology_show(struct ast_cli_entry *e, int cmd, str #undef FORMAT } -static char *complete_bridge_technology(const char *word, int state) +static char *complete_bridge_technology(const char *word) { struct ast_bridge_technology *cur; - char *res; - int which; int wordlen; - which = 0; wordlen = strlen(word); AST_RWLIST_RDLOCK(&bridge_technologies); AST_RWLIST_TRAVERSE(&bridge_technologies, cur, entry) { - if (!strncasecmp(cur->name, word, wordlen) && ++which > state) { - res = ast_strdup(cur->name); - AST_RWLIST_UNLOCK(&bridge_technologies); - return res; + if (!strncasecmp(cur->name, word, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cur->name))) { + break; + } } } AST_RWLIST_UNLOCK(&bridge_technologies); + return NULL; } @@ -5421,7 +5397,7 @@ static char *handle_bridge_technology_suspend(struct ast_cli_entry *e, int cmd, return NULL; case CLI_GENERATE: if (a->pos == 3) { - return complete_bridge_technology(a->word, a->n); + return complete_bridge_technology(a->word); } return NULL; } diff --git a/main/callerid.c b/main/callerid.c index d6f8575fb..6c4e5cf04 100644 --- a/main/callerid.c +++ b/main/callerid.c @@ -501,7 +501,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, s case 0x06: /* short dial number */ case 0x07: /* reserved */ default: /* reserved */ - if (option_debug > 1) + if (DEBUG_ATLEAST(2)) ast_log(LOG_NOTICE, "did info:#1=%X\n", (unsigned)cid->rawdata[x]); break ; } diff --git a/main/ccss.c b/main/ccss.c index ed0bba7f5..9cf16e34d 100644 --- a/main/ccss.c +++ b/main/ccss.c @@ -4547,11 +4547,9 @@ static int kill_cores(void *obj, void *arg, int flags) return 0; } -static char *complete_core_id(const char *line, const char *word, int pos, int state) +static char *complete_core_id(const char *word) { - int which = 0; int wordlen = strlen(word); - char *ret = NULL; struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0); struct cc_core_instance *core_instance; @@ -4559,15 +4557,16 @@ static char *complete_core_id(const char *line, const char *word, int pos, int s cc_unref(core_instance, "CLI tab completion iteration")) { char core_id_str[20]; snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id); - if (!strncmp(word, core_id_str, wordlen) && ++which > state) { - ret = ast_strdup(core_id_str); - cc_unref(core_instance, "Found a matching core ID for CLI tab-completion"); - break; + if (!strncmp(word, core_id_str, wordlen)) { + if (ast_cli_completion_add(ast_strdup(core_id_str))) { + cc_unref(core_instance, "Found a matching core ID for CLI tab-completion"); + break; + } } } ao2_iterator_destroy(&core_iter); - return ret; + return NULL; } static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) @@ -4583,7 +4582,7 @@ static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_arg return NULL; case CLI_GENERATE: if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) { - return complete_core_id(a->line, a->word, a->pos, a->n); + return complete_core_id(a->word); } return NULL; } @@ -4616,7 +4615,7 @@ static struct ast_cli_entry cc_cli[] = { AST_CLI_DEFINE(handle_cc_kill, "Kill a CC transaction"), }; -static void cc_shutdown(void) +static int unload_module(void) { ast_devstate_prov_del("ccss"); ast_cc_agent_unregister(&generic_agent_callbacks); @@ -4642,30 +4641,32 @@ static void cc_shutdown(void) ao2_t_ref(generic_monitors, -1, "Unref generic_monitor container in cc_shutdown"); generic_monitors = NULL; } + + return 0; } -int ast_cc_init(void) +static int load_module(void) { int res; if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS, cc_core_instance_hash_fn, cc_core_instance_cmp_fn, "Create core instance container"))) { - return -1; + return AST_MODULE_LOAD_FAILURE; } if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS, generic_monitor_instance_list_hash_fn, generic_monitor_instance_list_cmp_fn, "Create generic monitor container"))) { - return -1; + return AST_MODULE_LOAD_FAILURE; } if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS_core", TPS_REF_DEFAULT))) { - return -1; + return AST_MODULE_LOAD_FAILURE; } if (!(cc_sched_context = ast_sched_context_create())) { - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_sched_start_thread(cc_sched_context)) { - return -1; + return AST_MODULE_LOAD_FAILURE; } res = ast_register_application2(ccreq_app, ccreq_exec, NULL, NULL, NULL); res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL); @@ -4681,7 +4682,12 @@ int ast_cc_init(void) initialize_cc_devstate_map(); res |= ast_devstate_prov_add("ccss", ccss_device_state); - ast_register_cleanup(cc_shutdown); - - return res; + return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Completion Supplementary Services", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/cdr.c b/main/cdr.c index 4acadf975..528673311 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -53,6 +53,7 @@ #include "asterisk/cdr.h" #include "asterisk/callerid.h" #include "asterisk/manager.h" +#include "asterisk/module.h" #include "asterisk/causes.h" #include "asterisk/linkedlists.h" #include "asterisk/utils.h" @@ -3950,18 +3951,14 @@ static char *handle_cli_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a /*! \brief Complete user input for 'cdr show' */ static char *cli_complete_show(struct ast_cli_args *a) { - char *result = NULL; int wordlen = strlen(a->word); - int which = 0; struct ao2_iterator it_cdrs; struct cdr_object *cdr; it_cdrs = ao2_iterator_init(active_cdrs_master, 0); while ((cdr = ao2_iterator_next(&it_cdrs))) { - if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen) && - (++which > a->n)) { - result = ast_strdup(cdr->party_a.snapshot->name); - if (result) { + if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cdr->party_a.snapshot->name))) { ao2_ref(cdr, -1); break; } @@ -3969,7 +3966,8 @@ static char *cli_complete_show(struct ast_cli_args *a) ao2_ref(cdr, -1); } ao2_iterator_destroy(&it_cdrs); - return result; + + return NULL; } static void cli_show_channels(struct ast_cli_args *a) @@ -4366,11 +4364,6 @@ static int process_config(int reload) return 0; } -static void cdr_engine_cleanup(void) -{ - destroy_subscriptions(); -} - static void cdr_engine_shutdown(void) { stasis_message_router_unsubscribe_and_join(stasis_router); @@ -4503,26 +4496,33 @@ static int cdr_toggle_runtime_options(void) return mod_cfg ? 0 : -1; } -int ast_cdr_engine_init(void) +static int unload_module(void) +{ + destroy_subscriptions(); + + return 0; +} + +static int load_module(void) { if (process_config(0)) { - return -1; + return AST_MODULE_LOAD_FAILURE; } cdr_topic = stasis_topic_create("cdr_engine"); if (!cdr_topic) { - return -1; + return AST_MODULE_LOAD_FAILURE; } stasis_router = stasis_message_router_create(cdr_topic); if (!stasis_router) { - return -1; + return AST_MODULE_LOAD_FAILURE; } stasis_message_router_set_congestion_limits(stasis_router, -1, 10 * AST_TASKPROCESSOR_HIGH_WATER_LEVEL); if (STASIS_MESSAGE_TYPE_INIT(cdr_sync_message_type)) { - return -1; + return AST_MODULE_LOAD_FAILURE; } stasis_message_router_add_cache_update(stasis_router, ast_channel_snapshot_type(), handle_channel_cache_message, NULL); @@ -4535,28 +4535,27 @@ int ast_cdr_engine_init(void) active_cdrs_master = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NUM_CDR_BUCKETS, cdr_master_hash_fn, NULL, cdr_master_cmp_fn); if (!active_cdrs_master) { - return -1; + return AST_MODULE_LOAD_FAILURE; } ao2_container_register("cdrs_master", active_cdrs_master, cdr_master_print_fn); active_cdrs_all = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NUM_CDR_BUCKETS, cdr_all_hash_fn, NULL, cdr_all_cmp_fn); if (!active_cdrs_all) { - return -1; + return AST_MODULE_LOAD_FAILURE; } ao2_container_register("cdrs_all", active_cdrs_all, cdr_all_print_fn); sched = ast_sched_context_create(); if (!sched) { ast_log(LOG_ERROR, "Unable to create schedule context.\n"); - return -1; + return AST_MODULE_LOAD_FAILURE; } ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands)); - ast_register_cleanup(cdr_engine_cleanup); ast_register_atexit(cdr_engine_shutdown); - return cdr_toggle_runtime_options(); + return cdr_toggle_runtime_options() ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } void ast_cdr_engine_term(void) @@ -4599,7 +4598,7 @@ void ast_cdr_engine_term(void) } } -int ast_cdr_engine_reload(void) +static int reload_module(void) { struct module_config *old_mod_cfg; struct module_config *mod_cfg; @@ -4625,3 +4624,11 @@ int ast_cdr_engine_reload(void) ao2_cleanup(old_mod_cfg); return cdr_toggle_runtime_options(); } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "CDR Engine", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/cel.c b/main/cel.c index e4fae6dca..91c625a3c 100644 --- a/main/cel.c +++ b/main/cel.c @@ -38,7 +38,7 @@ #include "asterisk.h" -#include "asterisk/_private.h" +#include "asterisk/module.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" @@ -1421,7 +1421,7 @@ static void destroy_subscriptions(void) cel_cel_forwarder = stasis_forward_cancel(cel_cel_forwarder); } -static void cel_engine_cleanup(void) +static int unload_module(void) { destroy_routes(); destroy_subscriptions(); @@ -1433,6 +1433,8 @@ static void cel_engine_cleanup(void) ao2_global_obj_release(cel_dialstatus_store); ao2_global_obj_release(cel_linkedids); ao2_global_obj_release(cel_backends); + + return 0; } /*! @@ -1555,7 +1557,7 @@ static int create_routes(void) AO2_STRING_FIELD_HASH_FN(cel_linkedid, id) AO2_STRING_FIELD_CMP_FN(cel_linkedid, id) -int ast_cel_engine_init(void) +static int load_module(void) { struct ao2_container *container; @@ -1563,8 +1565,7 @@ int ast_cel_engine_init(void) ao2_global_obj_replace_unref(cel_linkedids, container); ao2_cleanup(container); if (!container) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } container = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS, @@ -1572,31 +1573,26 @@ int ast_cel_engine_init(void) ao2_global_obj_replace_unref(cel_dialstatus_store, container); ao2_cleanup(container); if (!container) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (STASIS_MESSAGE_TYPE_INIT(cel_generic_type)) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_cli_register(&cli_status)) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } container = ao2_container_alloc(BACKEND_BUCKETS, cel_backend_hash_fn, cel_backend_cmp_fn); ao2_global_obj_replace_unref(cel_backends, container); ao2_cleanup(container); if (!container) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (aco_info_init(&cel_cfg_info)) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } aco_option_register(&cel_cfg_info, "enable", ACO_EXACT, general_options, "no", OPT_BOOL_T, 1, FLDSET(struct ast_cel_general_config, enable)); @@ -1608,8 +1604,7 @@ int ast_cel_engine_init(void) struct cel_config *cel_cfg = cel_config_alloc(); if (!cel_cfg) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } /* We couldn't process the configuration so create a default config. */ @@ -1621,20 +1616,17 @@ int ast_cel_engine_init(void) } if (create_subscriptions()) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_cel_check_enabled() && create_routes()) { - cel_engine_cleanup(); - return -1; + return AST_MODULE_LOAD_FAILURE; } - ast_register_cleanup(cel_engine_cleanup); - return 0; + return AST_MODULE_LOAD_SUCCESS; } -int ast_cel_engine_reload(void) +static int reload_module(void) { unsigned int was_enabled = ast_cel_check_enabled(); unsigned int is_enabled; @@ -1754,3 +1746,11 @@ int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callba ao2_ref(backend, -1); return 0; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "CEL Engine", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/channel.c b/main/channel.c index c71d19b81..c7847cbd4 100644 --- a/main/channel.c +++ b/main/channel.c @@ -304,25 +304,23 @@ static char *handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, static char *complete_channeltypes(struct ast_cli_args *a) { struct chanlist *cl; - int which = 0; int wordlen; - char *ret = NULL; - if (a->pos != 3) + if (a->pos != 3) { return NULL; + } wordlen = strlen(a->word); AST_RWLIST_RDLOCK(&backends); AST_RWLIST_TRAVERSE(&backends, cl, list) { - if (!strncasecmp(a->word, cl->tech->type, wordlen) && ++which > a->n) { - ret = ast_strdup(cl->tech->type); - break; + if (!strncasecmp(a->word, cl->tech->type, wordlen)) { + ast_cli_completion_add(ast_strdup(cl->tech->type)); } } AST_RWLIST_UNLOCK(&backends); - return ret; + return NULL; } /*! \brief Show details about a channel driver - CLI command */ @@ -782,7 +780,7 @@ static int does_id_conflict(const char *uniqueid) } /*! \brief Create a new channel structure */ -static struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 0))) +static struct ast_channel *__attribute__((format(printf, 15, 0))) __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, @@ -7583,22 +7581,6 @@ static int ast_channel_hash_cb(const void *obj, const int flags) return ast_str_case_hash(name); } -int ast_plc_reload(void) -{ - struct ast_variable *var; - struct ast_flags config_flags = { 0 }; - struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) - return 0; - for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { - if (!strcasecmp(var->name, "genericplc")) { - ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC); - } - } - ast_config_destroy(cfg); - return 0; -} - /*! * \internal * \brief Print channel object key (name). @@ -7822,8 +7804,6 @@ int ast_channels_init(void) ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel)); - ast_plc_reload(); - ast_register_cleanup(channels_shutdown); AST_RWLIST_HEAD_INIT(&ami_vars); diff --git a/main/chanvars.c b/main/chanvars.c index 2cc90e43a..0802646b9 100644 --- a/main/chanvars.c +++ b/main/chanvars.c @@ -33,21 +33,15 @@ #include "asterisk/strings.h" #include "asterisk/utils.h" -#ifdef __AST_DEBUG_MALLOC struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function) -#else -struct ast_var_t *ast_var_assign(const char *name, const char *value) -#endif { struct ast_var_t *var; int name_len = strlen(name) + 1; int value_len = strlen(value) + 1; -#ifdef __AST_DEBUG_MALLOC - if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) { -#else - if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) { -#endif + var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), + file, lineno, function); + if (!var) { return NULL; } diff --git a/main/cli.c b/main/cli.c index 80c184328..e46d3427c 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1655,8 +1655,15 @@ char *ast_cli_complete(const char *word, const char * const choices[], int state len = ast_strlen_zero(word) ? 0 : strlen(word); for (i = 0; choices[i]; i++) { - if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) - return ast_strdup(choices[i]); + if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) { + if (state != -1) { + return ast_strdup(choices[i]); + } + + if (ast_cli_completion_add(ast_strdup(choices[i]))) { + return NULL; + } + } } return NULL; } @@ -1682,9 +1689,16 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta struct ast_channel_snapshot *snapshot = stasis_message_data(msg); if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) { - ret = ast_strdup(snapshot->name); - ao2_ref(msg, -1); - break; + if (state != -1) { + ret = ast_strdup(snapshot->name); + ao2_ref(msg, -1); + break; + } + + if (ast_cli_completion_add(ast_strdup(snapshot->name))) { + ao2_ref(msg, -1); + break; + } } } ao2_iterator_destroy(&iter); diff --git a/main/config.c b/main/config.c index 8107fce04..5adcb2386 100644 --- a/main/config.c +++ b/main/config.c @@ -30,6 +30,11 @@ <support_level>core</support_level> ***/ +/* This maintains the original "module reload extconfig" CLI command instead + * of replacing it with "module reload config". */ +#undef AST_MODULE +#define AST_MODULE "extconfig" + #include "asterisk.h" #include "asterisk/paths.h" /* use ast_config_AST_CONFIG_DIR */ @@ -54,6 +59,7 @@ #include "asterisk/astobj2.h" #include "asterisk/strings.h" /* for the ast_str_*() API */ #include "asterisk/netsock2.h" +#include "asterisk/module.h" #define MAX_NESTED_COMMENTS 128 #define COMMENT_START ";--" @@ -281,11 +287,7 @@ struct ast_config_include { static void ast_variable_destroy(struct ast_variable *doomed); static void ast_includes_destroy(struct ast_config_include *incls); -#ifdef __AST_DEBUG_MALLOC struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno) -#else -struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename) -#endif { struct ast_variable *variable; int name_len = strlen(name) + 1; @@ -297,13 +299,9 @@ struct ast_variable *ast_variable_new(const char *name, const char *value, const fn_len = MIN_VARIABLE_FNAME_SPACE; } - if ( -#ifdef __AST_DEBUG_MALLOC - (variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func)) -#else - (variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable))) -#endif - ) { + variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), + file, lineno, func); + if (variable) { char *dst = variable->stuff; /* writable space starts here */ /* Put file first so ast_include_rename() can calculate space available. */ @@ -2785,9 +2783,7 @@ int ast_config_text_file_save2(const char *configfile, const struct ast_config * } cat = cat->next; } - if (!option_debug) { - ast_verb(2, "Saving '%s': saved\n", fn); - } + ast_verb(2, "Saving '%s': saved\n", fn); } else { ast_debug(1, "Unable to open for writing: %s\n", fn); ast_verb(2, "Unable to write '%s' (%s)\n", fn, strerror(errno)); @@ -2885,7 +2881,7 @@ static int ast_realtime_append_mapping(const char *name, const char *driver, con return 0; } -int read_config_maps(void) +static int reload_module(void) { struct ast_config *config, *configtmp; struct ast_variable *v; @@ -3934,8 +3930,8 @@ static char *handle_cli_core_show_config_mappings(struct ast_cli_entry *e, int c static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct cache_file_mtime *cfmtime; - char *prev = "", *completion_value = NULL; - int wordlen, which = 0; + char *prev = ""; + int wordlen; switch (cmd) { case CLI_INIT: @@ -3953,19 +3949,20 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a AST_LIST_LOCK(&cfmtime_head); AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { - /* Skip duplicates - this only works because the list is sorted by filename */ - if (strcmp(cfmtime->filename, prev) == 0) { + /* Core configs cannot be reloaded */ + if (ast_strlen_zero(cfmtime->who_asked)) { continue; } - /* Core configs cannot be reloaded */ - if (ast_strlen_zero(cfmtime->who_asked)) { + /* Skip duplicates - this only works because the list is sorted by filename */ + if (!strcmp(cfmtime->filename, prev)) { continue; } - if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) { - completion_value = ast_strdup(cfmtime->filename); - break; + if (!strncmp(cfmtime->filename, a->word, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cfmtime->filename))) { + break; + } } /* Otherwise save that we've seen this filename */ @@ -3973,7 +3970,7 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a } AST_LIST_UNLOCK(&cfmtime_head); - return completion_value; + return NULL; } if (a->argc != 3) { @@ -4044,6 +4041,7 @@ static void config_shutdown(void) int register_config_cli(void) { ast_cli_register_multiple(cli_config, ARRAY_LEN(cli_config)); + /* This is separate from the module load so cleanup can happen very late. */ ast_register_cleanup(config_shutdown); return 0; } @@ -4130,3 +4128,26 @@ int ast_config_hook_register(const char *name, ao2_ref(hook, -1); return 0; } + +static int unload_module(void) +{ + return 0; +} + +static int load_module(void) +{ + if (ast_opt_console) { + ast_verb(0, "[ Initializing Custom Configuration Options ]\n"); + } + + return reload_module() ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; +} + +/* This module explicitly loads before realtime drivers. */ +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Configuration", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = 0, +); diff --git a/main/config_options.c b/main/config_options.c index 3aa00f921..41c8b222c 100644 --- a/main/config_options.c +++ b/main/config_options.c @@ -958,88 +958,79 @@ int aco_set_defaults(struct aco_type *type, const char *category, void *obj) /*! \internal * \brief Complete the name of the module the user is looking for */ -static char *complete_config_module(const char *word, int pos, int state) +static char *complete_config_module(const char *word) { - char *c = NULL; size_t wordlen = strlen(word); - int which = 0; struct ao2_iterator i; struct ast_xml_doc_item *cur; - if (pos != 3) { - return NULL; - } - i = ao2_iterator_init(xmldocs, 0); while ((cur = ao2_iterator_next(&i))) { - if (!strncasecmp(word, cur->name, wordlen) && ++which > state) { - c = ast_strdup(cur->name); - ao2_ref(cur, -1); - break; + if (!strncasecmp(word, cur->name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cur->name))) { + ao2_ref(cur, -1); + break; + } } ao2_ref(cur, -1); } ao2_iterator_destroy(&i); - return c; + return NULL; } /*! \internal * \brief Complete the name of the configuration type the user is looking for */ -static char *complete_config_type(const char *module, const char *word, int pos, int state) +static char *complete_config_type(const char *module, const char *word) { - char *c = NULL; size_t wordlen = strlen(word); - int which = 0; - RAII_VAR(struct ast_xml_doc_item *, info, NULL, ao2_cleanup); + struct ast_xml_doc_item *info; struct ast_xml_doc_item *cur; - if (pos != 4) { - return NULL; - } - - if (!(info = ao2_find(xmldocs, module, OBJ_KEY))) { + info = ao2_find(xmldocs, module, OBJ_KEY); + if (!info) { return NULL; } cur = info; while ((cur = AST_LIST_NEXT(cur, next))) { - if (!strcasecmp(cur->type, "configObject") && !strncasecmp(word, cur->name, wordlen) && ++which > state) { - c = ast_strdup(cur->name); - break; + if (!strcasecmp(cur->type, "configObject") && !strncasecmp(word, cur->name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cur->name))) { + break; + } } } - return c; + ao2_ref(info, -1); + + return NULL; } /*! \internal * \brief Complete the name of the configuration option the user is looking for */ -static char *complete_config_option(const char *module, const char *option, const char *word, int pos, int state) +static char *complete_config_option(const char *module, const char *option, const char *word) { - char *c = NULL; size_t wordlen = strlen(word); - int which = 0; - RAII_VAR(struct ast_xml_doc_item *, info, NULL, ao2_cleanup); + struct ast_xml_doc_item *info; struct ast_xml_doc_item *cur; - if (pos != 5) { - return NULL; - } - - if (!(info = ao2_find(xmldocs, module, OBJ_KEY))) { + info = ao2_find(xmldocs, module, OBJ_KEY); + if (!info) { return NULL; } cur = info; while ((cur = AST_LIST_NEXT(cur, next))) { - if (!strcasecmp(cur->type, "configOption") && !strcasecmp(cur->ref, option) && !strncasecmp(word, cur->name, wordlen) && ++which > state) { - c = ast_strdup(cur->name); - break; + if (!strcasecmp(cur->type, "configOption") && !strcasecmp(cur->ref, option) && !strncasecmp(word, cur->name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(cur->name))) { + break; + } } } - return c; + ao2_ref(info, -1); + + return NULL; } /* Define as 0 if we want to allow configurations to be registered without @@ -1340,10 +1331,14 @@ static char *cli_show_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args return NULL; case CLI_GENERATE: switch(a->pos) { - case 3: return complete_config_module(a->word, a->pos, a->n); - case 4: return complete_config_type(a->argv[3], a->word, a->pos, a->n); - case 5: return complete_config_option(a->argv[3], a->argv[4], a->word, a->pos, a->n); - default: return NULL; + case 3: + return complete_config_module(a->word); + case 4: + return complete_config_type(a->argv[3], a->word); + case 5: + return complete_config_option(a->argv[3], a->argv[4], a->word); + default: + return NULL; } } diff --git a/main/core_local.c b/main/core_local.c index 23c7cce9d..c3fa15f6c 100644 --- a/main/core_local.c +++ b/main/core_local.c @@ -1049,7 +1049,6 @@ static void local_shutdown(void) int ast_local_init(void) { - if (STASIS_MESSAGE_TYPE_INIT(ast_local_optimization_begin_type)) { return -1; } @@ -1069,17 +1068,13 @@ int ast_local_init(void) locals = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, locals_cmp_cb); if (!locals) { - ao2_cleanup(local_tech.capabilities); - local_tech.capabilities = NULL; return -1; } /* Make sure we can register our channel type */ if (ast_channel_register(&local_tech)) { ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n"); - ao2_ref(locals, -1); - ao2_cleanup(local_tech.capabilities); - local_tech.capabilities = NULL; + return -1; } ast_cli_register_multiple(cli_local, ARRAY_LEN(cli_local)); diff --git a/main/datastore.c b/main/datastore.c index a12bbdf34..5edad2413 100644 --- a/main/datastore.c +++ b/main/datastore.c @@ -47,7 +47,8 @@ struct ast_datastore *__ast_datastore_alloc( return NULL; } - if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) { + datastore = __ast_calloc(1, sizeof(*datastore), file, line, function); + if (!datastore) { return NULL; } diff --git a/main/devicestate.c b/main/devicestate.c index 1db9a1937..5df34497a 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -911,24 +911,20 @@ int devstate_init(void) } device_state_topic_all = stasis_topic_create("ast_device_state_topic"); if (!device_state_topic_all) { - devstate_cleanup(); return -1; } device_state_topic_pool = stasis_topic_pool_create(ast_device_state_topic_all()); if (!device_state_topic_pool) { - devstate_cleanup(); return -1; } device_state_cache = stasis_cache_create_full(device_state_get_id, device_state_aggregate_calc, device_state_aggregate_publish); if (!device_state_cache) { - devstate_cleanup(); return -1; } device_state_topic_cached = stasis_caching_topic_create(ast_device_state_topic_all(), device_state_cache); if (!device_state_topic_cached) { - devstate_cleanup(); return -1; } @@ -936,7 +932,6 @@ int devstate_init(void) devstate_change_cb, NULL); if (!devstate_message_sub) { ast_log(LOG_ERROR, "Failed to create subscription creating uncached device state aggregate events.\n"); - devstate_cleanup(); return -1; } diff --git a/main/dns_core.c b/main/dns_core.c index 3e270aff7..6f37a5d46 100644 --- a/main/dns_core.c +++ b/main/dns_core.c @@ -29,6 +29,7 @@ #include "asterisk.h" +#include "asterisk/_private.h" #include "asterisk/linkedlists.h" #include "asterisk/astobj2.h" #include "asterisk/strings.h" @@ -537,6 +538,22 @@ static void dns_shutdown(void) } } +int dns_core_init(void) +{ + sched = ast_sched_context_create(); + if (!sched) { + return -1; + } + + if (ast_sched_start_thread(sched)) { + return -1; + } + + ast_register_cleanup(dns_shutdown); + + return 0; +} + int ast_dns_resolver_register(struct ast_dns_resolver *resolver) { struct ast_dns_resolver *iter; @@ -559,27 +576,6 @@ int ast_dns_resolver_register(struct ast_dns_resolver *resolver) AST_RWLIST_WRLOCK(&resolvers); - /* On the first registration of a resolver start a scheduler for recurring queries */ - if (AST_LIST_EMPTY(&resolvers) && !sched) { - sched = ast_sched_context_create(); - if (!sched) { - ast_log(LOG_ERROR, "DNS resolver '%s' could not be registered: Failed to create scheduler for recurring DNS queries\n", - resolver->name); - AST_RWLIST_UNLOCK(&resolvers); - return -1; - } - - if (ast_sched_start_thread(sched)) { - ast_log(LOG_ERROR, "DNS resolver '%s' could not be registered: Failed to start thread for recurring DNS queries\n", - resolver->name); - dns_shutdown(); - AST_RWLIST_UNLOCK(&resolvers); - return -1; - } - - ast_register_cleanup(dns_shutdown); - } - AST_LIST_TRAVERSE(&resolvers, iter, next) { if (!strcmp(iter->name, resolver->name)) { ast_log(LOG_ERROR, "A DNS resolver with the name '%s' is already registered\n", resolver->name); diff --git a/main/dns_system_resolver.c b/main/dns_system_resolver.c index 9358577b6..8cb92c058 100644 --- a/main/dns_system_resolver.c +++ b/main/dns_system_resolver.c @@ -255,7 +255,6 @@ int ast_dns_system_resolver_init(void) /* Return error if the task processor failed to instantiate */ if (!dns_system_resolver_tp) { - dns_system_resolver_destroy(); return DNS_SYSTEM_RESOLVER_FAILURE; } diff --git a/main/dnsmgr.c b/main/dnsmgr.c index 0e5efd6da..c25b601b3 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -49,6 +49,7 @@ #include <regex.h> #include <signal.h> +#include "asterisk/module.h" #include "asterisk/dnsmgr.h" #include "asterisk/linkedlists.h" #include "asterisk/utils.h" @@ -406,7 +407,7 @@ static struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Relo static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh"); static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status"); -static void dnsmgr_shutdown(void) +static int unload_module(void) { ast_cli_unregister(&cli_reload); ast_cli_unregister(&cli_status); @@ -424,24 +425,24 @@ static void dnsmgr_shutdown(void) ast_mutex_unlock(&refresh_lock); ast_sched_context_destroy(sched); + + return 0; } -int dnsmgr_init(void) +static int load_module(void) { if (!(sched = ast_sched_context_create())) { ast_log(LOG_ERROR, "Unable to create schedule context.\n"); - return -1; + return AST_MODULE_LOAD_FAILURE; } ast_cli_register(&cli_reload); ast_cli_register(&cli_status); ast_cli_register(&cli_refresh); - ast_register_cleanup(dnsmgr_shutdown); - - return do_reload(1); + return do_reload(1) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } -int dnsmgr_reload(void) +static int reload_module(void) { return do_reload(0); } @@ -515,3 +516,11 @@ static int do_reload(int loading) return 0; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "DNS Manager", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/dsp.c b/main/dsp.c index 8b39fe55e..ea653d857 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -57,6 +57,7 @@ #include <math.h> +#include "asterisk/module.h" #include "asterisk/frame.h" #include "asterisk/format_cache.h" #include "asterisk/channel.h" @@ -1331,10 +1332,11 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) #ifndef BUSYDETECT_TONEONLY if ((hittone >= dsp->busycount - 1) && (hitsilence >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX) && - (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX)) { + (avgsilence >= BUSY_MIN && avgsilence <= BUSY_MAX)) #else - if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX)) { + if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX)) #endif + { #ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE if (avgtone > avgsilence) { if (avgtone - avgtone*BUSY_PERCENT/100 <= avgsilence) { @@ -2392,30 +2394,35 @@ AST_TEST_DEFINE(test_dsp_dtmf_detect) } #endif -#ifdef TEST_FRAMEWORK -static void test_dsp_shutdown(void) +static int unload_module(void) { AST_TEST_UNREGISTER(test_dsp_fax_detect); AST_TEST_UNREGISTER(test_dsp_dtmf_detect); + + return 0; } -#endif -int ast_dsp_init(void) +static int load_module(void) { - int res = _dsp_init(0); + if (_dsp_init(0)) { + return AST_MODULE_LOAD_FAILURE; + } -#ifdef TEST_FRAMEWORK - if (!res) { - AST_TEST_REGISTER(test_dsp_fax_detect); - AST_TEST_REGISTER(test_dsp_dtmf_detect); + AST_TEST_REGISTER(test_dsp_fax_detect); + AST_TEST_REGISTER(test_dsp_dtmf_detect); - ast_register_cleanup(test_dsp_shutdown); - } -#endif - return res; + return AST_MODULE_LOAD_SUCCESS; } -int ast_dsp_reload(void) +static int reload_module(void) { return _dsp_init(1); } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "DSP", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/enum.c b/main/enum.c index 5c217c43c..a44a60cbe 100644 --- a/main/enum.c +++ b/main/enum.c @@ -70,6 +70,7 @@ #include <ctype.h> #include <regex.h> +#include "asterisk/module.h" #include "asterisk/enum.h" #include "asterisk/dns.h" #include "asterisk/channel.h" @@ -1008,12 +1009,25 @@ static int private_enum_init(int reload) return 0; } -int ast_enum_init(void) +static int load_module(void) { - return private_enum_init(0); + return private_enum_init(0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } -int ast_enum_reload(void) +static int unload_module(void) +{ + return 0; +} + +static int reload_module(void) { return private_enum_init(1); } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "ENUM Support", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/features.c b/main/features.c index 516c64a4a..3db6d397b 100644 --- a/main/features.c +++ b/main/features.c @@ -40,6 +40,7 @@ #include "asterisk.h" #include "asterisk/_private.h" +#include "features_config.h" #include <pthread.h> #include <signal.h> @@ -1145,36 +1146,32 @@ done: return 0; } -/*! - * \internal - * \brief Clean up resources on Asterisk shutdown - */ -static void features_shutdown(void) +static int unload_module(void) { - ast_features_config_shutdown(); + unload_features_config(); ast_manager_unregister("Bridge"); ast_unregister_application(app_bridge); + return 0; } -int ast_features_init(void) +static int load_module(void) { int res; - res = ast_features_config_init(); - if (res) { - return res; - } + res = load_features_config(); res |= ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL); res |= ast_manager_register_xml_core("Bridge", EVENT_FLAG_CALL, action_bridge); - if (res) { - features_shutdown(); - } else { - ast_register_cleanup(features_shutdown); - } - - return res; + return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Features", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_features_config, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/features_config.c b/main/features_config.c index a773f497f..f116e89d5 100644 --- a/main/features_config.c +++ b/main/features_config.c @@ -26,6 +26,8 @@ #include "asterisk/app.h" #include "asterisk/cli.h" +#include "features_config.h" + /*** DOCUMENTATION <configInfo name="features" language="en_US"> <synopsis>Features Configuration</synopsis> @@ -1971,7 +1973,7 @@ static struct ast_cli_entry cli_features_config[] = { AST_CLI_DEFINE(handle_feature_show, "Lists configured features"), }; -void ast_features_config_shutdown(void) +void unload_features_config(void) { ast_custom_function_unregister(&featuremap_function); ast_custom_function_unregister(&feature_function); @@ -1980,7 +1982,7 @@ void ast_features_config_shutdown(void) ao2_global_obj_release(globals); } -int ast_features_config_reload(void) +int reload_features_config(void) { /* Rearm the parking config options have moved warning. */ parking_warning = 0; @@ -1991,7 +1993,7 @@ int ast_features_config_reload(void) return 0; } -int ast_features_config_init(void) +int load_features_config(void) { int res; @@ -2000,9 +2002,5 @@ int ast_features_config_init(void) res |= __ast_custom_function_register(&featuremap_function, NULL); res |= ast_cli_register_multiple(cli_features_config, ARRAY_LEN(cli_features_config)); - if (res) { - ast_features_config_shutdown(); - } - return res; } diff --git a/main/features_config.h b/main/features_config.h new file mode 100644 index 000000000..8e9e4acb3 --- /dev/null +++ b/main/features_config.h @@ -0,0 +1,28 @@ +/* +* Asterisk -- An open source telephony toolkit. +* +* Copyright (C) 2018, CFWare, LLC. +* +* Corey Farrell <git@cfware.com> +* +* See http://www.asterisk.org for more information about +* the Asterisk project. Please do not directly contact +* any of the maintainers of this project for assistance; +* the project provides a web site, mailing lists and IRC +* channels for your use. +* +* This program is free software, distributed under the terms of +* the GNU General Public License Version 2. See the LICENSE file +* at the top of the source tree. +*/ + +#ifndef FEATURES_CONFIG_H_ +#define FEATURES_CONFIG_H_ + +int load_features_config(void); + +int reload_features_config(void); + +void unload_features_config(void); + +#endif /* FEATURES_CONFIG_H_ */ diff --git a/main/hashtab.c b/main/hashtab.c index eefe44304..1f9c7bfe8 100644 --- a/main/hashtab.c +++ b/main/hashtab.c @@ -41,12 +41,10 @@ #include "asterisk/hashtab.h" -#ifdef __AST_DEBUG_MALLOC static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func); -#define ast_hashtab_resize(a) _ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) -#else -static void ast_hashtab_resize(struct ast_hashtab *tab); -#endif +#define ast_hashtab_resize(tab) \ + _ast_hashtab_resize(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) + static void *ast_hashtab_lookup_internal(struct ast_hashtab *tab, const void *obj, unsigned int h); /* some standard, default routines for general use */ @@ -215,40 +213,28 @@ unsigned int ast_hashtab_hash_short(const short x) return x; } -struct ast_hashtab * -#ifdef __AST_DEBUG_MALLOC -_ast_hashtab_create -#else -ast_hashtab_create -#endif -(int initial_buckets, +struct ast_hashtab *_ast_hashtab_create(int initial_buckets, int (*compare)(const void *a, const void *b), int (*resize)(struct ast_hashtab *), int (*newsize)(struct ast_hashtab *tab), unsigned int (*hash)(const void *obj), - int do_locking -#ifdef __AST_DEBUG_MALLOC - , const char *file, int lineno, const char *function -#endif + int do_locking, + const char *file, int lineno, const char *function ) { struct ast_hashtab *ht; -#ifdef __AST_DEBUG_MALLOC - if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function))) -#else - if (!(ht = ast_calloc(1, sizeof(*ht)))) -#endif + ht = __ast_calloc(1, sizeof(*ht), file, lineno, function); + if (!ht) { return NULL; + } while (!ast_is_prime(initial_buckets)) /* make sure this is prime */ initial_buckets++; -#ifdef __AST_DEBUG_MALLOC - if (!(ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), file, lineno, function))) { -#else - if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) { -#endif + ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), + file, lineno, function); + if (!ht->array) { ast_free(ht); return NULL; } @@ -272,25 +258,19 @@ ast_hashtab_create return ht; } -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func) -#else -struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj)) -#endif { struct ast_hashtab *ht; unsigned int i; - if (!(ht = ast_calloc(1, sizeof(*ht)))) + ht = __ast_calloc(1, sizeof(*ht), file, lineno, func); + if (!ht) { return NULL; + } - if (!(ht->array = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), file, lineno, func) -#else - ast_calloc(tab->hash_tab_size, sizeof(*(ht->array))) -#endif - )) { + ht->array = __ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), + file, lineno, func); + if (!ht->array) { ast_free(ht); return NULL; } @@ -312,12 +292,9 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun struct ast_hashtab_bucket *b = tab->array[i]; while (b) { void *newobj = (*obj_dup_func)(b->object); - if (newobj) -#ifdef __AST_DEBUG_MALLOC + if (newobj) { _ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func); -#else - ast_hashtab_insert_immediate_bucket(ht, newobj, i); -#endif + } b = b->next; } } @@ -424,11 +401,7 @@ void ast_hashtab_destroy(struct ast_hashtab *tab, void (*objdestroyfunc)(void *o } } -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func) -#else -int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj) -#endif { unsigned int h; int res=0; @@ -441,11 +414,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj) h = (*tab->hash)(obj) % tab->hash_tab_size; -#ifdef __AST_DEBUG_MALLOC res = _ast_hashtab_insert_immediate_bucket(tab, obj, h, file, lineno, func); -#else - res = ast_hashtab_insert_immediate_bucket(tab, obj, h); -#endif if (tab->do_locking) ast_rwlock_unlock(&tab->lock); @@ -453,11 +422,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj) return res; } -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func) -#else -int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h) -#endif { int c; struct ast_hashtab_bucket *b; @@ -471,13 +436,10 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj if (c + 1 > tab->largest_bucket_size) tab->largest_bucket_size = c + 1; - if (!(b = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(1, sizeof(*b), file, lineno, func) -#else - ast_calloc(1, sizeof(*b)) -#endif - )) return 0; + b = __ast_calloc(1, sizeof(*b), file, lineno, func); + if (!b) { + return 0; + } b->object = obj; b->next = tab->array[h]; @@ -495,11 +457,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj return 1; } -#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func) -#else -int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj) -#endif { /* check to see if the element is already there; insert only if it is not there. */ @@ -511,11 +469,7 @@ int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj) ast_rwlock_wrlock(&tab->lock); if (!ast_hashtab_lookup_bucket(tab, obj, &bucket)) { -#ifdef __AST_DEBUG_MALLOC int ret2 = _ast_hashtab_insert_immediate_bucket(tab, obj, bucket, file, lineno, func); -#else - int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket); -#endif if (tab->do_locking) ast_rwlock_unlock(&tab->lock); @@ -634,11 +588,7 @@ int ast_hashtab_capacity( struct ast_hashtab *tab) /* the insert operation calls this, and is wrlock'd when it does. */ /* if you want to call it, you should set the wrlock yourself */ -#ifdef __AST_DEBUG_MALLOC static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func) -#else -static void ast_hashtab_resize(struct ast_hashtab *tab) -#endif { /* this function is called either internally, when the resize func returns 1, or externally by the user to force a resize of the hash table */ @@ -656,14 +606,10 @@ static void ast_hashtab_resize(struct ast_hashtab *tab) tab->array[i] = 0; /* erase old ptrs */ } ast_free(tab->array); - if (!(tab->array = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func) -#else - ast_calloc(newsize, sizeof(*(tab->array))) -#endif - )) + tab->array = __ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func); + if (!tab->array) { return; + } /* now sort the buckets into their rightful new slots */ tab->resize_count++; @@ -688,23 +634,15 @@ static void ast_hashtab_resize(struct ast_hashtab *tab) } } -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func) -#else -struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab) -#endif { /* returns an iterator */ struct ast_hashtab_iter *it; - if (!(it = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(1, sizeof(*it), file, lineno, func) -#else - ast_calloc(1, sizeof(*it)) -#endif - )) + it = __ast_calloc(1, sizeof(*it), file, lineno, func); + if (!it) { return NULL; + } it->next = tab->tlist; it->tab = tab; @@ -715,23 +653,15 @@ struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab) } /* use this function to get a write lock */ -#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func) -#else -struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab) -#endif { /* returns an iterator */ struct ast_hashtab_iter *it; - if (!(it = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(1, sizeof(*it), file, lineno, func) -#else - ast_calloc(1, sizeof(*it)) -#endif - )) + it = __ast_calloc(1, sizeof(*it), file, lineno, func); + if (!it) { return NULL; + } it->next = tab->tlist; it->tab = tab; diff --git a/main/heap.c b/main/heap.c index b7d28ce2f..0b390f7b8 100644 --- a/main/heap.c +++ b/main/heap.c @@ -109,13 +109,8 @@ int ast_heap_verify(struct ast_heap *h) return 0; } -#ifdef __AST_DEBUG_MALLOC struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, - ssize_t index_offset, const char *file, int lineno, const char *func) -#else -struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, - ssize_t index_offset) -#endif + ssize_t index_offset, const char *file, int lineno, const char *func) { struct ast_heap *h; @@ -128,13 +123,8 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f init_height = 8; } - if (!(h = -#ifdef __AST_DEBUG_MALLOC - __ast_calloc(1, sizeof(*h), file, lineno, func) -#else - ast_calloc(1, sizeof(*h)) -#endif - )) { + h = __ast_calloc(1, sizeof(*h), file, lineno, func); + if (!h) { return NULL; } @@ -142,13 +132,8 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f h->index_offset = index_offset; h->avail_len = (1 << init_height) - 1; - if (!(h->heap = -#ifdef __AST_DEBUG_MALLOC - __ast_malloc(h->avail_len * sizeof(void *), file, lineno, func) -#else - ast_malloc(h->avail_len * sizeof(void *)) -#endif - )) { + h->heap = __ast_malloc(h->avail_len * sizeof(void *), file, lineno, func); + if (!h->heap) { ast_free(h); return NULL; } @@ -173,20 +158,12 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h) /*! * \brief Add a row of additional storage for the heap. */ -static int grow_heap(struct ast_heap *h -#ifdef __AST_DEBUG_MALLOC -, const char *file, int lineno, const char *func -#endif -) +static int grow_heap(struct ast_heap *h, const char *file, int lineno, const char *func) { void **new_heap; size_t new_len = h->avail_len * 2 + 1; -#ifdef __AST_DEBUG_MALLOC new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func); -#else - new_heap = ast_realloc(h->heap, new_len * sizeof(void *)); -#endif if (!new_heap) { return -1; } @@ -242,17 +219,9 @@ static int bubble_up(struct ast_heap *h, int i) return i; } -#ifdef __AST_DEBUG_MALLOC int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func) -#else -int ast_heap_push(struct ast_heap *h, void *elm) -#endif { - if (h->cur_len == h->avail_len && grow_heap(h -#ifdef __AST_DEBUG_MALLOC - , file, lineno, func -#endif - )) { + if (h->cur_len == h->avail_len && grow_heap(h, file, lineno, func)) { return -1; } diff --git a/main/http.c b/main/http.c index 30b2fe2c4..55d10290b 100644 --- a/main/http.c +++ b/main/http.c @@ -60,7 +60,7 @@ #include "asterisk/stringfields.h" #include "asterisk/ast_version.h" #include "asterisk/manager.h" -#include "asterisk/_private.h" +#include "asterisk/module.h" #include "asterisk/astobj2.h" #include "asterisk/netsock2.h" #include "asterisk/json.h" @@ -2264,7 +2264,7 @@ static char *handle_show_http(struct ast_cli_entry *e, int cmd, struct ast_cli_a return CLI_SUCCESS; } -int ast_http_reload(void) +static int reload_module(void) { return __ast_http_load(1); } @@ -2273,7 +2273,7 @@ static struct ast_cli_entry cli_http[] = { AST_CLI_DEFINE(handle_show_http, "Display HTTP server status"), }; -static void http_shutdown(void) +static int unload_module(void) { struct http_uri_redirect *redirect; ast_cli_unregister_multiple(cli_http, ARRAY_LEN(cli_http)); @@ -2295,14 +2295,23 @@ static void http_shutdown(void) ast_free(redirect); } AST_RWLIST_UNLOCK(&uri_redirects); + + return 0; } -int ast_http_init(void) +static int load_module(void) { ast_http_uri_link(&statusuri); ast_http_uri_link(&staticuri); ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http)); - ast_register_cleanup(http_shutdown); - return __ast_http_load(0); + return __ast_http_load(0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Built-in HTTP Server", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/indications.c b/main/indications.c index bde6e012d..9b0976809 100644 --- a/main/indications.c +++ b/main/indications.c @@ -1114,7 +1114,7 @@ static int ast_tone_zone_cmp(void *obj, void *arg, int flags) * \internal * \brief Clean up resources on Asterisk shutdown */ -static void indications_shutdown(void) +static int unload_module(void) { ast_cli_unregister_multiple(cli_indications, ARRAY_LEN(cli_indications)); if (default_tone_zone) { @@ -1125,29 +1125,38 @@ static void indications_shutdown(void) ao2_ref(ast_tone_zones, -1); ast_tone_zones = NULL; } + + return 0; } /*! \brief Load indications module */ -int ast_indications_init(void) +static int load_module(void) { - if (!(ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS, - ast_tone_zone_hash, ast_tone_zone_cmp))) { - return -1; + ast_tone_zones = ao2_container_alloc(NUM_TONE_ZONE_BUCKETS, + ast_tone_zone_hash, ast_tone_zone_cmp); + if (!ast_tone_zones) { + return AST_MODULE_LOAD_FAILURE; } if (load_indications(0)) { - indications_shutdown(); - return -1; + return AST_MODULE_LOAD_FAILURE; } ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications)); - ast_register_cleanup(indications_shutdown); - return 0; + return AST_MODULE_LOAD_SUCCESS; } /*! \brief Reload indications module */ -int ast_indications_reload(void) +static int reload_module(void) { return load_indications(1); } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Indication Tone Handling", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/loader.c b/main/loader.c index 08d9552ff..bc7896205 100644 --- a/main/loader.c +++ b/main/loader.c @@ -42,19 +42,12 @@ #include "asterisk/config.h" #include "asterisk/channel.h" #include "asterisk/term.h" -#include "asterisk/acl.h" #include "asterisk/manager.h" -#include "asterisk/cdr.h" -#include "asterisk/enum.h" -#include "asterisk/http.h" +#include "asterisk/io.h" #include "asterisk/lock.h" -#include "asterisk/features_config.h" -#include "asterisk/dsp.h" -#include "asterisk/udptl.h" #include "asterisk/vector.h" #include "asterisk/app.h" #include "asterisk/test.h" -#include "asterisk/sounds_index.h" #include "asterisk/cli.h" #include <dlfcn.h> @@ -513,10 +506,11 @@ void ast_module_register(const struct ast_module_info *info) struct ast_module *mod; if (!loader_ready) { - mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1); + mod = ast_std_calloc(1, sizeof(*mod) + strlen(info->name) + 1); if (!mod) { /* We haven't even reached main() yet, if we can't * allocate memory at this point just give up. */ + fprintf(stderr, "Allocation failure during startup.\n"); exit(2); } strcpy(mod->resource, info->name); /* safe */ @@ -580,7 +574,11 @@ static void module_destroy(struct ast_module *mod) AST_LIST_HEAD_DESTROY(&mod->users); ao2_cleanup(mod->ref_debug); - ast_free(mod); + if (mod->flags.builtin) { + ast_std_free(mod); + } else { + ast_free(mod); + } } void ast_module_unregister(const struct ast_module_info *info) @@ -690,33 +688,6 @@ void __ast_module_user_hangup_all(struct ast_module *mod) ast_update_use_count(); } -/*! \note - * In addition to modules, the reload command handles some extra keywords - * which are listed here together with the corresponding handlers. - * This table is also used by the command completion code. - */ -static struct reload_classes { - const char *name; - int (*reload_fn)(void); -} reload_classes[] = { /* list in alpha order, longest match first for cli completion */ - { "acl", ast_named_acl_reload }, - { "cdr", ast_cdr_engine_reload }, - { "cel", ast_cel_engine_reload }, - { "dnsmgr", dnsmgr_reload }, - { "dsp", ast_dsp_reload}, - { "extconfig", read_config_maps }, - { "enum", ast_enum_reload }, - { "features", ast_features_config_reload }, - { "http", ast_http_reload }, - { "indications", ast_indications_reload }, - { "logger", logger_reload }, - { "manager", reload_manager }, - { "plc", ast_plc_reload }, - { "sounds", ast_sounds_reindex }, - { "udptl", ast_udptl_reload }, - { NULL, NULL } -}; - static int printdigest(const unsigned char *d) { int x, pos; @@ -1160,16 +1131,6 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state, return NULL; } - if (type == AST_MODULE_HELPER_RELOAD) { - int idx; - - for (idx = 0; reload_classes[idx].name; idx++) { - if (!strncasecmp(word, reload_classes[idx].name, wordlen) && ++which > state) { - return ast_strdup(reload_classes[idx].name); - } - } - } - AST_DLLIST_LOCK(&module_list); AST_DLLIST_TRAVERSE(&module_list, mod, entry) { if (!module_matches_helper_type(mod, type)) { @@ -1345,7 +1306,6 @@ enum ast_module_reload_result ast_module_reload(const char *name) { struct ast_module *cur; enum ast_module_reload_result res = AST_MODULE_RELOAD_NOT_FOUND; - int i; size_t name_baselen = name ? resource_name_baselen(name) : 0; /* If we aren't fully booted, we just pretend we reloaded but we queue this @@ -1380,22 +1340,6 @@ enum ast_module_reload_result ast_module_reload(const char *name) } } - /* Call "predefined" reload here first */ - for (i = 0; reload_classes[i].name; i++) { - if (!name || !strcasecmp(name, reload_classes[i].name)) { - if (reload_classes[i].reload_fn() == AST_MODULE_LOAD_SUCCESS) { - res = AST_MODULE_RELOAD_SUCCESS; - } - } - } - - if (name && res == AST_MODULE_RELOAD_SUCCESS) { - if (ast_opt_lock_confdir) { - ast_unlock_path(ast_config_AST_CONFIG_DIR); - } - goto module_reload_done; - } - AST_DLLIST_LOCK(&module_list); AST_DLLIST_TRAVERSE(&module_list, cur, entry) { const struct ast_module_info *info = cur->info; @@ -1516,6 +1460,10 @@ static enum ast_module_load_result start_resource(struct ast_module *mod) } mod->flags.running = 1; + if (mod->flags.builtin) { + /* Built-in modules cannot be unloaded. */ + ast_module_shutdown_ref(mod); + } ast_update_use_count(); break; @@ -1881,6 +1829,19 @@ int load_modules(unsigned int preload_only) ast_module_register(resource_being_loaded->info); } + if (!preload_only) { + struct ast_module *mod; + + /* Add all built-in modules to the load order. */ + AST_DLLIST_TRAVERSE(&module_list, mod, entry) { + if (!mod->flags.builtin) { + continue; + } + + add_to_load_order(mod->resource, &load_order, 0); + } + } + cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); diff --git a/main/logger.c b/main/logger.c index 6060b3c4d..46d61ed33 100644 --- a/main/logger.c +++ b/main/logger.c @@ -49,6 +49,7 @@ #include <fcntl.h> #include "asterisk/_private.h" +#include "asterisk/module.h" #include "asterisk/paths.h" /* use ast_config_AST_LOG_DIR */ #include "asterisk/logger.h" #include "asterisk/lock.h" @@ -1125,16 +1126,6 @@ static int reload_logger(int rotate, const char *altconf) return res; } -/*! \brief Reload the logger module without rotating log files (also used from loader.c during - a full Asterisk reload) */ -int logger_reload(void) -{ - if (reload_logger(0, NULL)) { - return RESULT_FAILURE; - } - return RESULT_SUCCESS; -} - static char *handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { @@ -2369,3 +2360,27 @@ int ast_logger_get_queue_limit(void) { return logger_queue_limit; } + +static int reload_module(void) +{ + return reload_logger(0, NULL); +} + +static int unload_module(void) +{ + return 0; +} + +static int load_module(void) +{ + return AST_MODULE_LOAD_SUCCESS; +} + +/* Logger is initialized separate from the module loader, only reload_module does anything. */ +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Logger", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = 0, +); diff --git a/main/manager.c b/main/manager.c index b698702af..577c7f928 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2325,9 +2325,9 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ { struct manager_action *cur; struct ast_str *authority; - int num, l, which; + int num; + int l; const char *auth_str; - char *ret = NULL; #ifdef AST_XML_DOCS char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64]; char arguments_title[64], privilege_title[64], final_response_title[64], list_responses_title[64]; @@ -2342,16 +2342,16 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ return NULL; case CLI_GENERATE: l = strlen(a->word); - which = 0; AST_RWLIST_RDLOCK(&actions); AST_RWLIST_TRAVERSE(&actions, cur, list) { - if (!strncasecmp(a->word, cur->action, l) && ++which > a->n) { - ret = ast_strdup(cur->action); - break; /* make sure we exit even if ast_strdup() returns NULL */ + if (!strncasecmp(a->word, cur->action, l)) { + if (ast_cli_completion_add(ast_strdup(cur->action))) { + break; + } } } AST_RWLIST_UNLOCK(&actions); - return ret; + return NULL; } if (a->argc < 4) { return CLI_SHOWUSAGE; @@ -2481,8 +2481,7 @@ static char *handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_ar static char *handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_manager_user *user = NULL; - int l, which; - char *ret = NULL; + int l; struct ast_str *rauthority = ast_str_alloca(MAX_AUTH_PERM_STRING); struct ast_str *wauthority = ast_str_alloca(MAX_AUTH_PERM_STRING); struct ast_variable *v; @@ -2496,19 +2495,19 @@ static char *handle_showmanager(struct ast_cli_entry *e, int cmd, struct ast_cli return NULL; case CLI_GENERATE: l = strlen(a->word); - which = 0; if (a->pos != 3) { return NULL; } AST_RWLIST_RDLOCK(&users); AST_RWLIST_TRAVERSE(&users, user, list) { - if ( !strncasecmp(a->word, user->username, l) && ++which > a->n ) { - ret = ast_strdup(user->username); - break; + if (!strncasecmp(a->word, user->username, l)) { + if (ast_cli_completion_add(ast_strdup(user->username))) { + break; + } } } AST_RWLIST_UNLOCK(&users); - return ret; + return NULL; } if (a->argc != 4) { @@ -2710,6 +2709,8 @@ static char *handle_showmaneventq(struct ast_cli_entry *e, int cmd, struct ast_c return CLI_SUCCESS; } +static int reload_module(void); + /*! \brief CLI command manager reload */ static char *handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { @@ -2726,7 +2727,7 @@ static char *handle_manager_reload(struct ast_cli_entry *e, int cmd, struct ast_ if (a->argc > 2) { return CLI_SHOWUSAGE; } - reload_manager(); + reload_module(); return CLI_SUCCESS; } @@ -8643,8 +8644,6 @@ static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct struct ao2_iterator it_events; struct ast_xml_doc_item *item, *temp; int length; - int which; - char *match = NULL; if (cmd == CLI_INIT) { e->command = "manager show event"; @@ -8661,19 +8660,24 @@ static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct } if (cmd == CLI_GENERATE) { + if (a->pos != 3) { + return NULL; + } + length = strlen(a->word); - which = 0; it_events = ao2_iterator_init(events, 0); while ((item = ao2_iterator_next(&it_events))) { - if (!strncasecmp(a->word, item->name, length) && ++which > a->n) { - match = ast_strdup(item->name); - ao2_ref(item, -1); - break; + if (!strncasecmp(a->word, item->name, length)) { + if (ast_cli_completion_add(ast_strdup(item->name))) { + ao2_ref(item, -1); + break; + } } ao2_ref(item, -1); } ao2_iterator_destroy(&it_events); - return match; + + return NULL; } if (a->argc != 4) { @@ -8971,8 +8975,6 @@ static int __init_manager(int reload, int by_external_config) #endif int res; - ast_register_cleanup(manager_shutdown); - res = STASIS_MESSAGE_TYPE_INIT(ast_manager_get_generic_type); if (res != 0) { return -1; @@ -9455,12 +9457,19 @@ static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, __init_manager(1, 1); } -int init_manager(void) +static int unload_module(void) { - return __init_manager(0, 0); + return 0; +} + +static int load_module(void) +{ + ast_register_cleanup(manager_shutdown); + + return __init_manager(0, 0) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } -int reload_manager(void) +static int reload_module(void) { return __init_manager(1, 0); } @@ -9557,3 +9566,12 @@ ast_manager_event_blob_create( return ev; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Asterisk Manager Interface", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, + .requires = "http", +); diff --git a/main/media_cache.c b/main/media_cache.c index 90057dc6f..e93d1a02f 100644 --- a/main/media_cache.c +++ b/main/media_cache.c @@ -645,7 +645,7 @@ static struct ast_cli_entry cli_media_cache[] = { */ static void media_cache_shutdown(void) { - ao2_ref(media_cache, -1); + ao2_cleanup(media_cache); media_cache = NULL; ast_cli_unregister_multiple(cli_media_cache, ARRAY_LEN(cli_media_cache)); @@ -653,7 +653,7 @@ static void media_cache_shutdown(void) int ast_media_cache_init(void) { - ast_register_atexit(media_cache_shutdown); + ast_register_cleanup(media_cache_shutdown); media_cache = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, AO2_BUCKETS, ast_sorcery_object_id_hash, ast_sorcery_object_id_compare); @@ -662,7 +662,6 @@ int ast_media_cache_init(void) } if (ast_cli_register_multiple(cli_media_cache, ARRAY_LEN(cli_media_cache))) { - ao2_ref(media_cache, -1); return -1; } diff --git a/main/named_acl.c b/main/named_acl.c index 3a4c45401..c4628216f 100644 --- a/main/named_acl.c +++ b/main/named_acl.c @@ -27,6 +27,11 @@ * Olle E. Johansson <oej@edvina.net> */ +/* This maintains the original "module reload acl" CLI command instead + * of replacing it with "module reload named_acl". */ +#undef AST_MODULE +#define AST_MODULE "acl" + #include "asterisk.h" #include "asterisk/config.h" @@ -397,36 +402,6 @@ publish_failure: /*! * \internal - * \brief reload configuration for named ACLs - * - * \param fd file descriptor for CLI client - */ -int ast_named_acl_reload(void) -{ - enum aco_process_status status; - - status = aco_process_config(&cfg_info, 1); - - if (status == ACO_PROCESS_ERROR) { - ast_log(LOG_WARNING, "Could not reload ACL config\n"); - return 0; - } - - if (status == ACO_PROCESS_UNCHANGED) { - /* We don't actually log anything if the config was unchanged, - * but we don't need to send a config change event either. - */ - return 0; - } - - /* We need to push an ACL change event with no ACL name so that all subscribers update with all ACLs */ - publish_acl_change(""); - - return 0; -} - -/*! - * \internal * \brief secondary handler for the 'acl show <name>' command (with arg) * * \param fd file descriptor of the cli @@ -500,12 +475,10 @@ static void cli_display_named_acl_list(int fd) /* \brief ACL command show <name> */ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup); + struct named_acl_config *cfg; int length; - int which; struct ao2_iterator i; struct named_acl *named_acl; - char *match = NULL; switch (cmd) { case CLI_INIT: @@ -515,23 +488,29 @@ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct " Shows a list of named ACLs or lists all entries in a given named ACL.\n"; return NULL; case CLI_GENERATE: + if (a->pos != 2) { + return NULL; + } + + cfg = ao2_global_obj_ref(globals); if (!cfg) { return NULL; } length = strlen(a->word); - which = 0; i = ao2_iterator_init(cfg->named_acl_list, 0); while ((named_acl = ao2_iterator_next(&i))) { - if (!strncasecmp(a->word, named_acl->name, length) && ++which > a->n) { - match = ast_strdup(named_acl->name); - ao2_ref(named_acl, -1); - break; + if (!strncasecmp(a->word, named_acl->name, length)) { + if (ast_cli_completion_add(ast_strdup(named_acl->name))) { + ao2_ref(named_acl, -1); + break; + } } ao2_ref(named_acl, -1); } ao2_iterator_destroy(&i); - return match; + ao2_ref(cfg, -1); + return NULL; } if (a->argc == 2) { @@ -552,32 +531,64 @@ static struct ast_cli_entry cli_named_acl[] = { AST_CLI_DEFINE(handle_show_named_acl_cmd, "Show a named ACL or list all named ACLs"), }; -static void named_acl_cleanup(void) +static int reload_module(void) +{ + enum aco_process_status status; + + status = aco_process_config(&cfg_info, 1); + + if (status == ACO_PROCESS_ERROR) { + ast_log(LOG_WARNING, "Could not reload ACL config\n"); + return 0; + } + + if (status == ACO_PROCESS_UNCHANGED) { + /* We don't actually log anything if the config was unchanged, + * but we don't need to send a config change event either. + */ + return 0; + } + + /* We need to push an ACL change event with no ACL name so that all subscribers update with all ACLs */ + publish_acl_change(""); + + return 0; +} + +static int unload_module(void) { ast_cli_unregister_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl)); STASIS_MESSAGE_TYPE_CLEANUP(ast_named_acl_change_type); aco_info_destroy(&cfg_info); ao2_global_obj_release(globals); + + return 0; } -int ast_named_acl_init() +static int load_module(void) { - ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl)); - - STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type); - - ast_register_cleanup(named_acl_cleanup); - if (aco_info_init(&cfg_info)) { - return 0; + return AST_MODULE_LOAD_FAILURE; } + STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type); + /* Register the per level options. */ aco_option_register(&cfg_info, "permit", ACO_EXACT, named_acl_types, NULL, OPT_ACL_T, 1, FLDSET(struct named_acl, ha)); aco_option_register(&cfg_info, "deny", ACO_EXACT, named_acl_types, NULL, OPT_ACL_T, 0, FLDSET(struct named_acl, ha)); aco_process_config(&cfg_info, 0); - return 0; + ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl)); + + return AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Named ACL system", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/netsock2.c b/main/netsock2.c index ef74ab92b..fedbd94a0 100644 --- a/main/netsock2.c +++ b/main/netsock2.c @@ -443,7 +443,7 @@ uint16_t _ast_sockaddr_port(const struct ast_sockaddr *addr, const char *file, i && addr->ss.ss_family == AF_INET6) { return ntohs(((struct sockaddr_in6 *)&addr->ss)->sin6_port); } - if (option_debug >= 1) { + if (DEBUG_ATLEAST(1)) { ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot get port.\n"); } return 0; @@ -461,7 +461,7 @@ void _ast_sockaddr_set_port(struct ast_sockaddr *addr, uint16_t port, const char } else if (addr->len == sizeof(struct sockaddr_in6) && addr->ss.ss_family == AF_INET6) { ((struct sockaddr_in6 *)&addr->ss)->sin6_port = htons(port); - } else if (option_debug >= 1) { + } else if (DEBUG_ATLEAST(1)) { ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot set port.\n"); } @@ -657,7 +657,7 @@ int _ast_sockaddr_to_sin(const struct ast_sockaddr *addr, return 0; } - if (addr->ss.ss_family != AF_INET && option_debug >= 1) { + if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) { ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n"); } @@ -670,7 +670,7 @@ void _ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in { memcpy(&addr->ss, sin, sizeof(*sin)); - if (addr->ss.ss_family != AF_INET && option_debug >= 1) { + if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) { ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n"); } diff --git a/main/pbx.c b/main/pbx.c index 942c15c05..70e72fe43 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -7508,13 +7508,13 @@ static int ast_add_extension2_lockopt(struct ast_context *con, ast_add_hint(tmp); } } - if (option_debug) { + if (DEBUG_ATLEAST(1)) { if (tmp->matchcid == AST_EXT_MATCHCID_ON) { - ast_debug(1, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n", - tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con); + ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n", + tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con); } else { - ast_debug(1, "Added extension '%s' priority %d to %s (%p)\n", - tmp->name, tmp->priority, con->name, con); + ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s (%p)\n", + tmp->name, tmp->priority, con->name, con); } } diff --git a/main/pbx_app.c b/main/pbx_app.c index ec6bc7589..df8126c7f 100644 --- a/main/pbx_app.c +++ b/main/pbx_app.c @@ -275,7 +275,7 @@ static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct as * application at one time. You can type 'show application Dial Echo' and * you will see informations about these two applications ... */ - return ast_complete_applications(a->line, a->word, a->n); + return ast_complete_applications(a->line, a->word, -1); } if (a->argc < 4) { @@ -437,20 +437,23 @@ char *ast_complete_applications(const char *line, const char *word, int state) AST_RWLIST_RDLOCK(&apps); AST_RWLIST_TRAVERSE(&apps, app, list) { cmp = strncasecmp(word, app->name, wordlen); - if (cmp > 0) { - continue; - } - if (!cmp) { + if (cmp < 0) { + /* No more matches. */ + break; + } else if (!cmp) { /* Found match. */ - if (++which <= state) { - /* Not enough matches. */ - continue; + if (state != -1) { + if (++which <= state) { + /* Not enough matches. */ + continue; + } + ret = ast_strdup(app->name); + break; + } + if (ast_cli_completion_add(ast_strdup(app->name))) { + break; } - ret = ast_strdup(app->name); - break; } - /* Not in container. */ - break; } AST_RWLIST_UNLOCK(&apps); diff --git a/main/pbx_builtins.c b/main/pbx_builtins.c index 9d43c10ff..7f76b9776 100644 --- a/main/pbx_builtins.c +++ b/main/pbx_builtins.c @@ -1509,7 +1509,6 @@ int load_pbx_builtins(void) for (x = 0; x < ARRAY_LEN(builtins); x++) { if (ast_register_application2(builtins[x].name, builtins[x].execute, NULL, NULL, NULL)) { ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name); - unload_pbx_builtins(); return -1; } } diff --git a/main/plc.c b/main/plc.c index 2a8279f46..847ce65b0 100644 --- a/main/plc.c +++ b/main/plc.c @@ -38,6 +38,8 @@ #include <math.h> +#include "asterisk/config.h" +#include "asterisk/module.h" #include "asterisk/plc.h" #if !defined(FALSE) @@ -246,3 +248,43 @@ plc_state_t *plc_init(plc_state_t *s) } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ + +static int reload_module(void) +{ + struct ast_variable *var; + struct ast_flags config_flags = { 0 }; + struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); + + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { + return 0; + } + + for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { + if (!strcasecmp(var->name, "genericplc")) { + ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC); + } + } + ast_config_destroy(cfg); + + return 0; +} + +static int load_module(void) +{ + reload_module(); + + return AST_MODULE_LOAD_SUCCESS; +} + +static int unload_module(void) +{ + return 0; +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "PLC", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/sched.c b/main/sched.c index a4ca260c6..d8afc74e6 100644 --- a/main/sched.c +++ b/main/sched.c @@ -31,10 +31,7 @@ #include "asterisk.h" #ifdef DEBUG_SCHEDULER -#define DEBUG(a) do { \ - if (option_debug) \ - DEBUG_M(a) \ - } while (0) +#define DEBUG(a) a #else #define DEBUG(a) #endif @@ -548,8 +545,7 @@ int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb } #ifdef DUMP_SCHEDULER /* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */ - if (option_debug) - ast_sched_dump(con); + ast_sched_dump(con); #endif if (con->sched_thread) { ast_cond_signal(&con->sched_thread->cond); @@ -649,8 +645,7 @@ int _ast_sched_del(struct ast_sched_context *con, int id, const char *file, int #ifdef DUMP_SCHEDULER /* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */ - if (option_debug) - ast_sched_dump(con); + ast_sched_dump(con); #endif if (con->sched_thread) { ast_cond_signal(&con->sched_thread->cond); @@ -711,25 +706,33 @@ void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struc void ast_sched_dump(struct ast_sched_context *con) { struct sched *q; - struct timeval when = ast_tvnow(); + struct timeval when; int x; size_t heap_size; + + if (!DEBUG_ATLEAST(1)) { + return; + } + + when = ast_tvnow(); #ifdef SCHED_MAX_CACHE - ast_debug(1, "Asterisk Schedule Dump (%zu in Q, %u Total, %u Cache, %u high-water)\n", ast_heap_size(con->sched_heap), con->eventcnt - 1, con->schedccnt, con->highwater); + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%zu in Q, %u Total, %u Cache, %u high-water)\n", + ast_heap_size(con->sched_heap), con->eventcnt - 1, con->schedccnt, con->highwater); #else - ast_debug(1, "Asterisk Schedule Dump (%zu in Q, %u Total, %u high-water)\n", ast_heap_size(con->sched_heap), con->eventcnt - 1, con->highwater); + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%zu in Q, %u Total, %u high-water)\n", + ast_heap_size(con->sched_heap), con->eventcnt - 1, con->highwater); #endif - ast_debug(1, "=============================================================\n"); - ast_debug(1, "|ID Callback Data Time (sec:ms) |\n"); - ast_debug(1, "+-----+-----------------+-----------------+-----------------+\n"); + ast_log(LOG_DEBUG, "=============================================================\n"); + ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n"); + ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n"); ast_mutex_lock(&con->lock); heap_size = ast_heap_size(con->sched_heap); for (x = 1; x <= heap_size; x++) { struct timeval delta; q = ast_heap_peek(con->sched_heap, x); delta = ast_tvsub(q->when, when); - ast_debug(1, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", + ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", q->sched_id->id, q->callback, q->data, @@ -737,7 +740,7 @@ void ast_sched_dump(struct ast_sched_context *con) (long int)delta.tv_usec); } ast_mutex_unlock(&con->lock); - ast_debug(1, "=============================================================\n"); + ast_log(LOG_DEBUG, "=============================================================\n"); } /*! \brief diff --git a/main/sorcery.c b/main/sorcery.c index c79675cd8..902870793 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -388,20 +388,17 @@ int ast_sorcery_init(void) wizards = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, WIZARD_BUCKETS, ast_sorcery_internal_wizard_hash_fn, NULL, ast_sorcery_internal_wizard_cmp_fn); if (!wizards) { - sorcery_cleanup(); return -1; } observers = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, NULL, NULL); if (!observers) { - sorcery_cleanup(); return -1; } instances = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK, 0, INSTANCE_BUCKETS, sorcery_proxy_hash_fn, NULL, sorcery_proxy_cmp_fn); if (!instances) { - sorcery_cleanup(); return -1; } diff --git a/main/sounds.c b/main/sounds.c index c792c1bbd..745b62805 100644 --- a/main/sounds.c +++ b/main/sounds.c @@ -34,7 +34,7 @@ #include "asterisk/sounds_index.h" #include "asterisk/file.h" #include "asterisk/cli.h" -#include "asterisk/_private.h" +#include "asterisk/module.h" #include "asterisk/stasis_message_router.h" #include "asterisk/stasis_system.h" @@ -111,7 +111,7 @@ static int update_index_cb(void *obj, void *arg, int flags) AST_MUTEX_DEFINE_STATIC(reload_lock); -int ast_sounds_reindex(void) +static int reload_module(void) { RAII_VAR(struct ast_str *, sounds_dir, NULL, ast_free); RAII_VAR(struct ao2_container *, languages, NULL, ao2_cleanup); @@ -219,6 +219,11 @@ static char *handle_cli_sounds_show(struct ast_cli_entry *e, int cmd, struct ast /*! \brief Show details about a sound available in the system */ static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { + int length; + struct ao2_iterator it_sounds; + char *filename; + struct ao2_container *sound_files; + switch (cmd) { case CLI_INIT: e->command = "core show sound"; @@ -227,29 +232,30 @@ static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_ " Shows information about the specified sound.\n"; return NULL; case CLI_GENERATE: - { - int length = strlen(a->word); - int which = 0; - struct ao2_iterator it_sounds; - char *match = NULL; - char *filename; - RAII_VAR(struct ao2_container *, sound_files, ast_media_get_media(sounds_index), ao2_cleanup); + if (a->pos != 3) { + return NULL; + } + + sound_files = ast_media_get_media(sounds_index); if (!sound_files) { return NULL; } + length = strlen(a->word); it_sounds = ao2_iterator_init(sound_files, 0); while ((filename = ao2_iterator_next(&it_sounds))) { - if (!strncasecmp(a->word, filename, length) && ++which > a->n) { - match = ast_strdup(filename); - ao2_ref(filename, -1); - break; + if (!strncasecmp(a->word, filename, length)) { + if (ast_cli_completion_add(ast_strdup(filename))) { + ao2_ref(filename, -1); + break; + } } ao2_ref(filename, -1); } ao2_iterator_destroy(&it_sounds); - return match; - } + ao2_ref(sound_files, -1); + + return NULL; } if (a->argc == 4) { @@ -273,13 +279,15 @@ static struct ast_cli_entry cli_sounds[] = { AST_CLI_DEFINE(handle_cli_sound_show, "Shows details about a specific sound"), }; -static void sounds_cleanup(void) +static int unload_module(void) { stasis_message_router_unsubscribe_and_join(sounds_system_router); sounds_system_router = NULL; ast_cli_unregister_multiple(cli_sounds, ARRAY_LEN(cli_sounds)); ao2_cleanup(sounds_index); sounds_index = NULL; + + return 0; } static void format_update_cb(void *data, struct stasis_subscription *sub, @@ -287,21 +295,21 @@ static void format_update_cb(void *data, struct stasis_subscription *sub, { /* Reindexing during shutdown is pointless. */ if (!ast_shutting_down()) { - ast_sounds_reindex(); + reload_module(); } } -int ast_sounds_index_init(void) +static int load_module(void) { int res = 0; - if (ast_sounds_reindex()) { - return -1; + if (reload_module()) { + return AST_MODULE_LOAD_FAILURE; } res |= ast_cli_register_multiple(cli_sounds, ARRAY_LEN(cli_sounds)); sounds_system_router = stasis_message_router_create(ast_system_topic()); if (!sounds_system_router) { - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_format_register_type()) { @@ -320,15 +328,19 @@ int ast_sounds_index_init(void) NULL); } - if (res) { - return -1; - } - - ast_register_cleanup(sounds_cleanup); - return 0; + return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS; } struct ast_media_index *ast_sounds_get_index(void) { return ao2_bump(sounds_index); } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Sounds Index", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + /* Load after the format modules to reduce processing during startup. */ + .load_pri = AST_MODPRI_APP_DEPEND + 1, +); diff --git a/main/strcompat.c b/main/strcompat.c index c3b4ff180..0034c2177 100644 --- a/main/strcompat.c +++ b/main/strcompat.c @@ -25,6 +25,7 @@ <support_level>core</support_level> ***/ +#define ASTMM_LIBC ASTMM_IGNORE #include "asterisk.h" #include <ctype.h> @@ -139,7 +140,7 @@ size_t strnlen(const char *s, size_t n) } #endif /* !HAVE_STRNLEN */ -#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_STRNDUP) char *strndup(const char *s, size_t n) { size_t len = strnlen(s, n); @@ -151,9 +152,9 @@ char *strndup(const char *s, size_t n) new[len] = '\0'; return memcpy(new, s, len); } -#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_STRNDUP) */ -#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_VASPRINTF) int vasprintf(char **strp, const char *fmt, va_list ap) { int size; @@ -171,7 +172,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) return size; } -#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_VASPRINTF) */ #ifndef HAVE_TIMERSUB void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff) @@ -205,7 +206,7 @@ void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tv * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_ASPRINTF) int asprintf(char **str, const char *fmt, ...) { va_list ap; @@ -218,7 +219,7 @@ int asprintf(char **str, const char *fmt, ...) return ret; } -#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_ASPRINTF) */ #ifndef HAVE_STRTOQ #ifndef LONG_MIN diff --git a/main/stringfields.c b/main/stringfields.c index 7e52bbc9e..0a9e59903 100644 --- a/main/stringfields.c +++ b/main/stringfields.c @@ -55,12 +55,6 @@ static size_t optimal_alloc_size(size_t size) return (1 << count) - ALLOCATOR_OVERHEAD; } -static void *calloc_wrapper(unsigned int num_structs, size_t struct_size, - const char *file, int lineno, const char *func) -{ - return __ast_calloc(num_structs, struct_size, file, lineno, func); -} - /*! \brief add a new block to the pool. * We can only allocate from the topmost pool, so the * fields in *mgr reflect the size of that only. @@ -71,7 +65,8 @@ static int add_string_pool(struct ast_string_field_mgr *mgr, struct ast_string_f struct ast_string_field_pool *pool; size_t alloc_size = optimal_alloc_size(sizeof(*pool) + size); - if (!(pool = calloc_wrapper(1, alloc_size, file, lineno, func))) { + pool = __ast_calloc(1, alloc_size, file, lineno, func); + if (!pool) { return -1; } @@ -184,11 +179,6 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_ } mgr->last_alloc = NULL; -#if defined(__AST_DEBUG_MALLOC) - mgr->owner_file = file; - mgr->owner_func = func; - mgr->owner_line = lineno; -#endif if (AST_VECTOR_INIT(&mgr->string_fields, initial_vector_size)) { return -1; @@ -210,7 +200,8 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_ } ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, size_t needed) + struct ast_string_field_pool **pool_head, size_t needed, + const char *file, int lineno, const char *func) { char *result = NULL; size_t space = (*pool_head)->size - (*pool_head)->used; @@ -227,13 +218,9 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr new_size *= 2; } -#if defined(__AST_DEBUG_MALLOC) - if (add_string_pool(mgr, pool_head, new_size, mgr->owner_file, mgr->owner_line, mgr->owner_func)) + if (add_string_pool(mgr, pool_head, new_size, file, lineno, func)) { return NULL; -#else - if (add_string_pool(mgr, pool_head, new_size, __FILE__, __LINE__, __FUNCTION__)) - return NULL; -#endif + } } /* pool->base is always aligned (gcc aligned attribute). We ensure that @@ -298,7 +285,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, - const char *format, va_list ap) + const char *format, va_list ap, + const char *file, int lineno, const char *func) { size_t needed; size_t available; @@ -350,7 +338,8 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, (if it has one), or the space available in the pool (if it does not). allocate space for it, adding a new string pool if necessary. */ - if (!(target = (char *) __ast_string_field_alloc_space(mgr, pool_head, needed))) { + target = (char *) __ast_string_field_alloc_space(mgr, pool_head, needed, file, lineno, func); + if (!target) { return; } vsprintf(target, format, ap); @@ -377,19 +366,20 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, } } -void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, +void __ast_string_field_ptr_build(const char *file, int lineno, const char *func, + struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, const char *format, ...) { va_list ap; va_start(ap, format); - __ast_string_field_ptr_build_va(mgr, pool_head, ptr, format, ap); + __ast_string_field_ptr_build_va(mgr, pool_head, ptr, format, ap, file, lineno, func); va_end(ap); } void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_size, - size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file, - int lineno, const char *func) + size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, + const char *file, int lineno, const char *func) { struct ast_string_field_mgr *mgr; struct ast_string_field_pool *pool; @@ -402,7 +392,8 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz ast_assert(num_structs == 1); - if (!(allocation = calloc_wrapper(num_structs, size_to_alloc, file, lineno, func))) { + allocation = __ast_calloc(num_structs, size_to_alloc, file, lineno, func); + if (!allocation) { return NULL; } @@ -426,11 +417,6 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz mgr->embedded_pool = pool; *pool_head = pool; pool->size = size_to_alloc - struct_size - sizeof(*pool); -#if defined(__AST_DEBUG_MALLOC) - mgr->owner_file = file; - mgr->owner_func = func; - mgr->owner_line = lineno; -#endif return allocation; } @@ -453,7 +439,8 @@ int __ast_string_fields_cmp(struct ast_string_field_vector *left, } int __ast_string_fields_copy(struct ast_string_field_pool *copy_pool, - struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr) + struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr, + const char *file, int lineno, const char *func) { int i; struct ast_string_field_vector *dest = &(copy_mgr->string_fields); @@ -467,8 +454,8 @@ int __ast_string_fields_copy(struct ast_string_field_pool *copy_pool, } for (i = 0; i < AST_VECTOR_SIZE(dest); i++) { - if (ast_string_field_ptr_set_by_fields(copy_pool, *copy_mgr, AST_VECTOR_GET(dest, i), - *AST_VECTOR_GET(src, i))) { + if (__ast_string_field_ptr_set_by_fields(copy_pool, *copy_mgr, AST_VECTOR_GET(dest, i), + *AST_VECTOR_GET(src, i), file, lineno, func)) { return -1; } } diff --git a/main/strings.c b/main/strings.c index ad96df249..640af6123 100644 --- a/main/strings.c +++ b/main/strings.c @@ -52,13 +52,9 @@ * ast_str_append_va(...) */ -#ifdef __AST_DEBUG_MALLOC -int __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len, - int append, const char *fmt, va_list ap, const char *file, int lineno, const char *function) -#else int __ast_str_helper(struct ast_str **buf, ssize_t max_len, - int append, const char *fmt, va_list ap) -#endif + int append, const char *fmt, va_list ap, + const char *file, int lineno, const char *function) { int res; int added; @@ -110,13 +106,7 @@ int __ast_str_helper(struct ast_str **buf, ssize_t max_len, need = max_len; } - if ( -#ifdef __AST_DEBUG_MALLOC - _ast_str_make_space(buf, need, file, lineno, function) -#else - ast_str_make_space(buf, need) -#endif - ) { + if (_ast_str_make_space(buf, need, file, lineno, function)) { ast_log_safe(LOG_VERBOSE, "failed to extend from %d to %d\n", (int) (*buf)->__AST_STR_LEN, need); diff --git a/main/taskprocessor.c b/main/taskprocessor.c index cf82efff2..91eb7d993 100644 --- a/main/taskprocessor.c +++ b/main/taskprocessor.c @@ -341,26 +341,27 @@ static void *tps_task_free(struct tps_task *task) static char *tps_taskprocessor_tab_complete(struct ast_cli_args *a) { int tklen; - int wordnum = 0; struct ast_taskprocessor *p; - char *name = NULL; struct ao2_iterator i; - if (a->pos != 3) + if (a->pos != 3) { return NULL; + } tklen = strlen(a->word); i = ao2_iterator_init(tps_singletons, 0); while ((p = ao2_iterator_next(&i))) { - if (!strncasecmp(a->word, p->name, tklen) && ++wordnum > a->n) { - name = ast_strdup(p->name); - ast_taskprocessor_unreference(p); - break; + if (!strncasecmp(a->word, p->name, tklen)) { + if (ast_cli_completion_add(ast_strdup(p->name))) { + ast_taskprocessor_unreference(p); + break; + } } ast_taskprocessor_unreference(p); } ao2_iterator_destroy(&i); - return name; + + return NULL; } /* ping task handling function */ diff --git a/main/test.c b/main/test.c index f45ad9b62..b117c0814 100644 --- a/main/test.c +++ b/main/test.c @@ -691,40 +691,40 @@ static struct ast_test *test_alloc(ast_test_cb_t *cb) return test; } -static char *complete_test_category(const char *line, const char *word, int pos, int state) +static char *complete_test_category(const char *word) { - int which = 0; int wordlen = strlen(word); - char *ret = NULL; struct ast_test *test; AST_LIST_LOCK(&tests); AST_LIST_TRAVERSE(&tests, test, entry) { - if (!strncasecmp(word, test->info.category, wordlen) && ++which > state) { - ret = ast_strdup(test->info.category); - break; + if (!strncasecmp(word, test->info.category, wordlen)) { + if (ast_cli_completion_add(ast_strdup(test->info.category))) { + break; + } } } AST_LIST_UNLOCK(&tests); - return ret; + + return NULL; } -static char *complete_test_name(const char *line, const char *word, int pos, int state, const char *category) +static char *complete_test_name(const char *word, const char *category) { - int which = 0; int wordlen = strlen(word); - char *ret = NULL; struct ast_test *test; AST_LIST_LOCK(&tests); AST_LIST_TRAVERSE(&tests, test, entry) { - if (!test_cat_cmp(test->info.category, category) && (!strncasecmp(word, test->info.name, wordlen) && ++which > state)) { - ret = ast_strdup(test->info.name); - break; + if (!test_cat_cmp(test->info.category, category) && !strncasecmp(word, test->info.name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(test->info.name))) { + break; + } } } AST_LIST_UNLOCK(&tests); - return ret; + + return NULL; } /* CLI commands */ @@ -749,22 +749,22 @@ static char *test_cli_show_registered(struct ast_cli_entry *e, int cmd, struct a return NULL; case CLI_GENERATE: if (a->pos == 3) { - return ast_cli_complete(a->word, option1, a->n); + return ast_cli_complete(a->word, option1, -1); } - if (a->pos == 4) { - return complete_test_category(a->line, a->word, a->pos, a->n); + if (a->pos == 4 && !strcasecmp(a->argv[3], "category")) { + return complete_test_category(a->word); } if (a->pos == 5) { - return ast_cli_complete(a->word, option2, a->n); + return ast_cli_complete(a->word, option2, -1); } if (a->pos == 6) { - return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]); + return complete_test_name(a->word, a->argv[4]); } return NULL; case CLI_HANDLER: if ((a->argc < 4) || (a->argc == 6) || (a->argc > 7) || - ((a->argc == 4) && strcmp(a->argv[3], "all")) || - ((a->argc == 7) && strcmp(a->argv[5], "name"))) { + ((a->argc == 4) && strcasecmp(a->argv[3], "all")) || + ((a->argc == 7) && strcasecmp(a->argv[5], "name"))) { return CLI_SHOWUSAGE; } ast_cli(a->fd, FORMAT, "Category", "Name", "Summary", "Test Result"); @@ -808,16 +808,16 @@ static char *test_cli_execute_registered(struct ast_cli_entry *e, int cmd, struc return NULL; case CLI_GENERATE: if (a->pos == 2) { - return ast_cli_complete(a->word, option1, a->n); + return ast_cli_complete(a->word, option1, -1); } - if (a->pos == 3) { - return complete_test_category(a->line, a->word, a->pos, a->n); + if (a->pos == 3 && !strcasecmp(a->argv[2], "category")) { + return complete_test_category(a->word); } if (a->pos == 4) { - return ast_cli_complete(a->word, option2, a->n); + return ast_cli_complete(a->word, option2, -1); } if (a->pos == 5) { - return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]); + return complete_test_name(a->word, a->argv[3]); } return NULL; case CLI_HANDLER: @@ -826,7 +826,7 @@ static char *test_cli_execute_registered(struct ast_cli_entry *e, int cmd, struc return CLI_SHOWUSAGE; } - if ((a->argc == 3) && !strcmp(a->argv[2], "all")) { /* run all registered tests */ + if ((a->argc == 3) && !strcasecmp(a->argv[2], "all")) { /* run all registered tests */ ast_cli(a->fd, "Running all available tests...\n\n"); test_execute_multiple(NULL, NULL, a); } else if (a->argc == 4) { /* run only tests within a category */ @@ -877,7 +877,7 @@ static char *test_cli_show_results(struct ast_cli_entry *e, int cmd, struct ast_ return NULL; case CLI_GENERATE: if (a->pos == 3) { - return ast_cli_complete(a->word, option1, a->n); + return ast_cli_complete(a->word, option1, -1); } return NULL; case CLI_HANDLER: @@ -885,11 +885,11 @@ static char *test_cli_show_results(struct ast_cli_entry *e, int cmd, struct ast_ /* verify input */ if (a->argc != 4) { return CLI_SHOWUSAGE; - } else if (!strcmp(a->argv[3], "passed")) { + } else if (!strcasecmp(a->argv[3], "passed")) { mode = 2; - } else if (!strcmp(a->argv[3], "failed")) { + } else if (!strcasecmp(a->argv[3], "failed")) { mode = 1; - } else if (!strcmp(a->argv[3], "all")) { + } else if (!strcasecmp(a->argv[3], "all")) { mode = 0; } else { return CLI_SHOWUSAGE; @@ -950,7 +950,7 @@ static char *test_cli_generate_results(struct ast_cli_entry *e, int cmd, struct return NULL; case CLI_GENERATE: if (a->pos == 3) { - return ast_cli_complete(a->word, option, a->n); + return ast_cli_complete(a->word, option, -1); } return NULL; case CLI_HANDLER: @@ -958,10 +958,10 @@ static char *test_cli_generate_results(struct ast_cli_entry *e, int cmd, struct /* verify input */ if (a->argc < 4 || a->argc > 5) { return CLI_SHOWUSAGE; - } else if (!strcmp(a->argv[3], "xml")) { + } else if (!strcasecmp(a->argv[3], "xml")) { type = "xml"; isxml = 1; - } else if (!strcmp(a->argv[3], "txt")) { + } else if (!strcasecmp(a->argv[3], "txt")) { type = "txt"; } else { return CLI_SHOWUSAGE; diff --git a/main/translate.c b/main/translate.c index 226d0985d..396c5522e 100644 --- a/main/translate.c +++ b/main/translate.c @@ -900,9 +900,9 @@ const char *ast_translate_path_to_str(struct ast_trans_pvt *p, struct ast_str ** return ast_str_buffer(*str); } -static char *complete_trans_path_choice(const char *line, const char *word, int pos, int state) +static char *complete_trans_path_choice(const char *word) { - int i = 1, which = 0; + int i = 1; int wordlen = strlen(word); struct ast_codec *codec; @@ -912,13 +912,15 @@ static char *complete_trans_path_choice(const char *line, const char *word, int ao2_ref(codec, -1); continue; } - if (!strncasecmp(word, codec->name, wordlen) && ++which > state) { - char *res = ast_strdup(codec->name); - ao2_ref(codec, -1); - return res; + if (!strncasecmp(word, codec->name, wordlen)) { + if (ast_cli_completion_add(ast_strdup(codec->name))) { + ao2_ref(codec, -1); + break; + } } ao2_ref(codec, -1); } + return NULL; } @@ -1138,10 +1140,10 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, return NULL; case CLI_GENERATE: if (a->pos == 3) { - return ast_cli_complete(a->word, option, a->n); + return ast_cli_complete(a->word, option, -1); } if (a->pos == 4 && !strcasecmp(a->argv[3], option[1])) { - return complete_trans_path_choice(a->line, a->word, a->pos, a->n); + return complete_trans_path_choice(a->word); } /* BUGBUG - add tab completion for sample rates */ return NULL; diff --git a/main/udptl.c b/main/udptl.c index 5a491e65c..f6cd3b90a 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -67,6 +67,7 @@ #include <signal.h> #include <fcntl.h> +#include "asterisk/module.h" #include "asterisk/udptl.h" #include "asterisk/frame.h" #include "asterisk/channel.h" @@ -1355,9 +1356,10 @@ static int udptl_pre_apply_config(void) { return 0; } -int ast_udptl_reload(void) +static int reload_module(void) { __ast_udptl_reload(1); + return 0; } @@ -1365,17 +1367,19 @@ int ast_udptl_reload(void) * \internal * \brief Clean up resources on Asterisk shutdown */ -static void udptl_shutdown(void) +static int unload_module(void) { ast_cli_unregister_multiple(cli_udptl, ARRAY_LEN(cli_udptl)); ao2_t_global_obj_release(globals, "Unref udptl global container in shutdown"); aco_info_destroy(&cfg_info); + + return 0; } -void ast_udptl_init(void) +static int load_module(void) { if (aco_info_init(&cfg_info)) { - return; + return AST_MODULE_LOAD_FAILURE; } aco_option_register(&cfg_info, "udptlstart", ACO_EXACT, general_options, __stringify(DEFAULT_UDPTLSTART), @@ -1407,5 +1411,13 @@ void ast_udptl_init(void) ast_cli_register_multiple(cli_udptl, ARRAY_LEN(cli_udptl)); - ast_register_cleanup(udptl_shutdown); + return AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "UDPTL", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .reload = reload_module, + .load_pri = AST_MODPRI_CORE, +); diff --git a/main/utils.c b/main/utils.c index 7f74f40be..c2e07fccf 100644 --- a/main/utils.c +++ b/main/utils.c @@ -189,7 +189,9 @@ static int gethostbyname_r (const char *name, struct hostent *ret, char *buf, */ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp) { +#ifndef HAVE_GETHOSTBYNAME_R_5 int res; +#endif int herrno; int dots = 0; const char *s; @@ -199,7 +201,6 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp) integers, we break with tradition and refuse to look up a pure integer */ s = host; - res = 0; while (s && *s) { if (*s == '.') dots++; @@ -2321,28 +2322,6 @@ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, return 0; } -#ifndef __AST_DEBUG_MALLOC -int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...) -{ - int res; - va_list ap; - - va_start(ap, fmt); - res = vasprintf(ret, fmt, ap); - if (res < 0) { - /* - * *ret is undefined so set to NULL to ensure it is - * initialized to something useful. - */ - *ret = NULL; - MALLOC_FAILURE_MSG; - } - va_end(ap); - - return res; -} -#endif - int ast_get_tid(void) { int ret = -1; diff --git a/menuselect/strcompat.c b/menuselect/strcompat.c index c25609f4b..b78061ca3 100644 --- a/menuselect/strcompat.c +++ b/menuselect/strcompat.c @@ -138,7 +138,7 @@ size_t strnlen(const char *s, size_t n) } #endif /* !HAVE_STRNLEN */ -#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_STRNDUP) char *strndup(const char *s, size_t n) { size_t len = strnlen(s, n); @@ -150,9 +150,9 @@ char *strndup(const char *s, size_t n) new[len] = '\0'; return memcpy(new, s, len); } -#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_STRNDUP) */ -#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_VASPRINTF) int vasprintf(char **strp, const char *fmt, va_list ap) { int size; @@ -170,7 +170,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) return size; } -#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_VASPRINTF) */ /* * Based on Code from bsd-asprintf from OpenSSH @@ -191,7 +191,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) +#if !defined(HAVE_ASPRINTF) int asprintf(char **str, const char *fmt, ...) { va_list ap; @@ -204,7 +204,7 @@ int asprintf(char **str, const char *fmt, ...) return ret; } -#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */ +#endif /* !defined(HAVE_ASPRINTF) */ #ifndef HAVE_GETLOADAVG #ifdef linux diff --git a/res/res_ari.c b/res/res_ari.c index 5ffb5833f..354201bf3 100644 --- a/res/res_ari.c +++ b/res/res_ari.c @@ -1196,6 +1196,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .optional_modules = "res_http_websocket", - .requires = "res_stasis", + .requires = "http,res_stasis", .load_pri = AST_MODPRI_APP_DEPEND, ); diff --git a/res/res_config_curl.c b/res/res_config_curl.c index 03f0338cc..03ff80c2e 100644 --- a/res/res_config_curl.c +++ b/res/res_config_curl.c @@ -650,5 +650,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime Curl configu .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, - .requires = "res_curl,func_curl", + .requires = "extconfig,res_curl,func_curl", ); diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c index 10265c93d..d73f42b11 100644 --- a/res/res_config_ldap.c +++ b/res/res_config_ldap.c @@ -548,11 +548,11 @@ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_conf } /*!< while (ldap_attribute_name) */ ber_free(ber, 0); if (static_table_config == table_config) { - if (option_debug > 2) { + if (DEBUG_ATLEAST(3)) { const struct ast_variable *tmpdebug = variable_named(var, "variable_name"); const struct ast_variable *tmpdebug2 = variable_named(var, "variable_value"); if (tmpdebug && tmpdebug2) { - ast_debug(3, "Added to vars - %s = %s\n", tmpdebug->value, tmpdebug2->value); + ast_log(LOG_DEBUG, "Added to vars - %s = %s\n", tmpdebug->value, tmpdebug2->value); } } vars[entry_index++] = var; @@ -1618,14 +1618,14 @@ static int update2_ldap(const char *basedn, const char *table_name, const struct /* Ready to update */ ast_debug(3, "Modifying %zu matched entries\n", entry_count); - if (option_debug > 2) { + if (DEBUG_ATLEAST(3)) { size_t i; for (i = 0; modifications[i]; i++) { if (modifications[i]->mod_op != LDAP_MOD_DELETE) { - ast_debug(3, "%s => %s\n", modifications[i]->mod_type, - modifications[i]->mod_values[0]); + ast_log(LOG_DEBUG, "%s => %s\n", modifications[i]->mod_type, + modifications[i]->mod_values[0]); } else { - ast_debug(3, "deleting %s\n", modifications[i]->mod_type); + ast_log(LOG_DEBUG, "deleting %s\n", modifications[i]->mod_type); } } } @@ -1999,4 +1999,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "LDAP realtime interfa .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig", ); diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index 186e89dcd..be920d673 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -30,6 +30,7 @@ /*** MODULEINFO <depend>res_odbc</depend> + <depend>generic_odbc</depend> <support_level>core</support_level> ***/ @@ -1237,4 +1238,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime ODBC configu .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig,res_odbc", ); diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index cee4e488d..c8660fb3a 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -1528,16 +1528,16 @@ static int parse_config(int is_reload) ast_config_destroy(config); - if (option_debug) { + if (DEBUG_ATLEAST(1)) { if (!ast_strlen_zero(dbhost)) { - ast_debug(1, "PostgreSQL RealTime Host: %s\n", dbhost); - ast_debug(1, "PostgreSQL RealTime Port: %i\n", dbport); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Host: %s\n", dbhost); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Port: %i\n", dbport); } else { - ast_debug(1, "PostgreSQL RealTime Socket: %s\n", dbsock); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Socket: %s\n", dbsock); } - ast_debug(1, "PostgreSQL RealTime User: %s\n", dbuser); - ast_debug(1, "PostgreSQL RealTime Password: %s\n", dbpass); - ast_debug(1, "PostgreSQL RealTime DBName: %s\n", dbname); + ast_log(LOG_DEBUG, "PostgreSQL RealTime User: %s\n", dbuser); + ast_log(LOG_DEBUG, "PostgreSQL RealTime Password: %s\n", dbpass); + ast_log(LOG_DEBUG, "PostgreSQL RealTime DBName: %s\n", dbname); } if (!pgsql_reconnect(NULL)) { @@ -1720,4 +1720,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PostgreSQL RealTime C .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig", ); diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c index 83d2dca72..323d2249b 100644 --- a/res/res_config_sqlite.c +++ b/res/res_config_sqlite.c @@ -1772,9 +1772,16 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } +/* + * This module should require "cdr" to enforce startup/shutdown ordering but it + * loads at REALTIME_DRIVER priority which would cause "cdr" to load too early. + * + * ast_cdr_register / ast_cdr_unregister is safe for use while "cdr" is not running. + */ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Realtime SQLite configuration", - .support_level = AST_MODULE_SUPPORT_EXTENDED, + .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig", ); diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c index de2de1ce4..854034f38 100644 --- a/res/res_config_sqlite3.c +++ b/res/res_config_sqlite3.c @@ -1393,4 +1393,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite 3 realtime con .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, + .requires = "extconfig", ); diff --git a/res/res_http_post.c b/res/res_http_post.c index 44bb8ee9d..bf404ced6 100644 --- a/res/res_http_post.c +++ b/res/res_http_post.c @@ -36,7 +36,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <gmime/gmime.h> -#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__Darwin__) +#if defined (__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__Darwin__) #include <libgen.h> #endif @@ -513,4 +513,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "HTTP POST support", .load = load_module, .unload = unload_module, .reload = reload, + .requires = "http", ); diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index 223bb2dd8..9a32bf37c 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -1478,4 +1478,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, + .requires = "http", ); diff --git a/res/res_monitor.c b/res/res_monitor.c index 95acf554d..efedab7c3 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -1007,7 +1007,7 @@ static int unload_module(void) /* usecount semantics need to be defined */ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Monitoring Resource", - .support_level = AST_MODULE_SUPPORT_CORE, + .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, diff --git a/res/res_odbc.c b/res/res_odbc.c index 4a5411e7e..3ee8cba74 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -42,7 +42,6 @@ /*** MODULEINFO <depend>generic_odbc</depend> <depend>res_odbc_transaction</depend> - <depend>ltdl</depend> <support_level>core</support_level> ***/ diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c index 585056b75..70e133328 100644 --- a/res/res_phoneprov.c +++ b/res/res_phoneprov.c @@ -1498,6 +1498,7 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DEPEND, + .requires = "http", ); /**** Public API for register/unregister, set defaults, and add extension. ****/ diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 9f6b5d115..935a5598e 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -5213,6 +5213,6 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5, - .requires = "res_pjproject", + .requires = "dnsmgr,res_pjproject", .optional_modules = "res_statsd", ); diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c index 6c02a176c..76b0d08b0 100644 --- a/res/res_pjsip_rfc3326.c +++ b/res/res_pjsip_rfc3326.c @@ -35,32 +35,35 @@ static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata) { - const pj_str_t str_reason = { "Reason", 6 }; - pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL); - char buf[20], *cause, *text; + static const pj_str_t str_reason = { "Reason", 6 }; + pjsip_generic_string_hdr *header; + char buf[20]; + char *cause; + char *text; int code; - if (!header) { - return; - } + header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL); + for (; header; + header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, header->next)) { + ast_copy_pj_str(buf, &header->hvalue, sizeof(buf)); + cause = ast_skip_blanks(buf); - ast_copy_pj_str(buf, &header->hvalue, sizeof(buf)); - cause = ast_skip_blanks(buf); + if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) { + continue; + } - if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) { - return; - } + /* If text is present get rid of it */ + if ((text = strstr(cause, ";"))) { + *text = '\0'; + } - /* If text is present get rid of it */ - if ((text = strstr(cause, ";"))) { - *text = '\0'; - } + if (sscanf(cause, "cause=%30d", &code) != 1) { + continue; + } - if (sscanf(cause, "cause=%30d", &code) != 1) { - return; + ast_channel_hangupcause_set(session->channel, code & 0x7f); + break; } - - ast_channel_hangupcause_set(session->channel, code & 0x7f); } static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata) @@ -91,12 +94,12 @@ static void rfc3326_add_reason_header(struct ast_sip_session *session, struct pj { char buf[20]; - snprintf(buf, sizeof(buf), "Q.850;cause=%i", ast_channel_hangupcause(session->channel) & 0x7f); - ast_sip_add_header(tdata, "Reason", buf); - if (ast_channel_hangupcause(session->channel) == AST_CAUSE_ANSWERED_ELSEWHERE) { ast_sip_add_header(tdata, "Reason", "SIP;cause=200;text=\"Call completed elsewhere\""); } + + snprintf(buf, sizeof(buf), "Q.850;cause=%i", ast_channel_hangupcause(session->channel) & 0x7f); + ast_sip_add_header(tdata, "Reason", buf); } static void rfc3326_outgoing_request(struct ast_sip_session *session, struct pjsip_tx_data *tdata) diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index fcd190bcb..f25201731 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -876,15 +876,30 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_ struct ast_stream_topology *topology; unsigned int changed = 0; - /* This situation can legitimately happen when an SDP is received in a - * 183 Session Progress message. In that case, everything's been done - * by the time this function is called and there are no more pending - * streams. - */ if (!session->pending_media_state->topology) { - ast_debug(1, "Pending topology was NULL for channel '%s'\n", - session->channel ? ast_channel_name(session->channel) : "unknown"); - return 0; + if (session->active_media_state->topology) { + /* + * This happens when we have negotiated media after receiving a 183, + * and we're now receiving a 200 with a new SDP. In this case, there + * is active_media_state, but the pending_media_state has been reset. + */ + struct ast_sip_session_media_state *active_media_state_clone; + + active_media_state_clone = + ast_sip_session_media_state_clone(session->active_media_state); + if (!active_media_state_clone) { + ast_log(LOG_WARNING, "Unable to clone active media state for channel '%s'\n", + session->channel ? ast_channel_name(session->channel) : "unknown"); + return -1; + } + + ast_sip_session_media_state_free(session->pending_media_state); + session->pending_media_state = active_media_state_clone; + } else { + ast_log(LOG_WARNING, "No pending or active media state for channel '%s'\n", + session->channel ? ast_channel_name(session->channel) : "unknown"); + return -1; + } } /* If we're handling negotiated streams, then we should already have set diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index 249472ba9..333295fe6 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -1048,5 +1048,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP T.38 UDPTL Supp .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, - .requires = "res_pjsip,res_pjsip_session", + .requires = "res_pjsip,res_pjsip_session,udptl", ); diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index b53b38ad7..d0e482405 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -4565,11 +4565,9 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr format = frame->subclass.format; if (ast_format_cmp(rtp->lasttxformat, format) == AST_FORMAT_CMP_NOT_EQUAL) { /* Oh dear, if the format changed we will have to set up a new smoother */ - if (option_debug > 0) { - ast_debug(1, "Ooh, format changed from %s to %s\n", - ast_format_get_name(rtp->lasttxformat), - ast_format_get_name(frame->subclass.format)); - } + ast_debug(1, "Ooh, format changed from %s to %s\n", + ast_format_get_name(rtp->lasttxformat), + ast_format_get_name(frame->subclass.format)); ao2_replace(rtp->lasttxformat, format); if (rtp->smoother) { ast_smoother_free(rtp->smoother); @@ -5744,7 +5742,7 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, ast_sockaddr_stringify(&remote_address), strerror(errno)); } else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) { - if (option_debug || rtpdebug) { + if (rtpdebug || DEBUG_ATLEAST(1)) { ast_log(LOG_WARNING, "RTP NAT: Can't write RTP to private " "address %s, waiting for other end to " @@ -6117,13 +6115,14 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc if (ext) { hdrlen += (ntohl(rtpheader[hdrlen/4]) & 0xffff) << 2; hdrlen += 4; - if (option_debug) { + if (DEBUG_ATLEAST(1)) { unsigned int profile; profile = (ntohl(rtpheader[3]) & 0xffff0000) >> 16; - if (profile == 0x505a) - ast_debug(1, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); - else - ast_debug(1, "Found unknown RTP Extensions %x\n", profile); + if (profile == 0x505a) { + ast_log(LOG_DEBUG, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); + } else { + ast_log(LOG_DEBUG, "Found unknown RTP Extensions %x\n", profile); + } } } diff --git a/res/res_srtp.c b/res/res_srtp.c index 1077f2337..cda1291fa 100644 --- a/res/res_srtp.c +++ b/res/res_srtp.c @@ -41,7 +41,6 @@ #if HAVE_SRTP_VERSION > 1 # include <srtp2/srtp.h> -# include <srtp2/crypto_types.h> # include "srtp/srtp_compat.h" # include <openssl/rand.h> #else diff --git a/res/stasis_recording/stored.c b/res/stasis_recording/stored.c index ac216ff8c..909524e8f 100644 --- a/res/stasis_recording/stored.c +++ b/res/stasis_recording/stored.c @@ -123,18 +123,9 @@ static int split_path(const char *path, char **dir, char **file) return -1; } -#if defined(__AST_DEBUG_MALLOC) *dir = ast_strdup(real_dir); /* Dupe so we can ast_free() */ -#else - /* - * ast_std_free() and ast_free() are the same thing at this time - * so we don't need to dupe. - */ - *dir = real_dir; - real_dir = NULL; -#endif /* defined(__AST_DEBUG_MALLOC) */ *file = ast_strdup(file_portion); - return 0; + return (*dir && *file) ? 0 : -1; } struct match_recording_data { diff --git a/sounds/Makefile b/sounds/Makefile index 779d52a8e..606bbdcec 100644 --- a/sounds/Makefile +++ b/sounds/Makefile @@ -127,9 +127,9 @@ have_download: @if test "$(DOWNLOAD)" = ":" ; then \ echo "**************************************************"; \ echo "*** ***"; \ - echo "*** You must have either wget or fetch to be ***"; \ - echo "*** able to automatically download and install ***"; \ - echo "*** the requested sound packages. ***"; \ + echo "*** You must have either wget, curl, or fetch ***"; \ + echo "*** to be able to automatically download and ***"; \ + echo "*** install the requested sound packages. ***"; \ echo "*** ***"; \ echo "*** Please install one of these, or remove any ***"; \ echo "*** extra sound package selections in ***"; \ diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile index f7b9f0c3f..b95b33221 100644 --- a/third-party/pjproject/Makefile +++ b/third-party/pjproject/Makefile @@ -66,9 +66,9 @@ ifeq ($(SPECIAL_TARGETS),) endif ifeq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),MALLOC_DEBUG) CF += -DMALLOC_DEBUG - MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a - MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive endif + MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a + MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),) CF += -O3 endif diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4 index c1edaf9aa..42482b2e5 100644 --- a/third-party/pjproject/configure.m4 +++ b/third-party/pjproject/configure.m4 @@ -16,7 +16,7 @@ AC_DEFUN([_PJPROJECT_CONFIGURE], AC_MSG_RESULT(configuring) if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then - AC_MSG_ERROR(A download utility (wget, curl or fetch) is required to download bundled pjproject) + AC_MSG_ERROR(A download utility (wget, curl, or fetch) is required to download bundled pjproject) fi if test "${BZIP2}" = ":" ; then AC_MSG_ERROR(bzip2 is required to extract the pjproject tar file) diff --git a/third-party/pjproject/patches/0070-sdp_media_fmt.patch b/third-party/pjproject/patches/0070-sdp_media_fmt.patch deleted file mode 100644 index 0a0977d55..000000000 --- a/third-party/pjproject/patches/0070-sdp_media_fmt.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/pjmedia/src/pjmedia/sdp.c b/pjmedia/src/pjmedia/sdp.c -index a3dd80b..0a13206 100644 ---- a/pjmedia/src/pjmedia/sdp.c -+++ b/pjmedia/src/pjmedia/sdp.c -@@ -1516,11 +1516,12 @@ PJ_DEF(pj_status_t) pjmedia_sdp_validate2(const pjmedia_sdp_session *sdp, - * RTC based programs sends "null" for instant messaging! - */ - if (pj_isdigit(*m->desc.fmt[j].ptr)) { -- unsigned pt = pj_strtoul(&m->desc.fmt[j]); -+ unsigned long pt; -+ pj_status_t status = pj_strtoul3(&m->desc.fmt[j], &pt, 10); - - /* Payload type is between 0 and 127. - */ -- CHECK( pt <= 127, PJMEDIA_SDP_EINPT); -+ CHECK( status == PJ_SUCCESS && pt <= 127, PJMEDIA_SDP_EINPT); - - /* If port is not zero, then for each dynamic payload type, an - * rtpmap attribute must be specified. diff --git a/third-party/pjproject/patches/0071-sdp_fmtp_attr.patch b/third-party/pjproject/patches/0071-sdp_fmtp_attr.patch deleted file mode 100644 index 8228d5dd6..000000000 --- a/third-party/pjproject/patches/0071-sdp_fmtp_attr.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/pjmedia/src/pjmedia/sdp.c b/pjmedia/src/pjmedia/sdp.c -index a3dd80b..6117e07 100644 ---- a/pjmedia/src/pjmedia/sdp.c -+++ b/pjmedia/src/pjmedia/sdp.c -@@ -256,7 +256,8 @@ PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_rtpmap( const pjmedia_sdp_attr *attr, - - PJ_ASSERT_RETURN(pj_strcmp2(&attr->name, "rtpmap")==0, PJ_EINVALIDOP); - -- PJ_ASSERT_RETURN(attr->value.slen != 0, PJMEDIA_SDP_EINATTR); -+ if (attr->value.slen == 0) -+ return PJMEDIA_SDP_EINATTR; - - init_sdp_parser(); - -@@ -341,6 +342,9 @@ PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_fmtp( const pjmedia_sdp_attr *attr, - - PJ_ASSERT_RETURN(pj_strcmp2(&attr->name, "fmtp")==0, PJ_EINVALIDOP); - -+ if (attr->value.slen == 0) -+ return PJMEDIA_SDP_EINATTR; -+ - /* fmtp BNF: - * a=fmtp:<format> <format specific parameter> - */ -@@ -379,6 +383,9 @@ PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr, - - PJ_ASSERT_RETURN(pj_strcmp2(&attr->name, "rtcp")==0, PJ_EINVALIDOP); - -+ if (attr->value.slen == 0) -+ return PJMEDIA_SDP_EINATTR; -+ - init_sdp_parser(); - - /* fmtp BNF: diff --git a/third-party/pjproject/patches/asterisk_malloc_debug.c b/third-party/pjproject/patches/asterisk_malloc_debug.c index aaf79855a..061bdd491 100644 --- a/third-party/pjproject/patches/asterisk_malloc_debug.c +++ b/third-party/pjproject/patches/asterisk_malloc_debug.c @@ -22,7 +22,7 @@ #include <string.h> #include <stdarg.h> -int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) +int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) { va_list ap; int rc = 0; @@ -34,7 +34,7 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, return rc; } -void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) { return calloc(nmemb, size); } @@ -44,27 +44,27 @@ void __ast_free(void *ptr, const char *file, int lineno, const char *func) free(ptr); } -void *__ast_malloc(size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) { return malloc(size); } -void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func) +void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func) { return realloc(ptr, size); } -char *__ast_strdup(const char *s, const char *file, int lineno, const char *func) +char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) { return strdup(s); } -char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) +char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) { return strndup(s, n); } -int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) +int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) { return vasprintf(strp, format, ap); } diff --git a/third-party/pjproject/patches/asterisk_malloc_debug.h b/third-party/pjproject/patches/asterisk_malloc_debug.h index 44c473758..e5e04f1af 100644 --- a/third-party/pjproject/patches/asterisk_malloc_debug.h +++ b/third-party/pjproject/patches/asterisk_malloc_debug.h @@ -25,15 +25,15 @@ extern "C" { #endif -int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) +int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) __attribute__((format(printf, 5, 6))); -void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); +void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); void __ast_free(void *ptr, const char *file, int lineno, const char *func); -void *__ast_malloc(size_t size, const char *file, int lineno, const char *func); -void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func); -char *__ast_strdup(const char *s, const char *file, int lineno, const char *func); -char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); -int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) +void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func); +void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func); +char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func); +char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); +int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) __attribute__((format(printf, 2, 0))); /* Undefine any macros */ @@ -48,28 +48,28 @@ int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *fil /* Provide our own definitions */ #define asprintf(a, b, c...) \ - __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) + __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) #define calloc(a,b) \ - __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define free(a) \ __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define malloc(a) \ - __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define realloc(a,b) \ - __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define strdup(a) \ - __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define strndup(a,b) \ - __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define vasprintf(a,b,c) \ - __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_repl_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) #ifdef __cplusplus } diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h index d5aee82cc..67e3451d0 100644 --- a/third-party/pjproject/patches/config_site.h +++ b/third-party/pjproject/patches/config_site.h @@ -8,7 +8,7 @@ * Since both pjproject and asterisk source files will include config_site.h, * we need to make sure that only pjproject source files include asterisk_malloc_debug.h. */ -#if defined(MALLOC_DEBUG) && !defined(_ASTERISK_ASTMM_H) +#if !defined(_ASTERISK_ASTMM_H) #include "asterisk_malloc_debug.h" #endif diff --git a/third-party/versions.mak b/third-party/versions.mak index a90a52348..b6daf1989 100644 --- a/third-party/versions.mak +++ b/third-party/versions.mak @@ -1,2 +1,2 @@ -PJPROJECT_VERSION = 2.7.1 +PJPROJECT_VERSION = 2.7.2 diff --git a/utils/extconf.c b/utils/extconf.c index 1be739c17..5b3a95be9 100644 --- a/utils/extconf.c +++ b/utils/extconf.c @@ -780,7 +780,7 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( -void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), +void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), { void *newp; |