[asterisk-commits] file: branch file/cdrbatchretry r38309 - in /team/file/cdrbatchretry: ./ cdr/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jul 26 19:38:54 MST 2006


Author: file
Date: Wed Jul 26 21:38:53 2006
New Revision: 38309

URL: http://svn.digium.com/view/asterisk?rev=38309&view=rev
Log:
Enumify the result values from CDR engines

Modified:
    team/file/cdrbatchretry/cdr.c
    team/file/cdrbatchretry/cdr/cdr_csv.c
    team/file/cdrbatchretry/cdr/cdr_custom.c
    team/file/cdrbatchretry/cdr/cdr_manager.c
    team/file/cdrbatchretry/cdr/cdr_odbc.c
    team/file/cdrbatchretry/cdr/cdr_pgsql.c
    team/file/cdrbatchretry/cdr/cdr_radius.c
    team/file/cdrbatchretry/cdr/cdr_sqlite.c
    team/file/cdrbatchretry/cdr/cdr_tds.c
    team/file/cdrbatchretry/include/asterisk/cdr.h

Modified: team/file/cdrbatchretry/cdr.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr.c (original)
+++ team/file/cdrbatchretry/cdr.c Wed Jul 26 21:38:53 2006
@@ -794,10 +794,11 @@
 static void *do_batch_backend_process(void *data)
 {
 	char *chan = NULL;
-	int res = AST_CDR_ENGINE_SUCCESS, defer = 0;
+	int defer = 0;
 	struct ast_cdr_batch_item *batch_item = data;
 	struct ast_cdr_beitem *be = NULL;
 	AST_LIST_HEAD_NOLOCK(local_batch_list, ast_cdr_batch_item) local_batch_list;
+	enum ast_cdr_engine_result res = AST_CDR_ENGINE_SUCCESS;
 
 	if (!batch_item) {
 		return NULL;

Modified: team/file/cdrbatchretry/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_csv.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_csv.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_csv.c Wed Jul 26 21:38:53 2006
@@ -278,7 +278,7 @@
 }
 
 
-static int csv_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result csv_log(struct ast_cdr *cdr)
 {
 	/* Make sure we have a big enough buf */
 	char buf[1024];

Modified: team/file/cdrbatchretry/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_custom.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_custom.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_custom.c Wed Jul 26 21:38:53 2006
@@ -105,7 +105,7 @@
 
 
 
-static int custom_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result custom_log(struct ast_cdr *cdr)
 {
 	/* Make sure we have a big enough buf */
 	char buf[2048];

Modified: team/file/cdrbatchretry/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_manager.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_manager.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_manager.c Wed Jul 26 21:38:53 2006
@@ -83,7 +83,7 @@
 	ast_config_destroy(cfg);
 }
 
-static int manager_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result manager_log(struct ast_cdr *cdr)
 {
 	time_t t;
 	struct tm timeresult;

Modified: team/file/cdrbatchretry/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_odbc.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_odbc.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_odbc.c Wed Jul 26 21:38:53 2006
@@ -90,7 +90,7 @@
 	connected = 0;
 }
 
-static int odbc_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result odbc_log(struct ast_cdr *cdr)
 {
 	int ODBC_res;
 	char sqlcmd[2048] = "", timestr[128];

Modified: team/file/cdrbatchretry/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_pgsql.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_pgsql.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_pgsql.c Wed Jul 26 21:38:53 2006
@@ -70,7 +70,7 @@
 static PGconn	*conn;
 static PGresult	*result;
 
-static int pgsql_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result pgsql_log(struct ast_cdr *cdr)
 {
 	struct tm tm;
 	char sqlcmd[2048] = "", timestr[128];

Modified: team/file/cdrbatchretry/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_radius.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_radius.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_radius.c Wed Jul 26 21:38:53 2006
@@ -211,9 +211,10 @@
 	return AST_CDR_ENGINE_SUCCESS;
 }
 
-static int radius_log(struct ast_cdr *cdr)
-{
-	int result = ERROR_RC, res = AST_CDR_ENGINE_SUCCESS;
+static enum ast_cdr_engine_result radius_log(struct ast_cdr *cdr)
+{
+	int result = ERROR_RC;
+	enum ast_cdr_engine_result res = AST_CDR_ENGINE_SUCCESS;
 	VALUE_PAIR *send = NULL;
 
 	res = build_radius_record(&send, cdr);
@@ -224,10 +225,12 @@
 	}
 	
 	result = rc_acct(rh, 0, send);
-	if (result != OK_RC)
+	if (result != OK_RC) {
 		ast_log(LOG_ERROR, "Failed to record Radius CDR record!\n");
-
-	return result;
+		res = AST_CDR_ENGINE_FAILED;
+	}
+
+	return res;
 }
 
 static const char *description(void)

Modified: team/file/cdrbatchretry/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_sqlite.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_sqlite.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_sqlite.c Wed Jul 26 21:38:53 2006
@@ -90,7 +90,7 @@
 #endif
 ");";
 
-static int sqlite_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result sqlite_log(struct ast_cdr *cdr)
 {
 	int res = 0;
 	char *zErr = 0;

Modified: team/file/cdrbatchretry/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr/cdr_tds.c?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr/cdr_tds.c (original)
+++ team/file/cdrbatchretry/cdr/cdr_tds.c Wed Jul 26 21:38:53 2006
@@ -109,7 +109,7 @@
 static int mssql_connect(void);
 static int mssql_disconnect(void);
 
-static int tds_log(struct ast_cdr *cdr)
+static enum ast_cdr_engine_result tds_log(struct ast_cdr *cdr)
 {
 	char sqlcmd[2048], start[80], answer[80], end[80];
 	char *accountcode, *src, *dst, *dcontext, *clid, *channel, *dstchannel, *lastapp, *lastdata, *uniqueid;

Modified: team/file/cdrbatchretry/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/include/asterisk/cdr.h?rev=38309&r1=38308&r2=38309&view=diff
==============================================================================
--- team/file/cdrbatchretry/include/asterisk/cdr.h (original)
+++ team/file/cdrbatchretry/include/asterisk/cdr.h Wed Jul 26 21:38:53 2006
@@ -45,14 +45,16 @@
 #define AST_MAX_ACCOUNT_CODE			20
 
 /*! Engine posting return values */
-/*! Engine was successful with posting the record */
-#define AST_CDR_ENGINE_SUCCESS                  0
-/*! Engine was unwilling to post this record and it should be retried later */
-#define AST_CDR_ENGINE_DEFER                    1
-/*! Engine failed to post CDR record */
-#define AST_CDR_ENGINE_FAILED                   2
-/*! Engine failed to post CDR record and never will be able to */
-#define AST_CDR_ENGINE_DISCARD                  3
+enum ast_cdr_engine_result {
+	/*! Engine was successful with posting the record */
+	AST_CDR_ENGINE_SUCCESS = 0,
+        /*! Engine was unwilling to post this record and it should be retried later */
+	AST_CDR_ENGINE_DEFER,
+	/*! Engine failed to post CDR record */
+	AST_CDR_ENGINE_FAILED,
+        /*! Engine failed to post CDR record and never will be able to */
+	AST_CDR_ENGINE_DISCARD,
+};
 
 /* Include channel.h after relevant declarations it will need */
 #include "asterisk/channel.h"
@@ -113,7 +115,7 @@
 void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
 int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
 
-typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
+typedef enum ast_cdr_engine_result (*ast_cdrbe)(struct ast_cdr *cdr);
 
 /*! \brief Allocate a CDR record 
  * Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)



More information about the asterisk-commits mailing list