[Asterisk-cvs] asterisk channel.c,1.205,1.206

kpfleming at lists.digium.com kpfleming at lists.digium.com
Mon Jun 20 21:15:25 CDT 2005


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

Modified Files:
	channel.c 
Log Message:
add AGI 'RECEIVE TEXT' command (bug #4525)


Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- channel.c	18 Jun 2005 17:18:02 -0000	1.205
+++ channel.c	21 Jun 2005 01:16:18 -0000	1.206
@@ -1652,6 +1652,40 @@
 	}
 }
 
+char *ast_recvtext(struct ast_channel *chan, int timeout)
+{
+	int res,ourto;
+	struct ast_frame *f;
+	char *buf;
+	
+	ourto = timeout;
+	for(;;) {
+		if (ast_check_hangup(chan)) return NULL;
+		res = ast_waitfor(chan,ourto);
+		if (res <= 0) { 
+			/* if timeout */
+			return NULL;
+		}
+		ourto = res;
+		f = ast_read(chan);
+		if (f == NULL) return NULL; /* no frame */
+		if ((f->frametype == AST_FRAME_CONTROL) && 
+			(f->subclass == AST_CONTROL_HANGUP)) return NULL; /* if hangup */
+		if (f->frametype == AST_FRAME_TEXT) {
+			/* if a text frame */
+			buf = (char *)malloc(strlen((char *)f->data));
+			if (buf) {
+				strcpy(buf, (char *)f->data);
+				ast_frfree(f);
+				return(buf);
+		   	} else {
+				return NULL;
+			}
+		}
+		ast_frfree(f);
+	}
+}
+
 int ast_sendtext(struct ast_channel *chan, char *text)
 {
 	int res = 0;




More information about the svn-commits mailing list