From 85fc8c37e7fb48c6bcc1ad28dc332f5db265ab1c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 May 2008 19:03:57 +0000 Subject: [PATCH] fix bad pointer memory snafu in wrapped language libs git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8238 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/lua/mwi_event.lua | 2 +- scripts/lua/originate.lua | 2 +- src/include/switch_cpp.h | 17 +- .../src/org/freeswitch/swig/CoreSession.java | 8 +- .../org/freeswitch/swig/freeswitchJNI.java | 4 +- .../languages/mod_java/switch_swig_wrap.cpp | 88 ++++----- src/mod/languages/mod_lua/mod_lua_wrap.cpp | 61 +++---- src/mod/languages/mod_perl/mod_perl_wrap.cpp | 128 +++++-------- .../languages/mod_python/mod_python_wrap.cpp | 169 ++++++------------ src/switch_cpp.cpp | 41 +++-- src/switch_ivr_play_say.c | 2 +- 11 files changed, 195 insertions(+), 327 deletions(-) diff --git a/scripts/lua/mwi_event.lua b/scripts/lua/mwi_event.lua index 14c77f9fcc..6ce5fc0810 100644 --- a/scripts/lua/mwi_event.lua +++ b/scripts/lua/mwi_event.lua @@ -3,6 +3,6 @@ freeswitch.console_log("info", "Lua in da house!!!\n"); local event = freeswitch.Event("message_waiting"); -event:addHeader("MWI-Messages-Waiting", "yes"); +event:addHeader("MWI-Messages-Waiting", "no"); event:addHeader("MWI-Message-Account", "sip:1000@10.0.1.100"); event:fire(); diff --git a/scripts/lua/originate.lua b/scripts/lua/originate.lua index 3ac8cfcd29..a3312b32b5 100644 --- a/scripts/lua/originate.lua +++ b/scripts/lua/originate.lua @@ -1,6 +1,6 @@ -- Example Lua script to originate. luarun freeswitch.console_log("info", "Lua in da house!!!\n"); -local session = freeswitch.Session("sofia/10.0.1.100/1002"); +local session = freeswitch.Session("sofia/10.0.1.100/1001"); session:execute("playback", "/sr8k.wav"); session:hangup(); diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 4c84b67b8c..41171a1f7a 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -140,6 +140,7 @@ class CoreSession { void *on_hangup; // language specific callback function, cast as void * switch_file_handle_t local_fh; switch_file_handle_t *fhp; + char dtmf_buf[512]; SWITCH_DECLARE(switch_status_t) process_callback_result(char *ret); public: SWITCH_DECLARE_CONSTRUCTOR CoreSession(); @@ -219,13 +220,12 @@ class CoreSession { * (see mod_python.i). This does NOT call any callbacks upon * receiving dtmf digits. For that, use collectDigits. */ - SWITCH_DECLARE(int) getDigits(char *dtmf_buf, - switch_size_t buflen, - switch_size_t maxdigits, - char *terminators, - char *terminator, - int timeout); - + SWITCH_DECLARE(char *) getDigits( + switch_size_t maxdigits, + char *terminators, + char *terminator, + int timeout); + SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context); /** \brief Play a file into channel and collect dtmfs @@ -236,14 +236,13 @@ class CoreSession { * setDTMFCallback(..) as it uses its own internal callback * handler. */ - SWITCH_DECLARE(int) playAndGetDigits(int min_digits, + SWITCH_DECLARE(char *) playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, - char *dtmf_buf, char *digits_regex); /** \brief Play a file that resides on disk into the channel diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java index d733c65023..5808bd20ef 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java @@ -161,16 +161,16 @@ public class CoreSession { return freeswitchJNI.CoreSession_collectDigits(swigCPtr, this, timeout); } - public int getDigits(byte[] dtmf_buf, SWIGTYPE_p_switch_size_t buflen, SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) { - return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, dtmf_buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen), SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout); + public String getDigits(SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) { + return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout); } public int transfer(String extensions, String dialplan, String context) { return freeswitchJNI.CoreSession_transfer(swigCPtr, this, extensions, dialplan, context); } - public int playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, byte[] dtmf_buf, String digits_regex) { - return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, dtmf_buf, digits_regex); + public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) { + return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex); } public int streamFile(String file, int starting_sample_count) { diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index 4e9614cc68..f0a65d7190 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -87,9 +87,9 @@ class freeswitchJNI { public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2); public final static native void CoreSession_set_tts_parms(long jarg1, CoreSession jarg1_, String jarg2, String jarg3); public final static native int CoreSession_collectDigits(long jarg1, CoreSession jarg1_, int jarg2); - public final static native int CoreSession_getDigits(long jarg1, CoreSession jarg1_, byte[] jarg2, long jarg3, long jarg4, String jarg5, byte[] jarg6, int jarg7); + public final static native String CoreSession_getDigits(long jarg1, CoreSession jarg1_, long jarg2, String jarg3, byte[] jarg4, int jarg5); public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4); - public final static native int CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, byte[] jarg9, String jarg10); + public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9); public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3); public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2); public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_); diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index 3c324d0f40..3c4ba2e597 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -1576,59 +1576,42 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1coll } -SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jbyteArray jarg2, jlong jarg3, jlong jarg4, jstring jarg5, jbyteArray jarg6, jint jarg7) { - jint jresult = 0 ; +SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jstring jarg3, jbyteArray jarg4, jint jarg5) { + jstring jresult = 0 ; CoreSession *arg1 = (CoreSession *) 0 ; - char *arg2 = (char *) 0 ; - switch_size_t arg3 ; - switch_size_t arg4 ; - char *arg5 = (char *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - int result; - switch_size_t *argp3 ; - switch_size_t *argp4 ; + switch_size_t arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + char *result = 0 ; + switch_size_t *argp2 ; (void)jenv; (void)jcls; (void)jarg1_; arg1 = *(CoreSession **)&jarg1; - { - arg2 = (char*) jenv->GetByteArrayElements(jarg2, 0); - if (!arg2) return 0; - } - argp3 = *(switch_size_t **)&jarg3; - if (!argp3) { + argp2 = *(switch_size_t **)&jarg2; + if (!argp2) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null switch_size_t"); return 0; } - arg3 = *argp3; - argp4 = *(switch_size_t **)&jarg4; - if (!argp4) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null switch_size_t"); - return 0; - } - arg4 = *argp4; - arg5 = 0; - if (jarg5) { - arg5 = (char *)jenv->GetStringUTFChars(jarg5, 0); - if (!arg5) return 0; + arg2 = *argp2; + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; } { - arg6 = (char*) jenv->GetByteArrayElements(jarg6, 0); - if (!arg6) return 0; + arg4 = (char*) jenv->GetByteArrayElements(jarg4, 0); + if (!arg4) return 0; } - arg7 = (int)jarg7; - result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7); - jresult = (jint)result; + arg5 = (int)jarg5; + result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5); + if(result) jresult = jenv->NewStringUTF((const char *)result); { - jenv->ReleaseByteArrayElements(jarg2, (jbyte*) arg2, 0); + jenv->ReleaseByteArrayElements(jarg4, (jbyte*) arg4, 0); } - { - jenv->ReleaseByteArrayElements(jarg6, (jbyte*) arg6, 0); - } - - if (arg5) jenv->ReleaseStringUTFChars(jarg5, (const char *)arg5); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); return jresult; } @@ -1670,8 +1653,8 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1tran } -SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jbyteArray jarg9, jstring jarg10) { - jint jresult = 0 ; +SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) { + jstring jresult = 0 ; CoreSession *arg1 = (CoreSession *) 0 ; int arg2 ; int arg3 ; @@ -1681,8 +1664,7 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1play char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; char *arg9 = (char *) 0 ; - char *arg10 = (char *) 0 ; - int result; + char *result = 0 ; (void)jenv; (void)jcls; @@ -1707,25 +1689,17 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1play arg8 = (char *)jenv->GetStringUTFChars(jarg8, 0); if (!arg8) return 0; } - { - arg9 = (char*) jenv->GetByteArrayElements(jarg9, 0); + arg9 = 0; + if (jarg9) { + arg9 = (char *)jenv->GetStringUTFChars(jarg9, 0); if (!arg9) return 0; } - arg10 = 0; - if (jarg10) { - arg10 = (char *)jenv->GetStringUTFChars(jarg10, 0); - if (!arg10) return 0; - } - result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); - jresult = (jint)result; - { - jenv->ReleaseByteArrayElements(jarg9, (jbyte*) arg9, 0); - } + result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + if(result) jresult = jenv->NewStringUTF((const char *)result); if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6); if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7); if (arg8) jenv->ReleaseStringUTFChars(jarg8, (const char *)arg8); - - if (arg10) jenv->ReleaseStringUTFChars(jarg10, (const char *)arg10); + if (arg9) jenv->ReleaseStringUTFChars(jarg9, (const char *)arg9); return jresult; } diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index a1f1c308bb..98cc6fdccc 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -4097,48 +4097,36 @@ fail: static int _wrap_CoreSession_getDigits(lua_State* L) { int SWIG_arg = -1; CoreSession *arg1 = (CoreSession *) 0 ; - char *arg2 = (char *) 0 ; - switch_size_t arg3 ; - switch_size_t arg4 ; - char *arg5 = (char *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - int result; - switch_size_t *argp3 ; - switch_size_t *argp4 ; + switch_size_t arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + char *result = 0 ; + switch_size_t *argp2 ; - SWIG_check_num_args("getDigits",7,7) + SWIG_check_num_args("getDigits",5,5) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getDigits",1,"CoreSession *"); - if(!lua_isstring(L,2)) SWIG_fail_arg("getDigits",2,"char *"); - if(!lua_isuserdata(L,3)) SWIG_fail_arg("getDigits",3,"switch_size_t"); - if(!lua_isuserdata(L,4)) SWIG_fail_arg("getDigits",4,"switch_size_t"); - if(!lua_isstring(L,5)) SWIG_fail_arg("getDigits",5,"char *"); - if(!lua_isstring(L,6)) SWIG_fail_arg("getDigits",6,"char *"); - if(!lua_isnumber(L,7)) SWIG_fail_arg("getDigits",7,"int"); + if(!lua_isuserdata(L,2)) SWIG_fail_arg("getDigits",2,"switch_size_t"); + if(!lua_isstring(L,3)) SWIG_fail_arg("getDigits",3,"char *"); + if(!lua_isstring(L,4)) SWIG_fail_arg("getDigits",4,"char *"); + if(!lua_isnumber(L,5)) SWIG_fail_arg("getDigits",5,"int"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){ SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession); } - arg2 = (char *)lua_tostring(L, 2); - if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_size_t,0))){ - SWIG_fail_ptr("CoreSession_getDigits",3,SWIGTYPE_p_switch_size_t); + if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_size_t,0))){ + SWIG_fail_ptr("CoreSession_getDigits",2,SWIGTYPE_p_switch_size_t); } - arg3 = *argp3; + arg2 = *argp2; - - if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&argp4,SWIGTYPE_p_switch_size_t,0))){ - SWIG_fail_ptr("CoreSession_getDigits",4,SWIGTYPE_p_switch_size_t); - } - arg4 = *argp4; - - arg5 = (char *)lua_tostring(L, 5); - arg6 = (char *)lua_tostring(L, 6); - arg7 = (int)lua_tonumber(L, 7); - result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7); + arg3 = (char *)lua_tostring(L, 3); + arg4 = (char *)lua_tostring(L, 4); + arg5 = (int)lua_tonumber(L, 5); + result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5); SWIG_arg=0; - lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + lua_pushstring(L,(const char*)result); SWIG_arg++; return SWIG_arg; if(0) SWIG_fail; @@ -4194,10 +4182,9 @@ static int _wrap_CoreSession_playAndGetDigits(lua_State* L) { char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; char *arg9 = (char *) 0 ; - char *arg10 = (char *) 0 ; - int result; + char *result = 0 ; - SWIG_check_num_args("playAndGetDigits",10,10) + SWIG_check_num_args("playAndGetDigits",9,9) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("playAndGetDigits",1,"CoreSession *"); if(!lua_isnumber(L,2)) SWIG_fail_arg("playAndGetDigits",2,"int"); if(!lua_isnumber(L,3)) SWIG_fail_arg("playAndGetDigits",3,"int"); @@ -4207,7 +4194,6 @@ static int _wrap_CoreSession_playAndGetDigits(lua_State* L) { if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *"); if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *"); if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *"); - if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){ SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession); @@ -4221,10 +4207,9 @@ static int _wrap_CoreSession_playAndGetDigits(lua_State* L) { arg7 = (char *)lua_tostring(L, 7); arg8 = (char *)lua_tostring(L, 8); arg9 = (char *)lua_tostring(L, 9); - arg10 = (char *)lua_tostring(L, 10); - result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); SWIG_arg=0; - lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + lua_pushstring(L,(const char*)result); SWIG_arg++; return SWIG_arg; if(0) SWIG_fail; diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index 649f334790..1ef7a95b79 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -5223,96 +5223,71 @@ XS(_wrap_CoreSession_collectDigits) { XS(_wrap_CoreSession_getDigits) { { CoreSession *arg1 = (CoreSession *) 0 ; - char *arg2 = (char *) 0 ; - switch_size_t arg3 ; - switch_size_t arg4 ; - char *arg5 = (char *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - int result; + switch_size_t arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 ; - int res3 = 0 ; - void *argp4 ; - int res4 = 0 ; - int res5 ; - char *buf5 = 0 ; - int alloc5 = 0 ; - int res6 ; - char *buf6 = 0 ; - int alloc6 = 0 ; - int val7 ; - int ecode7 = 0 ; + void *argp2 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int val5 ; + int ecode5 = 0 ; int argvi = 0; dXSARGS; - if ((items < 7) || (items > 7)) { - SWIG_croak("Usage: CoreSession_getDigits(self,dtmf_buf,buflen,maxdigits,terminators,terminator,timeout);"); + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: CoreSession_getDigits(self,maxdigits,terminators,terminator,timeout);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'"); } arg1 = reinterpret_cast< CoreSession * >(argp1); - res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *""'"); - } - arg2 = reinterpret_cast< char * >(buf2); { - res3 = SWIG_ConvertPtr(ST(2), &argp3, SWIGTYPE_p_switch_size_t, 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'"); + res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_switch_size_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'"); } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'"); + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'"); } else { - arg3 = *(reinterpret_cast< switch_size_t * >(argp3)); + arg2 = *(reinterpret_cast< switch_size_t * >(argp2)); } } - { - res4 = SWIG_ConvertPtr(ST(3), &argp4, SWIGTYPE_p_switch_size_t, 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'"); - } else { - arg4 = *(reinterpret_cast< switch_size_t * >(argp4)); - } + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'"); } - res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'"); + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *""'"); } - arg5 = reinterpret_cast< char * >(buf5); - res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "char *""'"); - } - arg6 = reinterpret_cast< char * >(buf6); - ecode7 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(6), &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "CoreSession_getDigits" "', argument " "7"" of type '" "int""'"); + arg4 = reinterpret_cast< char * >(buf4); + ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "int""'"); } - arg7 = static_cast< int >(val7); - result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7); - ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + arg5 = static_cast< int >(val5); + result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; XSRETURN(argvi); fail: - if (alloc2 == SWIG_NEWOBJ) delete[] buf2; - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; - if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; SWIG_croak_null(); } @@ -5391,8 +5366,7 @@ XS(_wrap_CoreSession_playAndGetDigits) { char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; char *arg9 = (char *) 0 ; - char *arg10 = (char *) 0 ; - int result; + char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; @@ -5415,14 +5389,11 @@ XS(_wrap_CoreSession_playAndGetDigits) { int res9 ; char *buf9 = 0 ; int alloc9 = 0 ; - int res10 ; - char *buf10 = 0 ; - int alloc10 = 0 ; int argvi = 0; dXSARGS; - if ((items < 10) || (items > 10)) { - SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,dtmf_buf,digits_regex);"); + if ((items < 9) || (items > 9)) { + SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 ); if (!SWIG_IsOK(res1)) { @@ -5469,13 +5440,8 @@ XS(_wrap_CoreSession_playAndGetDigits) { SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'"); } arg9 = reinterpret_cast< char * >(buf9); - res10 = SWIG_AsCharPtrAndSize(ST(9), &buf10, NULL, &alloc10); - if (!SWIG_IsOK(res10)) { - SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'"); - } - arg10 = reinterpret_cast< char * >(buf10); - result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); - ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ; @@ -5485,7 +5451,6 @@ XS(_wrap_CoreSession_playAndGetDigits) { if (alloc7 == SWIG_NEWOBJ) delete[] buf7; if (alloc8 == SWIG_NEWOBJ) delete[] buf8; if (alloc9 == SWIG_NEWOBJ) delete[] buf9; - if (alloc10 == SWIG_NEWOBJ) delete[] buf10; XSRETURN(argvi); fail: @@ -5497,7 +5462,6 @@ XS(_wrap_CoreSession_playAndGetDigits) { if (alloc7 == SWIG_NEWOBJ) delete[] buf7; if (alloc8 == SWIG_NEWOBJ) delete[] buf8; if (alloc9 == SWIG_NEWOBJ) delete[] buf9; - if (alloc10 == SWIG_NEWOBJ) delete[] buf10; SWIG_croak_null(); } } diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index a2c21c8e7b..723dee7dab 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -5631,112 +5631,77 @@ fail: SWIGINTERN PyObject *_wrap_CoreSession_getDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; CoreSession *arg1 = (CoreSession *) 0 ; - char *arg2 = (char *) 0 ; - switch_size_t arg3 ; - switch_size_t arg4 ; - char *arg5 = (char *) 0 ; - char *arg6 = (char *) 0 ; - int arg7 ; - int result; + switch_size_t arg2 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int arg5 ; + char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; - int res2 ; - char temp2[128+1] ; - char *t2 = 0 ; - size_t n2 = 0 ; - int alloc2 = 0 ; - void *argp3 ; - int res3 = 0 ; - void *argp4 ; - int res4 = 0 ; - int res5 ; - char *buf5 = 0 ; - int alloc5 = 0 ; - int res6 ; - char temp6[8+1] ; - char *t6 = 0 ; - size_t n6 = 0 ; - int alloc6 = 0 ; - int val7 ; - int ecode7 = 0 ; + void *argp2 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char temp4[8+1] ; + char *t4 = 0 ; + size_t n4 = 0 ; + int alloc4 = 0 ; + int val5 ; + int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'"); } arg1 = reinterpret_cast< CoreSession * >(argp1); - res2 = SWIG_AsCharPtrAndSize(obj1, &t2, &n2, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *dtmf_buf""'"); - } - if ( n2 > (size_t) 128 ) n2 = (size_t) 128; - memcpy(temp2, t2, sizeof(char)*n2); - if (alloc2 == SWIG_NEWOBJ) delete[] t2; - temp2[n2 - 1] = 0; - arg2 = (char *) temp2; { - res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_switch_size_t, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'"); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_switch_size_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'"); } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'"); + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'"); } else { - switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp3); - arg3 = *temp; - if (SWIG_IsNewObj(res3)) delete temp; + switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; } } - { - res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_switch_size_t, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'"); - } else { - switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp4); - arg4 = *temp; - if (SWIG_IsNewObj(res4)) delete temp; - } + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'"); } - res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'"); + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_AsCharPtrAndSize(obj3, &t4, &n4, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *terminator""'"); } - arg5 = reinterpret_cast< char * >(buf5); - res6 = SWIG_AsCharPtrAndSize(obj5, &t6, &n6, &alloc6); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "char *terminator""'"); - } - if ( n6 > (size_t) 8 ) n6 = (size_t) 8; - memcpy(temp6, t6, sizeof(char)*n6); - if (alloc6 == SWIG_NEWOBJ) delete[] t6; - temp6[n6 - 1] = 0; - arg6 = (char *) temp6; - ecode7 = SWIG_AsVal_int(obj6, &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "CoreSession_getDigits" "', argument " "7"" of type '" "int""'"); + if ( n4 > (size_t) 8 ) n4 = (size_t) 8; + memcpy(temp4, t4, sizeof(char)*n4); + if (alloc4 == SWIG_NEWOBJ) delete[] t4; + temp4[n4 - 1] = 0; + arg4 = (char *) temp4; + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "int""'"); } - arg7 = static_cast< int >(val7); - result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7); - resultobj = SWIG_From_int(static_cast< int >(result)); - arg2[128] = 0; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg2)); - arg6[8] = 0; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg6)); - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + arg5 = static_cast< int >(val5); + result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5); + resultobj = SWIG_FromCharPtr((const char *)result); + arg4[8] = 0; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg4)); + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return resultobj; fail: - if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; return NULL; } @@ -5810,8 +5775,7 @@ SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM char *arg7 = (char *) 0 ; char *arg8 = (char *) 0 ; char *arg9 = (char *) 0 ; - char *arg10 = (char *) 0 ; - int result; + char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; @@ -5832,13 +5796,8 @@ SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM char *buf8 = 0 ; int alloc8 = 0 ; int res9 ; - char temp9[128+1] ; - char *t9 = 0 ; - size_t n9 = 0 ; + char *buf9 = 0 ; int alloc9 = 0 ; - int res10 ; - char *buf10 = 0 ; - int alloc10 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5848,9 +5807,8 @@ SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM PyObject * obj6 = 0 ; PyObject * obj7 = 0 ; PyObject * obj8 = 0 ; - PyObject * obj9 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'"); @@ -5891,34 +5849,23 @@ SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'"); } arg8 = reinterpret_cast< char * >(buf8); - res9 = SWIG_AsCharPtrAndSize(obj8, &t9, &n9, &alloc9); + res9 = SWIG_AsCharPtrAndSize(obj8, &buf9, NULL, &alloc9); if (!SWIG_IsOK(res9)) { - SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *dtmf_buf""'"); + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'"); } - if ( n9 > (size_t) 128 ) n9 = (size_t) 128; - memcpy(temp9, t9, sizeof(char)*n9); - if (alloc9 == SWIG_NEWOBJ) delete[] t9; - temp9[n9 - 1] = 0; - arg9 = (char *) temp9; - res10 = SWIG_AsCharPtrAndSize(obj9, &buf10, NULL, &alloc10); - if (!SWIG_IsOK(res10)) { - SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'"); - } - arg10 = reinterpret_cast< char * >(buf10); - result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); - resultobj = SWIG_From_int(static_cast< int >(result)); - arg9[128] = 0; - resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg9)); + arg9 = reinterpret_cast< char * >(buf9); + result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + resultobj = SWIG_FromCharPtr((const char *)result); if (alloc6 == SWIG_NEWOBJ) delete[] buf6; if (alloc7 == SWIG_NEWOBJ) delete[] buf7; if (alloc8 == SWIG_NEWOBJ) delete[] buf8; - if (alloc10 == SWIG_NEWOBJ) delete[] buf10; + if (alloc9 == SWIG_NEWOBJ) delete[] buf9; return resultobj; fail: if (alloc6 == SWIG_NEWOBJ) delete[] buf6; if (alloc7 == SWIG_NEWOBJ) delete[] buf7; if (alloc8 == SWIG_NEWOBJ) delete[] buf8; - if (alloc10 == SWIG_NEWOBJ) delete[] buf10; + if (alloc9 == SWIG_NEWOBJ) delete[] buf9; return NULL; } diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 4c61c27a72..a9de7df403 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -470,20 +470,19 @@ SWITCH_DECLARE(int) CoreSession::collectDigits(int timeout) { return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(int) CoreSession::getDigits(char *dtmf_buf, - switch_size_t buflen, - switch_size_t maxdigits, - char *terminators, - char *terminator, - int timeout) +SWITCH_DECLARE(char *) CoreSession::getDigits(switch_size_t maxdigits, + char *terminators, + char *terminator, + int timeout) { switch_status_t status; - sanity_check(-1); + sanity_check(""); begin_allow_threads(); + memset(dtmf_buf, 0, sizeof(dtmf_buf)); status = switch_ivr_collect_digits_count(session, dtmf_buf, - buflen, + sizeof(dtmf_buf), maxdigits, terminators, terminator, @@ -491,7 +490,7 @@ SWITCH_DECLARE(int) CoreSession::getDigits(char *dtmf_buf, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf); end_allow_threads(); - return status == SWITCH_STATUS_SUCCESS ? 1 : 0; + return dtmf_buf; } SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char *context) @@ -505,19 +504,19 @@ SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char return status == SWITCH_STATUS_SUCCESS ? 1 : 0; } -SWITCH_DECLARE(int) CoreSession::playAndGetDigits(int min_digits, - int max_digits, - int max_tries, - int timeout, - char *terminators, - char *audio_files, - char *bad_input_audio_files, - char *dtmf_buf, - char *digits_regex) +SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits, + int max_digits, + int max_tries, + int timeout, + char *terminators, + char *audio_files, + char *bad_input_audio_files, + char *digits_regex) { switch_status_t status; - sanity_check(-1); + sanity_check(""); begin_allow_threads(); + memset(dtmf_buf, 0, sizeof(dtmf_buf)); status = switch_play_and_get_digits( session, (uint32_t) min_digits, (uint32_t) max_digits, @@ -527,13 +526,13 @@ SWITCH_DECLARE(int) CoreSession::playAndGetDigits(int min_digits, audio_files, bad_input_audio_files, dtmf_buf, - 128, + sizeof(dtmf_buf), digits_regex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf); end_allow_threads(); - return status == SWITCH_STATUS_SUCCESS ? 1 : 0; + return dtmf_buf; } SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_count) { diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 8bd0dab088..019f21b121 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -1239,7 +1239,7 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t switch_channel_pre_answer(channel); //Start pestering the user for input - for (; (switch_channel_get_state(channel) == CS_EXECUTE) && max_tries > 0; max_tries--) { + for (; switch_channel_ready(channel) && max_tries > 0; max_tries--) { switch_input_args_t args = { 0 }; //make the buffer so fresh and so clean clean memset(digit_buffer, 0, digit_buffer_length);