On Wednesday 21 February 2007 23:56, Mikael Bjerkeland wrote:

> Great, could you please make a patch with "diff -Naur oldfile newfile >
> app_read.c.patch" and attach it here? I'll make sure it is added. Thanks
> for your help!



Below is a patch. It reverts it back to the asterisk code from 1.2/1.4. I 
can see what the code in openpbx was trying to do but it is flawed and can 
only be done elegantly by adding a new streamfile function that will accept 
multiple files and stream them as one.


--- corelib/app_old.c   2007-02-22 12:03:59.000000000 -0800
+++ corelib/app.c       2007-02-22 11:33:16.000000000 -0800
@@ -110,41 +110,24 @@
    "ludicrous time" (essentially never times out) */
 int opbx_app_getdata(struct opbx_channel *c, char *prompt, char *s, int 
maxlen, int timeout)
 {
-       int res=0;
-       int to,fto;
-       int result=0;
-       /* XXX Merge with full version? XXX */
-       if (maxlen)
-               s[0] = '\0';
-       if (prompt) {
-               char *front;
-               char *temp = opbx_strdupa(prompt);
-               while ( (!res) && (front = strsep(&temp, "&")) ) {
-                       if ( (res = opbx_streamfile(c, front, c->language)) ) {
-                               res = 0;
-                               break;
-                       }
-                       if (!res && !result)
-                               result = opbx_waitstream(c, OPBX_DIGIT_ANY);
-                       if (result)
-                               break;
-                       opbx_stopstream(c);
-               }
-       }
-       fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000;
-       to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
-
-       if (timeout > 0) 
-               fto = to = timeout;
-       if (timeout < 0) 
-               fto = to = 1000000000;
-       res = opbx_readstring(c, s, maxlen, to, fto, "#");
-       if (result) {
-               char tmp[256];
-               snprintf(tmp, sizeof(tmp), "%c%s", result, s);
-               snprintf(s, sizeof(tmp), "%s", tmp);
-       }
-       return res;
+        int res,to,fto;
+        /* XXX Merge with full version? XXX */
+        if (maxlen)
+                s[0] = '\0';
+        if (prompt) {
+                res = opbx_streamfile(c, prompt, c->language);
+                if (res < 0)
+                        return res;
+        }
+        fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000;
+        to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
+
+        if (timeout > 0)
+                fto = to = timeout;
+        if (timeout < 0)
+                fto = to = 1000000000;
+        res = opbx_readstring(c, s, maxlen, to, fto, "#");
+        return res;
 }
 
 
_______________________________________________
Openpbx-dev mailing list
[email protected]
http://lists.openpbx.org/mailman/listinfo/openpbx-dev

Reply via email to