mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-6796 #comment avoid use c++ string since it causing troubles
This commit is contained in:
parent
794f09bba0
commit
1a4e6e3093
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <string>
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#ifdef DOH
|
#ifdef DOH
|
||||||
@ -150,9 +149,9 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod
|
|||||||
SWITCH_DECLARE_CONSTRUCTOR Stream(void);
|
SWITCH_DECLARE_CONSTRUCTOR Stream(void);
|
||||||
SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
|
SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
|
||||||
virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
|
virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
|
||||||
SWITCH_DECLARE(std::string) read();
|
SWITCH_DECLARE(const char *) read(int *len);
|
||||||
SWITCH_DECLARE(void) write(const char *data);
|
SWITCH_DECLARE(void) write(const char *data);
|
||||||
SWITCH_DECLARE(void) raw_write(std::string data);
|
SWITCH_DECLARE(void) raw_write(const char *data, int len);
|
||||||
SWITCH_DECLARE(const char *) get_data(void);
|
SWITCH_DECLARE(const char *) get_data(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,5 +33,4 @@ lua_wrap: mod_lua_extra.c
|
|||||||
swig -lua -c++ -I../../../../src/include -oh mod_lua_wrap.h -o mod_lua_wrap.cpp freeswitch.i
|
swig -lua -c++ -I../../../../src/include -oh mod_lua_wrap.h -o mod_lua_wrap.cpp freeswitch.i
|
||||||
echo "#include \"mod_lua_extra.c\"" >> mod_lua_wrap.cpp
|
echo "#include \"mod_lua_extra.c\"" >> mod_lua_wrap.cpp
|
||||||
patch -s -p0 -i hack.diff
|
patch -s -p0 -i hack.diff
|
||||||
sed -i -e 's/lua_strlen/lua_rawlen/' mod_lua_wrap.cpp
|
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
%newobject API::execute;
|
%newobject API::execute;
|
||||||
%newobject API::executeString;
|
%newobject API::executeString;
|
||||||
|
|
||||||
%include "std_string.i"
|
%include "typemaps.i"
|
||||||
|
%apply int *OUTPUT { int *len };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tell swig to grok everything defined in these header files and
|
* tell swig to grok everything defined in these header files and
|
||||||
|
@ -2946,18 +2946,18 @@ fail:
|
|||||||
static int _wrap_Stream_raw_write(lua_State* L) {
|
static int _wrap_Stream_raw_write(lua_State* L) {
|
||||||
int SWIG_arg = -1;
|
int SWIG_arg = -1;
|
||||||
Stream *arg1 = (Stream *) 0 ;
|
Stream *arg1 = (Stream *) 0 ;
|
||||||
std::string arg2 ;
|
char *arg2 = (char *) 0 ;
|
||||||
|
|
||||||
SWIG_check_num_args("raw_write",2,2)
|
SWIG_check_num_args("raw_write",2,2)
|
||||||
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("raw_write",1,"Stream *");
|
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("raw_write",1,"Stream *");
|
||||||
if(!lua_isstring(L,2)) SWIG_fail_arg("raw_write",2,"std::string");
|
if(!lua_isstring(L,2)) SWIG_fail_arg("raw_write",2,"char const *");
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
|
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
|
||||||
SWIG_fail_ptr("Stream_raw_write",1,SWIGTYPE_p_Stream);
|
SWIG_fail_ptr("Stream_raw_write",1,SWIGTYPE_p_Stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
(&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2));
|
arg2 = (char *)lua_tostring(L, 2);
|
||||||
(arg1)->raw_write(arg2);
|
(arg1)->raw_write((char const *)arg2,lua_rawlen(L, 2));
|
||||||
SWIG_arg=0;
|
SWIG_arg=0;
|
||||||
|
|
||||||
return SWIG_arg;
|
return SWIG_arg;
|
||||||
|
@ -22,7 +22,10 @@ class Stream {
|
|||||||
Stream(void);
|
Stream(void);
|
||||||
Stream(switch_stream_handle_t *);
|
Stream(switch_stream_handle_t *);
|
||||||
virtual ~ Stream();
|
virtual ~ Stream();
|
||||||
string read();
|
|
||||||
|
%inline %{
|
||||||
|
char *read(int *len);
|
||||||
|
%}
|
||||||
void write(const char *data);
|
void write(const char *data);
|
||||||
void raw_write(void *data, int len);
|
void raw_write(void *data, int len);
|
||||||
const char *get_data(void);
|
const char *get_data(void);
|
||||||
|
@ -532,22 +532,20 @@ SWITCH_DECLARE_CONSTRUCTOR Stream::~Stream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* WARNING!! you are not encouraged to use this unless you understand the risk!!! */
|
/* WARNING!! you are not encouraged to use this unless you understand the risk!!! */
|
||||||
SWITCH_DECLARE(std::string) Stream::read()
|
SWITCH_DECLARE(const char *) Stream::read(int *len)
|
||||||
{
|
{
|
||||||
uint8_t *buff;
|
uint8_t *buff;
|
||||||
this_check(std::string(""));
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
this_check(std::string());
|
this_check(NULL);
|
||||||
|
|
||||||
if (!stream_p->read_function) return std::string();
|
if (!stream_p->read_function) return NULL;
|
||||||
|
|
||||||
buff = stream_p->read_function(stream_p, &len);
|
buff = stream_p->read_function(stream_p, len);
|
||||||
|
|
||||||
if (!buff) return std::string();
|
if (!buff) return NULL;
|
||||||
if (len < 0) return std::string();
|
if (len < 0) return NULL;
|
||||||
|
|
||||||
return std::string((const char *)buff, len);
|
return (const char *)buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) Stream::write(const char *data)
|
SWITCH_DECLARE(void) Stream::write(const char *data)
|
||||||
@ -556,10 +554,10 @@ SWITCH_DECLARE(void) Stream::write(const char *data)
|
|||||||
stream_p->write_function(stream_p, "%s", data);
|
stream_p->write_function(stream_p, "%s", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) Stream::raw_write(std::string data)
|
SWITCH_DECLARE(void) Stream::raw_write(const char *data, int len)
|
||||||
{
|
{
|
||||||
this_check_void();
|
this_check_void();
|
||||||
stream_p->raw_write_function(stream_p, (uint8_t *)data.c_str(), data.length());
|
stream_p->raw_write_function(stream_p, (uint8_t *)data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(const char *)Stream::get_data()
|
SWITCH_DECLARE(const char *)Stream::get_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user