From 04a965edb3d803e1a571934f76be127871791e30 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 12 Jun 2009 22:57:13 +0000 Subject: [PATCH] add socketDescriptor() method to ESL::Connection obj git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13770 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/esl/lua/esl_wrap.cpp | 26 ++++++++++++++++++++++++++ libs/esl/perl/ESL.pm | 1 + libs/esl/perl/esl_wrap.cpp | 29 +++++++++++++++++++++++++++++ libs/esl/php/ESL.php | 4 ++++ libs/esl/php/esl_wrap.cpp | 27 +++++++++++++++++++++++++++ libs/esl/php/php_ESL.h | 1 + libs/esl/python/ESL.py | 1 + libs/esl/python/esl_wrap.cpp | 23 +++++++++++++++++++++++ libs/esl/ruby/esl_wrap.cpp | 25 +++++++++++++++++++++++++ libs/esl/src/esl_oop.cpp | 10 ++++++++++ libs/esl/src/include/esl_oop.h | 1 + 11 files changed, 148 insertions(+) diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index 7aa2a82d0d..70692a91e4 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -2275,6 +2275,31 @@ fail: } +static int _wrap_ESLconnection_socketDescriptor(lua_State* L) { + int SWIG_arg = -1; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + + SWIG_check_num_args("socketDescriptor",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("socketDescriptor",1,"ESLconnection *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ + SWIG_fail_ptr("ESLconnection_socketDescriptor",1,SWIGTYPE_p_ESLconnection); + } + + result = (int)(arg1)->socketDescriptor(); + SWIG_arg=0; + lua_pushnumber(L, (lua_Number) result); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_ESLconnection_connected(lua_State* L) { int SWIG_arg = -1; ESLconnection *arg1 = (ESLconnection *) 0 ; @@ -2756,6 +2781,7 @@ ESLconnection *arg1 = (ESLconnection *) obj; delete arg1; } static swig_lua_method swig_ESLconnection_methods[] = { + {"socketDescriptor", _wrap_ESLconnection_socketDescriptor}, {"connected", _wrap_ESLconnection_connected}, {"getInfo", _wrap_ESLconnection_getInfo}, {"send", _wrap_ESLconnection_send}, diff --git a/libs/esl/perl/ESL.pm b/libs/esl/perl/ESL.pm index 9da5768fbd..b50ee4a083 100644 --- a/libs/esl/perl/ESL.pm +++ b/libs/esl/perl/ESL.pm @@ -128,6 +128,7 @@ sub DESTROY { } } +*socketDescriptor = *ESLc::ESLconnection_socketDescriptor; *connected = *ESLc::ESLconnection_connected; *getInfo = *ESLc::ESLconnection_getInfo; *send = *ESLc::ESLconnection_send; diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index ff0c736341..add8b4fa39 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -2745,6 +2745,34 @@ XS(_wrap_delete_ESLconnection) { } +XS(_wrap_ESLconnection_socketDescriptor) { + { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ESLconnection_socketDescriptor(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_socketDescriptor" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->socketDescriptor(); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_ESLconnection_connected) { { ESLconnection *arg1 = (ESLconnection *) 0 ; @@ -3514,6 +3542,7 @@ static swig_command_info swig_commands[] = { {"ESLc::ESLevent_nextHeader", _wrap_ESLevent_nextHeader}, {"ESLc::new_ESLconnection", _wrap_new_ESLconnection}, {"ESLc::delete_ESLconnection", _wrap_delete_ESLconnection}, +{"ESLc::ESLconnection_socketDescriptor", _wrap_ESLconnection_socketDescriptor}, {"ESLc::ESLconnection_connected", _wrap_ESLconnection_connected}, {"ESLc::ESLconnection_getInfo", _wrap_ESLconnection_getInfo}, {"ESLc::ESLconnection_send", _wrap_ESLconnection_send}, diff --git a/libs/esl/php/ESL.php b/libs/esl/php/ESL.php index 12afaeb718..a83df6a0b3 100644 --- a/libs/esl/php/ESL.php +++ b/libs/esl/php/ESL.php @@ -121,6 +121,10 @@ class ESLconnection { $this->_cPtr=$r; } + function socketDescriptor() { + return ESLconnection_socketDescriptor($this->_cPtr); + } + function connected() { return ESLconnection_connected($this->_cPtr); } diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index 6ef33ae932..c28ec3a143 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -1821,6 +1821,32 @@ static void __wrap_delete_ESLconnection(zend_rsrc_list_entry *rsrc, const char * } +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_socketDescriptor) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) { + WRONG_PARAM_COUNT; + } + + { + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ESLconnection_socketDescriptor. Expected SWIGTYPE_p_ESLconnection"); + } + } + if(!arg1) SWIG_PHP_Error(E_ERROR, "this pointer is NULL"); + result = (int)(arg1)->socketDescriptor(); + { + ZVAL_LONG(return_value,result); + } + return; +fail: + zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg()); +} + + ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected) { ESLconnection *arg1 = (ESLconnection *) 0 ; int result; @@ -2454,6 +2480,7 @@ static zend_function_entry ESL_functions[] = { SWIG_ZEND_NAMED_FE(eslevent_firstheader,_wrap_ESLevent_firstHeader,NULL) SWIG_ZEND_NAMED_FE(eslevent_nextheader,_wrap_ESLevent_nextHeader,NULL) SWIG_ZEND_NAMED_FE(new_eslconnection,_wrap_new_ESLconnection,NULL) + SWIG_ZEND_NAMED_FE(eslconnection_socketdescriptor,_wrap_ESLconnection_socketDescriptor,NULL) SWIG_ZEND_NAMED_FE(eslconnection_connected,_wrap_ESLconnection_connected,NULL) SWIG_ZEND_NAMED_FE(eslconnection_getinfo,_wrap_ESLconnection_getInfo,NULL) SWIG_ZEND_NAMED_FE(eslconnection_send,_wrap_ESLconnection_send,NULL) diff --git a/libs/esl/php/php_ESL.h b/libs/esl/php/php_ESL.h index 3f0109619f..8c9dede981 100644 --- a/libs/esl/php/php_ESL.h +++ b/libs/esl/php/php_ESL.h @@ -50,6 +50,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader); ZEND_NAMED_FUNCTION(_wrap_ESLevent_firstHeader); ZEND_NAMED_FUNCTION(_wrap_ESLevent_nextHeader); ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection); +ZEND_NAMED_FUNCTION(_wrap_ESLconnection_socketDescriptor); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_getInfo); ZEND_NAMED_FUNCTION(_wrap_ESLconnection_send); diff --git a/libs/esl/python/ESL.py b/libs/esl/python/ESL.py index ad81ff2b7d..8e52ea303f 100644 --- a/libs/esl/python/ESL.py +++ b/libs/esl/python/ESL.py @@ -77,6 +77,7 @@ class ESLconnection: except: self.this = this __swig_destroy__ = _ESL.delete_ESLconnection __del__ = lambda self : None; + def socketDescriptor(*args): return apply(_ESL.ESLconnection_socketDescriptor, args) def connected(*args): return apply(_ESL.ESLconnection_connected, args) def getInfo(*args): return apply(_ESL.ESLconnection_getInfo, args) def send(*args): return apply(_ESL.ESLconnection_send, args) diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index cd2a658c55..06dab8faa6 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -3659,6 +3659,28 @@ fail: } +SWIGINTERN PyObject *_wrap_ESLconnection_socketDescriptor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ESLconnection_socketDescriptor",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_socketDescriptor" "', argument " "1"" of type '" "ESLconnection *""'"); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->socketDescriptor(); + resultobj = SWIG_From_int(static_cast< int >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_ESLconnection_connected(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ESLconnection *arg1 = (ESLconnection *) 0 ; @@ -4307,6 +4329,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"ESLevent_swigregister", ESLevent_swigregister, METH_VARARGS, NULL}, { (char *)"new_ESLconnection", _wrap_new_ESLconnection, METH_VARARGS, NULL}, { (char *)"delete_ESLconnection", _wrap_delete_ESLconnection, METH_VARARGS, NULL}, + { (char *)"ESLconnection_socketDescriptor", _wrap_ESLconnection_socketDescriptor, METH_VARARGS, NULL}, { (char *)"ESLconnection_connected", _wrap_ESLconnection_connected, METH_VARARGS, NULL}, { (char *)"ESLconnection_getInfo", _wrap_ESLconnection_getInfo, METH_VARARGS, NULL}, { (char *)"ESLconnection_send", _wrap_ESLconnection_send, METH_VARARGS, NULL}, diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 84a655912e..238e6e1d0e 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -2780,6 +2780,30 @@ free_ESLconnection(ESLconnection *arg1) { delete arg1; } +SWIGINTERN VALUE +_wrap_ESLconnection_socketDescriptor(int argc, VALUE *argv, VALUE self) { + ESLconnection *arg1 = (ESLconnection *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "ESLconnection *","socketDescriptor", 1, self )); + } + arg1 = reinterpret_cast< ESLconnection * >(argp1); + result = (int)(arg1)->socketDescriptor(); + vresult = SWIG_From_int(static_cast< int >(result)); + return vresult; +fail: + return Qnil; +} + + SWIGINTERN VALUE _wrap_ESLconnection_connected(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; @@ -3729,6 +3753,7 @@ SWIGEXPORT void Init_ESL(void) { SWIG_TypeClientData(SWIGTYPE_p_ESLconnection, (void *) &cESLconnection); rb_define_alloc_func(cESLconnection.klass, _wrap_ESLconnection_allocate); rb_define_method(cESLconnection.klass, "initialize", VALUEFUNC(_wrap_new_ESLconnection), -1); + rb_define_method(cESLconnection.klass, "socketDescriptor", VALUEFUNC(_wrap_ESLconnection_socketDescriptor), -1); rb_define_method(cESLconnection.klass, "connected", VALUEFUNC(_wrap_ESLconnection_connected), -1); rb_define_method(cESLconnection.klass, "getInfo", VALUEFUNC(_wrap_ESLconnection_getInfo), -1); rb_define_method(cESLconnection.klass, "send", VALUEFUNC(_wrap_ESLconnection_send), -1); diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index e7168938ca..45d286a035 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -33,6 +33,16 @@ ESLconnection::~ESLconnection() } +int ESLconnection::socketDescriptor() +{ + if (handle.connected) { + return (int) handle.sock; + } + + return -1; +} + + int ESLconnection::disconnect() { if (handle.connected) { diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 840b0ef99e..4c47dd82e7 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -76,6 +76,7 @@ class ESLconnection { ESLconnection(const char *host, const char *port, const char *password); ESLconnection(int socket); virtual ~ESLconnection(); + int socketDescriptor(); int connected(); ESLevent *getInfo(); int send(const char *cmd);