[asterisk-commits] branch 1.2 r9581 - in /branches/1.2: ./ include/asterisk/ pbx/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Feb 11 11:15:04 MST 2006


Author: russell
Date: Sat Feb 11 12:15:00 2006
New Revision: 9581

URL: http://svn.digium.com/view/asterisk?rev=9581&view=rev
Log:
now that CDR is a loadable module, don't depend on it elsewhere (issue #6460)

Modified:
    branches/1.2/channel.c
    branches/1.2/include/asterisk/channel.h
    branches/1.2/include/asterisk/manager.h
    branches/1.2/include/asterisk/pbx.h
    branches/1.2/manager.c
    branches/1.2/pbx.c
    branches/1.2/pbx/pbx_spool.c

Modified: branches/1.2/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channel.c?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/channel.c (original)
+++ branches/1.2/channel.c Sat Feb 11 12:15:00 2006
@@ -2381,6 +2381,8 @@
 				ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
 			if (oh->parent_channel)
 				ast_channel_inherit_variables(oh->parent_channel, chan);
+			if (oh->account)
+				ast_cdr_setaccount(chan, oh->account);	
 		}
 		ast_set_callerid(chan, cid_num, cid_name, cid_num);
 

Modified: branches/1.2/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/channel.h?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/include/asterisk/channel.h (original)
+++ branches/1.2/include/asterisk/channel.h Sat Feb 11 12:15:00 2006
@@ -469,6 +469,7 @@
 	oh.priority = priority; \
 	oh.cid_num = cid_num; \
 	oh.cid_name = cid_name; \
+	oh.account = account; \
 	oh.vars = vars; \
 	oh.parent_channel = NULL; \
 } 
@@ -479,6 +480,7 @@
 	int priority;
 	const char *cid_num;
 	const char *cid_name;
+	const char *account;
 	struct ast_variable *vars;
 	struct ast_channel *parent_channel;
 };

Modified: branches/1.2/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/manager.h?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/include/asterisk/manager.h (original)
+++ branches/1.2/include/asterisk/manager.h Sat Feb 11 12:15:00 2006
@@ -56,8 +56,8 @@
 #define EVENT_FLAG_USER                 (1 << 6) /* Ability to read/set user info */
 
 /* Export manager structures */
-#define MAX_HEADERS 80
-#define MAX_LEN 256
+#define AST_MAX_MANHEADERS 80
+#define AST_MAX_MANHEADER_LEN 256
 
 struct eventqent {
 	struct eventqent *next;
@@ -88,7 +88,7 @@
 	/*! Authorization for writing */
 	int writeperm;
 	/*! Buffer */
-	char inbuf[MAX_LEN];
+	char inbuf[AST_MAX_MANHEADER_LEN];
 	int inlen;
 	int send_events;
 	/* Queued events that we've not had the ability to send yet */
@@ -101,7 +101,7 @@
 
 struct message {
 	int hdrcount;
-	char headers[MAX_HEADERS][MAX_LEN];
+	char headers[AST_MAX_MANHEADERS][AST_MAX_MANHEADER_LEN];
 };
 
 struct manager_action {

Modified: branches/1.2/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/pbx.h?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/include/asterisk/pbx.h (original)
+++ branches/1.2/include/asterisk/pbx.h Sat Feb 11 12:15:00 2006
@@ -563,11 +563,11 @@
 
 /* Synchronously or asynchronously make an outbound call and send it to a
    particular extension */
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /* Synchronously or asynchronously make an outbound call and send it to a
    particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /* Functions for returning values from structures */
 const char *ast_get_context_name(struct ast_context *con);

Modified: branches/1.2/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/manager.c?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/manager.c (original)
+++ branches/1.2/manager.c Sat Feb 11 12:15:00 2006
@@ -64,16 +64,17 @@
 #include "asterisk/utils.h"
 
 struct fast_originate_helper {
-	char tech[256];
-	char data[256];
+	char tech[AST_MAX_MANHEADER_LEN];
+	char data[AST_MAX_MANHEADER_LEN];
 	int timeout;
-	char app[256];
-	char appdata[256];
-	char cid_name[256];
-	char cid_num[256];
-	char context[256];
-	char exten[256];
-	char idtext[256];
+	char app[AST_MAX_APP];
+	char appdata[AST_MAX_MANHEADER_LEN];
+	char cid_name[AST_MAX_MANHEADER_LEN];
+	char cid_num[AST_MAX_MANHEADER_LEN];
+	char context[AST_MAX_CONTEXT];
+	char exten[AST_MAX_EXTENSION];
+	char idtext[AST_MAX_MANHEADER_LEN];
+	char account[AST_MAX_ACCOUNT_CODE];
 	int priority;
 	struct ast_variable *vars;
 };
@@ -939,12 +940,12 @@
 		res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, 
 			!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, 
 			!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
-			in->vars, &chan);
+			in->vars, in->account, &chan);
 	} else {
 		res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, 
 			!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, 
 			!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
-			in->vars, &chan);
+			in->vars, in->account, &chan);
 	}   
 	if (!res)
 		manager_event(EVENT_FLAG_CALL,
@@ -1047,12 +1048,6 @@
 		if (ast_strlen_zero(l))
 			l = NULL;
 	}
-	if (account) {
-		struct ast_variable *newvar;
-		newvar = ast_variable_new("CDR(accountcode|r)", account);
-		newvar->next = vars;
-		vars = newvar;
-	}
 	if (ast_true(async)) {
 		struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
 		if (!fast) {
@@ -1072,6 +1067,7 @@
 			fast->vars = vars;	
 			ast_copy_string(fast->context, context, sizeof(fast->context));
 			ast_copy_string(fast->exten, exten, sizeof(fast->exten));
+			ast_copy_string(fast->account, account, sizeof(fast->account));
 			fast->timeout = to;
 			fast->priority = pi;
 			pthread_attr_init(&attr);
@@ -1083,10 +1079,10 @@
 			}
 		}
 	} else if (!ast_strlen_zero(app)) {
-        	res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, NULL);
+        	res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
     	} else {
 		if (exten && context && pi)
-	        	res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, NULL);
+	        	res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
 		else {
 			astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
 			return 0;
@@ -1405,7 +1401,7 @@
 				if (process_message(s, &m))
 					break;
 				memset(&m, 0, sizeof(m));
-			} else if (m.hdrcount < MAX_HEADERS - 1)
+			} else if (m.hdrcount < AST_MAX_MANHEADERS - 1)
 				m.hdrcount++;
 		} else if (res < 0)
 			break;

Modified: branches/1.2/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx.c?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/pbx.c (original)
+++ branches/1.2/pbx.c Sat Feb 11 12:15:00 2006
@@ -4957,7 +4957,7 @@
 	return 0;  /* success */
 }
 
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
 {
 	struct ast_channel *chan;
 	struct async_stat *as;
@@ -4974,7 +4974,7 @@
 				ast_mutex_lock(&chan->lock);
 		}
 		if (chan) {
-			if(chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
+			if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
 				ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
 			} else {
 				chan->cdr = ast_cdr_alloc();   /* allocate a cdr for the channel */
@@ -5051,6 +5051,8 @@
 					ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
 					chan->priority = 1;
 					ast_set_variables(chan, vars);
+					if (account)
+						ast_cdr_setaccount(chan, account);
 					ast_pbx_run(chan);	
 				} else 
 					ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n");
@@ -5080,6 +5082,8 @@
 		as->priority = priority;
 		as->timeout = timeout;
 		ast_set_variables(chan, vars);
+		if (account)
+			ast_cdr_setaccount(chan, account);
 		pthread_attr_init(&attr);
 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 		if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
@@ -5121,7 +5125,7 @@
 	return NULL;
 }
 
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
 {
 	struct ast_channel *chan;
 	struct async_stat *as;
@@ -5129,9 +5133,10 @@
 	int res = -1, cdr_res = -1;
 	struct outgoing_helper oh;
 	pthread_attr_t attr;
-	
+
 	memset(&oh, 0, sizeof(oh));
-	oh.vars = vars;	
+	oh.vars = vars;
+	oh.account = account;	
 
 	if (locked_channel) 
 		*locked_channel = NULL;
@@ -5158,6 +5163,8 @@
 				ast_cdr_start(chan->cdr);
 			}
 			ast_set_variables(chan, vars);
+			if (account)
+				ast_cdr_setaccount(chan, account);
 			if (chan->_state == AST_STATE_UP) {
 				res = 0;
 				if (option_verbose > 3)
@@ -5237,6 +5244,8 @@
 			ast_copy_string(as->appdata,  appdata, sizeof(as->appdata));
 		as->timeout = timeout;
 		ast_set_variables(chan, vars);
+		if (account)
+			ast_cdr_setaccount(chan, account);
 		/* Start a new thread, and get something handling this channel. */
 		pthread_attr_init(&attr);
 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

Modified: branches/1.2/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx/pbx_spool.c?rev=9581&r1=9580&r2=9581&view=diff
==============================================================================
--- branches/1.2/pbx/pbx_spool.c (original)
+++ branches/1.2/pbx/pbx_spool.c Sat Feb 11 12:15:00 2006
@@ -85,6 +85,9 @@
 	/* CallerID Information */
 	char cid_num[256];
 	char cid_name[256];
+
+	/* account code */
+	char account[AST_MAX_ACCOUNT_CODE];
 
 	/* Variables and Functions */
 	struct ast_variable *vars;
@@ -212,11 +215,7 @@
 						ast_log(LOG_WARNING, "Malformed Set: argument! Should be Set: Variable=value\n");
 					}
 				} else if (!strcasecmp(buf, "account")) {
-					var = ast_variable_new("CDR(accountcode|r)", c);
-					if (var) {	
-						var->next = o->vars;
-						o->vars = var;
-					}
+					ast_copy_string(o->account, c, sizeof(o->account));
 				} else {
 					ast_log(LOG_WARNING, "Unknown keyword '%s' at line %d of %s\n", buf, lineno, fn);
 				}
@@ -260,11 +259,11 @@
 	if (!ast_strlen_zero(o->app)) {
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
-		res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
+		res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
 	} else {
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
-		res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
+		res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
 	}
 	if (res) {
 		ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);



More information about the asterisk-commits mailing list