[svn-commits] branch oej/test-this-branch r28053 - in /team/oej/test-this-branch: ./ apps/ ...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed May 17 23:09:55 MST 2006


Author: oej
Date: Thu May 18 01:09:55 2006
New Revision: 28053

URL: http://svn.digium.com/view/asterisk?rev=28053&view=rev
Log:
reset again

Modified:
    team/oej/test-this-branch/   (props changed)
    team/oej/test-this-branch/apps/app_queue.c
    team/oej/test-this-branch/channels/chan_iax2.c
    team/oej/test-this-branch/channels/chan_sip.c
    team/oej/test-this-branch/funcs/func_strings.c

Propchange: team/oej/test-this-branch/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/test-this-branch/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/test-this-branch/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 18 01:09:55 2006
@@ -1,1 +1,1 @@
-/trunk:1-27970
+/trunk:1-28052

Modified: team/oej/test-this-branch/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/apps/app_queue.c?rev=28053&r1=28052&r2=28053&view=diff
==============================================================================
--- team/oej/test-this-branch/apps/app_queue.c (original)
+++ team/oej/test-this-branch/apps/app_queue.c Thu May 18 01:09:55 2006
@@ -1895,11 +1895,10 @@
 	int res;
 
 	if (!qe->parent->autofill) {
-
 		/* Atomically read the parent head -- does not need a lock */
 		ch = qe->parent->head;
 		/* If we are now at the top of the head, break out */
-		if ((ch == qe) || (qe->parent->autofill)) {
+		if (ch == qe) {
 			if (option_debug)
 				ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
 			res = 1;

Modified: team/oej/test-this-branch/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_iax2.c?rev=28053&r1=28052&r2=28053&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_iax2.c (original)
+++ team/oej/test-this-branch/channels/chan_iax2.c Thu May 18 01:09:55 2006
@@ -418,7 +418,7 @@
 	int expire;				/*!< Sched ID of expiration */
 	int refresh;				/*!< How often to refresh */
 	enum iax_reg_state regstate;
-	int messages;				/*!< Message count */
+	int messages;				/*!< Message count, low 8 bits = new, high 8 bits = old */
 	int callno;				/*!< Associated call number if applicable */
 	struct sockaddr_in us;			/*!< Who the server thinks we are */
 	struct iax2_registry *next;
@@ -482,7 +482,10 @@
 	int maxtime;
 	/*! Peer Address */
 	struct sockaddr_in addr;
+	/*! Actual used codec preferences */
 	struct ast_codec_pref prefs;
+	/*! Requested codec preferences */
+	struct ast_codec_pref rprefs;
 	/*! Our call number */
 	unsigned short callno;
 	/*! Peer callno */
@@ -4707,9 +4710,12 @@
 	if (ies->version)
 		version = ies->version;
 
-	if(ies->codec_prefs)
+	/* Use provided preferences until told otherwise for actual preferences */
+	if(ies->codec_prefs) {
+		ast_codec_pref_convert(&iaxs[callno]->rprefs, ies->codec_prefs, 32, 0);
 		ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0);
-	
+	}
+
 	if (!gotcapability) 
 		iaxs[callno]->peercapability = iaxs[callno]->peerformat;
 	if (version > IAX_PROTO_VERSION) {
@@ -5420,7 +5426,7 @@
 		return -1;
 	}
 	memcpy(&reg->us, &us, sizeof(reg->us));
-	reg->messages = ies->msgcount;
+	reg->messages = ies->msgcount & 0xffff;		/* only low 16 bits are used in the transmission of the IE */
 	/* always refresh the registration at the interval requested by the server
 	   we are registering to
 	*/
@@ -5430,12 +5436,12 @@
 	reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
 	if (inaddrcmp(&oldus, &reg->us) || (reg->messages != oldmsgs)) {
 		if (option_verbose > 2) {
-			if (reg->messages > 65534)
-				snprintf(msgstatus, sizeof(msgstatus), " with message(s) waiting\n");
+			if (reg->messages > 255)
+				snprintf(msgstatus, sizeof(msgstatus), " with %d new and %d old messages waiting", reg->messages & 0xff, reg->messages >> 8);
 			else if (reg->messages > 1)
-				snprintf(msgstatus, sizeof(msgstatus), " with %d messages waiting\n", reg->messages);
+				snprintf(msgstatus, sizeof(msgstatus), " with %d new messages waiting\n", reg->messages);
 			else if (reg->messages > 0)
-				snprintf(msgstatus, sizeof(msgstatus), " with 1 message waiting\n");
+				snprintf(msgstatus, sizeof(msgstatus), " with 1 new message waiting\n");
 			else
 				snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n");
 			snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
@@ -6313,7 +6319,7 @@
 	struct iax_frame *duped_fr;
 	char host_pref_buf[128];
 	char caller_pref_buf[128];
-	struct ast_codec_pref pref,rpref;
+	struct ast_codec_pref pref;
 	char *using_prefs = "mine";
 
 	dblbuf[0] = 0;	/* Keep GCC from whining */
@@ -6833,20 +6839,22 @@
 							strcpy(host_pref_buf, "disabled");
 						} else {
 							using_prefs = "mine";
-							if(ies.codec_prefs) {
-								ast_codec_pref_convert(&rpref, ies.codec_prefs, 32, 0);
+							/* If the information elements are in here... use them */
+							if (ies.codec_prefs)
+								ast_codec_pref_convert(&iaxs[fr.callno]->rprefs, ies.codec_prefs, 32, 0);
+							if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
 								/* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/
 								if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
-									pref = rpref;
+									pref = iaxs[fr.callno]->rprefs;
 									using_prefs = "caller";
 								} else {
 									pref = iaxs[fr.callno]->prefs;
 								}
 							} else
 								pref = iaxs[fr.callno]->prefs;
-						
+							
 							format = ast_codec_choose(&pref, iaxs[fr.callno]->capability & iaxs[fr.callno]->peercapability, 0);
-							ast_codec_pref_string(&rpref, caller_pref_buf, sizeof(caller_pref_buf) - 1);
+							ast_codec_pref_string(&iaxs[fr.callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
 							ast_codec_pref_string(&iaxs[fr.callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
 						}
 						if (!format) {
@@ -6877,12 +6885,12 @@
 										strcpy(host_pref_buf,"disabled");
 									} else {
 										using_prefs = "mine";
-										if(ies.codec_prefs) {
+										if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
 											/* Do the opposite of what we tried above. */
 											if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
 												pref = iaxs[fr.callno]->prefs;								
 											} else {
-												pref = rpref;
+												pref = iaxs[fr.callno]->rprefs;
 												using_prefs = "caller";
 											}
 											format = ast_codec_choose(&pref, iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability, 1);
@@ -7235,11 +7243,11 @@
 						strcpy(host_pref_buf, "disabled");
 					} else {
 						using_prefs = "mine";
-						if(ies.codec_prefs) {
-							/* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/
-							ast_codec_pref_convert(&rpref, ies.codec_prefs, 32, 0);
+						if (ies.codec_prefs)
+							ast_codec_pref_convert(&iaxs[fr.callno]->rprefs, ies.codec_prefs, 32, 0);
+						if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
 							if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
-								ast_codec_pref_convert(&pref, ies.codec_prefs, 32, 0);
+								pref = iaxs[fr.callno]->rprefs;
 								using_prefs = "caller";
 							} else {
 								pref = iaxs[fr.callno]->prefs;
@@ -7248,7 +7256,7 @@
 							pref = iaxs[fr.callno]->prefs;
 					
 						format = ast_codec_choose(&pref, iaxs[fr.callno]->capability & iaxs[fr.callno]->peercapability, 0);
-						ast_codec_pref_string(&rpref, caller_pref_buf, sizeof(caller_pref_buf) - 1);
+						ast_codec_pref_string(&iaxs[fr.callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
 						ast_codec_pref_string(&iaxs[fr.callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
 					}
 					if (!format) {
@@ -7282,12 +7290,12 @@
 									strcpy(host_pref_buf,"disabled");
 								} else {
 									using_prefs = "mine";
-									if(ies.codec_prefs) {
+									if (ast_codec_pref_index(&iaxs[fr.callno]->rprefs, 0)) {
 										/* Do the opposite of what we tried above. */
 										if (ast_test_flag(iaxs[fr.callno], IAX_CODEC_USER_FIRST)) {
 											pref = iaxs[fr.callno]->prefs;						
 										} else {
-											pref = rpref;
+											pref = iaxs[fr.callno]->rprefs;
 											using_prefs = "caller";
 										}
 										format = ast_codec_choose(&pref, iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability, 1);

Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=28053&r1=28052&r2=28053&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Thu May 18 01:09:55 2006
@@ -2273,7 +2273,6 @@
 		ast_rtp_destroy(r->vrtp);
 		r->vrtp = NULL;
 	}
-	ast_rtp_setdtmf(r->rtp, ast_test_flag(&r->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 	r->prefs = peer->prefs;
 
 	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT)) {
@@ -2301,11 +2300,13 @@
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", natflags);
 		ast_rtp_setnat(r->rtp, natflags);
+		ast_rtp_setdtmf(r->rtp, ast_test_flag(&r->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 	}
 	if (r->vrtp) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", natflags);
 		ast_rtp_setnat(r->vrtp, natflags);
+		ast_rtp_setdtmf(r->vrtp, 0);
 	}
 	if (r->udptl) {
 		if (option_debug)

Modified: team/oej/test-this-branch/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/funcs/func_strings.c?rev=28053&r1=28052&r2=28053&view=diff
==============================================================================
--- team/oej/test-this-branch/funcs/func_strings.c (original)
+++ team/oej/test-this-branch/funcs/func_strings.c Thu May 18 01:09:55 2006
@@ -203,6 +203,149 @@
 		"Hence, Set(ARRAY(var1,var2)=1,2) will set var1 to 1 and var2 to 2\n"
 		"Note: remember to either backslash your commas in extensions.conf or quote the\n"
 		"entire argument, since Set can take multiple arguments itself.\n",
+};
+
+static int acf_sprintf(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+#define SPRINTF_FLAG	0
+#define SPRINTF_WIDTH	1
+#define SPRINTF_PRECISION	2
+#define SPRINTF_LENGTH	3
+#define SPRINTF_CONVERSION	4
+	int i, state = -1, argcount = 0;
+	char *formatstart = NULL, *bufptr = buf;
+	char formatbuf[256] = "";
+	int tmpi;
+	double tmpd;
+	AST_DECLARE_APP_ARGS(arg,
+				AST_APP_ARG(format);
+				AST_APP_ARG(var)[100];
+	);
+
+	AST_STANDARD_APP_ARGS(arg, data);
+
+	/* Scan the format, converting each argument into the requisite format type. */
+	for (i = 0; arg.format[i]; i++) {
+		switch (state) {
+		case SPRINTF_FLAG:
+			if (strchr("#0- +'I", arg.format[i]))
+				break;
+			state = SPRINTF_WIDTH;
+		case SPRINTF_WIDTH:
+			if (arg.format[i] >= '0' && arg.format[i] <= '9')
+				break;
+
+			/* Next character must be a period to go into a precision */
+			if (arg.format[i] == '.') {
+				state = SPRINTF_PRECISION;
+			} else {
+				state = SPRINTF_LENGTH;
+				i--;
+			}
+			break;
+		case SPRINTF_PRECISION:
+			if (arg.format[i] >= '0' && arg.format[i] <= '9')
+				break;
+			state = SPRINTF_LENGTH;
+		case SPRINTF_LENGTH:
+			if (strchr("hl", arg.format[i])) {
+				if (arg.format[i + 1] == arg.format[i])
+					i++;
+				state = SPRINTF_CONVERSION;
+				break;
+			} else if (strchr("Lqjzt", arg.format[i]))
+				state = SPRINTF_CONVERSION;
+				break;
+			state = SPRINTF_CONVERSION;
+		case SPRINTF_CONVERSION:
+			if (strchr("diouxXc", arg.format[i])) {
+				/* Integer */
+
+				/* Isolate this format alone */
+				ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
+				formatbuf[&arg.format[i] - formatstart + 1] = '\0';
+
+				/* Convert the argument into the required type */
+				if (sscanf(arg.var[argcount++], "%i", &tmpi) != 1) {
+					ast_log(LOG_ERROR, "Argument '%s' is not an integer number for format '%s'\n", arg.var[argcount - 1], formatbuf);
+					goto sprintf_fail;
+				}
+
+				/* Format the argument */
+				snprintf(bufptr, buf + len - bufptr, formatbuf, tmpi);
+
+				/* Update the position of the next parameter to print */
+				bufptr = strchr(buf, '\0');
+			} else if (strchr("eEfFgGaA", arg.format[i])) {
+				/* Double */
+
+				/* Isolate this format alone */
+				ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
+				formatbuf[&arg.format[i] - formatstart + 1] = '\0';
+
+				/* Convert the argument into the required type */
+				if (sscanf(arg.var[argcount++], "%lf", &tmpd) != 1) {
+					ast_log(LOG_ERROR, "Argument '%s' is not a floating point number for format '%s'\n", arg.var[argcount - 1], formatbuf);
+					goto sprintf_fail;
+				}
+
+				/* Format the argument */
+				snprintf(bufptr, buf + len - bufptr, formatbuf, tmpd);
+
+				/* Update the position of the next parameter to print */
+				bufptr = strchr(buf, '\0');
+			} else if (arg.format[i] == 's') {
+				/* String */
+
+				/* Isolate this format alone */
+				ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
+				formatbuf[&arg.format[i] - formatstart + 1] = '\0';
+
+				/* Format the argument */
+				snprintf(bufptr, buf + len - bufptr, formatbuf, arg.var[argcount++]);
+
+				/* Update the position of the next parameter to print */
+				bufptr = strchr(buf, '\0');
+			} else if (arg.format[i] == '%') {
+				/* Literal data to copy */
+				*bufptr++ = arg.format[i];
+			} else {
+				/* Not supported */
+
+				/* Isolate this format alone */
+				ast_copy_string(formatbuf, formatstart, sizeof(formatbuf));
+				formatbuf[&arg.format[i] - formatstart + 1] = '\0';
+
+				ast_log(LOG_ERROR, "Format type not supported: '%s' with argument '%s'\n", formatbuf, arg.var[argcount++]);
+				goto sprintf_fail;
+			}
+			state = -1;
+			break;
+		default:
+			if (arg.format[i] == '%') {
+				state = SPRINTF_FLAG;
+				formatstart = &arg.format[i];
+				break;
+			} else {
+				/* Literal data to copy */
+				*bufptr++ = arg.format[i];
+			}
+		}
+	}
+	return 0;
+sprintf_fail:
+	return -1;
+}
+
+static struct ast_custom_function sprintf_function = {
+	.name = "SPRINTF",
+	.synopsis = "Format a variable according to a format string",
+	.syntax = "SPRINTF(<format>,<arg1>[,...<argN>])",
+	.read = acf_sprintf,
+	.desc =
+"Parses the format string specified and returns a string matching that format.\n"
+"Supports most options supported by sprintf(3).  Returns a shortened string if\n"
+"a format specifier is not recognized.\n",
 };
 
 static int quote(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
@@ -499,6 +642,7 @@
 	res |= ast_custom_function_unregister(&keypadhash_function);
 	res |= ast_custom_function_unregister(&tolower_function);
 	res |= ast_custom_function_unregister(&toupper_function);
+	res |= ast_custom_function_unregister(&sprintf_function);
 
 	return res;
 }
@@ -519,6 +663,7 @@
 	res |= ast_custom_function_register(&keypadhash_function);
         res |= ast_custom_function_register(&tolower_function);
         res |= ast_custom_function_register(&toupper_function);
+	res |= ast_custom_function_register(&sprintf_function);
 
 	return res;
 }



More information about the svn-commits mailing list