aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-06 18:31:29 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-06 18:31:29 +0000
commita74f3f93f433594e6ac5a3fef0ea859ebfc43a14 (patch)
tree6514298a4a99d53248d9d2acc4065b9cc8c866d2
parent4b1baec1ef6a8d299c43030c55f9262578258e13 (diff)
add support for per-module version numbers
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5862 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xcli.c15
-rwxr-xr-xfuncs/pbx_functions.c5
-rwxr-xr-xinclude/asterisk/module.h7
-rwxr-xr-xloader.c23
4 files changed, 37 insertions, 13 deletions
diff --git a/cli.c b/cli.c
index 18aadd871..4f1ce103a 100755
--- a/cli.c
+++ b/cli.c
@@ -227,19 +227,18 @@ static int handle_unload(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
-#define MODLIST_FORMAT "%-25s %-40.40s %-10d\n"
-#define MODLIST_FORMAT2 "%-25s %-40.40s %-10s\n"
+#define MODLIST_FORMAT "%-30s %-40.40s %-20.20s %-10d\n"
+#define MODLIST_FORMAT2 "%-30s %-40.40s %-20.20s %-10s\n"
AST_MUTEX_DEFINE_STATIC(climodentrylock);
static int climodentryfd = -1;
-static int modlist_modentry(char *module, char *description, int usecnt, char *like)
+static int modlist_modentry(const char *module, const char *description, int usecnt, const char *version, const char *like)
{
/* Comparing the like with the module */
- if ( strstr(module,like) != NULL) {
- ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
+ if (strstr(module, like) != NULL) {
+ ast_cli(climodentryfd, MODLIST_FORMAT, module, description, version, usecnt);
return 1;
-
}
return 0;
}
@@ -385,8 +384,8 @@ static int handle_modlist(int fd, int argc, char *argv[])
ast_mutex_lock(&climodentrylock);
climodentryfd = fd;
- ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
- ast_cli(fd,"%d modules loaded\n",ast_update_module_list(modlist_modentry,like));
+ ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Version", "Use Count");
+ ast_cli(fd,"%d modules loaded\n", ast_update_module_list(modlist_modentry, like));
climodentryfd = -1;
ast_mutex_unlock(&climodentrylock);
return RESULT_SUCCESS;
diff --git a/funcs/pbx_functions.c b/funcs/pbx_functions.c
index 59925dafd..5171c6271 100755
--- a/funcs/pbx_functions.c
+++ b/funcs/pbx_functions.c
@@ -56,3 +56,8 @@ char *key()
{
return ASTERISK_GPL_KEY;
}
+
+const char *version()
+{
+ return "$Revision$";
+}
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index f1cc115f1..c674d16ae 100755
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -66,6 +66,8 @@ char *key(void); /*! Return the below mentioned key, unmodified */
*/
int reload(void); /*! reload configs */
+const char *version(void);
+
#define ASTERISK_GPL_KEY \
"This paragraph is Copyright (C) 2000, Linux Support Services, Inc. \
In order for your module to load, it must return this key via a function \
@@ -112,9 +114,10 @@ void ast_update_use_count(void);
/*!
* \param modentry a callback to an updater function
* For each of the modules loaded, modentry will be executed with the resource, description,
- * and usecount values of each particular module.
+ * version, and usecount values of each particular module.
*/
-int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt, char *like), char *like);
+int ast_update_module_list(int (*modentry)(const char *module, const char *description, int usecnt, const char *version, const char *like),
+ const char *like);
/*! Ask this procedure to be run with modules have been updated */
/*!
diff --git a/loader.c b/loader.c
index 4403652e4..6c3f9ef21 100755
--- a/loader.c
+++ b/loader.c
@@ -51,6 +51,7 @@ struct module {
char *(*description)(void);
char *(*key)(void);
int (*reload)(void);
+ const char *(*version)(void);
void *lib;
char resource[256];
struct module *next;
@@ -252,6 +253,11 @@ int ast_module_reload(const char *name)
return reloaded;
}
+static const char *unknown_version(void)
+{
+ return "--unknown--";
+}
+
static int __load_resource(const char *resource_name, const struct ast_config *cfg)
{
static char fn[256];
@@ -347,9 +353,17 @@ static int __load_resource(const char *resource_name, const struct ast_config *c
ast_log(LOG_WARNING, "No key routine in module %s\n", fn);
errors++;
}
+
m->reload = dlsym(m->lib, "reload");
if (m->reload == NULL)
m->reload = dlsym(m->lib, "_reload");
+
+ m->version = dlsym(m->lib, "version");
+ if (m->version == NULL)
+ m->version = dlsym(m->lib, "_version");
+ if (m->version == NULL)
+ m->version = unknown_version;
+
if (!m->key || !(key = m->key())) {
ast_log(LOG_WARNING, "Key routine returned NULL in module %s\n", fn);
key = NULL;
@@ -549,20 +563,23 @@ void ast_update_use_count(void)
}
-int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt, char *like), char *like)
+int ast_update_module_list(int (*modentry)(const char *module, const char *description, int usecnt, const char *version, const char *like),
+ const char *like)
{
struct module *m;
int unlock = -1;
int total_mod_loaded = 0;
+
if (ast_mutex_trylock(&modlock))
unlock = 0;
m = module_list;
- while(m) {
- total_mod_loaded += modentry(m->resource, m->description(), m->usecount(), like);
+ while (m) {
+ total_mod_loaded += modentry(m->resource, m->description(), m->usecount(), m->version(), like);
m = m->next;
}
if (unlock)
ast_mutex_unlock(&modlock);
+
return total_mod_loaded;
}