From 9e63b03d1c3aef56c876b88a6c237b08442cbef7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 20 Feb 2009 17:16:36 +0000 Subject: [PATCH] allow null arg to api and bgapi method git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12182 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/esl/lua/esl_wrap.cpp | 20 +++++++++------ libs/esl/perl/esl_wrap.cpp | 28 ++++++++++++--------- libs/esl/php/ESL.php | 14 ++++++++--- libs/esl/php/esl_wrap.cpp | 46 +++++++++++++++++++--------------- libs/esl/python/esl_wrap.cpp | 28 ++++++++++++--------- libs/esl/ruby/esl_wrap.cpp | 32 ++++++++++++----------- libs/esl/src/esl_oop.cpp | 20 ++++++++++++--- libs/esl/src/include/esl_oop.h | 4 +-- 8 files changed, 116 insertions(+), 76 deletions(-) diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index 81552fff62..1929060dec 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -2337,20 +2337,22 @@ static int _wrap_ESLconnection_api(lua_State* L) { int SWIG_arg = -1; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; - SWIG_check_num_args("api",3,3) + SWIG_check_num_args("api",2,3) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("api",1,"ESLconnection *"); if(!lua_isstring(L,2)) SWIG_fail_arg("api",2,"char const *"); - if(!lua_isstring(L,3)) SWIG_fail_arg("api",3,"char const *"); + if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("api",3,"char const *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ SWIG_fail_ptr("ESLconnection_api",1,SWIGTYPE_p_ESLconnection); } arg2 = (char *)lua_tostring(L, 2); - arg3 = (char *)lua_tostring(L, 3); + if(lua_gettop(L)>=3){ + arg3 = (char *)lua_tostring(L, 3); + } result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); SWIG_arg=0; SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,0); SWIG_arg++; @@ -2368,20 +2370,22 @@ static int _wrap_ESLconnection_bgapi(lua_State* L) { int SWIG_arg = -1; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; - SWIG_check_num_args("bgapi",3,3) + SWIG_check_num_args("bgapi",2,3) if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("bgapi",1,"ESLconnection *"); if(!lua_isstring(L,2)) SWIG_fail_arg("bgapi",2,"char const *"); - if(!lua_isstring(L,3)) SWIG_fail_arg("bgapi",3,"char const *"); + if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("bgapi",3,"char const *"); if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){ SWIG_fail_ptr("ESLconnection_bgapi",1,SWIGTYPE_p_ESLconnection); } arg2 = (char *)lua_tostring(L, 2); - arg3 = (char *)lua_tostring(L, 3); + if(lua_gettop(L)>=3){ + arg3 = (char *)lua_tostring(L, 3); + } result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); SWIG_arg=0; SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,0); SWIG_arg++; diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index 1e21d0b538..255533e8d2 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -2828,7 +2828,7 @@ XS(_wrap_ESLconnection_api) { { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -2841,7 +2841,7 @@ XS(_wrap_ESLconnection_api) { int argvi = 0; dXSARGS; - if ((items < 3) || (items > 3)) { + if ((items < 2) || (items > 3)) { SWIG_croak("Usage: ESLconnection_api(self,cmd,arg);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); @@ -2854,11 +2854,13 @@ XS(_wrap_ESLconnection_api) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_api" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ; @@ -2878,7 +2880,7 @@ XS(_wrap_ESLconnection_bgapi) { { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -2891,7 +2893,7 @@ XS(_wrap_ESLconnection_bgapi) { int argvi = 0; dXSARGS; - if ((items < 3) || (items > 3)) { + if ((items < 2) || (items > 3)) { SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg);"); } res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); @@ -2904,11 +2906,13 @@ XS(_wrap_ESLconnection_bgapi) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_bgapi" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ; diff --git a/libs/esl/php/ESL.php b/libs/esl/php/ESL.php index 5532f329b3..3f79425925 100644 --- a/libs/esl/php/ESL.php +++ b/libs/esl/php/ESL.php @@ -131,13 +131,19 @@ class ESLconnection { return is_resource($r) ? new ESLevent($r) : $r; } - function api($cmd,$arg) { - $r=ESLconnection_api($this->_cPtr,$cmd,$arg); + function api($cmd,$arg=null) { + switch (func_num_args()) { + case 1: $r=ESLconnection_api($this->_cPtr,$cmd); break; + default: $r=ESLconnection_api($this->_cPtr,$cmd,$arg); + } return is_resource($r) ? new ESLevent($r) : $r; } - function bgapi($cmd,$arg) { - $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); + function bgapi($cmd,$arg=null) { + switch (func_num_args()) { + case 1: $r=ESLconnection_bgapi($this->_cPtr,$cmd); break; + default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); + } return is_resource($r) ? new ESLevent($r) : $r; } diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index 9b4160339b..c6e96ad446 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -1889,14 +1889,16 @@ fail: ZEND_NAMED_FUNCTION(_wrap_ESLconnection_api) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; zval **args[3]; + int arg_count; SWIG_ResetError(); - if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { - WRONG_PARAM_COUNT; - } + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3 || + zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; { if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { @@ -1910,12 +1912,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_api) { arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); - /*@SWIG@*/; - + if(arg_count > 2) { + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + } result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); { SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); @@ -1929,14 +1932,16 @@ fail: ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; zval **args[3]; + int arg_count; SWIG_ResetError(); - if(ZEND_NUM_ARGS() != 3 || zend_get_parameters_array_ex(3, args) != SUCCESS) { - WRONG_PARAM_COUNT; - } + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3 || + zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; { if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_ESLconnection, 0) < 0) { @@ -1950,12 +1955,13 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) { arg2 = (char *) Z_STRVAL_PP(args[1]); /*@SWIG@*/; - - /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ - convert_to_string_ex(args[2]); - arg3 = (char *) Z_STRVAL_PP(args[2]); - /*@SWIG@*/; - + if(arg_count > 2) { + /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@SWIG@*/; + + } result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); { SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0); diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index 57ae33743b..183b137f45 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -3732,7 +3732,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_api(PyObject *SWIGUNUSEDPARM(self), PyO PyObject *resultobj = 0; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -3746,7 +3746,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_api(PyObject *SWIGUNUSEDPARM(self), PyO PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOO:ESLconnection_api",&obj0,&obj1,&obj2)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_api",&obj0,&obj1,&obj2)) 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_api" "', argument " "1"" of type '" "ESLconnection *""'"); @@ -3757,11 +3757,13 @@ SWIGINTERN PyObject *_wrap_ESLconnection_api(PyObject *SWIGUNUSEDPARM(self), PyO SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_api" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_api" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; @@ -3778,7 +3780,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P PyObject *resultobj = 0; ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -3792,7 +3794,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOO:ESLconnection_bgapi",&obj0,&obj1,&obj2)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_bgapi",&obj0,&obj1,&obj2)) 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_bgapi" "', argument " "1"" of type '" "ESLconnection *""'"); @@ -3803,11 +3805,13 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ESLconnection_bgapi" "', argument " "2"" of type '" "char const *""'"); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_bgapi" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 58b307435c..32bd14591e 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -2855,7 +2855,7 @@ SWIGINTERN VALUE _wrap_ESLconnection_api(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -2867,8 +2867,8 @@ _wrap_ESLconnection_api(int argc, VALUE *argv, VALUE self) { int alloc3 = 0 ; VALUE vresult = Qnil; - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; } res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { @@ -2880,11 +2880,13 @@ _wrap_ESLconnection_api(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","api", 2, argv[0] )); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","api", 3, argv[1] )); + if (argc > 1) { + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","api", 3, argv[1] )); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->api((char const *)arg2,(char const *)arg3); vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; @@ -2901,7 +2903,7 @@ SWIGINTERN VALUE _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { ESLconnection *arg1 = (ESLconnection *) 0 ; char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; + char *arg3 = (char *) NULL ; ESLevent *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; @@ -2913,8 +2915,8 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { int alloc3 = 0 ; VALUE vresult = Qnil; - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; } res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 ); if (!SWIG_IsOK(res1)) { @@ -2926,11 +2928,13 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) { SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","bgapi", 2, argv[0] )); } arg2 = reinterpret_cast< char * >(buf2); - res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","bgapi", 3, argv[1] )); + if (argc > 1) { + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","bgapi", 3, argv[1] )); + } + arg3 = reinterpret_cast< char * >(buf3); } - arg3 = reinterpret_cast< char * >(buf3); result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3); vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | 0 ); if (alloc2 == SWIG_NEWOBJ) delete[] buf2; diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index 696b67da37..260301b70d 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -56,13 +56,19 @@ ESLevent *ESLconnection::sendRecv(const char *cmd) ESLevent *ESLconnection::api(const char *cmd, const char *arg) { - size_t len = strlen(cmd) + strlen(arg) + 5; + size_t len; char *cmd_buf; + if (!cmd) { + return NULL; + } + + len = strlen(cmd) + (arg ? strlen(arg) : 0) + 5; + cmd_buf = (char *) malloc(len); assert(cmd_buf); - snprintf(cmd_buf, len, "api %s %s", cmd, arg); + snprintf(cmd_buf, len, "api %s %s", cmd, arg ? arg : ""); *(cmd_buf + len) = '\0'; if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { @@ -78,13 +84,19 @@ ESLevent *ESLconnection::api(const char *cmd, const char *arg) ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg) { - size_t len = strlen(cmd) + strlen(arg) + 5; + size_t len; char *cmd_buf; + if (!cmd) { + return NULL; + } + + len = strlen(cmd) + (arg ? strlen(arg) : 0) + 5; + cmd_buf = (char *) malloc(len); assert(cmd_buf); - snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg); + snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : ""); *(cmd_buf + len) = '\0'; if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) { diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index 017a87484d..082d86b7e7 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -77,8 +77,8 @@ class ESLconnection { ESLevent *getInfo(); esl_status_t send(const char *cmd); ESLevent *sendRecv(const char *cmd); - ESLevent *api(const char *cmd, const char *arg); - ESLevent *bgapi(const char *cmd, const char *arg); + ESLevent *api(const char *cmd, const char *arg = NULL); + ESLevent *bgapi(const char *cmd, const char *arg = NULL); esl_status_t sendEvent(ESLevent *send_me); ESLevent *recvEvent(); ESLevent *recvEventTimed(int ms);