[asterisk-commits] trunk r9582 - in /trunk: ./ include/asterisk/ pbx/ res/

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


Author: russell
Date: Sat Feb 11 12:31:59 2006
New Revision: 9582

URL: http://svn.digium.com/view/asterisk?rev=9582&view=rev
Log:
Merged revisions 9581 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r9581 | russell | 2006-02-11 13:15:00 -0500 (Sat, 11 Feb 2006) | 2 lines

now that CDR is a loadable module, don't depend on it elsewhere (issue #6460)

........

Modified:
    trunk/   (props changed)
    trunk/channel.c
    trunk/include/asterisk/channel.h
    trunk/include/asterisk/manager.h
    trunk/include/asterisk/pbx.h
    trunk/manager.c
    trunk/pbx.c
    trunk/pbx/pbx_spool.c
    trunk/res/res_clioriginate.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Sat Feb 11 12:31:59 2006
@@ -2434,6 +2434,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: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Sat Feb 11 12:31:59 2006
@@ -481,6 +481,7 @@
 	oh.priority = priority; \
 	oh.cid_num = cid_num; \
 	oh.cid_name = cid_name; \
+	oh.account = account; \
 	oh.vars = vars; \
 	oh.parent_channel = NULL; \
 } 
@@ -491,6 +492,7 @@
 	int priority;
 	const char *cid_num;
 	const char *cid_name;
+	const char *account;
 	struct ast_variable *vars;
 	struct ast_channel *parent_channel;
 };

Modified: trunk/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/manager.h?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/include/asterisk/manager.h (original)
+++ trunk/include/asterisk/manager.h Sat Feb 11 12:31:59 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: trunk/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/pbx.h?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/include/asterisk/pbx.h (original)
+++ trunk/include/asterisk/pbx.h Sat Feb 11 12:31:59 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: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Sat Feb 11 12:31:59 2006
@@ -66,16 +66,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;
 };
@@ -949,12 +950,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);
 	}   
 	
 	/* Tell the manager what happened with the channel */
@@ -1056,12 +1057,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) {
@@ -1081,6 +1076,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);
@@ -1092,10 +1088,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;
@@ -1414,7 +1410,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: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Sat Feb 11 12:31:59 2006
@@ -4649,7 +4649,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;
@@ -4666,7 +4666,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 */
@@ -4743,6 +4743,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");
@@ -4772,6 +4774,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)) {
@@ -4813,7 +4817,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;
@@ -4821,9 +4825,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;
@@ -4850,6 +4855,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)
@@ -4929,6 +4936,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: trunk/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_spool.c?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/pbx/pbx_spool.c (original)
+++ trunk/pbx/pbx_spool.c Sat Feb 11 12:31:59 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;
@@ -211,11 +214,7 @@
 					} else
 						ast_log(LOG_WARNING, "Malformed \"%s\" argument.  Should be \"%s: variable=value\"\n", buf, buf);
 				} 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);
 				}
@@ -259,11 +258,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);

Modified: trunk/res/res_clioriginate.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_clioriginate.c?rev=9582&r1=9581&r2=9582&view=diff
==============================================================================
--- trunk/res/res_clioriginate.c (original)
+++ trunk/res/res_clioriginate.c Sat Feb 11 12:31:59 2006
@@ -88,7 +88,7 @@
 		return RESULT_SHOWUSAGE;
 	}
 
-	ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 1, NULL, NULL, NULL, NULL);
+	ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 1, NULL, NULL, NULL, NULL, NULL);
 
 	return RESULT_SUCCESS;
 }
@@ -122,7 +122,7 @@
 	if (ast_strlen_zero(context))
 		context = "default";
 	
-	ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 1, NULL, NULL, NULL, NULL);
+	ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 1, NULL, NULL, NULL, NULL, NULL);
 
 	return RESULT_SUCCESS;
 }



More information about the asterisk-commits mailing list