Modules: Additional improvements to CLI completion.

Replace 'needsreload' argument with a 'type' argument to specify which
type of modules you want completion.  This provides more accurate CLI
completion for load and unload commands.

* 'module unload' now excludes modules that have active references or are
  not running.
* 'module load' now excludes modules that are already running.
* 'core set debug [atleast] <level> [module]' shows running modules only.

ASTERISK-27378

Change-Id: Iea3e00054461484196c46f688f02635cc886bad1
This commit is contained in:
Corey Farrell
2017-10-30 18:30:18 -04:00
parent a7c00707a5
commit bfb0f27c87
3 changed files with 133 additions and 52 deletions

View File

@@ -94,6 +94,20 @@ enum ast_module_support_level {
AST_MODULE_SUPPORT_DEPRECATED,
};
/*! Used to specify which modules should be returned by ast_module_helper. */
enum ast_module_helper_type {
/*! Modules that are loaded by dlopen. */
AST_MODULE_HELPER_LOADED = 0,
/*! Running modules that include a reload callback. */
AST_MODULE_HELPER_RELOAD = 1,
/*! Modules that can be loaded or started. */
AST_MODULE_HELPER_LOAD,
/*! Modules that can be unloaded. */
AST_MODULE_HELPER_UNLOAD,
/*! Running modules */
AST_MODULE_HELPER_RUNNING,
};
/*!
* \brief Load a module.
* \param resource_name The name of the module to load.
@@ -237,14 +251,13 @@ int ast_loader_unregister(int (*updater)(void));
* \param state The possible match to return.
* \param rpos The position we should be matching. This should be the same as
* pos.
* \param needsreload This should be 1 if we need to reload this module and 0
* otherwise. This function will only return modules that are reloadble
* if this is 1.
* \param type The type of action that will be performed by CLI.
* This argument accepts values of enum ast_module_helper_type.
*
* \retval A possible completion of the partial match.
* \retval NULL if no matches were found.
*/
char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload);
char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int type);
/* Opaque type for module handles generated by the loader */