[asterisk-commits] branch jcollie/bug7021 r28127 - in /team/jcollie/bug7021: ./ apps/ channels/ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 18 05:33:17 MST 2006


Author: jcollie
Date: Thu May 18 07:33:17 2006
New Revision: 28127

URL: http://svn.digium.com/view/asterisk?rev=28127&view=rev
Log:
Merged revisions 28016-28017,28055-28056,28091,28126 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r28016 | file | 2006-05-17 19:00:32 -0500 (Wed, 17 May 2006) | 2 lines

Add SPRINTF dialplan function made by the ever insaneful Corydon (issue #7078 reported by Corydon76)

........
r28017 | file | 2006-05-17 19:12:54 -0500 (Wed, 17 May 2006) | 2 lines

Fix receiving message count information from a remote IAX2 peer. (issue #7163 reported by and fixed by akohlsmith)

........
r28055 | russell | 2006-05-18 01:41:53 -0500 (Thu, 18 May 2006) | 4 lines

fix file dependency generation so that the resulting files in the subdirectories
are not of zero length (issue #7138, reported/patched by casper, fixed by a
different patch)

........
r28056 | russell | 2006-05-18 01:48:58 -0500 (Thu, 18 May 2006) | 3 lines

force a "make clean" because existing .depend files in the subdirectories
may be bogus

........
r28091 | crichter | 2006-05-18 03:45:43 -0500 (Thu, 18 May 2006) | 1 line

this is not a warning, it might happen during call initialization
........
r28126 | oej | 2006-05-18 07:19:00 -0500 (Thu, 18 May 2006) | 3 lines

Remove unsupported, unimplemented, unfunctional "v" option from meetme documentation
(Imported from 1.2)

........

Modified:
    team/jcollie/bug7021/   (props changed)
    team/jcollie/bug7021/.cleancount
    team/jcollie/bug7021/Makefile
    team/jcollie/bug7021/apps/app_meetme.c
    team/jcollie/bug7021/channels/chan_iax2.c
    team/jcollie/bug7021/channels/misdn/isdn_lib.c
    team/jcollie/bug7021/funcs/func_strings.c

Propchange: team/jcollie/bug7021/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/jcollie/bug7021/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/jcollie/bug7021/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 18 07:33:17 2006
@@ -1,1 +1,1 @@
-/trunk:1-27981
+/trunk:1-28126

Modified: team/jcollie/bug7021/.cleancount
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/.cleancount?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/.cleancount (original)
+++ team/jcollie/bug7021/.cleancount Thu May 18 07:33:17 2006
@@ -1,1 +1,1 @@
-16
+17

Modified: team/jcollie/bug7021/Makefile
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/Makefile?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/Makefile (original)
+++ team/jcollie/bug7021/Makefile Thu May 18 07:33:17 2006
@@ -284,7 +284,8 @@
 endif
 
 MOD_SUBDIRS=res channels pbx apps codecs formats cdr funcs
-SUBDIRS:=$(MOD_SUBDIRS) utils stdtime agi
+OTHER_SUBDIRS=utils stdtime agi
+SUBDIRS:=$(MOD_SUBDIRS) $(OTHER_SUBDIRS)
 
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
 	translate.o file.o pbx.o cli.o md5.o term.o \
@@ -871,7 +872,8 @@
 valgrind: dont-optimize
 
 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h 
-	@for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
+	@for x in $(MOD_SUBDIRS); do CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x depend || exit 1 ; done
+	@for x in $(OTHER_SUBDIRS); do CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x depend || exit 1 ; done
 
 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
 	build_tools/mkdep $(CFLAGS) $(wildcard *.c)

Modified: team/jcollie/bug7021/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/apps/app_meetme.c?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/apps/app_meetme.c (original)
+++ team/jcollie/bug7021/apps/app_meetme.c Thu May 18 07:33:17 2006
@@ -109,7 +109,6 @@
 "      's' -- Present menu (user or admin) when '*' is received ('send' to menu)\n"
 "      't' -- set talk only mode. (Talk only, no listening)\n"
 "      'T' -- set talker detection (sent to manager interface and meetme list)\n"
-"      'v' -- video mode\n"
 "      'w' -- wait until the marked user enters the conference\n"
 "      'x' -- close the conference when last marked user exits\n"
 "      'X' -- allow user to exit the conference by entering a valid single\n"
@@ -233,7 +232,7 @@
 #define CONFFLAG_STARMENU (1 << 4)		/* If set asterisk will provide a menu to the user when '*' is pressed */
 #define CONFFLAG_TALKER (1 << 5)		/* If set the use can only send audio to the conference */
 #define CONFFLAG_QUIET (1 << 6)			/* If set there will be no enter or leave sounds */
-#define CONFFLAG_VIDEO (1 << 7)			/* Set to enable video mode */
+#define CONFFLAG_ANNOUNCEUSERCOUNT (1 << 7)	/* If set, when user joins the conference, they will be told the number of users that are already in */
 #define CONFFLAG_AGI (1 << 8)			/* Set to run AGI Script in Background */
 #define CONFFLAG_MOH (1 << 9)			/* Set to have music on hold when user is alone in conference */
 #define CONFFLAG_MARKEDEXIT (1 << 10)		/* If set the MeetMe will return if all marked with this flag left */
@@ -248,10 +247,9 @@
 #define CONFFLAG_EMPTY (1 << 19)
 #define CONFFLAG_EMPTYNOPIN (1 << 20)
 #define CONFFLAG_ALWAYSPROMPT (1 << 21)
-#define CONFFLAG_ANNOUNCEUSERCOUNT (1 << 22)	/* If set, when user joins the conference, they will be told the number of users that are already in */
-#define CONFFLAG_OPTIMIZETALKER (1 << 23)	/* If set, treats talking users as muted users */
-#define CONFFLAG_NOONLYPERSON (1 << 24)		/* If set, won't speak the extra prompt when the first person enters the conference */
-#define CONFFLAG_INTROUSERNOREVIEW (1 << 25) /* If set, user will be asked to record name on entry of conference without review */
+#define CONFFLAG_OPTIMIZETALKER (1 << 22)	/* If set, treats talking users as muted users */
+#define CONFFLAG_NOONLYPERSON (1 << 23)		/* If set, won't speak the extra prompt when the first person enters the conference */
+#define CONFFLAG_INTROUSERNOREVIEW (1 << 24)	/* If set, user will be asked to record name on entry of conference without review */
 
 AST_APP_OPTIONS(meetme_opts, {
 	AST_APP_OPTION('A', CONFFLAG_MARKEDUSER ),

Modified: team/jcollie/bug7021/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/channels/chan_iax2.c?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/channels/chan_iax2.c (original)
+++ team/jcollie/bug7021/channels/chan_iax2.c Thu May 18 07:33:17 2006
@@ -412,7 +412,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;
@@ -5410,7 +5410,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
 	*/
@@ -5420,12 +5420,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));

Modified: team/jcollie/bug7021/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/channels/misdn/isdn_lib.c?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/channels/misdn/isdn_lib.c (original)
+++ team/jcollie/bug7021/channels/misdn/isdn_lib.c Thu May 18 07:33:17 2006
@@ -2581,7 +2581,7 @@
 		if (r<0) {
 			if (errno == EAGAIN) {
 				/*we wait for mISDN here*/
-				cb_log(-1,0,"mISDN_read wants us to wait\n");
+				cb_log(4,0,"mISDN_read wants us to wait\n");
 				usleep(5000);
 				goto AGAIN;
 			}

Modified: team/jcollie/bug7021/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug7021/funcs/func_strings.c?rev=28127&r1=28126&r2=28127&view=diff
==============================================================================
--- team/jcollie/bug7021/funcs/func_strings.c (original)
+++ team/jcollie/bug7021/funcs/func_strings.c Thu May 18 07:33:17 2006
@@ -207,6 +207,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)
@@ -495,9 +638,11 @@
 	res |= ast_custom_function_unregister(&strptime_function);
 	res |= ast_custom_function_unregister(&eval_function);
 	res |= ast_custom_function_unregister(&keypadhash_function);
+	res |= ast_custom_function_unregister(&sprintf_function);
 #ifdef HAVE_ICONV_H
 	res |= ast_custom_function_unregister(&iconv_function);
 #endif
+
 	return res;
 }
 
@@ -515,9 +660,11 @@
 	res |= ast_custom_function_register(&strptime_function);
 	res |= ast_custom_function_register(&eval_function);
 	res |= ast_custom_function_register(&keypadhash_function);
+	res |= ast_custom_function_register(&sprintf_function);
 #ifdef HAVE_ICONV_H
 	res |= ast_custom_function_register(&iconv_function);
 #endif
+
 	return res;
 }
 



More information about the asterisk-commits mailing list