[asterisk-commits] branch oej/cdr_radius r28437 - /team/oej/cdr_radius/cdr/cdr_radius.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 18 18:27:48 MST 2006


Author: russell
Date: Thu May 18 20:27:47 2006
New Revision: 28437

URL: http://svn.digium.com/view/asterisk?rev=28437&view=rev
Log:
- don't fail to load if radius.conf is not found, define a default path to the
  radiusclient-ng config file instead
- remove some unneeded code to browse the general context in radius.conf
- remove some unneeded braces and reformat some conditional statements to
  better conform to coding guidelines
- remove the reload function since it didn't do anything

Modified:
    team/oej/cdr_radius/cdr/cdr_radius.c

Modified: team/oej/cdr_radius/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/oej/cdr_radius/cdr/cdr_radius.c?rev=28437&r1=28436&r2=28437&view=diff
==============================================================================
--- team/oej/cdr_radius/cdr/cdr_radius.c (original)
+++ team/oej/cdr_radius/cdr/cdr_radius.c Thu May 18 20:27:47 2006
@@ -109,7 +109,7 @@
 static char *radius_config = "radius.conf";
 static char *cdr_config = "cdr.conf";
 
-static char radiuscfg[AST_CONFIG_MAX_PATH];
+static char radiuscfg[AST_CONFIG_MAX_PATH] = "/etc/radiusclient-ng/radiusclient.conf";
 
 AST_MUTEX_DEFINE_STATIC(rc_lock);
 
@@ -311,54 +311,32 @@
 
 static int load_module(void *mod)
 {
-	int res;
 	struct ast_config *cfg;
-	struct ast_variable *var;
 	char *tmp;
 
-	cfg = ast_config_load(radius_config);
-	if (!cfg) {
-		ast_log(LOG_WARNING,"Unable to load config for RADIUS CDR's: %s\n", radius_config);
-		return 0;
-	}
-	
-	var = ast_variable_browse(cfg, "global");
-	if (!var) {
-		/* nothing configured */
-		return 0;
-	}
-
-	tmp = ast_variable_retrieve(cfg, "global", "radiuscfg");
-	if (tmp) {
-		ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
-	}
-	else {
-		ast_log(LOG_ERROR,"Variable radiuscfg not set in config.\n");
-		return 0;
-	}
-
-	ast_config_destroy(cfg);
-
-	ast_log(LOG_DEBUG,"Got config file for radius client library: %s\n", radiuscfg);
-
+	if ((cfg = ast_config_load(radius_config))) {
+		if ((tmp = ast_variable_retrieve(cfg, "global", "radiuscfg")))
+			ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
+		ast_config_destroy(cfg);
+	}
+	
 	/* start logging */
 	rc_openlog("asterisk");
 
 	/* read radiusclient-ng config file */
-	if ((rh = rc_read_config(radiuscfg)) == NULL) {
+	if (!(rh = rc_read_config(radiuscfg))) {
 		ast_log(LOG_NOTICE, "Cannot load radiusclient-ng configuration file %s.\n", radiuscfg);
 		return -1;
 	}
 
 	/* read radiusclient-ng dictionaries */
-	if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
+	if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))) {
 		ast_log(LOG_NOTICE, "Cannot load radiusclient-ng dictionary file.\n");
 		return -1;
 	}
 
-	cfg = ast_config_load(cdr_config);
-	if (!cfg) {
-		ast_log(LOG_WARNING,"Unable to load config for RADIUS CDR's: %s\n", cdr_config);
+	if (!(cfg = ast_config_load(cdr_config))) {
+		ast_log(LOG_WARNING,"Unable to load CDR config: %s\n", cdr_config);
 		return 0;
 	}
 	
@@ -368,16 +346,7 @@
 		
 	ast_config_destroy(cfg);
 	
-	res = ast_cdr_register(name, desc, radius_log);
-	if (res) {
-		ast_log(LOG_ERROR, "Unable to register RADIUS CDR handling\n");
-	}
-	return res;
-}
-
-static int reload(void *mod)
-{
-	return 0;
+	return ast_cdr_register(name, desc, radius_log);
 }
 
 static const char *key(void)
@@ -385,4 +354,4 @@
 	return ASTERISK_GPL_KEY;
 }
 
-STD_MOD(MOD_0, reload, NULL, NULL);
+STD_MOD(MOD_0, NULL, NULL, NULL);



More information about the asterisk-commits mailing list