[Asterisk-cvs] asterisk app.c, 1.42, 1.43 cdr.c, 1.27, 1.28 channel.c, 1.163, 1.164

markster at lists.digium.com markster at lists.digium.com
Mon Jan 10 08:42:44 CST 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv31886

Modified Files:
	app.c cdr.c channel.c 
Log Message:
More flagification, courtesy drumkilla (bug #3280)


Index: app.c
===================================================================
RCS file: /usr/cvsroot/asterisk/app.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- app.c	9 Jan 2005 09:01:40 -0000	1.42
+++ app.c	10 Jan 2005 14:46:59 -0000	1.43
@@ -390,7 +390,7 @@
 	return res;
 }
 
-int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char *rev, char *stop, char *pause, int skipms) 
+int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, int skipms) 
 {
 	struct timeval started, ended;
 	long elapsed = 0,last_elapsed =0;
@@ -483,7 +483,7 @@
 	return res;
 }
 
-int ast_play_and_wait(struct ast_channel *chan, char *fn)
+int ast_play_and_wait(struct ast_channel *chan, const char *fn)
 {
 	int d;
 	d = ast_streamfile(chan, fn, chan->language);

Index: cdr.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cdr.c	27 Oct 2004 03:33:14 -0000	1.27
+++ cdr.c	10 Jan 2005 14:46:59 -0000	1.28
@@ -110,7 +110,7 @@
 	while (cdr) {
 		next = cdr->next;
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (!ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' not posted\n", chan);
 		if (!cdr->end.tv_sec && !cdr->end.tv_usec)
 			ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan);
@@ -135,9 +135,9 @@
 {
 	char *chan; 
 	while (cdr) {
-		if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 			if (cdr->start.tv_sec || cdr->start.tv_usec)
 				ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", chan);
@@ -152,7 +152,7 @@
 	char *chan; 
 	while (cdr) {
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 		if (cdr->disposition < AST_CDR_ANSWERED)
 			cdr->disposition = AST_CDR_ANSWERED;
@@ -167,9 +167,9 @@
 {
 	char *chan; 
 	while (cdr) {
-		if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 			if (cdr->disposition < AST_CDR_BUSY)
 				cdr->disposition = AST_CDR_BUSY;
@@ -183,9 +183,9 @@
 	char *chan; 
 	while (cdr) {
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED))
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			cdr->disposition = AST_CDR_FAILED;
 		cdr = cdr->next;
 	}
@@ -221,9 +221,9 @@
 	char *chan; 
 	while (cdr) {
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED))
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			strncpy(cdr->dstchannel, chann, sizeof(cdr->dstchannel) - 1);
 		cdr = cdr->next;
 	}
@@ -233,9 +233,9 @@
 {
 	char *chan; 
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 			if (!app)
 				app = "";
@@ -253,7 +253,7 @@
 	char tmp[AST_MAX_EXTENSION] = "";
 	char *num;
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			/* Grab source from ANI or normal Caller*ID */
 			if (c->cid.cid_ani)
 				num = c->cid.cid_ani;
@@ -285,7 +285,7 @@
 	char *num;
 	char tmp[AST_MAX_EXTENSION] = "";
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
 			if (!ast_strlen_zero(cdr->channel)) 
 				ast_log(LOG_WARNING, "CDR already initialized on '%s'\n", chan); 
@@ -335,7 +335,7 @@
 	char *chan;
 	while (cdr) {
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 		if (!cdr->start.tv_sec && !cdr->start.tv_usec)
 			ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan);
@@ -380,7 +380,7 @@
 
 	strncpy(chan->accountcode, account, sizeof(chan->accountcode) - 1);
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED))
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			strncpy(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode) - 1);
 		cdr = cdr->next;
 	}
@@ -404,7 +404,7 @@
 	struct ast_cdr *cdr = chan->cdr;
 
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) 
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) 
 			strncpy(cdr->userfield, userfield, sizeof(cdr->userfield) - 1);
 		cdr = cdr->next;
 	}
@@ -419,7 +419,7 @@
 	{
 
 		int len = strlen(cdr->userfield);
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED))
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1);
 		cdr = cdr->next;
 	}
@@ -433,7 +433,7 @@
 	char tmp[AST_MAX_EXTENSION] = "";
 	/* Grab source from ANI or normal Caller*ID */
 	while (cdr) {
-		if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
+		if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			/* Grab source from ANI or normal Caller*ID */
 			if (c->cid.cid_ani)
 				num = c->cid.cid_ani;
@@ -491,7 +491,7 @@
 	struct ast_cdr_beitem *i;
 	while (cdr) {
 		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED))
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
 		if (!cdr->end.tv_sec && !cdr->end.tv_usec)
 			ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan);
@@ -502,7 +502,7 @@
 			cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000;
 		} else
 			cdr->billsec = 0;
-		ast_cdr_add_flag(cdr,AST_CDR_FLAG_POSTED);
+		ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
 		ast_mutex_lock(&cdrlock);
 		i = bes;
 		while(i) {
@@ -516,15 +516,16 @@
 
 void ast_cdr_reset(struct ast_cdr *cdr, int flags)
 {
+	struct ast_flags tmp = {flags};
 	while (cdr) {
 		/* Post if requested */
-		if (ast_cdr_compare_flag(flags,AST_CDR_FLAG_LOCKED) || !ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) {
-			if (ast_cdr_compare_flag(flags,AST_CDR_FLAG_POSTED)) {
+		if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+			if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) {
 				ast_cdr_end(cdr);
 				ast_cdr_post(cdr);
 			}
 			/* Reset to initial state */
-			cdr->flags=0;
+			ast_clear_flag(cdr, AST_FLAGS_ALL);	
 			memset(&cdr->start, 0, sizeof(cdr->start));
 			memset(&cdr->end, 0, sizeof(cdr->end));
 			memset(&cdr->answer, 0, sizeof(cdr->answer));

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- channel.c	10 Jan 2005 04:23:39 -0000	1.163
+++ channel.c	10 Jan 2005 14:46:59 -0000	1.164
@@ -2675,9 +2675,9 @@
 	gettimeofday(&start_time,NULL);
 	time_left_ms = config->timelimit;
 
-	if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->start_sound && firstpass)
+	if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->start_sound && firstpass)
 		bridge_playfile(c0,c1,config->start_sound,time_left_ms / 1000);
-	if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->start_sound && firstpass)
+	if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->start_sound && firstpass)
 		bridge_playfile(c1,c0,config->start_sound,time_left_ms / 1000);
 
 	/* Stop if we're a zombie or need a soft hangup */
@@ -2715,7 +2715,7 @@
 			elapsed_ms = tvdiff(&precise_now,&start_time);
 			time_left_ms = config->timelimit - elapsed_ms;
 
-			if (playitagain && ((config->features_caller & AST_FEATURE_PLAY_WARNING) || (config->features_callee & AST_FEATURE_PLAY_WARNING)) && (config->play_warning && time_left_ms <= config->play_warning)) { 
+			if (playitagain && ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) || (ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING))) && (config->play_warning && time_left_ms <= config->play_warning)) { 
 				/* narrowing down to the end */
 				if (config->warning_freq == 0) {
 					playit = 1;
@@ -2731,9 +2731,9 @@
 				}
 			}
 			if (time_left_ms <= 0) {
-				if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->end_sound)
+				if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->end_sound)
 					bridge_playfile(c0,c1,config->end_sound,0);
-				if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->end_sound)
+				if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->end_sound)
 					bridge_playfile(c1,c0,config->end_sound,0);
 				*fo = NULL;
 				if (who) *rc = who;
@@ -2741,9 +2741,9 @@
 				break;
 			}
 			if (time_left_ms >= 5000 && playit) {
-				if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->warning_sound && config->play_warning)
+				if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->warning_sound && config->play_warning)
 					bridge_playfile(c0,c1,config->warning_sound,time_left_ms / 1000);
-				if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->warning_sound && config->play_warning)
+				if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->warning_sound && config->play_warning)
 					bridge_playfile(c1,c0,config->warning_sound,time_left_ms / 1000);
 				playit = 0;
 			}




More information about the svn-commits mailing list