[Freeswitch-svn] [commit] r12182 - in freeswitch/trunk/libs/esl: lua perl php python ruby src src/include

FreeSWITCH SVN anthm at freeswitch.org
Fri Feb 20 09:16:36 PST 2009


Author: anthm
Date: Fri Feb 20 11:16:36 2009
New Revision: 12182

Log:
allow null arg to api and bgapi method

Modified:
   freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
   freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
   freeswitch/trunk/libs/esl/php/ESL.php
   freeswitch/trunk/libs/esl/php/esl_wrap.cpp
   freeswitch/trunk/libs/esl/python/esl_wrap.cpp
   freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
   freeswitch/trunk/libs/esl/src/esl_oop.cpp
   freeswitch/trunk/libs/esl/src/include/esl_oop.h

Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp	Fri Feb 20 11:16:36 2009
@@ -2337,20 +2337,22 @@
   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 @@
   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++; 

Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp	Fri Feb 20 11:16:36 2009
@@ -2828,7 +2828,7 @@
   {
     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 @@
     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 @@
       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 @@
   {
     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 @@
     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 @@
       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++ ;
     

Modified: freeswitch/trunk/libs/esl/php/ESL.php
==============================================================================
--- freeswitch/trunk/libs/esl/php/ESL.php	(original)
+++ freeswitch/trunk/libs/esl/php/ESL.php	Fri Feb 20 11:16:36 2009
@@ -131,13 +131,19 @@
 		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;
 	}
 

Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/php/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp	Fri Feb 20 11:16:36 2009
@@ -1889,14 +1889,16 @@
 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 @@
   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 @@
 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 @@
   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);

Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/python/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp	Fri Feb 20 11:16:36 2009
@@ -3732,7 +3732,7 @@
   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 @@
   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 @@
     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 @@
   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 @@
   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 @@
     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;

Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp	(original)
+++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp	Fri Feb 20 11:16:36 2009
@@ -2855,7 +2855,7 @@
 _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 @@
   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 @@
     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 @@
 _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 @@
   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 @@
     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;

Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl_oop.cpp	(original)
+++ freeswitch/trunk/libs/esl/src/esl_oop.cpp	Fri Feb 20 11:16:36 2009
@@ -56,13 +56,19 @@
 
 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::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) {

Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h
==============================================================================
--- freeswitch/trunk/libs/esl/src/include/esl_oop.h	(original)
+++ freeswitch/trunk/libs/esl/src/include/esl_oop.h	Fri Feb 20 11:16:36 2009
@@ -77,8 +77,8 @@
 	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);



More information about the Freeswitch-svn mailing list