[DEV] update nullptr in null (specific etk)
This commit is contained in:
parent
1617790e48
commit
79c20a74ea
@ -105,7 +105,7 @@ enet::Http::Http(enet::Tcp _connection, bool _isServer) :
|
||||
m_isServer(_isServer),
|
||||
m_connection(etk::move(_connection)),
|
||||
m_headerIsSend(false),
|
||||
m_thread(nullptr),
|
||||
m_thread(null),
|
||||
m_threadRunning(false) {
|
||||
//setSendHeaderProperties("User-Agent", "e-net (ewol network interface)");
|
||||
/*
|
||||
@ -132,14 +132,14 @@ void enet::Http::threadCallback() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (m_observerRaw != nullptr) {
|
||||
if (m_observerRaw != null) {
|
||||
m_observerRaw(m_connection);
|
||||
} else {
|
||||
m_temporaryBuffer.resize(67000);
|
||||
int32_t len = m_connection.read(&m_temporaryBuffer[0], m_temporaryBuffer.size());
|
||||
if (len > 0) {
|
||||
ENET_INFO("Call client with datas ...");
|
||||
if (m_observer != nullptr) {
|
||||
if (m_observer != null) {
|
||||
m_observer(m_temporaryBuffer);
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ void enet::Http::start() {
|
||||
ENET_DEBUG("connect [START]");
|
||||
m_threadRunning = true;
|
||||
m_thread = ETK_NEW(ethread::Thread, [&](){ threadCallback();});
|
||||
if (m_thread == nullptr) {
|
||||
if (m_thread == null) {
|
||||
m_threadRunning = false;
|
||||
ENET_ERROR("creating callback thread!");
|
||||
return;
|
||||
@ -189,12 +189,12 @@ void enet::Http::stop(bool _inThreadStop){
|
||||
m_connection.unlink();
|
||||
}
|
||||
if (_inThreadStop == false) {
|
||||
if (m_thread != nullptr) {
|
||||
if (m_thread != null) {
|
||||
ENET_DEBUG("wait join Thread ...");
|
||||
m_thread->join();
|
||||
ENET_DEBUG("wait join Thread (done)");
|
||||
ETK_DELETE(ethread::Thread, m_thread);
|
||||
m_thread = nullptr;
|
||||
m_thread = null;
|
||||
}
|
||||
}
|
||||
ENET_DEBUG("disconnect [STOP]");
|
||||
@ -547,11 +547,11 @@ void enet::Http::getHeader() {
|
||||
}
|
||||
m_headerIsSend = true;
|
||||
if (m_isServer == false) {
|
||||
if (m_observerAnswer != nullptr) {
|
||||
if (m_observerAnswer != null) {
|
||||
m_observerAnswer(m_answerHeader);
|
||||
}
|
||||
} else {
|
||||
if (m_observerRequest != nullptr) {
|
||||
if (m_observerRequest != null) {
|
||||
m_observerRequest(m_requestHeader);
|
||||
}
|
||||
}
|
||||
|
@ -204,8 +204,8 @@ int32_t enet::Tcp::write(const void* _data, int32_t _len) {
|
||||
ENET_ERROR("Can not write on unlink connection");
|
||||
return -1;
|
||||
}
|
||||
if (_data == nullptr) {
|
||||
ENET_ERROR("try write nullptr data on TCP socket");
|
||||
if (_data == null) {
|
||||
ENET_ERROR("try write null data on TCP socket");
|
||||
return -1;
|
||||
}
|
||||
if (_len <= 0) {
|
||||
|
@ -79,7 +79,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
// Resolve the server address and port
|
||||
struct addrinfo* result = nullptr;
|
||||
struct addrinfo* result = null;
|
||||
etk::String portValue = etk::toString(_port);
|
||||
int iResult = getaddrinfo(_hostname.c_str(), portValue.c_str(), &hints, &result);
|
||||
if (iResult != 0) {
|
||||
@ -89,7 +89,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
||||
|
||||
// Attempt to connect to an address until one succeeds
|
||||
for(struct addrinfo* ptr=result;
|
||||
ptr != nullptr;
|
||||
ptr != null;
|
||||
ptr=ptr->ai_next) {
|
||||
ENET_DEBUG(" find one ...");
|
||||
// Create a SOCKET for connecting to server
|
||||
@ -149,7 +149,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
||||
}
|
||||
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
||||
struct sockaddr_in servAddr;
|
||||
struct hostent* server = nullptr;
|
||||
struct hostent* server = null;
|
||||
if ( _hostname.c_str()[0] >= '0'
|
||||
&& _hostname.c_str()[0] <= '9') {
|
||||
ENET_INFO("Calling gethostbyaddr with " << _hostname);
|
||||
@ -167,7 +167,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
||||
// TODO : This is deprecated use getaddrinfo like windows ...
|
||||
server = gethostbyname(_hostname.c_str());
|
||||
}
|
||||
if (server == nullptr) {
|
||||
if (server == null) {
|
||||
ENET_ERROR("ERROR, no such host : " << _hostname);
|
||||
continue;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void enet::TcpServer::setPort(uint16_t _port) {
|
||||
}
|
||||
ENET_INFO("Start connection on " << m_host << ":" << m_port);
|
||||
|
||||
struct addrinfo *result = nullptr;
|
||||
struct addrinfo *result = null;
|
||||
struct addrinfo hints;
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
@ -82,7 +82,7 @@ void enet::TcpServer::setPort(uint16_t _port) {
|
||||
|
||||
// Resolve the server address and port
|
||||
etk::String portValue = etk::toString(m_port);
|
||||
int iResult = getaddrinfo(nullptr, portValue.c_str(), &hints, &result);
|
||||
int iResult = getaddrinfo(null, portValue.c_str(), &hints, &result);
|
||||
if (iResult != 0) {
|
||||
ENET_ERROR("getaddrinfo failed with error: " << iResult);
|
||||
return 1;
|
||||
|
@ -29,22 +29,22 @@ namespace enet {
|
||||
|
||||
enet::WebSocket::WebSocket() :
|
||||
m_connectionValidate(false),
|
||||
m_interface(nullptr),
|
||||
m_observer(nullptr),
|
||||
m_observerUriCheck(nullptr) {
|
||||
m_interface(null),
|
||||
m_observer(null),
|
||||
m_observerUriCheck(null) {
|
||||
|
||||
}
|
||||
|
||||
enet::WebSocket::WebSocket(enet::Tcp _connection, bool _isServer) :
|
||||
m_connectionValidate(false),
|
||||
m_interface(nullptr),
|
||||
m_observer(nullptr),
|
||||
m_observerUriCheck(nullptr) {
|
||||
m_interface(null),
|
||||
m_observer(null),
|
||||
m_observerUriCheck(null) {
|
||||
setInterface(etk::move(_connection), _isServer);
|
||||
}
|
||||
|
||||
const etk::String& enet::WebSocket::getRemoteAddress() const {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
static const etk::String tmpOut;
|
||||
return tmpOut;
|
||||
}
|
||||
@ -56,17 +56,17 @@ void enet::WebSocket::setInterface(enet::Tcp _connection, bool _isServer) {
|
||||
if (_isServer == true) {
|
||||
ememory::SharedPtr<enet::HttpServer> interface = ememory::makeShared<enet::HttpServer>(etk::move(_connection));
|
||||
m_interface = interface;
|
||||
if (interface != nullptr) {
|
||||
if (interface != null) {
|
||||
interface->connectHeader(this, &enet::WebSocket::onReceiveRequest);
|
||||
}
|
||||
} else {
|
||||
ememory::SharedPtr<enet::HttpClient> interface = ememory::makeShared<enet::HttpClient>(etk::move(_connection));
|
||||
m_interface = interface;
|
||||
if (interface != nullptr) {
|
||||
if (interface != null) {
|
||||
interface->connectHeader(this, &enet::WebSocket::onReceiveAnswer);
|
||||
}
|
||||
}
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("can not create interface for the websocket");
|
||||
return;
|
||||
}
|
||||
@ -74,7 +74,7 @@ void enet::WebSocket::setInterface(enet::Tcp _connection, bool _isServer) {
|
||||
}
|
||||
|
||||
enet::WebSocket::~WebSocket() {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
return;
|
||||
}
|
||||
stop(true);
|
||||
@ -96,7 +96,7 @@ static etk::String generateCheckKey(const etk::String& _key) {
|
||||
}
|
||||
|
||||
void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::String>& _listProtocols) {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -131,7 +131,7 @@ void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::Stri
|
||||
req.setKey("Sec-WebSocket-Protocol", protocolList);
|
||||
}
|
||||
ememory::SharedPtr<enet::HttpClient> interface = ememory::dynamicPointerCast<enet::HttpClient>(m_interface);
|
||||
if (interface != nullptr) {
|
||||
if (interface != null) {
|
||||
interface->setHeader(req);
|
||||
int32_t timeout = 500000; // 5 second
|
||||
while ( timeout>=0
|
||||
@ -160,7 +160,7 @@ void enet::WebSocket::start(const etk::String& _uri, const etk::Vector<etk::Stri
|
||||
|
||||
void enet::WebSocket::stop(bool _inThread) {
|
||||
ENET_DEBUG("Stop interface ...");
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -309,14 +309,14 @@ void enet::WebSocket::onReceiveData(enet::Tcp& _connection) {
|
||||
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_TEXT) {
|
||||
// Close the conection by remote:
|
||||
ENET_WARNING("Receive a Text(UTF-8) data " << m_buffer.size() << " Bytes");
|
||||
if (m_observer != nullptr) {
|
||||
if (m_observer != null) {
|
||||
m_observer(m_buffer, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((opcode & 0x0F) == enet::websocket::OPCODE_FRAME_BINARY) {
|
||||
// Close the conection by remote:
|
||||
if (m_observer != nullptr) {
|
||||
if (m_observer != null) {
|
||||
m_observer(m_buffer, false);
|
||||
}
|
||||
return;
|
||||
@ -345,7 +345,7 @@ static etk::String removeStartAndStopSpace(const etk::String& _value) {
|
||||
|
||||
void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
||||
ememory::SharedPtr<enet::HttpServer> interface = ememory::dynamicPointerCast<enet::HttpServer>(m_interface);
|
||||
if (interface == nullptr) {
|
||||
if (interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -390,7 +390,7 @@ void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
||||
listProtocol[iii] = removeStartAndStopSpace(listProtocol[iii]);
|
||||
}
|
||||
}
|
||||
if (m_observerUriCheck != nullptr) {
|
||||
if (m_observerUriCheck != null) {
|
||||
etk::String ret = m_observerUriCheck(_data.getUri(), listProtocol);
|
||||
if (ret == "OK") {
|
||||
// Nothing to do
|
||||
@ -427,7 +427,7 @@ void enet::WebSocket::onReceiveRequest(const enet::HttpRequest& _data) {
|
||||
}
|
||||
|
||||
void enet::WebSocket::onReceiveAnswer(const enet::HttpAnswer& _data) {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -489,7 +489,7 @@ int32_t enet::WebSocket::writeData(uint8_t* _data, int32_t _len) {
|
||||
}
|
||||
|
||||
int32_t enet::WebSocket::send() {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return -1;
|
||||
}
|
||||
@ -547,7 +547,7 @@ int32_t enet::WebSocket::write(const void* _data, int32_t _len, bool _isString,
|
||||
}
|
||||
|
||||
void enet::WebSocket::controlPing() {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -561,7 +561,7 @@ void enet::WebSocket::controlPing() {
|
||||
}
|
||||
|
||||
void enet::WebSocket::controlPong() {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
@ -575,7 +575,7 @@ void enet::WebSocket::controlPong() {
|
||||
}
|
||||
|
||||
void enet::WebSocket::controlClose() {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
ENET_ERROR("Nullptr interface ...");
|
||||
return;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace enet {
|
||||
void start(const etk::String& _uri="", const etk::Vector<etk::String>& _listProtocols=etk::Vector<etk::String>());
|
||||
void stop(bool _inThread=false);
|
||||
bool isAlive() const {
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
return false;
|
||||
}
|
||||
return m_interface->isAlive();
|
||||
|
Loading…
Reference in New Issue
Block a user