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

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


Author: russell
Date: Thu May 18 20:51:26 2006
New Revision: 28442

URL: http://svn.digium.com/view/asterisk?rev=28442&view=rev
Log:
convert options to use flags

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=28442&r1=28441&r2=28442&view=diff
==============================================================================
--- team/oej/cdr_radius/cdr/cdr_radius.c (original)
+++ team/oej/cdr_radius/cdr/cdr_radius.c Thu May 18 20:51:26 2006
@@ -76,15 +76,22 @@
 	PW_AST_USER_FIELD =   118
 };
 
+enum {
+	/*! Log dates and times in UTC */
+	RADIUS_FLAG_USEGMTIME = (1 << 0),
+	/*! Log Unique ID */
+	RADIUS_FLAG_LOGUNIQUEID = (1 << 1),
+	/*! Log User Field */
+	RADIUS_FLAG_LOGUSERFIELD = (1 << 2)
+};
+
 static char *desc = "RADIUS CDR Backend";
 static char *name = "radius";
 static char *cdr_config = "cdr.conf";
 
 static char radiuscfg[AST_CONFIG_MAX_PATH] = "/etc/radiusclient-ng/radiusclient.conf";
 
-static int global_usegmtime = -1; /*!< log dates and times in UTC */
-static int global_loguniqueid = -1; /*!< log unique id */
-static int global_loguserfield = -1; /*!< log user field */
+static struct ast_flags global_flags = { RADIUS_FLAG_USEGMTIME | RADIUS_FLAG_LOGUNIQUEID | RADIUS_FLAG_LOGUSERFIELD };
 
 static rc_handle *rh = NULL;
 
@@ -165,7 +172,7 @@
 
 
 	/* Start Time */
-	if (global_usegmtime) 
+	if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
 		gmtime_r(&(cdr->start.tv_sec), &tm);
 	else
 		localtime_r(&(cdr->start.tv_sec), &tm);
@@ -176,7 +183,7 @@
 	}
 
 	/* Answer Time */
-	if (global_usegmtime) 
+	if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
 		gmtime_r(&(cdr->answer.tv_sec), &tm);
 	else
 		localtime_r(&(cdr->answer.tv_sec), &tm);
@@ -187,7 +194,7 @@
 	}
 
 	/* End Time */
-	if (global_usegmtime) 
+	if (ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME))
 		gmtime_r(&(cdr->end.tv_sec), &tm);
 	else
 		localtime_r(&(cdr->end.tv_sec), &tm);
@@ -225,7 +232,7 @@
 		return -1;
 	}
 
-	if (global_loguniqueid) {
+	if (ast_test_flag(&global_flags, RADIUS_FLAG_LOGUNIQUEID)) {
 		/* Unique ID */
 		ast_copy_string(buf, cdr->uniqueid, sizeof(buf));
 		if (!rc_avpair_add(rh, send, PW_AST_UNIQUE_ID, &buf, strlen(buf), VENDOR_CODE)) {
@@ -234,7 +241,7 @@
 		}
 	}
 
-	if (global_loguserfield) {
+	if (ast_test_flag(&global_flags, RADIUS_FLAG_LOGUSERFIELD)) {
 		/* append the user field */
 		ast_copy_string(buf, cdr->userfield, sizeof(buf));
 		if (!rc_avpair_add(rh, send, PW_AST_USER_FIELD, &buf, strlen(buf), VENDOR_CODE)) {
@@ -280,9 +287,9 @@
 	char *tmp;
 
 	if ((cfg = ast_config_load(cdr_config))) {
-		global_usegmtime = ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime"));
-		global_loguniqueid = ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid"));
-		global_loguserfield = ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield"));
+		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime")), RADIUS_FLAG_USEGMTIME);
+		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid")), RADIUS_FLAG_LOGUNIQUEID);
+		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield")), RADIUS_FLAG_LOGUSERFIELD);
 		if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
 			ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
 		ast_config_destroy(cfg);



More information about the asterisk-commits mailing list