]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
allow null arg to api and bgapi method
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 20 Feb 2009 17:16:36 +0000 (17:16 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 20 Feb 2009 17:16:36 +0000 (17:16 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12182 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 81552fff62686be02eaef0701b4fe1d9aa667751..1929060deccf2b7f8cc33de49cf7fd5e9fe07001 100644 (file)
@@ -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++; 
index 1e21d0b53890be16b379b6f79282f046c3a3df0d..255533e8d2bd5cb39ff46f2c7f2c7f99899e6493 100644 (file)
@@ -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++ ;
     
index 5532f329b348d1625751a7be5a8ebc572ed3c3bd..3f79425925be057d42e809ee5ebae289252ffe27 100644 (file)
@@ -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;
        }
 
index 9b4160339b0d8b1cba9c0859afa2c515cb7bf064..c6e96ad446d6b1926381f4da75c1bcdb3567a1e2 100644 (file)
@@ -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);
index 57ae33743b5c6dc01b7fa4ef342564ea4802faa9..183b137f45c9ed849d463f5ea87fd1130d18b9a8 100644 (file)
@@ -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;
index 58b307435c54eb59bc8d49042a3b08f355697784..32bd14591e0ad1deadba25a3eb3fd3728b0a89d0 100644 (file)
@@ -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;
index 696b67da37e4e749f36a6cfe929dfca2589c42d0..260301b70dafb085fabea5f0464ca18bc3dba948 100644 (file)
@@ -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) {
index 017a87484dc20877abbfc7569b620d9820f6d0be..082d86b7e7276d18de2d6de076da4adbcc798e57 100644 (file)
@@ -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);