char name[128];
char host[128];
esl_port_t port;
+ char user[256];
char pass[128];
int debug;
const char *console_fnkeys[12];
printf(" -?,-h --help Usage Information\n");
printf(" -H, --host=hostname Host to connect\n");
printf(" -P, --port=port Port to connect (1 - 65535)\n");
+ printf(" -u, --user=user@domain user@domain\n");
printf(" -p, --password=password Password\n");
printf(" -x, --execute=command Execute Command and Exit\n");
printf(" -l, --loglevel=command Log Level\n");
printf("Unknown command [%s]\n", cmd);
} else {
char cmd_str[1024] = "";
-
+ const char *err = NULL;
+
snprintf(cmd_str, sizeof(cmd_str), "api %s\n\n", cmd);
esl_send_recv(handle, cmd_str);
- if (handle->last_sr_event && handle->last_sr_event->body) {
- printf("%s\n", handle->last_sr_event->body);
+ if (handle->last_sr_event) {
+ if (handle->last_sr_event->body) {
+ printf("%s\n", handle->last_sr_event->body);
+ } else if ((err = esl_event_get_header(handle->last_sr_event, "reply-text")) && !strncasecmp(err, "-err", 3)) {
+ printf("Error: %s!\n", err + 4);
+ }
}
}
{"help", 0, 0, 'h'},
{"host", 1, 0, 'H'},
{"port", 1, 0, 'P'},
+ {"user", 1, 0, 'u'},
{"password", 1, 0, 'p'},
{"debug", 1, 0, 'd'},
{"execute", 1, 0, 'x'},
char temp_host[128];
int argv_host = 0;
+ char temp_user[256];
char temp_pass[128];
int argv_pass = 0 ;
+ int argv_user = 0 ;
int temp_port = 0;
int argv_port = 0;
int temp_log = -1;
for(;;) {
int option_index = 0;
- opt = getopt_long(argc, argv, "H:U:P:S:p:d:x:l:qh?", options, &option_index);
+ opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:qh?", options, &option_index);
if (opt == -1) break;
switch (opt)
{
argv_error = 1;
}
break;
+ case 'u':
+ esl_set_string(temp_user, optarg);
+ argv_user = 1;
+ break;
case 'p':
esl_set_string(temp_pass, optarg);
argv_pass = 1;
if (!strcasecmp(var, "host")) {
esl_set_string(profiles[pcount-1].host, val);
+ } else if (!strcasecmp(var, "user")) {
+ esl_set_string(profiles[pcount-1].user, val);
} else if (!strcasecmp(var, "password")) {
esl_set_string(profiles[pcount-1].pass, val);
} else if (!strcasecmp(var, "port")) {
if (argv_port) {
profile->port = (esl_port_t)temp_port;
}
+
+ if (argv_user) {
+ esl_set_string(profile->user, temp_user);
+ }
+
if (argv_pass) {
esl_set_string(profile->pass, temp_pass);
}
snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", profile->name);
}
- if (esl_connect(&handle, profile->host, profile->port, profile->pass)) {
+ if (esl_connect(&handle, profile->host, profile->port, profile->user, profile->pass)) {
esl_global_set_default_logger(7);
esl_log(ESL_LOG_ERROR, "Error Connecting [%s]\n", handle.err);
if (!argv_exec) usage(argv[0]);
if (argv_exec){
+ const char *err = NULL;
+
snprintf(cmd_str, sizeof(cmd_str), "api %s\n\n", argv_command);
esl_send_recv(&handle, cmd_str);
- if (handle.last_sr_event && handle.last_sr_event->body) {
- printf("%s\n", handle.last_sr_event->body);
+ if (handle.last_sr_event) {
+ if (handle.last_sr_event->body) {
+ printf("%s\n", handle.last_sr_event->body);
+ } else if ((err = esl_event_get_header(handle.last_sr_event, "reply-text")) && !strncasecmp(err, "-err", 3)) {
+ printf("Error: %s!\n", err + 4);
+ }
}
+
esl_disconnect(&handle);
return 0;
}
}
-SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) {
+SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4) {
+ jlong jresult = 0 ;
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = 0;
+ if (jarg1) {
+ arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
+ if (!arg1) return 0;
+ }
+ arg2 = 0;
+ if (jarg2) {
+ arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+ if (!arg2) return 0;
+ }
+ arg3 = 0;
+ if (jarg3) {
+ arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
+ if (!arg3) return 0;
+ }
+ arg4 = 0;
+ if (jarg4) {
+ arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0);
+ if (!arg4) return 0;
+ }
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ *(ESLconnection **)&jresult = result;
+ if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
+ if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+ if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
+ if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4);
+ return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3) {
jlong jresult = 0 ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
}
-SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jint jarg1) {
+SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_new_1ESLconnection_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jint jarg1) {
jlong jresult = 0 ;
int arg1 ;
ESLconnection *result = 0 ;
swigCPtr = 0;
}
+ public ESLconnection(String host, String port, String user, String password) {
+ this(eslJNI.new_ESLconnection__SWIG_0(host, port, user, password), true);
+ }
+
public ESLconnection(String host, String port, String password) {
- this(eslJNI.new_ESLconnection__SWIG_0(host, port, password), true);
+ this(eslJNI.new_ESLconnection__SWIG_1(host, port, password), true);
}
public ESLconnection(int socket) {
- this(eslJNI.new_ESLconnection__SWIG_1(socket), true);
+ this(eslJNI.new_ESLconnection__SWIG_2(socket), true);
}
public int socketDescriptor() {
public final static native boolean ESLevent_delHeader(long jarg1, ESLevent jarg1_, String jarg2);
public final static native String ESLevent_firstHeader(long jarg1, ESLevent jarg1_);
public final static native String ESLevent_nextHeader(long jarg1, ESLevent jarg1_);
- public final static native long new_ESLconnection__SWIG_0(String jarg1, String jarg2, String jarg3);
- public final static native long new_ESLconnection__SWIG_1(int jarg1);
+ public final static native long new_ESLconnection__SWIG_0(String jarg1, String jarg2, String jarg3, String jarg4);
+ public final static native long new_ESLconnection__SWIG_1(String jarg1, String jarg2, String jarg3);
+ public final static native long new_ESLconnection__SWIG_2(int jarg1);
public final static native void delete_ESLconnection(long jarg1);
public final static native int ESLconnection_socketDescriptor(long jarg1, ESLconnection jarg1_);
public final static native int ESLconnection_connected(long jarg1, ESLconnection jarg1_);
static swig_lua_class _wrap_class_ESLevent = { "ESLevent", &SWIGTYPE_p_ESLevent,_wrap_new_ESLevent, swig_delete_ESLevent, swig_ESLevent_methods, swig_ESLevent_attributes, swig_ESLevent_bases, swig_ESLevent_base_names };
static int _wrap_new_ESLconnection__SWIG_0(lua_State* L) {
+ int SWIG_arg = -1;
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+
+ SWIG_check_num_args("ESLconnection",4,4)
+ if(!lua_isstring(L,1)) SWIG_fail_arg("ESLconnection",1,"char const *");
+ if(!lua_isstring(L,2)) SWIG_fail_arg("ESLconnection",2,"char const *");
+ if(!lua_isstring(L,3)) SWIG_fail_arg("ESLconnection",3,"char const *");
+ if(!lua_isstring(L,4)) SWIG_fail_arg("ESLconnection",4,"char const *");
+ arg1 = (char *)lua_tostring(L, 1);
+ arg2 = (char *)lua_tostring(L, 2);
+ arg3 = (char *)lua_tostring(L, 3);
+ arg4 = (char *)lua_tostring(L, 4);
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ SWIG_arg=0;
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLconnection,1); SWIG_arg++;
+ return SWIG_arg;
+
+ if(0) SWIG_fail;
+
+fail:
+ lua_error(L);
+ return SWIG_arg;
+}
+
+
+static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) {
int SWIG_arg = -1;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
}
-static int _wrap_new_ESLconnection__SWIG_1(lua_State* L) {
+static int _wrap_new_ESLconnection__SWIG_2(lua_State* L) {
int SWIG_arg = -1;
int arg1 ;
ESLconnection *result = 0 ;
static int _wrap_new_ESLconnection(lua_State* L) {
int argc;
- int argv[4]={
- 1,2,3,4
+ int argv[5]={
+ 1,2,3,4,5
};
argc = lua_gettop(L);
_v = lua_isnumber(L,argv[0]);
}
if (_v) {
- return _wrap_new_ESLconnection__SWIG_1(L);
+ return _wrap_new_ESLconnection__SWIG_2(L);
}
}
if (argc == 3) {
_v = lua_isstring(L,argv[2]);
}
if (_v) {
- return _wrap_new_ESLconnection__SWIG_0(L);
+ return _wrap_new_ESLconnection__SWIG_1(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v;
+ {
+ _v = lua_isstring(L,argv[0]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_new_ESLconnection__SWIG_0(L);
+ }
}
}
}
public static extern string ESLevent_nextHeader(HandleRef jarg1);
[DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_0")]
- public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, string jarg2, string jarg3);
+ public static extern IntPtr new_ESLconnection__SWIG_0(string jarg1, string jarg2, string jarg3, string jarg4);
[DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_1")]
- public static extern IntPtr new_ESLconnection__SWIG_1(int jarg1);
+ public static extern IntPtr new_ESLconnection__SWIG_1(string jarg1, string jarg2, string jarg3);
+
+ [DllImport("ESL", EntryPoint="CSharp_new_ESLconnection__SWIG_2")]
+ public static extern IntPtr new_ESLconnection__SWIG_2(int jarg1);
[DllImport("ESL", EntryPoint="CSharp_delete_ESLconnection")]
public static extern void delete_ESLconnection(HandleRef jarg1);
}
}
- public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, password), true) {
+ public ESLconnection(string host, string port, string user, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_0(host, port, user, password), true) {
}
- public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(socket), true) {
+ public ESLconnection(string host, string port, string password) : this(ESLPINVOKE.new_ESLconnection__SWIG_1(host, port, password), true) {
+ }
+
+ public ESLconnection(int socket) : this(ESLPINVOKE.new_ESLconnection__SWIG_2(socket), true) {
}
public int socketDescriptor() {
}
-SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, char * jarg2, char * jarg3) {
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_0(char * jarg1, char * jarg2, char * jarg3, char * jarg4) {
+ void * jresult ;
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+
+ arg1 = (char *)jarg1;
+ arg2 = (char *)jarg2;
+ arg3 = (char *)jarg3;
+ arg4 = (char *)jarg4;
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(char * jarg1, char * jarg2, char * jarg3) {
void * jresult ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
}
-SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_1(int jarg1) {
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_ESLconnection__SWIG_2(int jarg1) {
void * jresult ;
int arg1 ;
ESLconnection *result = 0 ;
XS(_wrap_new_ESLconnection__SWIG_0) {
+ {
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 4) || (items > 4)) {
+ SWIG_croak("Usage: new_ESLconnection(host,port,user,password);");
+ }
+ res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'");
+ }
+ arg1 = reinterpret_cast< char * >(buf1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', 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 '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'");
+ }
+ 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 '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'");
+ }
+ arg4 = reinterpret_cast< char * >(buf4);
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ XSRETURN(argvi);
+ fail:
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_new_ESLconnection__SWIG_1) {
{
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
}
-XS(_wrap_new_ESLconnection__SWIG_1) {
+XS(_wrap_new_ESLconnection__SWIG_2) {
{
int arg1 ;
ESLconnection *result = 0 ;
}
check_2:
+ if (items == 4) {
+ SWIG_TypeRank _ranki = 0;
+ SWIG_TypeRank _rankm = 0;
+ SWIG_TypeRank _pi = 1;
+ int _v = 0;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_3;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_3;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_3;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(3), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_3;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ if (!_index || (_ranki < _rank)) {
+ _rank = _ranki; _index = 3;
+ if (_rank == _rankm) goto dispatch;
+ }
+ }
+ check_3:
+
dispatch:
switch(_index) {
case 1:
- ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_1); return;
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_2); return;
case 2:
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_1); return;
+ case 3:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_ESLconnection__SWIG_0); return;
}
}
class ESLconnection {
public $_cPtr=null;
- function __construct($host_or_socket,$port=null,$password=null) {
+ function __construct($host_or_socket,$port=null,$user_or_password=null,$password=null) {
switch (func_num_args()) {
case 1: $r=new_ESLconnection($host_or_socket); break;
case 2: $r=new_ESLconnection($host_or_socket,$port); break;
- default: $r=new_ESLconnection($host_or_socket,$port,$password);
+ case 3: $r=new_ESLconnection($host_or_socket,$port,$user_or_password); break;
+ default: $r=new_ESLconnection($host_or_socket,$port,$user_or_password,$password);
}
$this->_cPtr=$r;
}
ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_0) {
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+ zval **args[4];
+
+ SWIG_ResetError();
+ if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_array_ex(4, args) != SUCCESS) {
+ WRONG_PARAM_COUNT;
+ }
+
+
+ /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/
+ convert_to_string_ex(args[0]);
+ arg1 = (char *) Z_STRVAL_PP(args[0]);
+ /*@SWIG@*/;
+
+
+ /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/
+ convert_to_string_ex(args[1]);
+ 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@*/;
+
+
+ /*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/
+ convert_to_string_ex(args[3]);
+ arg4 = (char *) Z_STRVAL_PP(args[3]);
+ /*@SWIG@*/;
+
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ {
+ SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLconnection, 1);
+ }
+ return;
+fail:
+ zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());
+}
+
+
+ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) {
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
}
-ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_1) {
+ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection__SWIG_2) {
int arg1 ;
ESLconnection *result = 0 ;
zval **args[1];
ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection) {
int argc;
- zval **argv[3];
+ zval **argv[4];
argc = ZEND_NUM_ARGS();
zend_get_parameters_array_ex(argc,argv);
int _v;
_v = (Z_TYPE_PP(argv[0]) == IS_LONG);
if (_v) {
- return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return _wrap_new_ESLconnection__SWIG_2(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
}
if (argc == 3) {
if (_v) {
_v = (Z_TYPE_PP(argv[2]) == IS_STRING);
if (_v) {
- return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ return _wrap_new_ESLconnection__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v;
+ _v = (Z_TYPE_PP(argv[0]) == IS_STRING);
+ if (_v) {
+ _v = (Z_TYPE_PP(argv[1]) == IS_STRING);
+ if (_v) {
+ _v = (Z_TYPE_PP(argv[2]) == IS_STRING);
+ if (_v) {
+ _v = (Z_TYPE_PP(argv[3]) == IS_STRING);
+ if (_v) {
+ return _wrap_new_ESLconnection__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ }
}
}
}
}
SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOO:new_ESLconnection",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ESLconnection" "', argument " "1"" of type '" "char const *""'");
+ }
+ arg1 = reinterpret_cast< char * >(buf1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_ESLconnection" "', 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 '" "new_ESLconnection" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = reinterpret_cast< char * >(buf3);
+ res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_ESLconnection" "', argument " "4"" of type '" "char const *""'");
+ }
+ arg4 = reinterpret_cast< char * >(buf4);
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLconnection, SWIG_POINTER_NEW | 0 );
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ return resultobj;
+fail:
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
}
-SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_ESLconnection__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int arg1 ;
ESLconnection *result = 0 ;
SWIGINTERN PyObject *_wrap_new_ESLconnection(PyObject *self, PyObject *args) {
int argc;
- PyObject *argv[4];
+ PyObject *argv[5];
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
argc = (int)PyObject_Length(args);
- for (ii = 0; (ii < argc) && (ii < 3); ii++) {
+ for (ii = 0; (ii < argc) && (ii < 4); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
if (argc == 1) {
_v = SWIG_CheckState(res);
}
if (_v) {
- return _wrap_new_ESLconnection__SWIG_1(self, args);
+ return _wrap_new_ESLconnection__SWIG_2(self, args);
}
}
if (argc == 3) {
int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_ESLconnection__SWIG_0(self, args);
+ return _wrap_new_ESLconnection__SWIG_1(self, args);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v;
+ int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_new_ESLconnection__SWIG_0(self, args);
+ }
}
}
}
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_ESLconnection'.\n"
" Possible C/C++ prototypes are:\n"
+ " ESLconnection(char const *,char const *,char const *,char const *)\n"
" ESLconnection(char const *,char const *,char const *)\n"
" ESLconnection(int)\n");
return NULL;
SWIGINTERN VALUE
_wrap_new_ESLconnection__SWIG_0(int argc, VALUE *argv, VALUE self) {
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ ESLconnection *result = 0 ;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+
+ if ((argc < 4) || (argc > 4)) {
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail;
+ }
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","ESLconnection", 1, argv[0] ));
+ }
+ arg1 = reinterpret_cast< char * >(buf1);
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","ESLconnection", 2, argv[1] ));
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","ESLconnection", 3, argv[2] ));
+ }
+ arg3 = reinterpret_cast< char * >(buf3);
+ res4 = SWIG_AsCharPtrAndSize(argv[3], &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","ESLconnection", 4, argv[3] ));
+ }
+ arg4 = reinterpret_cast< char * >(buf4);
+ result = (ESLconnection *)new ESLconnection((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);DATA_PTR(self) = result;
+
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ return self;
+fail:
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ return Qnil;
+}
+
+
+SWIGINTERN VALUE
+_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) {
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
SWIGINTERN VALUE
-_wrap_new_ESLconnection__SWIG_1(int argc, VALUE *argv, VALUE self) {
+_wrap_new_ESLconnection__SWIG_2(int argc, VALUE *argv, VALUE self) {
int arg1 ;
ESLconnection *result = 0 ;
int val1 ;
SWIGINTERN VALUE _wrap_new_ESLconnection(int nargs, VALUE *args, VALUE self) {
int argc;
- VALUE argv[3];
+ VALUE argv[4];
int ii;
argc = nargs;
- if (argc > 3) SWIG_fail;
+ if (argc > 4) SWIG_fail;
for (ii = 0; (ii < argc); ++ii) {
argv[ii] = args[ii];
}
_v = SWIG_CheckState(res);
}
if (_v) {
- return _wrap_new_ESLconnection__SWIG_1(nargs, args, self);
+ return _wrap_new_ESLconnection__SWIG_2(nargs, args, self);
}
}
if (argc == 3) {
int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_ESLconnection__SWIG_0(nargs, args, self);
+ return _wrap_new_ESLconnection__SWIG_1(nargs, args, self);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v;
+ int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[3], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_new_ESLconnection__SWIG_0(nargs, args, self);
+ }
}
}
}
}
fail:
- Ruby_Format_OverloadedError( argc, 3, "ESLconnection.new",
+ Ruby_Format_OverloadedError( argc, 4, "ESLconnection.new",
+ " ESLconnection.new(char const *host, char const *port, char const *user, char const *password)\n"
" ESLconnection.new(char const *host, char const *port, char const *password)\n"
" ESLconnection.new(int socket)\n");
}
-ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *password)
+ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *user, const char *password)
{
struct hostent *result;
goto fail;
}
- snprintf(sendbuf, sizeof(sendbuf), "auth %s\n\n", password);
+ if (esl_strlen_zero(user)) {
+ snprintf(sendbuf, sizeof(sendbuf), "auth %s\n\n", password);
+ } else {
+ snprintf(sendbuf, sizeof(sendbuf), "userauth %s:%s\n\n", user, password);
+ }
+
esl_send(handle, sendbuf);
connection_construct_common();
int x_port = atoi(port);
- esl_connect(&handle, host, x_port, password);
+ esl_connect(&handle, host, x_port, NULL, password);
+}
+
+ESLconnection::ESLconnection(const char *host, const char *port, const char *user, const char *password)
+{
+ connection_construct_common();
+ int x_port = atoi(port);
+
+ esl_connect(&handle, host, x_port, user, password);
}
\param handle Handle to connect
\param host Host to be connected
\param port Port to be connected
+ \param password FreeSWITCH server username (optional)
\param password FreeSWITCH server password
*/
-ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *password);
+ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *user, const char *password);
/*!
\brief Disconnect a handle
\param handle Handle to be disconnected
private:
esl_handle_t handle;
public:
+ ESLconnection(const char *host, const char *port, const char *user, const char *password);
ESLconnection(const char *host, const char *port, const char *password);
ESLconnection(int socket);
virtual ~ESLconnection();
{
esl_handle_t handle = {{0}};
- esl_connect(&handle, "localhost", 8021, "ClueCon");
+ esl_connect(&handle, "localhost", 8021, NULL, "ClueCon");
esl_send_recv(&handle, "api status\n\n");