[Asterisk-cvs] asterisk cli.c,1.84,1.85 loader.c,1.42,1.43

kpfleming at lists.digium.com kpfleming at lists.digium.com
Mon Jun 6 14:29:03 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv9837

Modified Files:
	cli.c loader.c 
Log Message:
add support for per-module version numbers


Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- cli.c	6 Jun 2005 03:04:58 -0000	1.84
+++ cli.c	6 Jun 2005 18:31:29 -0000	1.85
@@ -227,19 +227,18 @@
 	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 @@
 		
 	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;

Index: loader.c
===================================================================
RCS file: /usr/cvsroot/asterisk/loader.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- loader.c	6 Jun 2005 03:04:58 -0000	1.42
+++ loader.c	6 Jun 2005 18:31:29 -0000	1.43
@@ -51,6 +51,7 @@
 	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 @@
 	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 @@
 		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 @@
 	
 }
 
-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;
 }
 




More information about the svn-commits mailing list