Merge topics 'ASTERISK-25049', 'ASTERISK-25056'

* changes:
  CLI: Enable automatic references to modules.
  Modules: Make ast_module_info->self available to auxiliary sources.
changes/90/390/1
Matt Jordan 11 years ago committed by Gerrit Code Review
commit f451af65c4

@ -60,7 +60,11 @@ endif
# is used to collect the required flags for a module... which can # is used to collect the required flags for a module... which can
# then be used any place they are required. # then be used any place they are required.
MOD_ASTCFLAGS=-DAST_MODULE=\"$(1)\" $(MENUSELECT_OPTS_$(1):%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE)) MOD_ASTCFLAGS=\
-DAST_MODULE=\"$(1)\" \
-DAST_MODULE_SELF_SYM=__internal_$(1)_self \
$(MENUSELECT_OPTS_$(1):%=-D%) \
$(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE))
define MOD_ADD_SOURCE define MOD_ADD_SOURCE
$$(if $$(filter $(1),$$(EMBEDDED_MODS)),modules.link,$(1).so): $$(subst $(3),$(5),$(2)) $$(if $$(filter $(1),$$(EMBEDDED_MODS)),modules.link,$(1).so): $$(subst $(3),$(5),$(2))

@ -19519,7 +19519,7 @@ static int load_module(void)
ast_format_cap_append(dahdi_tech.capabilities, ast_format_ulaw, 0); ast_format_cap_append(dahdi_tech.capabilities, ast_format_ulaw, 0);
ast_format_cap_append(dahdi_tech.capabilities, ast_format_alaw, 0); ast_format_cap_append(dahdi_tech.capabilities, ast_format_alaw, 0);
if (dahdi_native_load(ast_module_info->self, &dahdi_tech)) { if (dahdi_native_load(&dahdi_tech)) {
ao2_ref(dahdi_tech.capabilities, -1); ao2_ref(dahdi_tech.capabilities, -1);
return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_FAILURE;
} }

@ -903,11 +903,11 @@ void dahdi_native_unload(void)
* \retval 0 on success. * \retval 0 on success.
* \retval -1 on error. * \retval -1 on error.
*/ */
int dahdi_native_load(struct ast_module *mod, const struct ast_channel_tech *tech) int dahdi_native_load(const struct ast_channel_tech *tech)
{ {
dahdi_tech = tech; dahdi_tech = tech;
if (__ast_bridge_technology_register(&native_bridge, mod)) { if (ast_bridge_technology_register(&native_bridge)) {
dahdi_native_unload(); dahdi_native_unload();
return -1; return -1;
} }

@ -36,7 +36,7 @@ extern "C" {
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
void dahdi_native_unload(void); void dahdi_native_unload(void);
int dahdi_native_load(struct ast_module *mod, const struct ast_channel_tech *tech); int dahdi_native_load(const struct ast_channel_tech *tech);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */

@ -338,7 +338,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
break; break;
} }
ast_rtp_engine_register2(&test_engine, NULL); ast_rtp_engine_register(&test_engine);
/* Have to associate this with a SIP pvt and an ast_channel */ /* Have to associate this with a SIP pvt and an ast_channel */
if (!(p = sip_alloc(0, NULL, 0, SIP_NOTIFY, NULL, 0))) { if (!(p = sip_alloc(0, NULL, 0, SIP_NOTIFY, NULL, 0))) {
res = AST_TEST_NOT_RUN; res = AST_TEST_NOT_RUN;

@ -34,7 +34,7 @@ Some OSS fixes and a few lpc changes to make it actually work
-lf2c -lm (in that order) -lf2c -lm (in that order)
*/ */
#include "asterisk.h" #include <stdlib.h>
#include "f2c.h" #include "f2c.h"
#ifdef P_R_O_T_O_T_Y_P_E_S #ifdef P_R_O_T_O_T_Y_P_E_S

@ -271,4 +271,21 @@ struct ast_sched_context;
#define __stringify_1(x) #x #define __stringify_1(x) #x
#define __stringify(x) __stringify_1(x) #define __stringify(x) __stringify_1(x)
#if defined(AST_IN_CORE) \
|| (!defined(AST_MODULE_SELF_SYM) \
&& (defined(STANDALONE) || defined(STANDALONE2) || defined(AST_NOT_MODULE)))
#define AST_MODULE_SELF NULL
#elif defined(AST_MODULE_SELF_SYM)
/*! Retreive the 'struct ast_module *' for the current module. */
#define AST_MODULE_SELF AST_MODULE_SELF_SYM()
struct ast_module;
/* Internal/forward declaration, AST_MODULE_SELF should be used instead. */
struct ast_module *AST_MODULE_SELF_SYM(void);
#endif
#endif /* _ASTERISK_H */ #endif /* _ASTERISK_H */

@ -584,7 +584,7 @@ int ast_vm_is_registered(void);
int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module); int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module);
/*! \brief See \ref __ast_vm_register() */ /*! \brief See \ref __ast_vm_register() */
#define ast_vm_register(vm_table) __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL) #define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF)
/*! /*!
* \brief Unregister the specified voicemail provider * \brief Unregister the specified voicemail provider
@ -652,7 +652,7 @@ int ast_vm_greeter_is_registered(void);
int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module); int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module);
/*! \brief See \ref __ast_vm_greeter_register() */ /*! \brief See \ref __ast_vm_greeter_register() */
#define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, ast_module_info ? ast_module_info->self : NULL) #define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF)
/*! /*!
* \brief Unregister the specified voicemail greeter provider * \brief Unregister the specified voicemail greeter provider

@ -182,7 +182,7 @@ struct ast_bridge_technology {
int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod); int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod);
/*! \brief See \ref __ast_bridge_technology_register() */ /*! \brief See \ref __ast_bridge_technology_register() */
#define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self) #define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, AST_MODULE_SELF)
/*! /*!
* \brief Unregister a bridge technology from use * \brief Unregister a bridge technology from use

@ -134,7 +134,7 @@ int ast_bucket_init(void);
* *
* \note Once a scheme has been registered it can not be unregistered * \note Once a scheme has been registered it can not be unregistered
*/ */
#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, ast_module_info ? ast_module_info->self : NULL) #define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, AST_MODULE_SELF)
/*! /*!
* \brief Register support for a specific scheme * \brief Register support for a specific scheme

@ -177,7 +177,7 @@ struct ast_cli_entry {
const char * usage; /*!< Detailed usage information */ const char * usage; /*!< Detailed usage information */
int inuse; /*!< For keeping track of usage */ int inuse; /*!< For keeping track of usage */
struct module *module; /*!< module this belongs to */ struct ast_module *module; /*!< module this belongs to */
char *_full_cmd; /*!< built at load time from cmda[] */ char *_full_cmd; /*!< built at load time from cmda[] */
int cmdlen; /*!< len up to the first invalid char [<{% */ int cmdlen; /*!< len up to the first invalid char [<{% */
/*! \brief This gets set in ast_cli_register() /*! \brief This gets set in ast_cli_register()
@ -253,14 +253,19 @@ int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const c
* \retval 0 on success * \retval 0 on success
* \retval -1 on failure * \retval -1 on failure
*/ */
int ast_cli_register(struct ast_cli_entry *e); #define ast_cli_register(e) __ast_cli_register(e, AST_MODULE_SELF)
int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *mod);
/*! /*!
* \brief Register multiple commands * \brief Register multiple commands
* \param e pointer to first cli entry to register * \param e pointer to first cli entry to register
* \param len number of entries to register * \param len number of entries to register
*/ */
int ast_cli_register_multiple(struct ast_cli_entry *e, int len); #define ast_cli_register_multiple(e, len) \
__ast_cli_register_multiple(e, len, AST_MODULE_SELF)
int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *mod);
/*! /*!
* \brief Unregisters a command or an array of commands * \brief Unregisters a command or an array of commands

@ -116,7 +116,7 @@ int __ast_codec_register(struct ast_codec *codec, struct ast_module *mod);
* \retval 0 success * \retval 0 success
* \retval -1 failure * \retval -1 failure
*/ */
#define ast_codec_register(codec) __ast_codec_register(codec, ast_module_info->self) #define ast_codec_register(codec) __ast_codec_register(codec, AST_MODULE_SELF)
/*! /*!
* \brief Retrieve a codec given a name, type, and sample rate * \brief Retrieve a codec given a name, type, and sample rate

@ -360,7 +360,7 @@ struct ast_data_mapping_structure {
*/ */
int __ast_data_register(const char *path, const struct ast_data_handler *handler, int __ast_data_register(const char *path, const struct ast_data_handler *handler,
const char *registrar, struct ast_module *mod); const char *registrar, struct ast_module *mod);
#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, ast_module_info->self) #define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, AST_MODULE_SELF)
#define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL) #define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL)
/*! /*!
@ -376,7 +376,7 @@ int __ast_data_register(const char *path, const struct ast_data_handler *handler
int __ast_data_register_multiple(const struct ast_data_entry *data_entries, int __ast_data_register_multiple(const struct ast_data_entry *data_entries,
size_t entries, const char *registrar, struct ast_module *mod); size_t entries, const char *registrar, struct ast_module *mod);
#define ast_data_register_multiple(data_entries, entries) \ #define ast_data_register_multiple(data_entries, entries) \
__ast_data_register_multiple(data_entries, entries, __FILE__, ast_module_info->self) __ast_data_register_multiple(data_entries, entries, __FILE__, AST_MODULE_SELF)
#define ast_data_register_multiple_core(data_entries, entries) \ #define ast_data_register_multiple_core(data_entries, entries) \
__ast_data_register_multiple(data_entries, entries, __FILE__, NULL) __ast_data_register_multiple(data_entries, entries, __FILE__, NULL)

@ -247,7 +247,7 @@ int __ast_format_interface_register(const char *codec, const struct ast_format_i
* \retval 0 success * \retval 0 success
* \retval -1 failure * \retval -1 failure
*/ */
#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, ast_module_info->self) #define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, AST_MODULE_SELF)
/*! /*!
* \brief Get the attribute data on a format * \brief Get the attribute data on a format

@ -180,10 +180,10 @@ struct manager_action {
/*! \brief External routines may register/unregister manager callbacks this way /*! \brief External routines may register/unregister manager callbacks this way
* \note Use ast_manager_register2() to register with help text for new manager commands */ * \note Use ast_manager_register2() to register with help text for new manager commands */
#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, ast_module_info->self, synopsis, NULL) #define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL)
/*! \brief Register a manager callback using XML documentation to describe the manager. */ /*! \brief Register a manager callback using XML documentation to describe the manager. */
#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, ast_module_info->self, NULL, NULL) #define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL)
/*! /*!
* \brief Register a manager callback using XML documentation to describe the manager. * \brief Register a manager callback using XML documentation to describe the manager.

@ -128,7 +128,7 @@ struct ast_filestream {
* \retval -1 on failure * \retval -1 on failure
*/ */
int __ast_format_def_register(const struct ast_format_def *f, struct ast_module *mod); int __ast_format_def_register(const struct ast_format_def *f, struct ast_module *mod);
#define ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self) #define ast_format_def_register(f) __ast_format_def_register(f, AST_MODULE_SELF)
/*! /*!
* \brief Unregisters a file format * \brief Unregisters a file format

@ -312,9 +312,9 @@ struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_ch
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *); void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
void __ast_module_user_hangup_all(struct ast_module *); void __ast_module_user_hangup_all(struct ast_module *);
#define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan) #define ast_module_user_add(chan) __ast_module_user_add(AST_MODULE_SELF, chan)
#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user) #define ast_module_user_remove(user) __ast_module_user_remove(AST_MODULE_SELF, user)
#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self) #define ast_module_user_hangup_all() __ast_module_user_hangup_all(AST_MODULE_SELF)
struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func); struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func);
void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func); void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func);
@ -368,8 +368,13 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
{ \ { \
ast_module_unregister(&__mod_info); \ ast_module_unregister(&__mod_info); \
} \ } \
struct ast_module *AST_MODULE_SELF_SYM(void) \
{ \
return __mod_info.self; \
} \
static const __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info static const __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info
#define AST_MODULE_INFO_STANDARD(keystr, desc) \ #define AST_MODULE_INFO_STANDARD(keystr, desc) \
AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc, \ AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc, \
load_module, \ load_module, \
@ -401,7 +406,9 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
/* forward declare this pointer in modules, so that macro/function /* forward declare this pointer in modules, so that macro/function
calls that need it can get it, since it will actually be declared calls that need it can get it, since it will actually be declared
and populated at the end of the module's source file... */ and populated at the end of the module's source file... */
#if !defined(AST_IN_CORE)
static const __attribute__((unused)) struct ast_module_info *ast_module_info; static const __attribute__((unused)) struct ast_module_info *ast_module_info;
#endif
#if !defined(EMBEDDED_MODULE) #if !defined(EMBEDDED_MODULE)
#define __MODULE_INFO_SECTION #define __MODULE_INFO_SECTION
@ -482,6 +489,10 @@ static void __restore_globals(void)
{ \ { \
ast_module_unregister(&__mod_info); \ ast_module_unregister(&__mod_info); \
} \ } \
struct ast_module *AST_MODULE_SELF_SYM(void) \
{ \
return __mod_info.self; \
} \
static const struct ast_module_info *ast_module_info = &__mod_info static const struct ast_module_info *ast_module_info = &__mod_info
#define AST_MODULE_INFO_STANDARD(keystr, desc) \ #define AST_MODULE_INFO_STANDARD(keystr, desc) \
@ -527,7 +538,7 @@ static void __restore_globals(void)
* \retval 0 success * \retval 0 success
* \retval -1 failure. * \retval -1 failure.
*/ */
#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self) #define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, AST_MODULE_SELF)
/*! /*!
* \brief Register an application using XML documentation. * \brief Register an application using XML documentation.

@ -196,7 +196,7 @@ struct ast_parking_bridge_feature_fn_table {
int (* parking_park_bridge_channel)(struct ast_bridge_channel *parkee, const char *parkee_uuid, const char *parker_uuid, const char *app_data); int (* parking_park_bridge_channel)(struct ast_bridge_channel *parkee, const char *parkee_uuid, const char *parker_uuid, const char *app_data);
/*! \brief The module info for the module registering this parking provider */ /*! \brief The module info for the module registering this parking provider */
const struct ast_module_info *module_info; struct ast_module *module;
}; };
/*! /*!

@ -1406,7 +1406,7 @@ enum ast_custom_function_escalation {
/*! /*!
* \brief Register a custom function * \brief Register a custom function
*/ */
#define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self) #define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF)
/*! /*!
* \brief Register a custom function which requires escalated privileges. * \brief Register a custom function which requires escalated privileges.
@ -1415,7 +1415,7 @@ enum ast_custom_function_escalation {
* arbitrary code) or FILE() (for which write needs permission to change files * arbitrary code) or FILE() (for which write needs permission to change files
* on the filesystem). * on the filesystem).
*/ */
#define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, ast_module_info->self) #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF)
/*! /*!
* \brief Register a custom function * \brief Register a custom function

@ -643,7 +643,7 @@ struct ast_rtp_glue {
*/ */
struct ast_rtp_payload_type *ast_rtp_engine_alloc_payload_type(void); struct ast_rtp_payload_type *ast_rtp_engine_alloc_payload_type(void);
#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self) #define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, AST_MODULE_SELF)
/*! /*!
* \brief Register an RTP engine * \brief Register an RTP engine
@ -696,7 +696,7 @@ int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_
void ast_rtp_engine_unregister_srtp(void); void ast_rtp_engine_unregister_srtp(void);
int ast_rtp_engine_srtp_is_registered(void); int ast_rtp_engine_srtp_is_registered(void);
#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self) #define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, AST_MODULE_SELF)
/*! /*!
* \brief Register RTP glue * \brief Register RTP glue

@ -366,7 +366,7 @@ int __ast_sorcery_wizard_register(const struct ast_sorcery_wizard *interface, st
/*! /*!
* \brief See \ref __ast_sorcery_wizard_register() * \brief See \ref __ast_sorcery_wizard_register()
*/ */
#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, ast_module_info ? ast_module_info->self : NULL) #define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, AST_MODULE_SELF)
/*! /*!
* \brief Unregister a sorcery wizard * \brief Unregister a sorcery wizard

@ -92,7 +92,7 @@ struct ast_timing_interface {
* \retval non-Null handle to be passed to ast_unregister_timing_interface() on success * \retval non-Null handle to be passed to ast_unregister_timing_interface() on success
* \since 1.6.1 * \since 1.6.1
*/ */
#define ast_register_timing_interface(i) _ast_register_timing_interface(i, ast_module_info->self) #define ast_register_timing_interface(i) _ast_register_timing_interface(i, AST_MODULE_SELF)
void *_ast_register_timing_interface(struct ast_timing_interface *funcs, void *_ast_register_timing_interface(struct ast_timing_interface *funcs,
struct ast_module *mod); struct ast_module *mod);

@ -241,7 +241,7 @@ struct ast_trans_pvt;
int __ast_register_translator(struct ast_translator *t, struct ast_module *module); int __ast_register_translator(struct ast_translator *t, struct ast_module *module);
/*! \brief See \ref __ast_register_translator() */ /*! \brief See \ref __ast_register_translator() */
#define ast_register_translator(t) __ast_register_translator(t, ast_module_info->self) #define ast_register_translator(t) __ast_register_translator(t, AST_MODULE_SELF)
/*! /*!
* \brief Unregister a translator * \brief Unregister a translator

@ -201,7 +201,7 @@ ifeq ($(findstring darwin,$(OSARCH)),) # not Darwin
ASTSSL_LIB:=libasteriskssl.so ASTSSL_LIB:=libasteriskssl.so
$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTLDFLAGS+=-Wl,-soname=$(ASTSSL_LIB).$(ASTSSL_SO_VERSION) $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTLDFLAGS+=-Wl,-soname=$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)
$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\" $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\" -DAST_NOT_MODULE
$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): LIBS+=$(ASTSSL_LIBS) $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): LIBS+=$(ASTSSL_LIBS)
ifeq ($(GNU_LD),1) ifeq ($(GNU_LD),1)
$(ASTSSL_LIB).$(ASTSSL_SO_VERSION): SO_SUPPRESS_SYMBOLS=-Wl,--version-script,libasteriskssl.exports,--warn-common $(ASTSSL_LIB).$(ASTSSL_SO_VERSION): SO_SUPPRESS_SYMBOLS=-Wl,--version-script,libasteriskssl.exports,--warn-common

@ -2203,7 +2203,7 @@ static int cli_is_registered(struct ast_cli_entry *e)
return 0; return 0;
} }
static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *ed) int ast_cli_unregister(struct ast_cli_entry *e)
{ {
if (e->inuse) { if (e->inuse) {
ast_log(LOG_WARNING, "Can't remove command that is in use\n"); ast_log(LOG_WARNING, "Can't remove command that is in use\n");
@ -2225,7 +2225,7 @@ static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *e
return 0; return 0;
} }
static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed) int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *module)
{ {
struct ast_cli_entry *cur; struct ast_cli_entry *cur;
int i, lf, ret = -1; int i, lf, ret = -1;
@ -2244,7 +2244,11 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
} }
memset(&a, '\0', sizeof(a)); memset(&a, '\0', sizeof(a));
e->module = module;
/* No module reference needed here, the module called us. */
e->handler(e, CLI_INIT, &a); e->handler(e, CLI_INIT, &a);
/* XXX check that usage and command are filled up */ /* XXX check that usage and command are filled up */
s = ast_skip_blanks(e->command); s = ast_skip_blanks(e->command);
s = e->command = ast_strdup(s); s = e->command = ast_strdup(s);
@ -2295,27 +2299,16 @@ done:
return ret; return ret;
} }
/* wrapper function, so we can unregister deprecated commands recursively */
int ast_cli_unregister(struct ast_cli_entry *e)
{
return __ast_cli_unregister(e, NULL);
}
/* wrapper function, so we can register deprecated commands recursively */
int ast_cli_register(struct ast_cli_entry *e)
{
return __ast_cli_register(e, NULL);
}
/* /*
* register/unregister an array of entries. * register/unregister an array of entries.
*/ */
int ast_cli_register_multiple(struct ast_cli_entry *e, int len) int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *module)
{ {
int i, res = 0; int i, res = 0;
for (i = 0; i < len; i++) for (i = 0; i < len; i++) {
res |= ast_cli_register(e + i); res |= __ast_cli_register(e + i, module);
}
return res; return res;
} }
@ -2657,7 +2650,9 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
.n = state - matchnum, .n = state - matchnum,
.argv = argv, .argv = argv,
.argc = x}; .argc = x};
ast_module_ref(e->module);
ret = e->handler(e, CLI_GENERATE, &a); ret = e->handler(e, CLI_GENERATE, &a);
ast_module_unref(e->module);
} }
if (ret) if (ret)
break; break;
@ -2714,7 +2709,9 @@ int ast_cli_command_full(int uid, int gid, int fd, const char *s)
*/ */
args[0] = (char *)e; args[0] = (char *)e;
ast_module_ref(e->module);
retval = e->handler(e, CLI_HANDLER, &a); retval = e->handler(e, CLI_HANDLER, &a);
ast_module_unref(e->module);
if (retval == CLI_SHOWUSAGE) { if (retval == CLI_SHOWUSAGE) {
ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n")); ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n"));

@ -134,8 +134,8 @@ int ast_parking_park_bridge_channel(struct ast_bridge_channel *parkee, const cha
return -1; return -1;
} }
if (table->module_info) { if (table->module) {
SCOPED_MODULE_USE(table->module_info->self); SCOPED_MODULE_USE(table->module);
return table->parking_park_bridge_channel(parkee, parkee_uuid, parker_uuid, app_data); return table->parking_park_bridge_channel(parkee, parkee_uuid, parker_uuid, app_data);
} }
@ -153,8 +153,8 @@ int ast_parking_blind_transfer_park(struct ast_bridge_channel *parker,
return -1; return -1;
} }
if (table->module_info) { if (table->module) {
SCOPED_MODULE_USE(table->module_info->self); SCOPED_MODULE_USE(table->module);
return table->parking_blind_transfer_park(parker, context, exten, parked_channel_cb, parked_channel_data); return table->parking_blind_transfer_park(parker, context, exten, parked_channel_cb, parked_channel_data);
} }
@ -170,8 +170,8 @@ int ast_parking_park_call(struct ast_bridge_channel *parker, char *exten, size_t
return -1; return -1;
} }
if (table->module_info) { if (table->module) {
SCOPED_MODULE_USE(table->module_info->self); SCOPED_MODULE_USE(table->module);
return table->parking_park_call(parker, exten, length); return table->parking_park_call(parker, exten, length);
} }
@ -187,8 +187,8 @@ int ast_parking_is_exten_park(const char *context, const char *exten)
return -1; return -1;
} }
if (table->module_info) { if (table->module) {
SCOPED_MODULE_USE(table->module_info->self); SCOPED_MODULE_USE(table->module);
return table->parking_is_exten_park(context, exten); return table->parking_is_exten_park(context, exten);
} }

@ -868,8 +868,6 @@ static int park_and_announce_app_exec(struct ast_channel *chan, const char *data
int load_parking_applications(void) int load_parking_applications(void)
{ {
const struct ast_module_info *ast_module_info = parking_get_module_info();
if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) { if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) {
return -1; return -1;
} }

@ -502,7 +502,7 @@ static int parking_park_call(struct ast_bridge_channel *parker, char *exten, siz
static int feature_park_call(struct ast_bridge_channel *bridge_channel, void *hook_pvt) static int feature_park_call(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{ {
SCOPED_MODULE_USE(parking_get_module_info()->self); SCOPED_MODULE_USE(AST_MODULE_SELF);
return parking_park_call(bridge_channel, NULL, 0); return parking_park_call(bridge_channel, NULL, 0);
} }
@ -726,7 +726,7 @@ void unload_parking_bridge_features(void)
int load_parking_bridge_features(void) int load_parking_bridge_features(void)
{ {
parking_provider.module_info = parking_get_module_info(); parking_provider.module = AST_MODULE_SELF;
if (ast_parking_register_bridge_features(&parking_provider)) { if (ast_parking_register_bridge_features(&parking_provider)) {
return -1; return -1;

@ -678,11 +678,10 @@ static void parking_manager_enable_stasis(void)
int load_parking_manager(void) int load_parking_manager(void)
{ {
int res; int res;
const struct ast_module_info *module = parking_get_module_info();
res = ast_manager_register2("Parkinglots", EVENT_FLAG_CALL, manager_parking_lot_list, module->self, NULL, NULL); res = ast_manager_register_xml("Parkinglots", EVENT_FLAG_CALL, manager_parking_lot_list);
res |= ast_manager_register2("ParkedCalls", EVENT_FLAG_CALL, manager_parking_status, module->self, NULL, NULL); res |= ast_manager_register_xml("ParkedCalls", EVENT_FLAG_CALL, manager_parking_status);
res |= ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, module->self, NULL, NULL); res |= ast_manager_register_xml("Park", EVENT_FLAG_CALL, manager_park);
parking_manager_enable_stasis(); parking_manager_enable_stasis();
return res ? -1 : 0; return res ? -1 : 0;
} }

@ -560,12 +560,3 @@ int load_parking_tests(void);
* \return Nothing * \return Nothing
*/ */
void unload_parking_tests(void); void unload_parking_tests(void);
struct ast_module_info;
/*!
* \since 12.0.0
* \brief Get res_parking's module info
*
* \retval res_parking's ast_module
*/
const struct ast_module_info *parking_get_module_info(void);

@ -156,8 +156,6 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
"used. If no extension is given, the 's' extension will be used.\n"; "used. If no extension is given, the 's' extension will be used.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
/* ugly, can be removed when CLI entries have ast_module pointers */
ast_module_ref(ast_module_info->self);
if (a->pos == 3) { if (a->pos == 3) {
res = ast_cli_complete(a->word, choices, a->n); res = ast_cli_complete(a->word, choices, a->n);
} else if (a->pos == 4) { } else if (a->pos == 4) {
@ -165,16 +163,12 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
res = ast_complete_applications(a->line, a->word, a->n); res = ast_complete_applications(a->line, a->word, a->n);
} }
} }
ast_module_unref(ast_module_info->self);
return res; return res;
} }
if (ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3])) if (ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3]))
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
/* ugly, can be removed when CLI entries have ast_module pointers */
ast_module_ref(ast_module_info->self);
if (!strcasecmp("application", a->argv[3])) { if (!strcasecmp("application", a->argv[3])) {
res = orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]); res = orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]);
} else if (!strcasecmp("extension", a->argv[3])) { } else if (!strcasecmp("extension", a->argv[3])) {
@ -183,8 +177,6 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
res = CLI_SHOWUSAGE; res = CLI_SHOWUSAGE;
} }
ast_module_unref(ast_module_info->self);
return res; return res;
} }

@ -88,9 +88,6 @@ static char *handle_cli_file_convert(struct ast_cli_entry *e, int cmd, struct as
return NULL; return NULL;
} }
/* ugly, can be removed when CLI entries have ast_module pointers */
ast_module_ref(ast_module_info->self);
if (a->argc != 4 || ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3])) { if (a->argc != 4 || ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3])) {
ret = CLI_SHOWUSAGE; ret = CLI_SHOWUSAGE;
goto fail_out; goto fail_out;
@ -142,8 +139,6 @@ fail_out:
if (fs_in) if (fs_in)
ast_closestream(fs_in); ast_closestream(fs_in);
ast_module_unref(ast_module_info->self);
return ret; return ret;
} }

@ -1159,11 +1159,6 @@ static void link_configured_disable_marked_lots(void)
disable_marked_lots(); disable_marked_lots();
} }
const struct ast_module_info *parking_get_module_info(void)
{
return ast_module_info;
}
static int unload_module(void) static int unload_module(void)
{ {
unload_parking_bridge_features(); unload_parking_bridge_features();

@ -3650,7 +3650,7 @@ static int load_module(void)
ast_sip_initialize_global_headers(); ast_sip_initialize_global_headers();
if (ast_res_pjsip_initialize_configuration(ast_module_info)) { if (ast_res_pjsip_initialize_configuration()) {
ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n"); ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n");
ast_sip_destroy_global_headers(); ast_sip_destroy_global_headers();
stop_monitor_thread(); stop_monitor_thread();

@ -25,7 +25,7 @@ struct ast_sip_cli_context;
* \internal * \internal
* \brief Initialize the configuration for res_pjsip * \brief Initialize the configuration for res_pjsip
*/ */
int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_module_info); int ast_res_pjsip_initialize_configuration(void);
/*! /*!
* \internal * \internal

@ -1742,7 +1742,7 @@ static struct ast_cli_entry cli_commands[] = {
struct ast_sip_cli_formatter_entry *channel_formatter; struct ast_sip_cli_formatter_entry *channel_formatter;
struct ast_sip_cli_formatter_entry *endpoint_formatter; struct ast_sip_cli_formatter_entry *endpoint_formatter;
int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_module_info) int ast_res_pjsip_initialize_configuration(void)
{ {
if (ast_manager_register_xml(AMI_SHOW_ENDPOINTS, EVENT_FLAG_SYSTEM, ami_show_endpoints) || if (ast_manager_register_xml(AMI_SHOW_ENDPOINTS, EVENT_FLAG_SYSTEM, ami_show_endpoints) ||
ast_manager_register_xml(AMI_SHOW_ENDPOINT, EVENT_FLAG_SYSTEM, ami_show_endpoint)) { ast_manager_register_xml(AMI_SHOW_ENDPOINT, EVENT_FLAG_SYSTEM, ami_show_endpoint)) {

@ -1181,7 +1181,7 @@ int ast_res_pjsip_init_options_handling(int reload)
} }
internal_sip_register_endpoint_formatter(&contact_status_formatter); internal_sip_register_endpoint_formatter(&contact_status_formatter);
ast_manager_register2("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify, NULL, NULL, NULL); ast_manager_register_xml("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify);
ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options)); ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));
qualify_and_schedule_all(); qualify_and_schedule_all();

@ -150,6 +150,8 @@ pbx_ael.c: $(ASTTOPDIR)/pbx/pbx_ael.c
$(CMD_PREFIX) sed 's/ast_debug([[:digit:]][[:digit:]]*/ast_log(LOG_DEBUG/' "$@" > "$@.new" $(CMD_PREFIX) sed 's/ast_debug([[:digit:]][[:digit:]]*/ast_log(LOG_DEBUG/' "$@" > "$@.new"
$(CMD_PREFIX) mv "$@.new" "$@" $(CMD_PREFIX) mv "$@.new" "$@"
pbx_ael.o: _ASTCFLAGS+=-DAST_MODULE_SELF_SYM=__internal_pbx_ael_self
aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@" $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
$(CMD_PREFIX) cp "$<" "$@" $(CMD_PREFIX) cp "$<" "$@"

@ -103,7 +103,7 @@ static char var_dir[PATH_MAX];
const char *ast_config_AST_CONFIG_DIR = config_dir; const char *ast_config_AST_CONFIG_DIR = config_dir;
const char *ast_config_AST_VAR_DIR = var_dir; const char *ast_config_AST_VAR_DIR = var_dir;
void ast_cli_register_multiple(void); void __ast_cli_register_multiple(void);
int ast_add_extension2(struct ast_context *con, int ast_add_extension2(struct ast_context *con,
int replace, const char *extension, int priority, const char *label, const char *callerid, int replace, const char *extension, int priority, const char *label, const char *callerid,
const char *application, void *data, void (*datad)(void *), const char *application, void *data, void (*datad)(void *),
@ -208,7 +208,7 @@ void ast_module_unregister(const struct ast_module_info *x)
} }
void ast_cli_register_multiple(void) void __ast_cli_register_multiple(void)
{ {
if(!no_comp) if(!no_comp)
printf("Executed ast_cli_register_multiple();\n"); printf("Executed ast_cli_register_multiple();\n");

@ -21,8 +21,8 @@ int ast_register_cleanup(void (*func)(void))
return 0; return 0;
} }
int ast_cli_register_multiple(struct ast_cli_entry *e, int len); int __ast_cli_register_multiple(struct ast_cli_entry *e, int len);
int ast_cli_register_multiple(struct ast_cli_entry *e, int len) int __ast_cli_register_multiple(struct ast_cli_entry *e, int len)
{ {
return 0; return 0;
} }

@ -605,9 +605,9 @@ struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts,
return localized_context_find_or_create(extcontexts, exttable, name, registrar); return localized_context_find_or_create(extcontexts, exttable, name, registrar);
} }
void ast_cli_register_multiple(void); void __ast_cli_register_multiple(void);
void ast_cli_register_multiple(void) void __ast_cli_register_multiple(void)
{ {
} }

Loading…
Cancel
Save