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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed May 17 23:30:41 MST 2006


Author: russell
Date: Thu May 18 01:30:41 2006
New Revision: 28054

URL: http://svn.digium.com/view/asterisk?rev=28054&view=rev
Log:
move a bunch of defines to an enum, remove some unneeded braces, and various
other tiny cleanups

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=28054&r1=28053&r2=28054&view=diff
==============================================================================
--- team/oej/cdr_radius/cdr/cdr_radius.c (original)
+++ team/oej/cdr_radius/cdr/cdr_radius.c Thu May 18 01:30:41 2006
@@ -27,14 +27,13 @@
  * \ingroup cdr_drivers
  */
 
-#include <sys/types.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-
-#include <stdlib.h>
 #include <unistd.h>
 #include <time.h>
+#include <sys/types.h>
 #include <radiusclient-ng.h>
 
 #include "asterisk.h"
@@ -47,29 +46,31 @@
 #include "asterisk/logger.h"
 #include "asterisk/utils.h"
 
-/* ISO 8601 standard format */
+/*! ISO 8601 standard format */
 #define DATE_FORMAT "%Y-%m-%d %T %z"
 
 #define VENDOR_CODE           22736
 
-#define PW_AST_ACCT_CODE      101
-#define PW_AST_SRC            102
-#define PW_AST_DST            103
-#define PW_AST_DST_CTX        104
-#define PW_AST_CLID           105
-#define PW_AST_CHAN           106
-#define PW_AST_DST_CHAN       107
-#define PW_AST_LAST_APP       108
-#define PW_AST_LAST_DATA      109
-#define PW_AST_START_TIME     110
-#define PW_AST_ANSWER_TIME    111
-#define PW_AST_END_TIME       112
-#define PW_AST_DURATION       113
-#define PW_AST_BILL_SEC       114
-#define PW_AST_DISPOSITION    115
-#define PW_AST_AMA_FLAGS      116
-#define PW_AST_UNIQUE_ID      117
-#define PW_AST_USER_FIELD     118
+enum {
+	PW_AST_ACCT_CODE =    101,
+	PW_AST_SRC =          102,
+	PW_AST_DST =          103,
+	PW_AST_DST_CTX =      104,
+	PW_AST_CLID =         105,
+	PW_AST_CHAN =         106,
+	PW_AST_DST_CHAN =     107,
+	PW_AST_LAST_APP =     108,
+	PW_AST_LAST_DATA =    109,
+	PW_AST_START_TIME =   110,
+	PW_AST_ANSWER_TIME =  111,
+	PW_AST_END_TIME =     112,
+	PW_AST_DURATION =     113,
+	PW_AST_BILL_SEC =     114,
+	PW_AST_DISPOSITION =  115,
+	PW_AST_AMA_FLAGS =    116,
+	PW_AST_UNIQUE_ID =    117,
+	PW_AST_USER_FIELD =   118
+};
 
 /*----------------------------------------------------
   The values are as follows (taken from cdr_cdsv.c):
@@ -116,13 +117,11 @@
 
 static int build_radius_record(VALUE_PAIR **send, struct ast_cdr *cdr)
 {
-
-	int aux;
+	int aux = PW_STATUS_STOP;
 	char buf[253];
 	struct tm tm;
 	char timestr[128];
 
-	aux = PW_STATUS_STOP;
 	if (!rc_avpair_add(rh, send, PW_ACCT_STATUS_TYPE, &aux, 0, 0)) {
 		ast_log(LOG_WARNING, "Failed to add VALUE PAIR. RADIUS CDR not recorded!\n");
 		return -1;
@@ -281,17 +280,14 @@
 
 	ast_mutex_lock(&rc_lock);	
 	
-	if (!build_radius_record(&send, cdr)) {
+	if (!build_radius_record(&send, cdr))
 		ast_log(LOG_WARNING, "Unable to create RADIUS record. CDR not recorded!\n");
-	}
 	
 	result = rc_acct(rh, 0, send);
-	if (result == OK_RC) {
+	if (result == OK_RC)
 		ast_log(LOG_NOTICE, "RADIUS CDR recorded.\n");
-	}
-	else {
+	else
 		ast_log(LOG_NOTICE, "Failed to record CDR.\n");
-	}
 
 	ast_mutex_unlock(&rc_lock);
 



More information about the asterisk-commits mailing list