diff --git a/asynio/asynframeimpl.cpp b/asynio/asynframeimpl.cpp index 8d4c5f83f81b84ed111ef2bcf1e914372f3f438d..64a490e5af2d036ba7a266eed8d3a5f3c61dbaba 100644 --- a/asynio/asynframeimpl.cpp +++ b/asynio/asynframeimpl.cpp @@ -47,6 +47,7 @@ HRESULT CAsynFrameImpl::Start(_pinstance hInstance, UINT uType) } HRESULT CAsynFrameImpl::Stop(UINT uExitCode) { + CThread::Stop_Thread(); contexts_uninit(); UnInitSocketEnv(2, 0); diff --git a/asynio/asynframeimpl.h b/asynio/asynframeimpl.h index 091712a6d4abd162dab224a7b621a27643f8f61a..e0b3350cce008fdad391cfa1420a76640d3ceedc 100644 --- a/asynio/asynframeimpl.h +++ b/asynio/asynframeimpl.h @@ -2,7 +2,7 @@ #define _ASYNFRAMEIMPL_H_ #include "stdafx.h" - +#include "iocontext.hpp" class CAsynFrameImpl : public IAsynFrame, public IPlugin, public IPluginRun, diff --git a/asynio/iostream.hpp b/asynio/iostream.hpp index 15f68d511183cc00c67ca263c499ccc7892c5703..30d0e010bbb6b438bfa246337918d9948e4b818b 100644 --- a/asynio/iostream.hpp +++ b/asynio/iostream.hpp @@ -18,30 +18,34 @@ public: } public: - int async_read(BUF_PTR buf, BUF_SIZE size) { + int async_read(BUF_PTR buf, BUF_SIZE size, IBase* pBase) { rc_assert(this->ptr != NULL, S_ERROR) rc_assert(this->safe != NULL, S_ERROR) //no need try catch + pBase->AddRef(); this->ptr->async_receive(boost::asio::buffer(this->ctx.rptr, this->ctx.rlen), safe->wrap(boost::bind(&IoStreamBase::stream_handle_read, this, + pBase, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); return S_SUCCESS; } - int async_write(BUF_PTR buf, BUF_SIZE size) { + int async_write(BUF_PTR buf, BUF_SIZE size, IBase* pBase) { rc_assert(this->ptr != NULL, S_ERROR) rc_assert(this->safe != NULL, S_ERROR) //no need try catch + pBase->AddRef(); this->ptr->async_send(boost::asio::buffer(this->ctx.wptr, this->ctx.wlen), safe->wrap(boost::bind(&IoStreamBase::stream_handle_write, this, + pBase, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); @@ -76,7 +80,7 @@ public: return rc; } private: - int stream_handle_read(io_c_error_code ec,size_t rbytes) { + int stream_handle_read(IBase* pBase, io_c_error_code ec,size_t rbytes) { if (ec) { this->StreamEventcb(this->ctx.data, STREAM_READ_ERROR); @@ -84,10 +88,11 @@ private: else { this->StreamReadcb(this->ctx.data, rbytes); } + pBase->Release(); return S_SUCCESS; } - int stream_handle_write(io_c_error_code ec, size_t wbytes) { + int stream_handle_write(IBase* pBase, io_c_error_code ec, size_t wbytes) { if (ec) { this->StreamEventcb(this->ctx.data, STREAM_WRITE_ERROR); @@ -95,6 +100,7 @@ private: else { this->StreamWritecb(this->ctx.data, wbytes); } + pBase->Release(); return S_SUCCESS; } private: diff --git a/asynio/iotcp.hpp b/asynio/iotcp.hpp index 92f90a86e0c84a94e64c5c7cc250a2fcce091d96..405df819e1f8dc823a2db65accb9b4d5b0ae0098 100644 --- a/asynio/iotcp.hpp +++ b/asynio/iotcp.hpp @@ -14,7 +14,6 @@ public: this->ptr = NULL; this->safe = NULL; this->tm = NULL; - conn = 0; contimeout = 0; s_memset(&this->ctx, 0, sizeof(io_data_t)); } @@ -25,7 +24,7 @@ public: int tcp_create(io_service* pService) { this->ptr = ALLOC_NEW io_socket(*pService); - rc_assert(this->ptr!= NULL, S_ERROR) + rc_assert(this->ptr != NULL, S_ERROR) this->tm = ALLOC_NEW io_time(*pService); rc_assert(this->tm!= NULL, S_ERROR) @@ -73,7 +72,6 @@ public: io_error_code ec; try { - this->tm->cancel(ec); if (ec) { loge("this->tm->cancel==>%s", ec.message().c_str()); @@ -101,7 +99,7 @@ public: return rc; } //https://www.boost.org/doc/libs/1_68_0/doc/html/boost_asio/example/cpp03/timeouts/async_tcp_client.cpp - int tcp_async_connect(void* data, const char* addr, unsigned short port, int timeout) { + int tcp_async_connect(void* data, const char* addr, unsigned short port, int timeout, IBase* pBase) { rc_assert(this->ptr!= NULL, S_ERROR) rc_assert(this->tm!= NULL, S_ERROR) @@ -111,18 +109,23 @@ public: try { this->netaddr = boost::asio::ip::address::from_string(addr); + + pBase->AddRef(); this->ptr->async_connect( tcp::endpoint(this->netaddr, port), boost::bind(&IoTcpBase::tcp_connect_handler, this, + pBase, boost::asio::placeholders::error)); this->tm->expires_from_now(boost::posix_time::seconds(timeout)); this->tm->async_wait(boost::bind(&IoTcpBase::tcp_connect_timeout_handler, this, + pBase, boost::asio::placeholders::error)); } catch (stdexcep err) { + pBase->Release(); loge("std::exception:%s", err.what()); rc = S_ERROR; } @@ -169,36 +172,34 @@ public: return rc; } - int tcp_connect_handler(io_c_error_code ec) { + int tcp_connect_handler(IBase* pBase, io_c_error_code ec) { if (ec) { if (ec.value() != boost::system::errc::operation_canceled) { - + this->ptr->close(); + this->ConnectCB(this->ctx.data, TCP_CONNECT_FAILD); } - this->conn = TCP_CONNECT_FAILD; - this->ptr->close(); - this->ConnectCB(this->ctx.data, TCP_CONNECT_FAILD); - } else { this->tcp_setoption(); - this->conn = TCP_CONNECTED; this->ConnectCB(this->ctx.data, TCP_CONNECTED); } //this->tm->cancel();//win xp ==> No support + pBase->Release(); return S_SUCCESS; } - int tcp_connect_timeout_handler(io_c_error_code ec) { + int tcp_connect_timeout_handler(IBase* pBase, io_c_error_code ec) { if (ec) { + logi("error %d==>%error_messag==%s\n", ec.value(), ec.message().c_str()); if (ec.value() != boost::system::errc::operation_canceled) { - this->ConnectCB(this->ctx.data, TCP_CONNECT_FAILD); - this->conn = TCP_CONNECT_FAILD; + //this->ConnectCB(this->ctx.data, TCP_CONNECT_FAILD); } } else { - conn = TCP_CONNECT_TIMEOUT; this->ConnectCB(this->ctx.data, TCP_CONNECT_TIMEOUT); + pBase->Release(); } + return S_SUCCESS; } @@ -211,7 +212,6 @@ public: io_time_ptr tm; io_address netaddr; io_data_t ctx; - int conn; int contimeout; public: virtual void ConnectCB(void *data, event_id error_code) = 0; diff --git a/asynio/iotcpaccept.hpp b/asynio/iotcpaccept.hpp index 472a411b6fd090a4c1704c0c394d163204a28c27..3c6cbf1087ba2d1f427c233e0f1b88dbfbd57638 100644 --- a/asynio/iotcpaccept.hpp +++ b/asynio/iotcpaccept.hpp @@ -31,15 +31,11 @@ public: this->safe = ALLOC_NEW io_strand(*pService); rc_assert(this->safe!= NULL, S_ERROR) - _sem_init(&this->post_sem, 0); - - post_ref.value = 0; - return S_SUCCESS; } int accpet_destory() { - _sem_destroy(&this->post_sem); + rc_assert(this->acceptptr != NULL, S_ERROR) delete this->acceptptr; @@ -74,10 +70,8 @@ public: int rc = S_SUCCESS; try { - this->acceptptr->close(); - if (post_ref.value > 0) - this->accept_wait_sem(); + this->acceptptr->close(); } catch (stdexcep err) { loge("std::exception:%s", err.what()); @@ -115,17 +109,17 @@ public: } return rc; } - int accpet_wait(const IoTcpBase* tcp, void* data) { + int accpet_wait(const IoTcpBase* tcp, IBase* data, IBase* accept) { rc_assert(this->acceptptr != NULL, S_ERROR) - this->accept_add_ref(); - + accept->AddRef(); this->acceptptr->async_accept(*tcp->ptr, safe->wrap(boost::bind(&IoTcpAccpet::accept_handle, this, boost::asio::placeholders::error, data, + accept, tcp))); @@ -136,55 +130,28 @@ public: rc_assert(this->acceptptr->is_open(), S_ERROR) return S_SUCCESS; } - int accept_handle(io_c_error_code ec, void* data, const IoTcpBase* tcp) { + int accept_handle(io_c_error_code ec, IBase* data, IBase* accept, const IoTcpBase* tcp) { - this->accept_del_ref(); int rc = S_SUCCESS; + + if (ec) { - try { - if (ec) { - loge("accept error %ld", this->post_ref); + if (ec.value() != boost::system::errc::operation_canceled) { this->AcceptCB(data, TCP_ACCEPT_FAILD, 0); - } else { - this->AcceptCB(data, TCP_ACCEPT_CONNECTED, tcp->ptr->native_handle()); } - } catch (stdexcep err) { - loge("std::exception:%s", err.what()); - rc = S_ERROR; - } - - if (post_ref.value == 0) - { - accept_post_sem(); + } else { + this->AcceptCB(data, TCP_ACCEPT_CONNECTED, tcp->ptr->native_handle()); } + accept->Release(); return rc; } - long accept_add_ref() { - - return _atomic_add(&this->post_ref); - } - long accept_del_ref() { - - return _atomic_del(&this->post_ref); - } - void accept_wait_sem() { - - _sem_wait(&this->post_sem); - } - void accept_post_sem() { - - _sem_post(&this->post_sem); - } io_acceptor_ptr acceptptr; io_strand_ptr safe; - _atomic_t post_ref; - _sem_t post_sem; - public: - virtual void AcceptCB(void *data, event_id error_code, _sock_t s) = 0; + virtual void AcceptCB(IBase* pBase, event_id error_code, _sock_t s) = 0; }; #endif diff --git a/asynio/iotimer.hpp b/asynio/iotimer.hpp index 63b2d4ce3df8ef50d0513af05777b8fdd5825f6b..ecd25a4cfb972b81da526b65b169ba55e325bd94 100644 --- a/asynio/iotimer.hpp +++ b/asynio/iotimer.hpp @@ -1,27 +1,25 @@ #ifndef _IO_TIMER_H_ #define _IO_TIMER_H_ -#include "ioeventdef.h" +#include "stdafx.h" -class IoTimer + +class evtimer { public: - IoTimer(void) { - + evtimer() { second = 0; - stat = S_ERROR; this->tm = NULL; this->safe = NULL; } - virtual ~IoTimer(void) { - + virtual ~evtimer(void) { + time_destory(); } - int time_create(io_service* pService) { - + int time_create(io_service* pService) + { this->tm = ALLOC_NEW io_time(*pService); rc_assert(this->tm != NULL, S_ERROR) - return S_SUCCESS; } int time_destory() { @@ -29,7 +27,6 @@ public: rc_assert(this->tm != NULL, S_ERROR) delete this->tm; this->tm = NULL; - return S_SUCCESS; } @@ -38,58 +35,34 @@ public: rc_assert(this->tm != NULL, S_ERROR) int rc = S_SUCCESS; - try { - this->tm->expires_from_now(boost::posix_time::seconds(sec)); - second = sec; - } catch (stdexcep err) { - loge("std::exception:%s", err.what()); - rc = S_ERROR; - } + second = sec; + return S_SUCCESS; } - int time_start() { - - rc_assert(this->tm != NULL, S_ERROR) - int rc = S_SUCCESS; - - try { - this->tm->async_wait(boost::bind(&IoTimer::timer_handler, - this, - boost::asio::placeholders::error)); + int time_start(IBase *pBase) { - stat = S_SUCCESS; - - } catch (stdexcep err) { - loge("std::exception:%s", err.what()); - rc = S_ERROR; - } - return rc; + return time_contine(pBase); } int time_stop() { rc_assert(this->tm != NULL, S_ERROR) - int rc = S_SUCCESS; - - try { - this->tm->cancel(); - stat = S_ERROR; - } - catch (stdexcep err) { - loge("std::exception:%s", err.what()); - rc = S_ERROR; - } - + boost::system::error_code ec; + this->tm->cancel(ec); + return S_SUCCESS; } - int time_contine() { + int time_contine(IBase* pBase) { rc_assert(this->tm != NULL, S_ERROR) int rc = S_SUCCESS; try { + + pBase->AddRef(); this->tm->expires_from_now(boost::posix_time::seconds(second)); - this->tm->async_wait(boost::bind(&IoTimer::timer_handler, + this->tm->async_wait(boost::bind(&evtimer::timer_handler, this, + pBase, boost::asio::placeholders::error)); } catch (stdexcep err) { loge("std::exception:%s", err.what()); @@ -98,24 +71,28 @@ public: return S_SUCCESS; } - int timer_handler(io_c_error_code ec) { + int timer_handler(IBase* pBase, io_c_error_code ec) { + + if (!ec) { + this->OnTime(1); + goto end; + } + + logi("error %d==>error_messag==%s\n", ec.value(), ec.message().c_str()); + if (ec.value() != boost::system::errc::operation_canceled) { - if (ec) { - if (ec.value() != boost::system::errc::operation_canceled) { - //this->OnTime(S_ERROR); - } - } else { - this->OnTime(S_SUCCESS); } + this->OnTime(S_SUCCESS); + + end: + pBase->Release(); return S_SUCCESS; } -public: - virtual int OnTime(UINT err) = 0; - +protected: + virtual int OnTime(UINT err) = 0; private: int second; - int stat; io_time_ptr tm; io_strand_ptr safe; }; diff --git a/asynio/spipeimpl.cpp b/asynio/spipeimpl.cpp index 75b8275d998e0650ec4514382f806d4d4d0b8ee4..847eeed34b2f3004f49d0ddd045855198e2b3c20 100644 --- a/asynio/spipeimpl.cpp +++ b/asynio/spipeimpl.cpp @@ -1,14 +1,14 @@ #include "spipeimpl.h" -void OnOperation(void* owner, - boost::asio::detail::operation* a, - const boost::system::error_code&, std::size_t) -{ - -} - -CSPipeImpl::CSPipeImpl(void) : - boost::asio::detail::operation(OnOperation) +//void OnOperation(void* owner, +// boost::asio::detail::operation* a, +// const boost::system::error_code&, std::size_t) +//{ +// +//} + +CSPipeImpl::CSPipeImpl(void)/* : + boost::asio::detail::operation(OnOperation)*/ { } diff --git a/asynio/spipeimpl.h b/asynio/spipeimpl.h index 26e3726ae1ba248bee1d56970c083696ad49d484..d6ecef03aa1adef509b44074bd0380405bdd5659 100644 --- a/asynio/spipeimpl.h +++ b/asynio/spipeimpl.h @@ -2,11 +2,11 @@ #define _SPIPEIMPL_H_ #include "stdafx.h" -#include "boost/asio/detail/operation.hpp" +#include "boost_def.hpp" class CSPipeImpl : public ISPipe, - public CUnknownImp, - public boost::asio::detail::operation + public CUnknownImp + { public: CSPipeImpl(void); diff --git a/asynio/stdafx.h b/asynio/stdafx.h index 82562ac7757bf72d2f2a594fd5243772d64a1558..d0b479292680bf9209204265d76a3cae77ee2bb0 100644 --- a/asynio/stdafx.h +++ b/asynio/stdafx.h @@ -9,11 +9,7 @@ #include #include -#include "iocontext.hpp" -#include "iotcpaccept.hpp" -#include "iotimer.hpp" -#include "iodgram.hpp" -#include "iostream.hpp" +#include "ioeventdef.h" typedef map SockOptionTable; typedef SockOptionTable::iterator SockOption; diff --git a/asynio/tcplistensocketimpl.cpp b/asynio/tcplistensocketimpl.cpp index 3076d89d807f62c12226295383806a91c0ad296b..8d8f178ad354c43466b7bb6b14bc120a775108f1 100644 --- a/asynio/tcplistensocketimpl.cpp +++ b/asynio/tcplistensocketimpl.cpp @@ -93,7 +93,7 @@ HRESULT CTcpListenSocketImpl::Accept(IBase* pBase) CTcpSocketImpl *sock = static_cast(pAsynTcpScoket.m_p); rc_assert(sock != NULL, E_FAIL) - rc_assert(accpet_wait(sock->GetIoTcp(), pBase) == S_SUCCESS, E_FAIL) + rc_assert(accpet_wait(sock->GetIoTcp(), pBase, this) == S_SUCCESS, E_FAIL) return hr; } @@ -108,13 +108,10 @@ HRESULT CTcpListenSocketImpl::UnBindAccpet() m_accept.dispose(); return S_OK; } -void CTcpListenSocketImpl::AcceptCB(void *data, event_id error_code, _sock_t s) +void CTcpListenSocketImpl::AcceptCB(IBase* pBase, event_id error_code, _sock_t s) { - c_assert(data != NULL) - IBase* pBase = static_cast(data); - c_assert(pBase != NULL) - c_assert(m_accept != NULL) + c_assert(m_accept.m_p != NULL) m_accept->Accept(pBase, s, error_code); } diff --git a/asynio/tcplistensocketimpl.h b/asynio/tcplistensocketimpl.h index 2374669fdaa62b7ee5c37a7d1c6e6d18af08da60..748de2042cc1ac6be415cbfb9048cd86e343c171 100644 --- a/asynio/tcplistensocketimpl.h +++ b/asynio/tcplistensocketimpl.h @@ -2,10 +2,10 @@ #define _ASYNCTCPLISTENSOCKIMPL_H_ #include "stdafx.h" - -class CTcpListenSocketImpl : public ITcpListen, - public CUnknownImp, - public IoTcpAccpet +#include "iotcpaccept.hpp" +class CTcpListenSocketImpl : public ITcpListen, + public CUnknownImp, + public IoTcpAccpet { public: CTcpListenSocketImpl(void); @@ -41,7 +41,7 @@ public: std_method(UnBindAccpet)(); public: - void AcceptCB(void *data, event_id error_code, _sock_t s); + void AcceptCB(IBase* pBase, event_id error_code, _sock_t s); private: _sock_t m_sock; AcceptListenPtr m_accept; diff --git a/asynio/tcpsocketimpl.cpp b/asynio/tcpsocketimpl.cpp index 3aae5f94398ba69db38995adb4f28d7aef2ef380..cb12d50f9879ac9b411a04b1112176565c1618aa 100644 --- a/asynio/tcpsocketimpl.cpp +++ b/asynio/tcpsocketimpl.cpp @@ -12,6 +12,7 @@ CTcpSocketImpl::~CTcpSocketImpl() HRESULT CTcpSocketImpl::CloseIo(UINT rw) { tcp_close(); + m_pOperation.dispose(); return S_OK; } @@ -161,21 +162,22 @@ HRESULT CTcpSocketImpl::ReadIo(IBase* pBase, event_id event) HRESULT hr = S_OK; int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); + + + hr = pBase->QueryInterface(IID_IOperation, (void**)&m_pOperation); rc_assert(hr == S_OK, E_FAIL) this->ctx.data = pBase; this->ctx.event = event; - hr = pOperation->GetPtr(&this->ctx.rptr); + hr = m_pOperation->GetPtr(&this->ctx.rptr); rc_assert(this->ctx.rptr != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) - hr = pOperation->GetExpect(&this->ctx.rlen); + hr = m_pOperation->GetExpect(&this->ctx.rlen); rc_assert(hr == S_OK, E_FAIL) - rc = async_read(this->ctx.rptr, this->ctx.rlen); + rc = async_read(this->ctx.rptr, this->ctx.rlen, this); return (S_SUCCESS == rc) ? S_OK : E_FAIL; } HRESULT CTcpSocketImpl::WriteIo(IBase* pBase, event_id event) @@ -184,21 +186,21 @@ HRESULT CTcpSocketImpl::WriteIo(IBase* pBase, event_id event) HRESULT hr = S_OK; int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); + + hr = pBase->QueryInterface(IID_IOperation, (void**)&m_pOperation); rc_assert(hr == S_OK, E_FAIL) this->ctx.data = pBase; this->ctx.event = event; - hr = pOperation->GetPtr(&this->ctx.wptr); + hr = m_pOperation->GetPtr(&this->ctx.wptr); rc_assert(this->ctx.wptr != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) - hr = pOperation->GetExpect(&this->ctx.wlen); + hr = m_pOperation->GetExpect(&this->ctx.wlen); rc_assert(hr == S_OK, E_FAIL) - rc = async_write(this->ctx.wptr, this->ctx.wlen); + rc = async_write(this->ctx.wptr, this->ctx.wlen, this); return (S_SUCCESS == rc) ? S_OK : E_FAIL; } @@ -211,13 +213,13 @@ HRESULT CTcpSocketImpl::ConnectIo(NET_ADDR addr, NET_PORT port, HRESULT hr = S_OK; int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); + + hr = pBase->QueryInterface(IID_IOperation, (void**)&m_pOperation); rc_assert(hr == S_OK, E_FAIL) this->ctx.data = pBase; this->ctx.event = event; - rc = tcp_async_connect(pOperation, addr, port, contimeout); + rc = tcp_async_connect(m_pOperation, addr, port, contimeout, this); return (rc == S_SUCCESS) ? S_OK : E_FAIL; } diff --git a/asynio/tcpsocketimpl.h b/asynio/tcpsocketimpl.h index 806d4c8bf3d3ef8134763110119470b8f0d09f81..07fc6c5c2fc59a93a6dd5eda0b65454dad2a53cf 100644 --- a/asynio/tcpsocketimpl.h +++ b/asynio/tcpsocketimpl.h @@ -2,7 +2,7 @@ #define _ASYNCTCPSOCKIMPL_H_ #include "stdafx.h" - +#include "iostream.hpp" class CTcpSocketImpl : public ITcpSocket, public CUnknownImp, public IoStreamBase @@ -50,7 +50,7 @@ private: private: _sock_t m_sock; SockOptionTable m_sockoption; - + OperationPtr m_pOperation; }; diff --git a/asynio/tcpsocketsslimpl.cpp b/asynio/tcpsocketsslimpl.cpp index 8953cf28f5c66e8827aab6361966b8ecc8a20dc5..094dac6348acafd8b306790cc261d3ff50d04119 100644 --- a/asynio/tcpsocketsslimpl.cpp +++ b/asynio/tcpsocketsslimpl.cpp @@ -11,7 +11,7 @@ CTcpSocketSSLImpl::~CTcpSocketSSLImpl() HRESULT CTcpSocketSSLImpl::CloseIo(UINT rw) { tcp_close(); - + m_pOperation.dispose(); return S_OK; } HRESULT CTcpSocketSSLImpl::BindIo() @@ -63,72 +63,6 @@ HRESULT CTcpSocketSSLImpl::SetOption(LPCSTR opt, int val) { HRESULT hr = S_OK; - if (s_strcmp(opt, SOL_REUSEDDR) == 0) { - - SetReuseAddr(&m_sock, val); - } - else if (s_strcmp(opt, SOL_NODELAY) == 0) { - - SetNoDelay(&m_sock, val); - } - else if (s_strcmp(opt, SOL_LINGER) == 0) { - - SetLinger(&m_sock, val); - } - else if (s_strcmp(opt, SOL_KEEPLIVE) == 0) { - - SetKeepalive(&m_sock, val); - } - else if (s_strcmp(opt, SOL_CORK) == 0) { - - SetCork(&m_sock, val); - } - else if (s_strcmp(opt, SOL_NOSIGPIPE) == 0) { - - SetNoSigPipe(&m_sock, val); - } - else if (s_strcmp(opt, SOL_RECVLEN) == 0) { - - SetRecvBufLen(&m_sock, val); - } - else if (s_strcmp(opt, SOL_SENDLEN) == 0) { - - SetSendBufLen(&m_sock, val); - } - else if (s_strcmp(opt, SOL_SENDTM) == 0) { - - SetSendTimeOut(&m_sock, val); - } - else if (s_strcmp(opt, SOL_RECVTM) == 0) { - - SetRecvTimeOut(&m_sock, val); - } - else if (s_strcmp(opt, SOL_CONTM) == 0) { - - SetConTimeOut(&m_sock, val); - } - else if (s_strcmp(opt, SOL_SENDLOWAT) == 0) { - - SetSendLoWat(&m_sock, val); - } - else if (s_strcmp(opt, SOL_RECVLOWAT) == 0) { - - SetRecvLoWat(&m_sock, val); - } - else if (s_strcmp(opt, SOL_ONLY_READ) == 0) { - - _shutdown_sock(m_sock, SHUT_SOCK_RD); - } - else if (s_strcmp(opt, SOL_ONLY_WRITE) == 0) { - - _shutdown_sock(m_sock, SHUT_SOCK_RW); - } - else { - return E_FAIL; - } - - m_sockoption[opt] = val; - return hr; } HRESULT CTcpSocketSSLImpl::GetOption(LPCSTR opt, int* val) @@ -151,54 +85,20 @@ HRESULT CTcpSocketSSLImpl::SyncConnect(NET_ADDR addr, NET_PORT port) { rc_assert(addr != NULL, E_FAIL) rc_assert(port != INVALID_NET_PORT, E_FAIL) - return (tcp_sync_connect(addr, port) == S_SUCCESS ? S_OK : E_FAIL); + return S_OK; } HRESULT CTcpSocketSSLImpl::ReadIo(IBase* pBase, event_id event) { rc_assert(pBase != NULL, E_FAIL) - - HRESULT hr = S_OK; - int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); - rc_assert(hr == S_OK, E_FAIL) - - this->ctx.data = pBase; - this->ctx.event = event; - - hr = pOperation->GetPtr(&this->ctx.rptr); - rc_assert(this->ctx.rptr != NULL, E_FAIL) - rc_assert(hr == S_OK, E_FAIL) - - hr = pOperation->GetExpect(&this->ctx.rlen); - rc_assert(hr == S_OK, E_FAIL) - - rc = async_read(this->ctx.rptr, this->ctx.rlen); - return (S_SUCCESS == rc) ? S_OK : E_FAIL; + return S_OK; } HRESULT CTcpSocketSSLImpl::WriteIo(IBase* pBase, event_id event) { rc_assert(pBase != NULL, E_FAIL) HRESULT hr = S_OK; - int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); - rc_assert(hr == S_OK, E_FAIL) - - this->ctx.data = pBase; - this->ctx.event = event; - hr = pOperation->GetPtr(&this->ctx.wptr); - rc_assert(this->ctx.wptr != NULL, E_FAIL) - rc_assert(hr == S_OK, E_FAIL) - - hr = pOperation->GetExpect(&this->ctx.wlen); - rc_assert(hr == S_OK, E_FAIL) - - rc = async_write(this->ctx.wptr, this->ctx.wlen); - - return (S_SUCCESS == rc) ? S_OK : E_FAIL; + return S_OK; } HRESULT CTcpSocketSSLImpl::ConnectIo(NET_ADDR addr, NET_PORT port, IBase* pBase, event_id event) @@ -207,28 +107,10 @@ HRESULT CTcpSocketSSLImpl::ConnectIo(NET_ADDR addr, NET_PORT port, rc_assert(port != INVALID_NET_PORT, E_FAIL) rc_assert(pBase != NULL, E_FAIL) - HRESULT hr = S_OK; - int rc = S_SUCCESS; - OperationPtr pOperation; - hr = pBase->QueryInterface(IID_IOperation, (void**)&pOperation); - rc_assert(hr == S_OK, E_FAIL) - - this->ctx.data = pBase; - this->ctx.event = event; - rc = tcp_async_connect(pOperation, addr, port, contimeout); - - return (rc == S_SUCCESS) ? S_OK : E_FAIL; + return S_OK; } HRESULT CTcpSocketSSLImpl::LoadCertificate(UCHAR* buf, size_t size) { - - //char cwd_buff[100 + 1] = {0x00}; - //int ret = 0; - //ret = mbedtls_x509_crt_parse_file(&m_cacert, cwd_buff); - //https://blog.csdn.net/nicholas_duan/article/details/93727630 - rc_assert(buf != NULL, E_FAIL) - rc_assert(size != 0, E_FAIL) - return S_OK; } HRESULT CTcpSocketSSLImpl::SetSSLCtxAddress(LPCSTR hostname) @@ -239,60 +121,19 @@ HRESULT CTcpSocketSSLImpl::SetSSLCtxAddress(LPCSTR hostname) } void CTcpSocketSSLImpl::ConnectCB(void *data, event_id error_code) { - IOperation* pOperation = static_cast(this->ctx.data); - c_assert(pOperation != NULL); - event_id rc = error_code == TCP_CONNECTED ? S_SUCCESS : error_code; - - if (rc == TCP_CONNECTED) - { - - - } - else - { - pOperation->SetResult(rc, 0); - pOperation->Post(this->ctx.event, error_code); - } + } void CTcpSocketSSLImpl::StreamWritecb(void *data, BUF_SIZE len) { - IOperation* pOperation = static_cast(this->ctx.data); - c_assert(pOperation != NULL); - pOperation->SetResult(0, len); - pOperation->Post(this->ctx.event, S_SUCCESS); } void CTcpSocketSSLImpl::StreamReadcb(void *data, BUF_SIZE len) { - IOperation* pOperation = static_cast(this->ctx.data); - c_assert(pOperation != NULL); - - pOperation->SetResult(0, len); - pOperation->Post(this->ctx.event, S_SUCCESS); + } void CTcpSocketSSLImpl::StreamEventcb(void *data, event_id what) { - IOperation* pOperation = static_cast(this->ctx.data); - c_assert(pOperation != NULL); - event_errcode error_code = S_SUCCESS; - if (what == STREAM_WRITE_ERROR) { - pOperation->SetResult(OP_WRITEERROR, 0); - error_code = OP_WRITEERROR; - } - else if (what == STREAM_READ_ERROR) { - pOperation->SetResult(OP_READERROR, 0); - error_code = OP_READERROR; - } - else if (what == STREAM_READ_TIMEOUT) { - pOperation->SetResult(OP_READTIMEOUT, 0); - error_code = OP_READTIMEOUT; - } - else if (what == STREAM_WRITE_TIMEOUT) { - pOperation->SetResult(OP_WRITETIMEOUT, 0); - error_code = OP_WRITETIMEOUT; - } - pOperation->Post(this->ctx.event, error_code); } IoTcpBase* CTcpSocketSSLImpl::GetIoTcp() { diff --git a/asynio/tcpsocketsslimpl.h b/asynio/tcpsocketsslimpl.h index 0803130082b739dda89255531a20b8d90f89f901..33f271f228c8c30b5646c98810a47151aaac4942 100644 --- a/asynio/tcpsocketsslimpl.h +++ b/asynio/tcpsocketsslimpl.h @@ -2,6 +2,7 @@ #define _ASYNCTCPSOCKSSLIMPL_H_ #include "stdafx.h" +#include "iostream.hpp" #include "tlswrap.h" class CTcpSocketSSLImpl : public ITcpSocketSSL, @@ -55,7 +56,7 @@ private: private: _sock_t m_sock; SockOptionTable m_sockoption; - + OperationPtr m_pOperation; }; #endif diff --git a/asynio/timerimpl.cpp b/asynio/timerimpl.cpp index 53e4d105b379967c97cf06af67425edda4587763..9450fce60d7ebd004f1df187b491e4b294b63530 100644 --- a/asynio/timerimpl.cpp +++ b/asynio/timerimpl.cpp @@ -10,15 +10,15 @@ CTimerImpl::~CTimerImpl(void) } HRESULT CTimerImpl::Start() { - return (S_SUCCESS == this->time_start()) ? S_OK : E_FAIL; + return (S_SUCCESS == time_start(this)) ? S_OK : E_FAIL; } HRESULT CTimerImpl::Stop() { - return (S_SUCCESS == this->time_stop()) ? S_OK : E_FAIL; + return (S_SUCCESS == time_stop()) ? S_OK : E_FAIL; } HRESULT CTimerImpl::SetSec(int isec) { - return (S_SUCCESS == this->time_sec(isec)) ? S_OK : E_FAIL; + return (S_SUCCESS == time_sec(isec)) ? S_OK : E_FAIL; } HRESULT CTimerImpl::UnBind() { @@ -42,7 +42,6 @@ HRESULT CTimerImpl::SetId(UINT uId) } int CTimerImpl::OnTime(UINT err) { - rc_assert(m_Event!= NULL, S_ERROR) + rc_assert(m_Event.m_p != NULL, S_ERROR) return m_Event->OnTimer(m_uId, err) == S_OK ? S_SUCCESS : S_ERROR; } - diff --git a/asynio/timerimpl.h b/asynio/timerimpl.h index d4937852e7a877ee4768c60f6e9d253ad7f3d493..290312ad638ad4817503f40dc2e89c0674dbe12f 100644 --- a/asynio/timerimpl.h +++ b/asynio/timerimpl.h @@ -2,10 +2,11 @@ #define _TIMEIMPL_H_ #include "stdafx.h" +#include "iotimer.hpp" -class CTimerImpl : public ITimer, - public CUnknownImp, - public IoTimer +class CTimerImpl : public ITimer, + public CUnknownImp, + public evtimer { public: CTimerImpl(); @@ -16,7 +17,6 @@ public: STDCOM_INTERFACE_ENTRY_UNKNOWN_(ITimer) END_STDCOM_MAP - //ITimer std_method(Start)(); std_method(Stop)(); @@ -27,6 +27,7 @@ public: std_method(SetId)(UINT uId); int OnTime(UINT err); + private: UINT m_uId; TimerEventPtr m_Event; diff --git a/asynio/udpsocketimpl.h b/asynio/udpsocketimpl.h index 56b9dbd04f1a9004fb0a6f154f5900420a5d867a..62d5e081e9bec1ea4e31c6d04fd8637160f8508a 100644 --- a/asynio/udpsocketimpl.h +++ b/asynio/udpsocketimpl.h @@ -2,7 +2,7 @@ #define _ASYNCUDPSOCKIMPL_H_ #include "stdafx.h" - +#include "iodgram.hpp" class CUdpSocketImpl : public IUdpSocket, public CUnknownImp, public IoDgramBase diff --git a/container/mainrun.cpp b/container/mainrun.cpp index 3d7ed0d3e69e10414ae71dce105c8a90d8186615..f8b7074b357ac360cf0d2521363b311538e329ec 100644 --- a/container/mainrun.cpp +++ b/container/mainrun.cpp @@ -9,7 +9,7 @@ CMainRunImpl::~CMainRunImpl(void) { logi("CMainRun::~CMainRun"); } -HRESULT CMainRunImpl::CreateObject(const SafeStringPtr* name, +HRESULT CMainRunImpl::CreateObject(REFCLSID rid, IBase** pIObjectRun, const SafePStringPtr* path, const SafeStringPtr* code) @@ -17,10 +17,6 @@ HRESULT CMainRunImpl::CreateObject(const SafeStringPtr* name, HRESULT hr = S_OK; - rc_assert(name != NULL, E_FAIL) - rc_assert(name->len != 0, E_FAIL) - rc_assert(name->ptr != NULL, E_FAIL) - rc_assert(path != NULL, E_FAIL) rc_assert(path->len != 0, E_FAIL) rc_assert(path->ptr != NULL, E_FAIL) @@ -31,14 +27,12 @@ HRESULT CMainRunImpl::CreateObject(const SafeStringPtr* name, SYNC_OBJ(&m_lockSection) - rc_assert(m_obj.count(name->ptr) == 0, E_FAIL) + rc_assert(m_obj.count(rid) == 0, E_FAIL) CObjectRunImpl *p = ALLOC_NEW CObjectRunImpl(); rc_assert(p != NULL, E_OUTOFMEMORY) - p->SetName(name); - - ObjectRunItem& Item = m_obj[name->ptr]; + ObjectRunItem& Item = m_obj[rid]; hr = p->QueryInterface(IID_IObjectRun, (void**)&Item.m_ptr); rc_assert(hr == S_OK, E_FAIL); @@ -46,7 +40,7 @@ HRESULT CMainRunImpl::CreateObject(const SafeStringPtr* name, hr = Item.m_ptr->Clear(); rc_assert(hr == S_OK, E_FAIL) - hr = Item.m_ptr->SetName(name); + hr = Item.m_ptr->SetClsid(rid); rc_assert(hr == S_OK, E_FAIL) hr = Item.m_ptr->SetPath(path); @@ -58,50 +52,38 @@ HRESULT CMainRunImpl::CreateObject(const SafeStringPtr* name, hr = Item.m_ptr->QueryInterface(IID_IObjectRun, (void**)pIObjectRun); rc_assert(hr == S_OK, E_FAIL); - hr = Item.m_ptr->SetRot(this); + hr = Item.m_ptr->SetMainRun(this); rc_assert(hr == S_OK, E_FAIL); return S_OK; } -int CMainRunImpl::IsObjectExist(const SafeStringPtr* name) +int CMainRunImpl::IsObjectExist(REFCLSID rid) { - rc_assert(name != NULL, E_FAIL) - rc_assert(name->len != 0, E_FAIL) - rc_assert(name->ptr != NULL, E_FAIL) - SYNC_OBJ(&m_lockSection) - ObjectStructIterator it = m_obj.find(name->ptr); + ObjectStructIterator it = m_obj.find(rid); rc_assert(m_obj.end() != it, S_ERROR) return S_SUCCESS; } -HRESULT CMainRunImpl::GetObjectRun(const SafeStringPtr* name, - IBase** pIObjectRun) +HRESULT CMainRunImpl::GetObjectRun(REFCLSID rid, IBase** pIObjectRun) { - rc_assert(name != NULL, E_FAIL) - rc_assert(name->len != 0, E_FAIL) - rc_assert(name->ptr != NULL, E_FAIL) SYNC_OBJ(&m_lockSection) - ObjectStructIterator it = m_obj.find(name->ptr); + ObjectStructIterator it = m_obj.find(rid); rc_assert(m_obj.end() != it, S_ERROR) return it->second.m_ptr->QueryInterface(IID_IObjectRun, (void**)pIObjectRun); } -HRESULT CMainRunImpl::GetObject(const SafeStringPtr* name, +HRESULT CMainRunImpl::GetObject(REFCLSID rid, REFCLSID clsid, REFCLSID iid, IBase** ppunk) { HRESULT hr = S_OK; - rc_assert(name != NULL, E_FAIL) - rc_assert(name->len != 0, E_FAIL) - rc_assert(name->ptr != NULL, E_FAIL) - SYNC_OBJ(&m_lockSection) - ObjectStructIterator it = m_obj.find(name->ptr); + ObjectStructIterator it = m_obj.find(rid); rc_assert(m_obj.end() != it, S_ERROR) ObjectRunPtr objectrunptr; @@ -114,7 +96,7 @@ HRESULT CMainRunImpl::GetObject(const SafeStringPtr* name, return rotptr->GetObject(clsid, iid, ppunk); } -HRESULT CMainRunImpl::FreeObject(const SafeStringPtr* name, UINT exit) +HRESULT CMainRunImpl::FreeObject(REFCLSID id, UINT exit) { SYNC_OBJ(&m_lockSection) return S_OK; @@ -125,17 +107,14 @@ HRESULT CMainRunImpl::Free(UINT exit) m_obj.clear(); return S_OK; } -HRESULT CMainRunImpl::SendMessage(const SafeStringPtr* name, - CLSID sn, CLSID tn, UINT msg, IBase* inmsg, IBase** outmsg) +HRESULT CMainRunImpl::SendMessage(REFCLSID rid, REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg, IBase** outmsg) { - rc_assert(name != NULL, E_FAIL) - rc_assert(name->len != 0, E_FAIL) - rc_assert(name->ptr != NULL, E_FAIL) HRESULT hr = S_OK; ObjectRunPtr pIObjectRun; - hr = this->GetObjectRun(name, (IBase**)&pIObjectRun); + hr = this->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(hr == S_OK, E_FAIL) MsgPluginPtr pIMsgRun; @@ -145,8 +124,8 @@ HRESULT CMainRunImpl::SendMessage(const SafeStringPtr* name, return pIMsgRun->OnMsgSend(sn, tn, msg, inmsg, outmsg); } -HRESULT CMainRunImpl::SendBroadcastMessage(CLSID sn, CLSID tn, UINT msg, - IBase* inmsg) +HRESULT CMainRunImpl::SendBroadcastMessage(REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg) { SYNC_OBJ(&m_lockSection) diff --git a/container/mainrun.h b/container/mainrun.h index 95fda1e6f666537dfb5229c90ebd611011853a98..501d97a5c3e548a1434c78642eff75993c94c0ab 100644 --- a/container/mainrun.h +++ b/container/mainrun.h @@ -19,29 +19,28 @@ public: public: //IMainRun - std_method(CreateObject)(const SafeStringPtr* name, + std_method(CreateObject)(REFCLSID rid, IBase** pIObjectRun, const SafePStringPtr* path, const SafeStringPtr* code); - std_method_(int, IsObjectExist)(const SafeStringPtr* name); - std_method(GetObjectRun)(const SafeStringPtr* name, - IBase** pIObjectRun); - std_method(GetObject)(const SafeStringPtr* name, + std_method_(int, IsObjectExist)(REFCLSID rid); + std_method(GetObjectRun)(REFCLSID rid, IBase** pIObjectRun); + std_method(GetObject)(REFCLSID rid, REFCLSID clsid, REFCLSID iid, IBase** ppunk); - std_method(FreeObject)(const SafeStringPtr* name, UINT exit); + std_method(FreeObject)(REFCLSID id, UINT exit); std_method(Free)(UINT exit); - std_method(SendMessage)(const SafeStringPtr* name, - CLSID sn, CLSID tn, UINT msg, IBase* inmsg, IBase** outmsg); - std_method(SendBroadcastMessage)(CLSID sn, CLSID tn, UINT msg, - IBase* inmsg); + std_method(SendMessage)(REFCLSID rid, REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg, IBase** outmsg); + std_method(SendBroadcastMessage)(REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg); private: typedef struct ObjectRunItem{ ObjectRunPtr m_ptr; }*pObjectRunItemPtr; - typedef std::map ObjectStruct; - typedef ObjectStruct::iterator ObjectStructIterator; + typedef std::map > ObjectStruct; + typedef ObjectStruct::iterator ObjectStructIterator; ObjectStruct m_obj; unsigned long m_index; CAutoLock m_lockSection; diff --git a/container/objectrun.cpp b/container/objectrun.cpp index 54f09dc5282799bfec5394fc974b72bc688fdba1..da46013ab9650849c1cdd1e8be3f275a11ba4dd6 100644 --- a/container/objectrun.cpp +++ b/container/objectrun.cpp @@ -13,29 +13,26 @@ CObjectRunImpl::~CObjectRunImpl(void) { logi("CObjectRunImpl::~CObjectRunImpl"); } -HRESULT CObjectRunImpl::SetRot(IBase *pBase) +HRESULT CObjectRunImpl::SetMainRun(IBase *pBase) { rc_assert(pBase != NULL, E_FAIL) m_pMainRun.dispose(); return pBase->QueryInterface(IID_IMainRun, (void**)&m_pMainRun); } -HRESULT CObjectRunImpl::SetName(const SafeStringPtr* name) + + +HRESULT CObjectRunImpl::SetClsid(REFCLSID clsid) { HRESULT hr = S_OK; - rc_assert(name != NULL, OBJECT_RUN_RET_PARAMERR) - rc_assert(name->len != 0, OBJECT_RUN_RET_PARAMERR) - rc_assert(name->ptr != NULL, OBJECT_RUN_RET_PARAMERR) - - m_strObjectName.clear(); - m_strObjectName.append(name->ptr); + m_strObjectClsid = clsid; return hr; } -LPCSTR CObjectRunImpl::GetName() +CLSID CObjectRunImpl::GetClsid() { - return m_strObjectName.c_str(); + return m_strObjectClsid; } HRESULT CObjectRunImpl::RegisterCode(const SafeStringPtr* code) { @@ -680,7 +677,7 @@ HRESULT CObjectRunImpl::Reset() m_RunPlugin = COMPONENT_NULL; m_pRot.dispose(); m_pLibManager.dispose(); - m_strObjectName.clear(); + m_type = 0; m_instance = INSNULL; m_exitcode = OBJECT_RUN_RET_SUCCESS; diff --git a/container/objectrun.h b/container/objectrun.h index a64370d42d06e6487585914fd8b3ca8d8eca1571..a5d513722ffa2eb9a932943b7017c6fa043c20bb 100644 --- a/container/objectrun.h +++ b/container/objectrun.h @@ -20,9 +20,9 @@ public: public: //IObjectRun - std_method(SetRot)(IBase *pBase); - std_method(SetName)(const SafeStringPtr* name); - std_method_(LPCSTR, GetName)(); + std_method(SetMainRun)(IBase *pBase); + std_method(SetClsid)(REFCLSID clsid); + std_method_(CLSID, GetClsid)(); std_method(RegisterCode)(const SafeStringPtr* code); std_method_(LPCSTR, GetRegisterCode)(); std_method(SetPath)(const SafePStringPtr* path); @@ -113,7 +113,7 @@ private: basic_tchar** m_argv; UINT m_argc; private: - string m_strObjectName; + CLSID m_strObjectClsid; UINT m_type; _pinstance m_instance; UINT m_exitcode; diff --git a/crt/crt_avl.h b/crt/crt_avl.h new file mode 100644 index 0000000000000000000000000000000000000000..9456e6d224d4f637a7163801c839a379d1580e3a --- /dev/null +++ b/crt/crt_avl.h @@ -0,0 +1,112 @@ +#ifndef _CRT_AVL_H +#define _CRT_AVL_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct avl_tree avl_tree_t; +typedef struct avl_node avl_node_t; +typedef uintptr_t avl_index_t; + + +#ifndef __LP64__ + +struct avl_node { + struct avl_node *avl_child[2]; + struct avl_node *avl_parent; + unsigned short avl_child_index; + short avl_balance; +}; + +#define AVL_XPARENT(n) ((n)->avl_parent) +#define AVL_SETPARENT(n, p) ((n)->avl_parent = (p)) + +#define AVL_XCHILD(n) ((n)->avl_child_index) +#define AVL_SETCHILD(n, c) ((n)->avl_child_index = (unsigned short)(c)) + +#define AVL_XBALANCE(n) ((n)->avl_balance) +#define AVL_SETBALANCE(n, b) ((n)->avl_balance = (short)(b)) + +#else + +struct avl_node { + struct avl_node *avl_child[2]; + uintptr_t avl_pcb; +}; + +#define AVL_XPARENT(n) ((struct avl_node *)((n)->avl_pcb & ~7)) +#define AVL_SETPARENT(n, p) \ + ((n)->avl_pcb = (((n)->avl_pcb & 7) | (uintptr_t)(p))) + +#define AVL_XCHILD(n) (((n)->avl_pcb >> 2) & 1) +#define AVL_SETCHILD(n, c) \ + ((n)->avl_pcb = (uintptr_t)(((n)->avl_pcb & ~4) | ((c) << 2))) + +#define AVL_XBALANCE(n) ((int)(((n)->avl_pcb & 3) - 1)) +#define AVL_SETBALANCE(n, b) \ + ((n)->avl_pcb = (uintptr_t)((((n)->avl_pcb & ~3) | ((b) + 1)))) + +#endif + +#define AVL_NODE2DATA(n, o) ((void *)((uintptr_t)(n) - (o))) +#define AVL_DATA2NODE(d, o) ((struct avl_node *)((uintptr_t)(d) + (o))) + +#define AVL_INDEX2NODE(x) ((avl_node_t *)((x) & ~1)) +#define AVL_INDEX2CHILD(x) ((x) & 1) +#define AVL_MKINDEX(n, c) ((avl_index_t)(n) | (c)) + + +struct avl_tree { + struct avl_node *avl_root; + int(*avl_compar)(const void *, const void *); + size_t avl_offset; + unsigned long avl_numnodes; + size_t avl_size; +}; + +#define AVL_BEFORE (0) +#define AVL_AFTER (1) + +void avl_create(avl_tree_t *tree, + int (*compar) (const void *, const void *), size_t size, size_t offset); + +void *avl_find(avl_tree_t *tree, void *node, avl_index_t *where); + + +void avl_insert(avl_tree_t *tree, void *node, avl_index_t where); + +void avl_insert_here(avl_tree_t *tree, void *new_data, void *here, + int direction); + +void *avl_first(avl_tree_t *tree); +void *avl_last(avl_tree_t *tree); + +#define AVL_NEXT(tree, node) avl_walk(tree, node, AVL_AFTER) +#define AVL_PREV(tree, node) avl_walk(tree, node, AVL_BEFORE) + +void *avl_nearest(avl_tree_t *tree, avl_index_t where, int direction); + +void avl_add(avl_tree_t *tree, void *node); +void avl_remove(avl_tree_t *tree, void *node); + +int avl_update(avl_tree_t *, void *); +int avl_update_lt(avl_tree_t *, void *); +int avl_update_gt(avl_tree_t *, void *); + +unsigned long avl_numnodes(avl_tree_t *tree); +int avl_is_empty(avl_tree_t *tree); + +void *avl_destroy_nodes(avl_tree_t *tree, void **cookie); + + +void avl_destroy(avl_tree_t *tree); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/crt/crt_core.hpp b/crt/crt_core.hpp index b01779dfd7ee28ef38bb8702d21ccbf12fb452e8..094af00856e1f23e9511949607a6c5c312dc1f13 100644 --- a/crt/crt_core.hpp +++ b/crt/crt_core.hpp @@ -4,7 +4,7 @@ #include #if 1 -#define LIKELY(x) __builtin_expect(!!(x), 1) +#define LIKELY(x) __builtin_expect(!!(x), 1) #define UNLIKELY(x) __builtin_expect(!!(x), 0) #else #define LIKELY diff --git a/crt/crt_def.h b/crt/crt_def.h index 09305ea477676f7e4d8b0878271bc379a02f8dd7..bb6fc6b1dbc958bb53c5d0fbfd93c0ae0c1184bf 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -95,6 +95,14 @@ typedef struct MemoryPtr_s { #elif (TARGET_OS == OS_DARWIN) +#if defined __GNUC__ || defined __llvm__ +#define uu_fast(x) __builtin_expect ((x), 1) +#define uu_slow(x) __builtin_expect ((x), 0) +#else +#define uu_fast(x) (x) +#define uu_slow(x) (x) +#endif + #define _container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) diff --git a/crt/crt_memory.h b/crt/crt_memory.h index 4ed1bb61b0486b5b28d81897cdea353722a30f01..c020b48d486ba9ff72e964f4365b4ae05a2cd8f3 100644 --- a/crt/crt_memory.h +++ b/crt/crt_memory.h @@ -11,7 +11,7 @@ extern "C" void* heap_malloc(size_t size); -void* heap_calloc(size_t n,size_t size); +void* heap_calloc(size_t count,size_t size); void* heap_realloc(void *mem_address, size_t size); void heap_free(void *ptr); char* heap_strdup(const char *str); diff --git a/crt/crt_stdtime.h b/crt/crt_stdtime.h index 5e9e24fdc8c135de8f188b4be4019950fbb376c2..5a7f3dfd67b7f666f598f0a3cef65aad064a0347 100644 --- a/crt/crt_stdtime.h +++ b/crt/crt_stdtime.h @@ -58,9 +58,11 @@ int _gettimeofday(struct timeval* tv, struct timezone* tz); unsigned long GetTickCount(void); #endif -unsigned long long _gettimeofday_s(void); -unsigned long long _gettimeofday_ms(void); -unsigned long long _gettimeofday_us(void); +uint64_t _gettimeofday_s(void); +uint64_t _gettimeofday_ms(void); +uint64_t _gettimeofday_us(void); +uint64_t _getclock_ms(void); + struct tm* _localtime_t(const time_t* timep, struct tm* result); int get_time_t(char* tm, unsigned long len); diff --git a/crt/crt_util.h b/crt/crt_util.h index 94ab221d77639ef52e8f55f335928a808dcc674e..4a2ab1bc0e65664402c8d4232a1ca8ec39a690b6 100644 --- a/crt/crt_util.h +++ b/crt/crt_util.h @@ -118,6 +118,7 @@ In summary, the compiler aligns data types along natural boundaries, which means #include #include #include +#include #endif // !_UTIL_H_ diff --git a/dispatch/dllmain.cpp b/dispatch/dllmain.cpp index f839cdd3b15cc3892277492d7ab7150231746f46..c2148d47b0a410d9364be277b84dbe0087a1e337 100644 --- a/dispatch/dllmain.cpp +++ b/dispatch/dllmain.cpp @@ -18,7 +18,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, _stdmethod_export(HRESULT,DoInit)() { - CLoadContainer loader("dispatch"); + CLoadContainer loader("{409C8B8C-8467-47EE-B1BE-4E4112E64926}"); LPSTRING path = _T("/home/com/Snows/libs/"); LPCSTR code = "{\"component\": [ \ diff --git a/dispatch/native-lib.cpp b/dispatch/native-lib.cpp index 03282c99e1c81e256ba2291bad7b310f86381668..6e4d2d3480c1a903e93268fb808e96cc9578f988 100644 --- a/dispatch/native-lib.cpp +++ b/dispatch/native-lib.cpp @@ -107,7 +107,7 @@ JNIEXPORT jstring JNICALL Java_app_AppDispatch_InitEnv(JNIEnv* env, jclass obj, logi("Java_app_AppDispatch_InitEnv ==>%s","ok"); - pConatainer = ALLOC_NEW CLoadContainer("android_app"); + pConatainer = ALLOC_NEW CLoadContainer("{409C8B8C-8467-47EE-B1BE-4E4112E64926}"); string path = jstring2str(env,value); const char* pCode = "{\"component\": [ \ @@ -121,7 +121,6 @@ JNIEXPORT jstring JNICALL Java_app_AppDispatch_InitEnv(JNIEnv* env, jclass obj, logi("native run %s",path.c_str()); path += "/"; - pConatainer->Init(NULL, path.c_str(),pCode); pConatainer->Start(0); return env->NewStringUTF(result.c_str()); @@ -166,4 +165,4 @@ JNIEXPORT jstring JNICALL Java_app_AppDispatch_SetKey(JNIEnv* env, jclass obj, j std::string result = "ok"; return env->NewStringUTF(result.c_str()); -} \ No newline at end of file +} diff --git a/dispatch/src/loadcontainer.cc b/dispatch/src/loadcontainer.cc index a99466cad559353567ec3b1d6d94ab99c4eaf954..35a88490a7ac8aef6851e7b4a7d57ce19fb3355c 100644 --- a/dispatch/src/loadcontainer.cc +++ b/dispatch/src/loadcontainer.cc @@ -2,7 +2,7 @@ CLoadContainer::CLoadContainer(LPCSTR name) { - m_appname = name; + m_appclsid = StringToGUID(name); } CLoadContainer::~CLoadContainer() @@ -21,20 +21,17 @@ int CLoadContainer::Init(_pinstance hinstance, LPSTRING path, LPCSTR code) containercode.ptr = code; containercode.len = s_strlen(code); - SafeStringPtr appname; - appname.ptr = m_appname.c_str(); - appname.len = m_appname.length(); logi("LoadContainer"); m_Container.LoadContainer(&containerpath); rc_assert(rc == S_SUCCESS, E_FAIL) logi("CreateContainer"); - m_Container.CreateContainer(&appname, &containerpath, &containercode); + m_Container.CreateContainer(m_appclsid, &containerpath, &containercode); rc_assert(rc == S_SUCCESS, E_FAIL) logi("InitContainer"); - m_Container.InitContainer(&appname, NULL, NULL, 0); + m_Container.InitContainer(m_appclsid, NULL, NULL, 0); rc_assert(rc == S_SUCCESS, E_FAIL) return S_SUCCESS; @@ -42,39 +39,24 @@ int CLoadContainer::Init(_pinstance hinstance, LPSTRING path, LPCSTR code) int CLoadContainer::UnInit() { - SafeStringPtr appname; - appname.ptr = m_appname.c_str(); - appname.len = m_appname.length(); logi("UnInitContainer"); - return m_Container.UnInitContainer(&appname); + return m_Container.UnInitContainer(m_appclsid); } int CLoadContainer::Start(UINT type) { - SafeStringPtr appname; - appname.ptr = m_appname.c_str(); - appname.len = m_appname.length(); - logi("StartContainer"); - return m_Container.StartContainer(&appname, 0); + return m_Container.StartContainer(m_appclsid, 0); } int CLoadContainer::Stop(UINT type, UINT exit) { - SafeStringPtr appname; - appname.ptr = m_appname.c_str(); - appname.len = m_appname.length(); - logi("StopContainer"); - return m_Container.StopContainer(&appname, 0, OBJECT_RUN_RET_SUCCESS); + return m_Container.StopContainer(m_appclsid, 0, OBJECT_RUN_RET_SUCCESS); } int CLoadContainer::Exit(UINT exit) { - SafeStringPtr appname; - appname.ptr = m_appname.c_str(); - appname.len = m_appname.length(); - logi("ExitContainer"); - return m_Container.ExitContainer(&appname, exit); + return m_Container.ExitContainer(m_appclsid, exit); } \ No newline at end of file diff --git a/dispatch/src/loadcontainer.h b/dispatch/src/loadcontainer.h index c45f00aa892f289f55c0edf6ceb4ad1c2d89c839..071c44bc03d438f05782725638d26b1575e41af3 100644 --- a/dispatch/src/loadcontainer.h +++ b/dispatch/src/loadcontainer.h @@ -8,7 +8,7 @@ class CLoadContainer { public: - CLoadContainer(LPCSTR name); + CLoadContainer(LPCSTR name = "{409C8B8C-8467-47EE-B1BE-4E4112E64926}"); virtual ~CLoadContainer(); public: int Init(_pinstance hinstance, LPSTRING path, LPCSTR code); @@ -19,7 +19,7 @@ public: private: CContainer m_Container; - string m_appname; + CLSID m_appclsid; }; #endif diff --git a/framwork.xcodeproj/project.xcworkspace/xcuserdata/com.app.xcuserdatad/UserInterfaceState.xcuserstate b/framwork.xcodeproj/project.xcworkspace/xcuserdata/com.app.xcuserdatad/UserInterfaceState.xcuserstate index 8928aa49c86c3f44f87c7de952d3eac93f5dfc13..d913c4f057b080302c200ed03a49915563dfaa26 100644 Binary files a/framwork.xcodeproj/project.xcworkspace/xcuserdata/com.app.xcuserdatad/UserInterfaceState.xcuserstate and b/framwork.xcodeproj/project.xcworkspace/xcuserdata/com.app.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index f8ad75a5f8b1a8381909bec5a18ee2b9f739126e..42ce6b0c6d1c0ae45044d9af21060fca2e4229f2 100644 --- a/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -190,8 +190,8 @@ filePath = "mainuiapp/main.mm" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "49" - endingLineNumber = "49" + startingLineNumber = "53" + endingLineNumber = "53" landmarkName = "RunContainer(argc, argv, path)" landmarkType = "9"> @@ -206,8 +206,8 @@ filePath = "mainuiapp/main.mm" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "77" - endingLineNumber = "77" + startingLineNumber = "81" + endingLineNumber = "81" landmarkName = "RunContainer(argc, argv, path)" landmarkType = "9"> @@ -276,21 +276,5 @@ landmarkType = "7"> - - - - diff --git a/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcschemes/xcschememanagement.plist b/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcschemes/xcschememanagement.plist index 996e10eaebfacbd9afc867606cbf797d47a4f241..e38d442d01893f8e9b1420a2edf5b242f8a2abe9 100644 --- a/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/framwork.xcodeproj/xcuserdata/com.app.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ access.xcscheme_^#shared#^_ orderHint - 11 + 13 asynio.xcscheme_^#shared#^_ @@ -22,17 +22,17 @@ guidgen.xcscheme_^#shared#^_ orderHint - 15 + 7 license.xcscheme_^#shared#^_ orderHint - 7 + 6 logs.xcscheme_^#shared#^_ orderHint - 14 + 9 mainui.xcscheme_^#shared#^_ @@ -47,12 +47,12 @@ mainview.xcscheme_^#shared#^_ orderHint - 12 + 14 mempool.xcscheme_^#shared#^_ orderHint - 13 + 15 msgbus.xcscheme_^#shared#^_ @@ -62,17 +62,17 @@ net.xcscheme_^#shared#^_ orderHint - 8 + 12 render.xcscheme_^#shared#^_ orderHint - 6 + 10 res.xcscheme_^#shared#^_ orderHint - 9 + 11 std_com.xcscheme_^#shared#^_ @@ -87,7 +87,7 @@ stdcrt_test.xcscheme_^#shared#^_ orderHint - 10 + 8 SuppressBuildableAutocreation diff --git a/include/comutiliy/schannel.hpp b/include/comutiliy/schannel.hpp index 1d4ce8a059077745d378a515244c0c31be51936c..843bcac7a680fe8360de09002227fa072db20537 100644 --- a/include/comutiliy/schannel.hpp +++ b/include/comutiliy/schannel.hpp @@ -92,6 +92,8 @@ public: pSocket->AddRef(); // + 1 + rc_assert(m_pIListen.m_p != NULL, E_FAIL) + hr = m_pIListen->Accept(pSocket); rc_assert(hr == S_OK, E_FAIL) diff --git a/include/dlcom/icombase.h b/include/dlcom/icombase.h index d22155bbe1568c74b30aba9562d2bcacf852299d..67f1de6d0c14bb54618d939e8e4486b7780fc6cd 100644 --- a/include/dlcom/icombase.h +++ b/include/dlcom/icombase.h @@ -94,9 +94,9 @@ _DEFINE_IID(IID_IExit, interface IObjectRun : public IBase { - std_method(SetRot)(IBase *pBase) PURE; - std_method(SetName)(const SafeStringPtr* name) PURE; - std_method_(LPCSTR, GetName)() PURE; + std_method(SetMainRun)(IBase *pBase) PURE; + std_method(SetClsid)(REFCLSID clsid) PURE; + std_method_(CLSID, GetClsid)() PURE; std_method(RegisterCode)(const SafeStringPtr* code) PURE; std_method_(LPCSTR, GetRegisterCode)() PURE; std_method(SetPath)(const SafePStringPtr* path) PURE; @@ -135,22 +135,20 @@ _DEFINE_GUID(CLSID_CObjectRun, interface IMainRun : public IBase { - std_method(CreateObject)(const SafeStringPtr* name, + std_method(CreateObject)(REFCLSID rid, IBase** pIObjectRun, const SafePStringPtr* path, const SafeStringPtr* code) PURE; - std_method_(int, IsObjectExist)(const SafeStringPtr* name) PURE; - std_method(GetObjectRun)(const SafeStringPtr* name, - IBase** pIObjectRun) PURE; - std_method(GetObject)(const SafeStringPtr* name, + std_method_(int, IsObjectExist)(REFCLSID rid) PURE; + std_method(GetObjectRun)(REFCLSID rid, IBase** pIObjectRun) PURE; + std_method(GetObject)(REFCLSID rid, REFCLSID clsid, REFCLSID iid, IBase** ppunk) PURE; - std_method(FreeObject)(const SafeStringPtr* name, UINT exit) PURE; + std_method(FreeObject)(REFCLSID id, UINT exit) PURE; std_method(Free)(UINT exit) PURE; - std_method(SendMessage)(const SafeStringPtr* name, - CLSID sn, CLSID tn, UINT msg, IBase* inmsg, IBase** outmsg) PURE; - std_method(SendBroadcastMessage)(CLSID sn, CLSID tn, UINT msg, - IBase* inmsg) PURE; - + std_method(SendMessage)(REFCLSID rid, REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg, IBase** outmsg) PURE; + std_method(SendBroadcastMessage)(REFCLSID gn, + REFCLSID sn, REFCLSID tn, UINT msg, IBase* inmsg) PURE; }; // {8902BA7D-F254-4455-92A3-98FF5BD85AAA} diff --git a/include/dlcom/objectrun.hpp b/include/dlcom/objectrun.hpp index 27e8258a204b9a3d121ee244e141bb1871361a55..bd056646dd8afb2ba62c03268ad17aa7474abfc4 100644 --- a/include/dlcom/objectrun.hpp +++ b/include/dlcom/objectrun.hpp @@ -48,7 +48,7 @@ public: return hr; } - HRESULT CreateContainer(const SafeStringPtr* name, + HRESULT CreateContainer(REFCLSID rid, const SafePStringPtr* path, const SafeStringPtr* code) { @@ -57,7 +57,7 @@ public: _lComPtr pIObjectRun; - hr = m_pIMainRun->CreateObject(name, (IBase**)&pIObjectRun, path, code); + hr = m_pIMainRun->CreateObject(rid, (IBase**)&pIObjectRun, path, code); rc_assert(hr == S_OK, E_FAIL) pIObjectRun.dispose(); @@ -65,54 +65,53 @@ public: return S_OK; } - HRESULT ExitContainer(const SafeStringPtr* name, - UINT exit) { + HRESULT ExitContainer(REFCLSID rid, UINT exit) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->Exit(exit); } - HRESULT InitContainer(const SafeStringPtr* name, + HRESULT InitContainer(REFCLSID rid, _pinstance instance, basic_tchar* argv[], int argc) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->Init(instance, argv, argc); } - HRESULT StartContainer(const SafeStringPtr* name, UINT type) { + HRESULT StartContainer(REFCLSID rid, UINT type) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->Start(type); } - HRESULT StopContainer(const SafeStringPtr* name, UINT type, UINT exit) { + HRESULT StopContainer(REFCLSID rid, UINT type, UINT exit) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->Stop(type, exit); } - HRESULT RegisterComponent(const SafeStringPtr* name, + HRESULT RegisterComponent(REFCLSID rid, REFCLSID clsid, LPCSTR progId, IBase* pBase, ULONG Id, LPCSTR Component, UINT type) { @@ -122,7 +121,7 @@ public: rc_assert(pBase != NULL, E_FAIL) _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) @@ -130,12 +129,11 @@ public: } - HRESULT RunContainer(const SafeStringPtr* name, UINT type) { - + HRESULT RunContainer(REFCLSID rid, UINT type) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) @@ -152,44 +150,44 @@ public: return pIObjectRun->Stop(type, code); } - HRESULT UnInitContainer(const SafeStringPtr* name) { + HRESULT UnInitContainer(REFCLSID rid) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, E_FAIL) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->Uninit(); } - UINT GetContainerExitCode(const SafeStringPtr* name) { + UINT GetContainerExitCode(REFCLSID rid) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, OBJECT_RUN_RET_ERROR) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->GetExitCode(); } - ULONG GetStartIndex(const SafeStringPtr* name, ULONG index) { + ULONG GetStartIndex(REFCLSID rid, ULONG index) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, OBJECT_RUN_RET_ERROR) rc_assert(hr == S_OK, E_FAIL) return pIObjectRun->GetRunIndex(index); } - ULONG GetCompentCount(const SafeStringPtr* name) { + ULONG GetCompentCount(REFCLSID rid) { HRESULT hr = S_OK; _lComPtr pIObjectRun; - m_pIMainRun->GetObjectRun(name, (IBase**)&pIObjectRun); + m_pIMainRun->GetObjectRun(rid, (IBase**)&pIObjectRun); rc_assert(pIObjectRun != NULL, OBJECT_RUN_RET_ERROR) rc_assert(hr == S_OK, E_FAIL) diff --git a/include/utilex/string.hpp b/include/utilex/string.hpp index 3c0b575496af1cf3c0c2bf44a78098a818a42f90..470bbfdf46e016b9ed53ad3ca7f2d001ddfbc078 100644 --- a/include/utilex/string.hpp +++ b/include/utilex/string.hpp @@ -19,7 +19,7 @@ struct ChartoUcs2Struct template static void destroy(_Ptr p) { if (p != NULL) { - free(p); + heap_free(p); } } }; @@ -42,11 +42,8 @@ static_inline int BasicString_Append_Char(basic_tstring &src ,const char *dst, s return S_SUCCESS; } - #endif - - #endif \ No newline at end of file diff --git a/main/main.cpp b/main/main.cpp index 6ae2915b9312df49d6f2d515630bb81d6cb9a82a..88b34b23794e55d46c971a37ca5386dabe6f5d22 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -58,7 +58,10 @@ int main_t(_pinstance hInstance, int argc, basic_tchar* argv[]) hr = licnese.func("id", LicenseCb, (void**)&plicense.m_p, &sLicnese); rc_assert(hr == S_OK, S_ERROR) ////////////////////////////////////////////////////////////////////////// + const char* strguid = "{409C8B8C-8467-47EE-B1BE-4E4112E64926}"; CContainer com; + GUID rid; + rid = StringToGUID(strguid); SafePStringPtr containerpath; containerpath.ptr = path; @@ -78,23 +81,23 @@ int main_t(_pinstance hInstance, int argc, basic_tchar* argv[]) rc_assert(hr == S_OK, S_ERROR) logi("CreateContainer"); - hr = com.CreateContainer(&appname, &containerpath, &containercode); + hr = com.CreateContainer(rid, &containerpath, &containercode); rc_assert(hr == S_OK, S_ERROR) logi("InitContainer"); - hr = com.InitContainer(&appname, hInstance, argv, argc); + hr = com.InitContainer(rid, hInstance, argv, argc); rc_assert(hr == S_OK, S_ERROR) logi("RunContainer"); - hr = com.RunContainer(&appname, 0); + hr = com.RunContainer(rid, 0); rc_assert(hr == S_OK, S_ERROR) logi("UnInitContainer"); - hr = com.UnInitContainer(&appname); + hr = com.UnInitContainer(rid); rc_assert(hr == S_OK, S_ERROR) logi("DestroyContainer"); - iRes = com.GetContainerExitCode(&appname); + iRes = com.GetContainerExitCode(rid); } while (iRes == OBJECT_RUN_RET_RESTART); diff --git a/mainui/appviewimpl.cpp b/mainui/appviewimpl.cpp index 405959f6b5dc281c4738a548855f25e374e4e8c9..968408298f9dd4cf276ccf208ca0067920a9d218 100644 --- a/mainui/appviewimpl.cpp +++ b/mainui/appviewimpl.cpp @@ -26,29 +26,6 @@ HRESULT CAppViewImpl::Start(_pinstance hInstance, UINT uType) { HRESULT hr = S_OK; - - _atomic_t value; - atomic_type v1 = 0; - _atomic_init(&value); - - v1 = _atomic_add(&value); - v1 = _atomic_add(&value); - v1 = _atomic_add(&value); - - v1 = _atomic_del(&value); - - atomic_type comp = 2; - atomic_type value2 = 300; - bool ret = _atomic_cmp(comp, &value); - - if (ret) { - logi("cmp\n"); - } - - _atomic_set(value2, &value); - - _atomic_uninit(&value); - /* NetPtr pINet; @@ -78,12 +55,16 @@ HRESULT CAppViewImpl::Start(_pinstance hInstance, UINT uType) handle.Wait(); */ + InitBus(); return hr; } HRESULT CAppViewImpl::Stop(UINT uExitCode) { HRESULT hr = S_OK; + + UnInitBus(); + return hr; } //IHttpInstanceProc @@ -127,4 +108,70 @@ HRESULT CAppViewImpl::OnHttpRecvBody(UCHAR* data, BUF_SIZE size) HRESULT hr = S_OK; return hr; } +HRESULT CAppViewImpl::InitBus() +{ + HRESULT hr = S_OK; + + hr = m_pRot->GetObject(CLSID_IMsgBus, IID_IMsgBus, (IBase**)&m_pIMsgBus); + rc_assert(hr == S_OK, E_FAIL) + + hr = m_pIMsgBus->CreateNode(NDC_BROKER, (IBase**)&m_pIBroker); + rc_assert(hr == S_OK, E_FAIL) + + m_pIBroker->Listen("127.0.0.1:8080", s_strlen("127.0.0.1:8080"), 5); + + hr = m_pIMsgBus->CreateNode(NDC_CONSUMER, (IBase**)&m_pIConsumer); + rc_assert(hr == S_OK, E_FAIL) + + m_pIConsumer->SetId(_inet_addr_v4("255.254.253.252")); + m_pIConsumer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + + hr = m_pIMsgBus->CreateNode(NDC_PRODUCER, (IBase**)&m_pIProducer); + rc_assert(hr == S_OK, E_FAIL) + + m_pIProducer->SetId(_inet_addr_v4("255.254.253.251")); + m_pIProducer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + + hr = m_pIMsgBus->CreateNode(NDC_AGENT, (IBase**)&m_pIAgent); + rc_assert(hr == S_OK, E_FAIL) + + m_pIAgent->SetId(_inet_addr_v4("255.254.253.250")); + m_pIAgent->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + int sec = 0; + sec = 10; + + return m_pIBroker->Dispatch(sec); + +} +HRESULT CAppViewImpl::UnInitBus() +{ + HRESULT hr = S_OK; + + if (m_pIBroker.m_p != NULL) + { + m_pIBroker->Close(); + m_pIBroker.dispose(); + } + if(m_pIConsumer.m_p != NULL) + { + m_pIConsumer->Close(); + m_pIConsumer.dispose(); + } + + if(m_pIProducer.m_p != NULL) + { + m_pIProducer->Close(); + m_pIProducer.dispose(); + } + + if(m_pIAgent.m_p != NULL) + { + m_pIAgent->Close(); + m_pIAgent.dispose(); + } + + m_pIMsgBus.dispose(); + + return hr; +} diff --git a/mainui/appviewimpl.h b/mainui/appviewimpl.h index 4c8828c21d965bd31eb9fa845c8cdbca0b5381bf..c61f0853d2acc34792472d209bc61ea4afb7e29e 100644 --- a/mainui/appviewimpl.h +++ b/mainui/appviewimpl.h @@ -3,7 +3,10 @@ #include #include +#include #include +#include + //{a7957a54-37cb-42a4-9ee8-599168c2a3d1} _DEFINE_GUID_IMPL(CLSID_AppView, @@ -43,10 +46,19 @@ public: std_method(OnHttpRecvHeaded)(UCHAR* data, BUF_SIZE size); std_method(OnHttpSendBody)(UCHAR* data, BUF_SIZE size); std_method(OnHttpRecvBody)(UCHAR* data, BUF_SIZE size); - + + HRESULT InitBus(); + HRESULT UnInitBus(); + private: - RotPtr m_pRot; - HttpInstancePtr m_pIHttp; + RotPtr m_pRot; + HttpInstancePtr m_pIHttp; + MsgBusPtr m_pIMsgBus; + BrokerPtr m_pIBroker; + ConsumerPtr m_pIConsumer; + ProducerPtr m_pIProducer; + AgentPtr m_pIAgent; + AsynFramePtr m_pIAsynFrame; }; #endif diff --git a/mainui/main.mm b/mainui/main.mm index eda648848f3092470594f41f89b1a05b7d6f097f..803e7bb2cde06bbb06bb19ed9f255cdbbd1a9183 100644 --- a/mainui/main.mm +++ b/mainui/main.mm @@ -25,7 +25,11 @@ int RunContainer(int argc, char* argv[], const char* path) { HRESULT hr = S_OK; - string strcode = "{\"component\":[\ + const char* strguid = "{409C8B8C-8467-47EE-B1BE-4E4112E64926}"; + GUID rid; + rid = StringToGUID(strguid); + + const char* code = "{\"component\":[\ \"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:4\",\ \"{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:net:2:4\",\ \"{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:10:4\"]}"; @@ -37,28 +41,24 @@ int RunContainer(int argc, char* argv[], const char* path) { containerpath.len = container_framework_path.length(); SafeStringPtr containercode; - containercode.ptr = strcode.c_str(); - containercode.len = strcode.length();//s_strlen(code); - - SafeStringPtr appname; - appname.ptr = "macosxapp"; - appname.len = s_strlen("macosxapp"); + containercode.ptr = code; + containercode.len = s_strlen(code); logi("test_main_LoadContainer"); hr = com.LoadContainer(&containerpath); rc_assert(hr == S_OK, S_ERROR) logi("test_main_CreateContainer"); - hr = com.CreateContainer(&appname, &containerpath, &containercode); + hr = com.CreateContainer(rid, &containerpath, &containercode); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.InitContainer(&appname, hInstance, argv, argc); + hr = com.InitContainer(rid, hInstance, argv, argc); rc_assert(hr == S_OK, S_ERROR) - ULONG count = com.GetCompentCount(&appname); - ULONG Index = com.GetStartIndex(&appname, count - 1); + ULONG count = com.GetCompentCount(rid); + ULONG index = com.GetStartIndex(rid, count - 1); CAppViewImpl *app = ALLOC_NEW CAppViewImpl(); @@ -66,19 +66,19 @@ int RunContainer(int argc, char* argv[], const char* path) { hr = app->QueryInterface(IID_IBase, (void**)&pBase); rc_assert(hr == S_OK, S_ERROR) - hr = com.RegisterComponent(&appname, CLSID_AppView, + hr = com.RegisterComponent(rid, CLSID_AppView, "AppView.impl.V1", - pBase, Index - 1, "appview", - STD_COMPOENT | STD_INIT | STD_START); + pBase, index - 1, "appview", + STD_COMPOENT | STD_INIT ); rc_assert(hr == S_OK, S_ERROR) logi("test_main_RunContainer"); - hr = com.RunContainer(&appname, 0); + hr = com.RunContainer(rid, 0); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.UnInitContainer(&appname); + hr = com.UnInitContainer(rid); rc_assert(hr == S_OK, S_ERROR) return S_SUCCESS; diff --git a/mainuiapp/main.mm b/mainuiapp/main.mm index f35758608f1d7aa143e3ec4a14d09c36cfec6e2d..5660fcb8250b7c0f465f5d52b918aab827c9736c 100644 --- a/mainuiapp/main.mm +++ b/mainuiapp/main.mm @@ -38,6 +38,10 @@ int RunContainer(int argc, char* argv[], const char* path) { \"{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:10:4\" \ ]}"; + const char* strguid = "{409C8B8C-8467-47EE-B1BE-4E4112E64926}"; + GUID rid; + rid = StringToGUID(strguid); + CContainer com; SafePStringPtr containerpath; @@ -57,16 +61,16 @@ int RunContainer(int argc, char* argv[], const char* path) { rc_assert(hr == S_OK, S_ERROR) logi("test_main_CreateContainer"); - hr = com.CreateContainer(&appname, &containerpath, &containercode); + hr = com.CreateContainer(rid, &containerpath, &containercode); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.InitContainer(&appname, hInstance, argv, argc); + hr = com.InitContainer(rid, hInstance, argv, argc); rc_assert(hr == S_OK, S_ERROR) - ULONG count = com.GetCompentCount(&appname); - ULONG Index = com.GetStartIndex(&appname, count - 1); + ULONG count = com.GetCompentCount(rid); + ULONG index = com.GetStartIndex(rid, count - 1); CAppViewImpl *app = ALLOC_NEW CAppViewImpl(); @@ -74,18 +78,18 @@ int RunContainer(int argc, char* argv[], const char* path) { hr = app->QueryInterface(IID_IBase, (void**)&pBase); rc_assert(hr == S_OK, S_ERROR) - hr = com.RegisterComponent(&appname, CLSID_AppView, + hr = com.RegisterComponent(rid, CLSID_AppView, "AppView.impl.V1", - pBase, Index - 1, "appview", - STD_COMPOENT | STD_INIT | STD_START); + pBase, index - 1, "appview", + STD_COMPOENT | STD_INIT ); rc_assert(hr == S_OK, S_ERROR) logi("test_main_RunContainer"); - hr = com.RunContainer(&appname, 0); + hr = com.RunContainer(rid, 0); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.UnInitContainer(&appname); + hr = com.UnInitContainer(rid); rc_assert(hr == S_OK, S_ERROR) return S_SUCCESS; diff --git a/mainview/mainviewimpl.cpp b/mainview/mainviewimpl.cpp index 4f414198f78cb64384d4ec5abfdcb78edcdfc5fe..82d442a08f6b263cf426a0a7adef3099e2efce93 100644 --- a/mainview/mainviewimpl.cpp +++ b/mainview/mainviewimpl.cpp @@ -130,6 +130,7 @@ HRESULT CMainViewImpl::OnUiEvent(const NotifyEvent* event) appname.len = s_strlen("app"); return m_pMainRun->SendBroadcastMessage( + COMPONENT_NULL, CLSID_IMainViewImpl, COMPONENT_NULL, 100, NULL); diff --git a/msgbus/broker.cpp b/msgbus/broker.cpp index 50c1c7b20249381dec0c62a7e0e298e8e95962a6..6a5e8bdfe1b51da978af3385e63d1fe98c4a7300 100644 --- a/msgbus/broker.cpp +++ b/msgbus/broker.cpp @@ -300,9 +300,14 @@ HRESULT CBrokerImpl::UnInit() { HRESULT hr = S_OK; + + m_ConnectTimer->UnBind(); + hr = m_ConnectTimer->Stop(); rc_assert(hr == S_OK, E_FAIL) + m_HeartTimer->UnBind(); + hr = m_HeartTimer->Stop(); rc_assert(hr == S_OK, E_FAIL) diff --git a/msgbus/idl/channel.acf b/msgbus/idl/channel.acf new file mode 100644 index 0000000000000000000000000000000000000000..42d45e6f10104c8e70d870ae2cded9ceada1ace6 --- /dev/null +++ b/msgbus/idl/channel.acf @@ -0,0 +1,7 @@ +interface IChannel +{ + [async] Channel_Ping(); + [async] Channel_CheckSecurity(); + [async] Channel_PostBroadcast(); + [async] Channel_Post(); +} \ No newline at end of file diff --git a/msgbus/idl/channel.idl b/msgbus/idl/channel.idl new file mode 100644 index 0000000000000000000000000000000000000000..06fb1f4f03c3594a0b8e46f97cdffe03d4041d24 --- /dev/null +++ b/msgbus/idl/channel.idl @@ -0,0 +1,36 @@ +import "oaidl.idl"; +import "ocidl.idl"; +[ + uuid(897D44D0-D350-48EE-B981-D5A9EF3A99B0), + version(1.0), + pointer_default(unique) +] + +interface IChannel +{ + error_status_t Channel_Ping(); + + error_status_t Channel_CheckSecurity(); + + error_status_t Channel_PostBroadcast( + [in] GUID sg, + [in] GUID source, + [in] GUID target, + [in] ULONG msgid, + [size_is(namelen), in] BYTE* name, + [in] UINT namelen, + [in, size_is(inlen)] BYTE* inmsg, + [in] ULONG inlen); + + error_status_t Channel_Post( + [in] GUID sg, + [in] GUID source, + [in] GUID target, + [in] ULONG msgid, + [size_is(namelen), in] BYTE* name, + [in] UINT namelen, + [in, size_is(inlen)] BYTE* inmsg, + [in] ULONG inlen, + [out, size_is(*outlen)] BYTE* outmsg, + [in, out] ULONG* outlen); +} diff --git a/msgbus/idl/channel_c.c b/msgbus/idl/channel_c.c new file mode 100644 index 0000000000000000000000000000000000000000..6dda948b30fb0df3197e11045b56ff23f243bbab --- /dev/null +++ b/msgbus/idl/channel_c.c @@ -0,0 +1,538 @@ + + +/* this ALWAYS GENERATED file contains the RPC client stubs */ + + + /* File created by MIDL compiler version 7.00.0555 */ +/* at Tue Jun 28 10:35:13 2022 + */ +/* Compiler settings for idl\channel.idl: + Oicf, W1, Zp1, env=Win32 (32b run), target_arch=X86 7.00.0555 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if !defined(_M_IA64) && !defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ +#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */ + +#pragma optimize("", off ) + +#include + +#include "channel_h.h" + +#define TYPE_FORMAT_STRING_SIZE 73 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _channel_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } channel_MIDL_TYPE_FORMAT_STRING; + +typedef struct _channel_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } channel_MIDL_PROC_FORMAT_STRING; + +typedef struct _channel_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } channel_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + + +extern const channel_MIDL_TYPE_FORMAT_STRING channel__MIDL_TypeFormatString; +extern const channel_MIDL_PROC_FORMAT_STRING channel__MIDL_ProcFormatString; +extern const channel_MIDL_EXPR_FORMAT_STRING channel__MIDL_ExprFormatString; + +#define GENERIC_BINDING_TABLE_SIZE 0 + + +/* Standard interface: IChannel, ver. 1.0, + GUID={0x897D44D0,0xD350,0x48EE,{0xB9,0x81,0xD5,0xA9,0xEF,0x3A,0x99,0xB0}} */ + + + +static const RPC_CLIENT_INTERFACE IChannel___RpcClientInterface = + { + sizeof(RPC_CLIENT_INTERFACE), + {{0x897D44D0,0xD350,0x48EE,{0xB9,0x81,0xD5,0xA9,0xEF,0x3A,0x99,0xB0}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + 0, + 0, + 0, + 0, + 0, + 0x00000000 + }; +RPC_IF_HANDLE C_IChannel_v1_0_c_ifspec = (RPC_IF_HANDLE)& IChannel___RpcClientInterface; + +extern const MIDL_STUB_DESC IChannel_StubDesc; + +static RPC_BINDING_HANDLE IChannel__MIDL_AutoBindHandle; + + +error_status_t C_Channel_Ping( + /* [in] */ handle_t IDL_handle) +{ + + CLIENT_CALL_RETURN _RetVal; + + _RetVal = NdrClientCall2( + ( PMIDL_STUB_DESC )&IChannel_StubDesc, + (PFORMAT_STRING) &channel__MIDL_ProcFormatString.Format[0], + ( unsigned char * )&IDL_handle); + return ( error_status_t )_RetVal.Simple; + +} + + +error_status_t C_Channel_CheckSecurity( + /* [in] */ handle_t IDL_handle) +{ + + CLIENT_CALL_RETURN _RetVal; + + _RetVal = NdrClientCall2( + ( PMIDL_STUB_DESC )&IChannel_StubDesc, + (PFORMAT_STRING) &channel__MIDL_ProcFormatString.Format[34], + ( unsigned char * )&IDL_handle); + return ( error_status_t )_RetVal.Simple; + +} + + +error_status_t C_Channel_PostBroadcast( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen) +{ + + CLIENT_CALL_RETURN _RetVal; + + _RetVal = NdrClientCall2( + ( PMIDL_STUB_DESC )&IChannel_StubDesc, + (PFORMAT_STRING) &channel__MIDL_ProcFormatString.Format[68], + ( unsigned char * )&IDL_handle); + return ( error_status_t )_RetVal.Simple; + +} + + +error_status_t C_Channel_Post( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen, + /* [size_is][out] */ BYTE *outmsg, + /* [out][in] */ ULONG *outlen) +{ + + CLIENT_CALL_RETURN _RetVal; + + _RetVal = NdrClientCall2( + ( PMIDL_STUB_DESC )&IChannel_StubDesc, + (PFORMAT_STRING) &channel__MIDL_ProcFormatString.Format[150], + ( unsigned char * )&IDL_handle); + return ( error_status_t )_RetVal.Simple; + +} + + +#if !defined(__RPC_WIN32__) +#error Invalid build platform for this stub. +#endif + +#if !(TARGET_IS_NT50_OR_LATER) +#error You need Windows 2000 or later to run this stub because it uses these features: +#error /robust command line switch. +#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems. +#error This app will fail with the RPC_X_WRONG_STUB_VERSION error. +#endif + + +static const channel_MIDL_PROC_FORMAT_STRING channel__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure Channel_Ping */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x8 ), /* 8 */ +/* 18 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x1, /* 1 */ +/* 20 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 28 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 30 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 32 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_CheckSecurity */ + + + /* Return value */ + +/* 34 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 36 */ NdrFcLong( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x1 ), /* 1 */ +/* 42 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 44 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 46 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 48 */ NdrFcShort( 0x0 ), /* 0 */ +/* 50 */ NdrFcShort( 0x8 ), /* 8 */ +/* 52 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x1, /* 1 */ +/* 54 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 56 */ NdrFcShort( 0x0 ), /* 0 */ +/* 58 */ NdrFcShort( 0x0 ), /* 0 */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 62 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 64 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 66 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_PostBroadcast */ + + + /* Return value */ + +/* 68 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 70 */ NdrFcLong( 0x0 ), /* 0 */ +/* 74 */ NdrFcShort( 0x2 ), /* 2 */ +/* 76 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 78 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 80 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 82 */ NdrFcShort( 0xa8 ), /* 168 */ +/* 84 */ NdrFcShort( 0x8 ), /* 8 */ +/* 86 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x9, /* 9 */ +/* 88 */ 0x8, /* 8 */ + 0x5, /* Ext Flags: new corr desc, srv corr check, */ +/* 90 */ NdrFcShort( 0x0 ), /* 0 */ +/* 92 */ NdrFcShort( 0x1 ), /* 1 */ +/* 94 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 96 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 98 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 100 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter sg */ + +/* 102 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 104 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 106 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter source */ + +/* 108 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 110 */ NdrFcShort( 0x24 ), /* x86 Stack size/offset = 36 */ +/* 112 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter target */ + +/* 114 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 116 */ NdrFcShort( 0x34 ), /* x86 Stack size/offset = 52 */ +/* 118 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter msgid */ + +/* 120 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 122 */ NdrFcShort( 0x38 ), /* x86 Stack size/offset = 56 */ +/* 124 */ NdrFcShort( 0x18 ), /* Type Offset=24 */ + + /* Parameter name */ + +/* 126 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 128 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 130 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter namelen */ + +/* 132 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 134 */ NdrFcShort( 0x40 ), /* x86 Stack size/offset = 64 */ +/* 136 */ NdrFcShort( 0x28 ), /* Type Offset=40 */ + + /* Parameter inmsg */ + +/* 138 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 140 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 142 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter inlen */ + +/* 144 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 146 */ NdrFcShort( 0x48 ), /* x86 Stack size/offset = 72 */ +/* 148 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_Post */ + + + /* Return value */ + +/* 150 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 152 */ NdrFcLong( 0x0 ), /* 0 */ +/* 156 */ NdrFcShort( 0x3 ), /* 3 */ +/* 158 */ NdrFcShort( 0x54 ), /* x86 Stack size/offset = 84 */ +/* 160 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 162 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 164 */ NdrFcShort( 0xc4 ), /* 196 */ +/* 166 */ NdrFcShort( 0x24 ), /* 36 */ +/* 168 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */ + 0xb, /* 11 */ +/* 170 */ 0x8, /* 8 */ + 0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */ +/* 172 */ NdrFcShort( 0x1 ), /* 1 */ +/* 174 */ NdrFcShort( 0x1 ), /* 1 */ +/* 176 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 178 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 180 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 182 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter sg */ + +/* 184 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 186 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 188 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter source */ + +/* 190 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 192 */ NdrFcShort( 0x24 ), /* x86 Stack size/offset = 36 */ +/* 194 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter target */ + +/* 196 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 198 */ NdrFcShort( 0x34 ), /* x86 Stack size/offset = 52 */ +/* 200 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter msgid */ + +/* 202 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 204 */ NdrFcShort( 0x38 ), /* x86 Stack size/offset = 56 */ +/* 206 */ NdrFcShort( 0x18 ), /* Type Offset=24 */ + + /* Parameter name */ + +/* 208 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 210 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 212 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter namelen */ + +/* 214 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 216 */ NdrFcShort( 0x40 ), /* x86 Stack size/offset = 64 */ +/* 218 */ NdrFcShort( 0x28 ), /* Type Offset=40 */ + + /* Parameter inmsg */ + +/* 220 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 222 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 224 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter inlen */ + +/* 226 */ NdrFcShort( 0x113 ), /* Flags: must size, must free, out, simple ref, */ +/* 228 */ NdrFcShort( 0x48 ), /* x86 Stack size/offset = 72 */ +/* 230 */ NdrFcShort( 0x38 ), /* Type Offset=56 */ + + /* Parameter outmsg */ + +/* 232 */ NdrFcShort( 0x158 ), /* Flags: in, out, base type, simple ref, */ +/* 234 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 236 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter outlen */ + +/* 238 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 240 */ NdrFcShort( 0x50 ), /* x86 Stack size/offset = 80 */ +/* 242 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const channel_MIDL_TYPE_FORMAT_STRING channel__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x1d, /* FC_SMFARRAY */ + 0x0, /* 0 */ +/* 4 */ NdrFcShort( 0x8 ), /* 8 */ +/* 6 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 8 */ + 0x15, /* FC_STRUCT */ + 0x3, /* 3 */ +/* 10 */ NdrFcShort( 0x10 ), /* 16 */ +/* 12 */ 0x8, /* FC_LONG */ + 0x6, /* FC_SHORT */ +/* 14 */ 0x6, /* FC_SHORT */ + 0x4c, /* FC_EMBEDDED_COMPLEX */ +/* 16 */ 0x0, /* 0 */ + NdrFcShort( 0xfff1 ), /* Offset= -15 (2) */ + 0x5b, /* FC_END */ +/* 20 */ + 0x11, 0x0, /* FC_RP */ +/* 22 */ NdrFcShort( 0x2 ), /* Offset= 2 (24) */ +/* 24 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 26 */ NdrFcShort( 0x1 ), /* 1 */ +/* 28 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x0, /* */ +/* 30 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 32 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 34 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 36 */ + 0x11, 0x0, /* FC_RP */ +/* 38 */ NdrFcShort( 0x2 ), /* Offset= 2 (40) */ +/* 40 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x0, /* */ +/* 46 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 48 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 50 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 52 */ + 0x11, 0x0, /* FC_RP */ +/* 54 */ NdrFcShort( 0x2 ), /* Offset= 2 (56) */ +/* 56 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 58 */ NdrFcShort( 0x1 ), /* 1 */ +/* 60 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x54, /* FC_DEREFERENCE */ +/* 62 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 64 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 66 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 68 */ + 0x11, 0x8, /* FC_RP [simple_pointer] */ +/* 70 */ 0x8, /* FC_LONG */ + 0x5c, /* FC_PAD */ + + 0x0 + } + }; + +static const unsigned short IChannel_FormatStringOffsetTable[] = + { + 0, + 34, + 68, + 150 + }; + + +static const MIDL_STUB_DESC IChannel_StubDesc = + { + (void *)& IChannel___RpcClientInterface, + MIDL_user_allocate, + MIDL_user_free, + &IChannel__MIDL_AutoBindHandle, + 0, + 0, + 0, + 0, + channel__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x700022b, /* MIDL Version 7.0.555 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; +#pragma optimize("", on ) +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/ + diff --git a/msgbus/idl/channel_h.h b/msgbus/idl/channel_h.h new file mode 100644 index 0000000000000000000000000000000000000000..f88830a187ae2bb8a1b1b20322f6e791fc097ecc --- /dev/null +++ b/msgbus/idl/channel_h.h @@ -0,0 +1,170 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0555 */ +/* at Tue Jun 28 10:35:13 2022 + */ +/* Compiler settings for idl\channel.idl: + Oicf, W1, Zp1, env=Win32 (32b run), target_arch=X86 7.00.0555 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + + +#ifndef __channel_h_h__ +#define __channel_h_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IChannel_INTERFACE_DEFINED__ +#define __IChannel_INTERFACE_DEFINED__ + +/* interface IChannel */ +/* [unique][version][uuid] */ + +/* client prototype */ +error_status_t C_Channel_Ping( + /* [in] */ handle_t IDL_handle); +/* server prototype */ +error_status_t S_Channel_Ping( + /* [in] */ handle_t IDL_handle); +/* switch prototype */ +error_status_t Channel_Ping( + /* [in] */ handle_t IDL_handle); + +/* client prototype */ +error_status_t C_Channel_CheckSecurity( + /* [in] */ handle_t IDL_handle); +/* server prototype */ +error_status_t S_Channel_CheckSecurity( + /* [in] */ handle_t IDL_handle); +/* switch prototype */ +error_status_t Channel_CheckSecurity( + /* [in] */ handle_t IDL_handle); + +/* client prototype */ +error_status_t C_Channel_PostBroadcast( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen); +/* server prototype */ +error_status_t S_Channel_PostBroadcast( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen); +/* switch prototype */ +error_status_t Channel_PostBroadcast( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen); + +/* client prototype */ +error_status_t C_Channel_Post( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen, + /* [size_is][out] */ BYTE *outmsg, + /* [out][in] */ ULONG *outlen); +/* server prototype */ +error_status_t S_Channel_Post( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen, + /* [size_is][out] */ BYTE *outmsg, + /* [out][in] */ ULONG *outlen); +/* switch prototype */ +error_status_t Channel_Post( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE *name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE *inmsg, + /* [in] */ ULONG inlen, + /* [size_is][out] */ BYTE *outmsg, + /* [out][in] */ ULONG *outlen); + + + +extern RPC_IF_HANDLE C_IChannel_v1_0_c_ifspec; +extern RPC_IF_HANDLE IChannel_v1_0_c_ifspec; +extern RPC_IF_HANDLE S_IChannel_v1_0_s_ifspec; +#endif /* __IChannel_INTERFACE_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/msgbus/idl/channel_s.c b/msgbus/idl/channel_s.c new file mode 100644 index 0000000000000000000000000000000000000000..f372c0bfb0e138423145316f1fcb7ca51810508e --- /dev/null +++ b/msgbus/idl/channel_s.c @@ -0,0 +1,489 @@ + + +/* this ALWAYS GENERATED file contains the RPC server stubs */ + + + /* File created by MIDL compiler version 7.00.0555 */ +/* at Tue Jun 28 10:35:13 2022 + */ +/* Compiler settings for idl\channel.idl: + Oicf, W1, Zp1, env=Win32 (32b run), target_arch=X86 7.00.0555 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if !defined(_M_IA64) && !defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ +#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */ + +#pragma optimize("", off ) + +#include +#include "channel_h.h" + +#define TYPE_FORMAT_STRING_SIZE 73 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _channel_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } channel_MIDL_TYPE_FORMAT_STRING; + +typedef struct _channel_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } channel_MIDL_PROC_FORMAT_STRING; + +typedef struct _channel_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } channel_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + +extern const channel_MIDL_TYPE_FORMAT_STRING channel__MIDL_TypeFormatString; +extern const channel_MIDL_PROC_FORMAT_STRING channel__MIDL_ProcFormatString; +extern const channel_MIDL_EXPR_FORMAT_STRING channel__MIDL_ExprFormatString; + +/* Standard interface: IChannel, ver. 1.0, + GUID={0x897D44D0,0xD350,0x48EE,{0xB9,0x81,0xD5,0xA9,0xEF,0x3A,0x99,0xB0}} */ + + +extern const MIDL_SERVER_INFO IChannel_ServerInfo; + +extern const RPC_DISPATCH_TABLE IChannel_v1_0_DispatchTable; + +static const RPC_SERVER_INTERFACE IChannel___RpcServerInterface = + { + sizeof(RPC_SERVER_INTERFACE), + {{0x897D44D0,0xD350,0x48EE,{0xB9,0x81,0xD5,0xA9,0xEF,0x3A,0x99,0xB0}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + (RPC_DISPATCH_TABLE*)&IChannel_v1_0_DispatchTable, + 0, + 0, + 0, + &IChannel_ServerInfo, + 0x04000000 + }; +RPC_IF_HANDLE S_IChannel_v1_0_s_ifspec = (RPC_IF_HANDLE)& IChannel___RpcServerInterface; + +extern const MIDL_STUB_DESC IChannel_StubDesc; + + +#if !defined(__RPC_WIN32__) +#error Invalid build platform for this stub. +#endif + +#if !(TARGET_IS_NT50_OR_LATER) +#error You need Windows 2000 or later to run this stub because it uses these features: +#error /robust command line switch. +#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems. +#error This app will fail with the RPC_X_WRONG_STUB_VERSION error. +#endif + + +static const channel_MIDL_PROC_FORMAT_STRING channel__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure Channel_Ping */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x8 ), /* 8 */ +/* 18 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x1, /* 1 */ +/* 20 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 28 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 30 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 32 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_CheckSecurity */ + + + /* Return value */ + +/* 34 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 36 */ NdrFcLong( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x1 ), /* 1 */ +/* 42 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 44 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 46 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 48 */ NdrFcShort( 0x0 ), /* 0 */ +/* 50 */ NdrFcShort( 0x8 ), /* 8 */ +/* 52 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x1, /* 1 */ +/* 54 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 56 */ NdrFcShort( 0x0 ), /* 0 */ +/* 58 */ NdrFcShort( 0x0 ), /* 0 */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 62 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 64 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 66 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_PostBroadcast */ + + + /* Return value */ + +/* 68 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 70 */ NdrFcLong( 0x0 ), /* 0 */ +/* 74 */ NdrFcShort( 0x2 ), /* 2 */ +/* 76 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 78 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 80 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 82 */ NdrFcShort( 0xa8 ), /* 168 */ +/* 84 */ NdrFcShort( 0x8 ), /* 8 */ +/* 86 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x9, /* 9 */ +/* 88 */ 0x8, /* 8 */ + 0x5, /* Ext Flags: new corr desc, srv corr check, */ +/* 90 */ NdrFcShort( 0x0 ), /* 0 */ +/* 92 */ NdrFcShort( 0x1 ), /* 1 */ +/* 94 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 96 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 98 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 100 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter sg */ + +/* 102 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 104 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 106 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter source */ + +/* 108 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 110 */ NdrFcShort( 0x24 ), /* x86 Stack size/offset = 36 */ +/* 112 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter target */ + +/* 114 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 116 */ NdrFcShort( 0x34 ), /* x86 Stack size/offset = 52 */ +/* 118 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter msgid */ + +/* 120 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 122 */ NdrFcShort( 0x38 ), /* x86 Stack size/offset = 56 */ +/* 124 */ NdrFcShort( 0x18 ), /* Type Offset=24 */ + + /* Parameter name */ + +/* 126 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 128 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 130 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter namelen */ + +/* 132 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 134 */ NdrFcShort( 0x40 ), /* x86 Stack size/offset = 64 */ +/* 136 */ NdrFcShort( 0x28 ), /* Type Offset=40 */ + + /* Parameter inmsg */ + +/* 138 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 140 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 142 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter inlen */ + +/* 144 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 146 */ NdrFcShort( 0x48 ), /* x86 Stack size/offset = 72 */ +/* 148 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + /* Procedure Channel_Post */ + + + /* Return value */ + +/* 150 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 152 */ NdrFcLong( 0x0 ), /* 0 */ +/* 156 */ NdrFcShort( 0x3 ), /* 3 */ +/* 158 */ NdrFcShort( 0x54 ), /* x86 Stack size/offset = 84 */ +/* 160 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 162 */ NdrFcShort( 0x0 ), /* x86 Stack size/offset = 0 */ +/* 164 */ NdrFcShort( 0xc4 ), /* 196 */ +/* 166 */ NdrFcShort( 0x24 ), /* 36 */ +/* 168 */ 0x47, /* Oi2 Flags: srv must size, clt must size, has return, has ext, */ + 0xb, /* 11 */ +/* 170 */ 0x8, /* 8 */ + 0x7, /* Ext Flags: new corr desc, clt corr check, srv corr check, */ +/* 172 */ NdrFcShort( 0x1 ), /* 1 */ +/* 174 */ NdrFcShort( 0x1 ), /* 1 */ +/* 176 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter IDL_handle */ + +/* 178 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 180 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 182 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter sg */ + +/* 184 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 186 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 188 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter source */ + +/* 190 */ NdrFcShort( 0x8a ), /* Flags: must free, in, by val, */ +/* 192 */ NdrFcShort( 0x24 ), /* x86 Stack size/offset = 36 */ +/* 194 */ NdrFcShort( 0x8 ), /* Type Offset=8 */ + + /* Parameter target */ + +/* 196 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 198 */ NdrFcShort( 0x34 ), /* x86 Stack size/offset = 52 */ +/* 200 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter msgid */ + +/* 202 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 204 */ NdrFcShort( 0x38 ), /* x86 Stack size/offset = 56 */ +/* 206 */ NdrFcShort( 0x18 ), /* Type Offset=24 */ + + /* Parameter name */ + +/* 208 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 210 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 212 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter namelen */ + +/* 214 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */ +/* 216 */ NdrFcShort( 0x40 ), /* x86 Stack size/offset = 64 */ +/* 218 */ NdrFcShort( 0x28 ), /* Type Offset=40 */ + + /* Parameter inmsg */ + +/* 220 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 222 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 224 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter inlen */ + +/* 226 */ NdrFcShort( 0x113 ), /* Flags: must size, must free, out, simple ref, */ +/* 228 */ NdrFcShort( 0x48 ), /* x86 Stack size/offset = 72 */ +/* 230 */ NdrFcShort( 0x38 ), /* Type Offset=56 */ + + /* Parameter outmsg */ + +/* 232 */ NdrFcShort( 0x158 ), /* Flags: in, out, base type, simple ref, */ +/* 234 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 236 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter outlen */ + +/* 238 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 240 */ NdrFcShort( 0x50 ), /* x86 Stack size/offset = 80 */ +/* 242 */ 0x10, /* FC_ERROR_STATUS_T */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const channel_MIDL_TYPE_FORMAT_STRING channel__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x1d, /* FC_SMFARRAY */ + 0x0, /* 0 */ +/* 4 */ NdrFcShort( 0x8 ), /* 8 */ +/* 6 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 8 */ + 0x15, /* FC_STRUCT */ + 0x3, /* 3 */ +/* 10 */ NdrFcShort( 0x10 ), /* 16 */ +/* 12 */ 0x8, /* FC_LONG */ + 0x6, /* FC_SHORT */ +/* 14 */ 0x6, /* FC_SHORT */ + 0x4c, /* FC_EMBEDDED_COMPLEX */ +/* 16 */ 0x0, /* 0 */ + NdrFcShort( 0xfff1 ), /* Offset= -15 (2) */ + 0x5b, /* FC_END */ +/* 20 */ + 0x11, 0x0, /* FC_RP */ +/* 22 */ NdrFcShort( 0x2 ), /* Offset= 2 (24) */ +/* 24 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 26 */ NdrFcShort( 0x1 ), /* 1 */ +/* 28 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x0, /* */ +/* 30 */ NdrFcShort( 0x3c ), /* x86 Stack size/offset = 60 */ +/* 32 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 34 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 36 */ + 0x11, 0x0, /* FC_RP */ +/* 38 */ NdrFcShort( 0x2 ), /* Offset= 2 (40) */ +/* 40 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x0, /* */ +/* 46 */ NdrFcShort( 0x44 ), /* x86 Stack size/offset = 68 */ +/* 48 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 50 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 52 */ + 0x11, 0x0, /* FC_RP */ +/* 54 */ NdrFcShort( 0x2 ), /* Offset= 2 (56) */ +/* 56 */ + 0x1b, /* FC_CARRAY */ + 0x0, /* 0 */ +/* 58 */ NdrFcShort( 0x1 ), /* 1 */ +/* 60 */ 0x29, /* Corr desc: parameter, FC_ULONG */ + 0x54, /* FC_DEREFERENCE */ +/* 62 */ NdrFcShort( 0x4c ), /* x86 Stack size/offset = 76 */ +/* 64 */ NdrFcShort( 0x0 ), /* Corr flags: */ +/* 66 */ 0x1, /* FC_BYTE */ + 0x5b, /* FC_END */ +/* 68 */ + 0x11, 0x8, /* FC_RP [simple_pointer] */ +/* 70 */ 0x8, /* FC_LONG */ + 0x5c, /* FC_PAD */ + + 0x0 + } + }; + +static const unsigned short IChannel_FormatStringOffsetTable[] = + { + 0, + 34, + 68, + 150 + }; + + +static const MIDL_STUB_DESC IChannel_StubDesc = + { + (void *)& IChannel___RpcServerInterface, + MIDL_user_allocate, + MIDL_user_free, + 0, + 0, + 0, + 0, + 0, + channel__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x700022b, /* MIDL Version 7.0.555 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +static const RPC_DISPATCH_FUNCTION IChannel_table[] = + { + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + 0 + }; +static const RPC_DISPATCH_TABLE IChannel_v1_0_DispatchTable = + { + 4, + (RPC_DISPATCH_FUNCTION*)IChannel_table + }; + +static const SERVER_ROUTINE IChannel_ServerRoutineTable[] = + { + (SERVER_ROUTINE)S_Channel_Ping, + (SERVER_ROUTINE)S_Channel_CheckSecurity, + (SERVER_ROUTINE)S_Channel_PostBroadcast, + (SERVER_ROUTINE)S_Channel_Post + }; + +static const MIDL_SERVER_INFO IChannel_ServerInfo = + { + &IChannel_StubDesc, + IChannel_ServerRoutineTable, + channel__MIDL_ProcFormatString.Format, + IChannel_FormatStringOffsetTable, + 0, + 0, + 0, + 0}; +#pragma optimize("", on ) +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/ + diff --git a/msgbus/idl/rpcmsg.cpp b/msgbus/idl/rpcmsg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9011bcd31f9d582dfe9d4e5ea0902639ac5ccc76 --- /dev/null +++ b/msgbus/idl/rpcmsg.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#pragma comment(lib,"rpcrt4.lib") +#include "rpcmsg.h" +#include "channel_h.h" + + +void __RPC_FAR* __RPC_USER midl_user_allocate(size_t len) +{ + void* ptr = NULL; + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, len); + HeapUnlock(heap); + return ptr; +} + +void __RPC_USER midl_user_free(void __RPC_FAR* ptr) +{ + if (ptr != NULL) { + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + HeapFree(GetProcessHeap(), 0, ptr); + HeapUnlock(heap); + ptr = NULL; + } +} + +error_status_t S_Channel_Ping( + /* [in] */ handle_t IDL_handle) +{ + return S_OK; +} + +error_status_t S_Channel_CheckSecurity( + /* [in] */ handle_t IDL_handle) +{ + return S_OK; +} + +error_status_t S_Channel_PostBroadcast( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE* name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE* inmsg, + /* [in] */ ULONG inlen) +{ + return S_OK; +} + +error_status_t S_Channel_Post( + /* [in] */ handle_t IDL_handle, + /* [in] */ GUID sg, + /* [in] */ GUID source, + /* [in] */ GUID target, + /* [in] */ ULONG msgid, + /* [in][size_is] */ BYTE* name, + /* [in] */ UINT namelen, + /* [size_is][in] */ BYTE* inmsg, + /* [in] */ ULONG inlen, + /* [size_is][out] */ BYTE* outmsg, + /* [out][in] */ ULONG* outlen) +{ + return S_OK; +} \ No newline at end of file diff --git a/msgbus/idl/rpcmsg.h b/msgbus/idl/rpcmsg.h new file mode 100644 index 0000000000000000000000000000000000000000..c70c083d23c2e37c7a888de5ca1131870a8dc265 --- /dev/null +++ b/msgbus/idl/rpcmsg.h @@ -0,0 +1,13 @@ +#ifndef _RPC_MSG_ +#define _RPC_MSG_ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/msgbus/msgbus.vcxproj b/msgbus/msgbus.vcxproj index 1ed3fae81baf1b77230e09eb4708a9dc4b38a1bd..e6a1453b638e991a0d44728fa95ee24d9a7a78f2 100644 --- a/msgbus/msgbus.vcxproj +++ b/msgbus/msgbus.vcxproj @@ -14,7 +14,6 @@ {605622C7-BC7E-488D-AE97-B6C1A30F65D3} Plugin Win32Proj - 7.0 @@ -104,6 +103,7 @@ + @@ -117,6 +117,9 @@ false + + + @@ -131,6 +134,8 @@ + + @@ -141,6 +146,12 @@ + + + /prefix client "C_" server "S_" /out $(ProjectDir)/idl /pack 1 /robust /Oicf %(AdditionalOptions) + /prefix client "C_" server "S_" /out $(ProjectDir)/idl /pack 1 /robust /Oicf %(AdditionalOptions) + + diff --git a/msgbus/msgbus.vcxproj.filters b/msgbus/msgbus.vcxproj.filters index 2a13820ff8fb5f5d99ec08a3127de7347d4cfec8..908b9e48b41a78e1bb2183ce858d1f4ee3b7742b 100644 --- a/msgbus/msgbus.vcxproj.filters +++ b/msgbus/msgbus.vcxproj.filters @@ -10,6 +10,15 @@ + + idl + + + idl + + + idl + @@ -22,11 +31,30 @@ + + idl + + + idl + + + idl + + + + {07c76460-2cd6-4d11-9b53-f42c0b67dabd} + + + + + idl + + \ No newline at end of file diff --git a/stdcrt/compat_log.c b/stdcrt/compat_log.c index 0c24fb6799203491d9029f55e2dc1f232849611d..f05e5466671deb45457ed89cd9bc478436bdc9b1 100644 --- a/stdcrt/compat_log.c +++ b/stdcrt/compat_log.c @@ -22,7 +22,6 @@ static int _log_print(int proi, va_list ap) { - char* msg = NULL; int hmsglen = 0; int msglen = 0; diff --git a/stdcrt/stdcrt.vcxproj b/stdcrt/stdcrt.vcxproj index b7fb7700bfabd25e390bbc2f69b8c8db8924c73f..f85135c615d96a0a804a1d71855773193d2cf8ac 100644 --- a/stdcrt/stdcrt.vcxproj +++ b/stdcrt/stdcrt.vcxproj @@ -104,6 +104,7 @@ + diff --git a/stdcrt/stdcrt.vcxproj.filters b/stdcrt/stdcrt.vcxproj.filters index 212c11c64ffab3b395ce4e51e1114d33bfb06b53..5ceb2414f21aa63b005651e6dba00057d8179450 100644 --- a/stdcrt/stdcrt.vcxproj.filters +++ b/stdcrt/stdcrt.vcxproj.filters @@ -123,6 +123,9 @@ event + + stdlib + diff --git a/stdcrt/stdlib/compat_avl.c b/stdcrt/stdlib/compat_avl.c new file mode 100644 index 0000000000000000000000000000000000000000..442757ce575ca86fb621fd2d7eec29759f24843d --- /dev/null +++ b/stdcrt/stdlib/compat_avl.c @@ -0,0 +1,809 @@ +#include + + +void * +avl_walk(avl_tree_t *tree, void *oldnode, int left) +{ + size_t off = tree->avl_offset; + avl_node_t *node = AVL_DATA2NODE(oldnode, off); + int right = 1 - left; + int was_child; + + + if (node == NULL) + return (NULL); + + if (node->avl_child[left] != NULL) { + for (node = node->avl_child[left]; + node->avl_child[right] != NULL; + node = node->avl_child[right]) + ; + + } else { + for (;;) { + was_child = AVL_XCHILD(node); + node = AVL_XPARENT(node); + if (node == NULL) + return (NULL); + if (was_child == right) + break; + } + } + + return (AVL_NODE2DATA(node, off)); +} + +void * +avl_first(avl_tree_t *tree) +{ + avl_node_t *node; + avl_node_t *prev = NULL; + size_t off = tree->avl_offset; + + for (node = tree->avl_root; node != NULL; node = node->avl_child[0]) + prev = node; + + if (prev != NULL) + return (AVL_NODE2DATA(prev, off)); + return (NULL); +} + +void * +avl_last(avl_tree_t *tree) +{ + avl_node_t *node; + avl_node_t *prev = NULL; + size_t off = tree->avl_offset; + + for (node = tree->avl_root; node != NULL; node = node->avl_child[1]) + prev = node; + + if (prev != NULL) + return (AVL_NODE2DATA(prev, off)); + return (NULL); +} + +void * +avl_nearest(avl_tree_t *tree, avl_index_t where, int direction) +{ + int child = AVL_INDEX2CHILD(where); + avl_node_t *node = AVL_INDEX2NODE(where); + void *data; + size_t off = tree->avl_offset; + + if (node == NULL) { + return (NULL); + } + data = AVL_NODE2DATA(node, off); + if (child != direction) + return (data); + + return (avl_walk(tree, data, direction)); +} + + +/* + * Search for the node which contains "value". The algorithm is a + * simple binary tree search. + * + * return value: + * NULL: the value is not in the AVL tree + * *where (if not NULL) is set to indicate the insertion point + * "void *" of the found tree node + */ +void * +avl_find(avl_tree_t *tree, void *value, avl_index_t *where) +{ + avl_node_t *node; + avl_node_t *prev = NULL; + int child = 0; + int diff; + size_t off = tree->avl_offset; + int avl_balance2child[] = { 0, 0, 1 }; + + for (node = tree->avl_root; node != NULL; + node = node->avl_child[child]) { + + prev = node; + + diff = tree->avl_compar(value, AVL_NODE2DATA(node, off)); + if (diff == 0) { +#ifdef DEBUG + if (where != NULL) + *where = 0; +#endif + return (AVL_NODE2DATA(node, off)); + } + child = avl_balance2child[1 + diff]; + + } + + if (where != NULL) + *where = AVL_MKINDEX(prev, child); + + return (NULL); +} + + +/* + * Perform a rotation to restore balance at the subtree given by depth. + * + * This routine is used by both insertion and deletion. The return value + * indicates: + * 0 : subtree did not change height + * !0 : subtree was reduced in height + * + * The code is written as if handling left rotations, right rotations are + * symmetric and handled by swapping values of variables right/left[_heavy] + * + * On input balance is the "new" balance at "node". This value is either + * -2 or +2. + */ +static int +avl_rotation(avl_tree_t *tree, avl_node_t *node, int balance) +{ + int left = !(balance < 0); /* when balance = -2, left will be 0 */ + int right = 1 - left; + int left_heavy = balance >> 1; + int right_heavy = -left_heavy; + avl_node_t *parent = AVL_XPARENT(node); + avl_node_t *child = node->avl_child[left]; + avl_node_t *cright; + avl_node_t *gchild; + avl_node_t *gright; + avl_node_t *gleft; + int which_child = AVL_XCHILD(node); + int child_bal = AVL_XBALANCE(child); + + /* BEGIN CSTYLED */ + /* + * case 1 : node is overly left heavy, the left child is balanced or + * also left heavy. This requires the following rotation. + * + * (node bal:-2) + * / \ + * / \ + * (child bal:0 or -1) + * / \ + * / \ + * cright + * + * becomes: + * + * (child bal:1 or 0) + * / \ + * / \ + * (node bal:-1 or 0) + * / \ + * / \ + * cright + * + * we detect this situation by noting that child's balance is not + * right_heavy. + */ + /* END CSTYLED */ + if (child_bal != right_heavy) { + + /* + * compute new balance of nodes + * + * If child used to be left heavy (now balanced) we reduced + * the height of this sub-tree -- used in "return...;" below + */ + child_bal += right_heavy; /* adjust towards right */ + + /* + * move "cright" to be node's left child + */ + cright = child->avl_child[right]; + node->avl_child[left] = cright; + if (cright != NULL) { + AVL_SETPARENT(cright, node); + AVL_SETCHILD(cright, left); + } + + /* + * move node to be child's right child + */ + child->avl_child[right] = node; + AVL_SETBALANCE(node, -child_bal); + AVL_SETCHILD(node, right); + AVL_SETPARENT(node, child); + + /* + * update the pointer into this subtree + */ + AVL_SETBALANCE(child, child_bal); + AVL_SETCHILD(child, which_child); + AVL_SETPARENT(child, parent); + if (parent != NULL) + parent->avl_child[which_child] = child; + else + tree->avl_root = child; + + return (child_bal == 0); + } + + /* BEGIN CSTYLED */ + /* + * case 2 : When node is left heavy, but child is right heavy we use + * a different rotation. + * + * (node b:-2) + * / \ + * / \ + * / \ + * (child b:+1) + * / \ + * / \ + * (gchild b: != 0) + * / \ + * / \ + * gleft gright + * + * becomes: + * + * (gchild b:0) + * / \ + * / \ + * / \ + * (child b:?) (node b:?) + * / \ / \ + * / \ / \ + * gleft gright + * + * computing the new balances is more complicated. As an example: + * if gchild was right_heavy, then child is now left heavy + * else it is balanced + */ + /* END CSTYLED */ + gchild = child->avl_child[right]; + gleft = gchild->avl_child[left]; + gright = gchild->avl_child[right]; + + /* + * move gright to left child of node and + * + * move gleft to right child of node + */ + node->avl_child[left] = gright; + if (gright != NULL) { + AVL_SETPARENT(gright, node); + AVL_SETCHILD(gright, left); + } + + child->avl_child[right] = gleft; + if (gleft != NULL) { + AVL_SETPARENT(gleft, child); + AVL_SETCHILD(gleft, right); + } + + /* + * move child to left child of gchild and + * + * move node to right child of gchild and + * + * fixup parent of all this to point to gchild + */ + balance = AVL_XBALANCE(gchild); + gchild->avl_child[left] = child; + AVL_SETBALANCE(child, (balance == right_heavy ? left_heavy : 0)); + AVL_SETPARENT(child, gchild); + AVL_SETCHILD(child, left); + + gchild->avl_child[right] = node; + AVL_SETBALANCE(node, (balance == left_heavy ? right_heavy : 0)); + AVL_SETPARENT(node, gchild); + AVL_SETCHILD(node, right); + + AVL_SETBALANCE(gchild, 0); + AVL_SETPARENT(gchild, parent); + AVL_SETCHILD(gchild, which_child); + if (parent != NULL) + parent->avl_child[which_child] = gchild; + else + tree->avl_root = gchild; + + return (1); /* the new tree is always shorter */ +} + + +/* + * Insert a new node into an AVL tree at the specified (from avl_find()) place. + * + * Newly inserted nodes are always leaf nodes in the tree, since avl_find() + * searches out to the leaf positions. The avl_index_t indicates the node + * which will be the parent of the new node. + * + * After the node is inserted, a single rotation further up the tree may + * be necessary to maintain an acceptable AVL balance. + */ +void +avl_insert(avl_tree_t *tree, void *new_data, avl_index_t where) +{ + + + c_assert(tree != NULL) + avl_node_t *node; + avl_node_t *parent = AVL_INDEX2NODE(where); + int old_balance; + int new_balance; + int which_child = AVL_INDEX2CHILD(where); + size_t off = tree->avl_offset; + + int avl_child2balance[2] = { -1, 1 }; + + node = AVL_DATA2NODE(new_data, off); + + /* + * First, add the node to the tree at the indicated position. + */ + ++tree->avl_numnodes; + + node->avl_child[0] = NULL; + node->avl_child[1] = NULL; + + AVL_SETCHILD(node, which_child); + AVL_SETBALANCE(node, 0); + AVL_SETPARENT(node, parent); + if (parent != NULL) { + parent->avl_child[which_child] = node; + } else { + tree->avl_root = node; + } + /* + * Now, back up the tree modifying the balance of all nodes above the + * insertion point. If we get to a highly unbalanced ancestor, we + * need to do a rotation. If we back out of the tree we are done. + * If we brought any subtree into perfect balance (0), we are also done. + */ + for (;;) { + node = parent; + if (node == NULL) + return; + + /* + * Compute the new balance + */ + old_balance = AVL_XBALANCE(node); + new_balance = old_balance + avl_child2balance[which_child]; + + /* + * If we introduced equal balance, then we are done immediately + */ + if (new_balance == 0) { + AVL_SETBALANCE(node, 0); + return; + } + + /* + * If both old and new are not zero we went + * from -1 to -2 balance, do a rotation. + */ + if (old_balance != 0) + break; + + AVL_SETBALANCE(node, new_balance); + parent = AVL_XPARENT(node); + which_child = AVL_XCHILD(node); + } + + /* + * perform a rotation to fix the tree and return + */ + (void) avl_rotation(tree, node, new_balance); +} + +/* + * Insert "new_data" in "tree" in the given "direction" either after or + * before (AVL_AFTER, AVL_BEFORE) the data "here". + * + * Insertions can only be done at empty leaf points in the tree, therefore + * if the given child of the node is already present we move to either + * the AVL_PREV or AVL_NEXT and reverse the insertion direction. Since + * every other node in the tree is a leaf, this always works. + * + * To help developers using this interface, we assert that the new node + * is correctly ordered at every step of the way in DEBUG kernels. + */ +void +avl_insert_here( + avl_tree_t *tree, + void *new_data, + void *here, + int direction) +{ + avl_node_t *node; + int child = direction; /* rely on AVL_BEFORE == 0, AVL_AFTER == 1 */ + + c_assert(tree != NULL); + c_assert(new_data != NULL); + c_assert(here != NULL); + c_assert(direction == AVL_BEFORE || direction == AVL_AFTER); + + /* + * If corresponding child of node is not NULL, go to the neighboring + * node and reverse the insertion direction. + */ + node = AVL_DATA2NODE(here, tree->avl_offset); + + + if (node->avl_child[child] != NULL) { + node = node->avl_child[child]; + child = 1 - child; + while (node->avl_child[child] != NULL) { + + node = node->avl_child[child]; + } + } + avl_insert(tree, new_data, AVL_MKINDEX(node, child)); +} + +/* + * Add a new node to an AVL tree. + */ +void +avl_add(avl_tree_t *tree, void *new_node) +{ + avl_index_t where = 0; + avl_insert(tree, new_node, where); +} + +/* + * Delete a node from the AVL tree. Deletion is similar to insertion, but + * with 2 complications. + * + * First, we may be deleting an interior node. Consider the following subtree: + * + * d c c + * / \ / \ / \ + * b e b e b e + * / \ / \ / + * a c a a + * + * When we are deleting node (d), we find and bring up an adjacent valued leaf + * node, say (c), to take the interior node's place. In the code this is + * handled by temporarily swapping (d) and (c) in the tree and then using + * common code to delete (d) from the leaf position. + * + * Secondly, an interior deletion from a deep tree may require more than one + * rotation to fix the balance. This is handled by moving up the tree through + * parents and applying rotations as needed. The return value from + * avl_rotation() is used to detect when a subtree did not change overall + * height due to a rotation. + */ +void +avl_remove(avl_tree_t *tree, void *data) +{ + avl_node_t *delete; + avl_node_t *parent; + avl_node_t *node; + avl_node_t tmp; + int old_balance; + int new_balance; + int left; + int right; + int which_child; + size_t off = tree->avl_offset; + + int avl_child2balance[2] = { -1, 1 }; + int avl_balance2child[] = { 0, 0, 1 }; + + c_assert(tree); + + delete = AVL_DATA2NODE(data, off); + + /* + * Deletion is easiest with a node that has at most 1 child. + * We swap a node with 2 children with a sequentially valued + * neighbor node. That node will have at most 1 child. Note this + * has no effect on the ordering of the remaining nodes. + * + * As an optimization, we choose the greater neighbor if the tree + * is right heavy, otherwise the left neighbor. This reduces the + * number of rotations needed. + */ + if (delete->avl_child[0] != NULL && delete->avl_child[1] != NULL) { + + /* + * choose node to swap from whichever side is taller + */ + old_balance = AVL_XBALANCE(delete); + left = avl_balance2child[old_balance + 1]; + right = 1 - left; + + /* + * get to the previous value'd node + * (down 1 left, as far as possible right) + */ + for (node = delete->avl_child[left]; + node->avl_child[right] != NULL; + node = node->avl_child[right]) + ; + + /* + * create a temp placeholder for 'node' + * move 'node' to delete's spot in the tree + */ + tmp = *node; + + *node = *delete; + if (node->avl_child[left] == node) + node->avl_child[left] = &tmp; + + parent = AVL_XPARENT(node); + if (parent != NULL) + parent->avl_child[AVL_XCHILD(node)] = node; + else + tree->avl_root = node; + AVL_SETPARENT(node->avl_child[left], node); + AVL_SETPARENT(node->avl_child[right], node); + + /* + * Put tmp where node used to be (just temporary). + * It always has a parent and at most 1 child. + */ + delete = &tmp; + parent = AVL_XPARENT(delete); + parent->avl_child[AVL_XCHILD(delete)] = delete; + which_child = (delete->avl_child[1] != 0); + if (delete->avl_child[which_child] != NULL) + AVL_SETPARENT(delete->avl_child[which_child], delete); + } + + + /* + * Here we know "delete" is at least partially a leaf node. It can + * be easily removed from the tree. + */ + c_assert(tree->avl_numnodes > 0); + + --tree->avl_numnodes; + parent = AVL_XPARENT(delete); + which_child = AVL_XCHILD(delete); + if (delete->avl_child[0] != NULL) + node = delete->avl_child[0]; + else + node = delete->avl_child[1]; + + /* + * Connect parent directly to node (leaving out delete). + */ + if (node != NULL) { + AVL_SETPARENT(node, parent); + AVL_SETCHILD(node, which_child); + } + if (parent == NULL) { + tree->avl_root = node; + return; + } + parent->avl_child[which_child] = node; + + + /* + * Since the subtree is now shorter, begin adjusting parent balances + * and performing any needed rotations. + */ + do { + + /* + * Move up the tree and adjust the balance + * + * Capture the parent and which_child values for the next + * iteration before any rotations occur. + */ + node = parent; + old_balance = AVL_XBALANCE(node); + new_balance = old_balance - avl_child2balance[which_child]; + parent = AVL_XPARENT(node); + which_child = AVL_XCHILD(node); + + /* + * If a node was in perfect balance but isn't anymore then + * we can stop, since the height didn't change above this point + * due to a deletion. + */ + if (old_balance == 0) { + AVL_SETBALANCE(node, new_balance); + break; + } + + /* + * If the new balance is zero, we don't need to rotate + * else + * need a rotation to fix the balance. + * If the rotation doesn't change the height + * of the sub-tree we have finished adjusting. + */ + if (new_balance == 0) + AVL_SETBALANCE(node, new_balance); + else if (!avl_rotation(tree, node, new_balance)) + break; + } while (parent != NULL); +} + +#define AVL_REINSERT(tree, obj) \ + avl_remove((tree), (obj)); \ + avl_add((tree), (obj)) + +int +avl_update_lt(avl_tree_t *t, void *obj) +{ + void *neighbor; + + neighbor = AVL_PREV(t, obj); + if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) { + AVL_REINSERT(t, obj); + return S_SUCCESS; + } + + return S_ERROR; +} + +int +avl_update_gt(avl_tree_t *t, void *obj) +{ + void *neighbor; + + neighbor = AVL_NEXT(t, obj); + if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) { + AVL_REINSERT(t, obj); + return S_SUCCESS; + } + + return S_ERROR; +} + +int +avl_update(avl_tree_t *t, void *obj) +{ + void *neighbor; + + neighbor = AVL_PREV(t, obj); + if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) { + AVL_REINSERT(t, obj); + return S_SUCCESS; + } + + neighbor = AVL_NEXT(t, obj); + if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) { + AVL_REINSERT(t, obj); + return S_SUCCESS; + } + + return S_ERROR; +} + +/* + * initialize a new AVL tree + */ +void +avl_create(avl_tree_t *tree, int (*compar) (const void *, const void *), + size_t size, size_t offset) +{ + c_assert(tree); + c_assert(compar); + c_assert(size > 0); + c_assert(size >= offset + sizeof (avl_node_t)); + + + tree->avl_compar = compar; + tree->avl_root = NULL; + tree->avl_numnodes = 0; + tree->avl_size = size; + tree->avl_offset = offset; +} + + +void +avl_destroy(avl_tree_t *tree) +{ + +} + + +unsigned long +avl_numnodes(avl_tree_t *tree) +{ + rc_assert(tree, 0); + return (tree->avl_numnodes); +} + +int +avl_is_empty(avl_tree_t *tree) +{ + rc_assert(tree, S_ERROR); + return (tree->avl_numnodes == 0 ? S_SUCCESS : S_ERROR); +} + +#define CHILDBIT (1L) + +void * +avl_destroy_nodes(avl_tree_t *tree, void **cookie) +{ + avl_node_t *node; + avl_node_t *parent; + int child; + void *first; + size_t off = tree->avl_offset; + + /* + * Initial calls go to the first node or it's right descendant. + */ + if (*cookie == NULL) { + first = avl_first(tree); + + /* + * deal with an empty tree + */ + if (first == NULL) { + *cookie = (void *)CHILDBIT; + return (NULL); + } + + node = AVL_DATA2NODE(first, off); + parent = AVL_XPARENT(node); + goto check_right_side; + } + + /* + * If there is no parent to return to we are done. + */ + parent = (avl_node_t *)((uintptr_t)(*cookie) & ~CHILDBIT); + if (parent == NULL) { + if (tree->avl_root != NULL) { + tree->avl_root = NULL; + tree->avl_numnodes = 0; + } + return (NULL); + } + + /* + * Remove the child pointer we just visited from the parent and tree. + */ + child = (uintptr_t)(*cookie) & CHILDBIT; + parent->avl_child[child] = NULL; + + --tree->avl_numnodes; + + /* + * If we just did a right child or there isn't one, go up to parent. + */ + if (child == 1 || parent->avl_child[1] == NULL) { + node = parent; + parent = AVL_XPARENT(parent); + goto done; + } + + /* + * Do parent's right child, then leftmost descendent. + */ + node = parent->avl_child[1]; + while (node->avl_child[0] != NULL) { + parent = node; + node = node->avl_child[0]; + } + + /* + * If here, we moved to a left child. It may have one + * child on the right (when balance == +1). + */ +check_right_side: + if (node->avl_child[1] != NULL) { + + parent = node; + node = node->avl_child[1]; + + } else { + + } + +done: + if (parent == NULL) { + *cookie = (void *)CHILDBIT; + } else { + *cookie = (void *)((uintptr_t)parent | AVL_XCHILD(node)); + } + + return (AVL_NODE2DATA(node, off)); +} diff --git a/stdcrt/stdlib/compat_memory.c b/stdcrt/stdlib/compat_memory.c index 611dbada2887955c2db70bb096c43f4f2b9ae21e..99064bba333f06e9a21a3abbff5279ffe6a83b67 100644 --- a/stdcrt/stdlib/compat_memory.c +++ b/stdcrt/stdlib/compat_memory.c @@ -2,26 +2,64 @@ void* heap_malloc(size_t size) { - void *p = malloc(size); - return p; + void* ptr = NULL; +#if (TARGET_OS == OS_WINDOWS) + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + ptr = HeapAlloc(heap, 0, size); + HeapUnlock(heap); +#elif (TARGET_OS == OS_POSIX) + ptr = malloc(size); +#elif (TARGET_OS == OS_DARWIN) + ptr = malloc(size); +#endif + return ptr; } void heap_free(void *ptr) { if(ptr != NULL) { +#if (TARGET_OS == OS_WINDOWS) + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + HeapFree(GetProcessHeap(), 0, ptr); + HeapUnlock(heap); +#elif (TARGET_OS == OS_POSIX) + free(ptr); +#elif (TARGET_OS == OS_DARWIN) free(ptr); +#endif ptr = NULL; - } - + } } -void* heap_calloc(size_t n, size_t size) +void* heap_calloc(size_t count, size_t size) { - void* ptr = calloc(n, size); + void* ptr = NULL; +#if (TARGET_OS == OS_WINDOWS) + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + ptr = HeapAlloc(heap, HEAP_ZERO_MEMORY, count * size); + HeapUnlock(heap); +#elif (TARGET_OS == OS_POSIX) + ptr = calloc(count, size); +#elif (TARGET_OS == OS_DARWIN) + ptr = calloc(count, size); +#endif return ptr; } void* heap_realloc(void *mem_address, size_t size) { - void* ptr = heap_malloc(size); + void* ptr = NULL; +#if (TARGET_OS == OS_WINDOWS) + HANDLE heap = GetProcessHeap(); + HeapLock(heap); + ptr = HeapReAlloc(heap, 0, mem_address, size); + HeapUnlock(heap); +#elif (TARGET_OS == OS_POSIX) + ptr = realloc(mem_address, size); +#elif (TARGET_OS == OS_DARWIN) + ptr = realloc(mem_address, size); +#endif return ptr; } diff --git a/stdcrt/stdlib/compat_stdtime.c b/stdcrt/stdlib/compat_stdtime.c index c97ef4d5dc1c40860a1d3e6c9b025187dab4a8c4..28f5fd58a6449020c7627d21cce0bcaa953dcc5a 100644 --- a/stdcrt/stdlib/compat_stdtime.c +++ b/stdcrt/stdlib/compat_stdtime.c @@ -1,5 +1,10 @@ #include + +#if(TARGET_OS == OS_DARWIN) +#include +#endif + #if (TARGET_OS == OS_WINDOWS) #include @@ -69,7 +74,7 @@ unsigned long GetTickCount(void) #endif -unsigned long long _gettimeofday_s(void) +uint64_t _gettimeofday_s(void) { struct timeval tv; #if (TARGET_OS == OS_WINDOWS) @@ -79,7 +84,7 @@ unsigned long long _gettimeofday_s(void) #endif return tv.tv_sec + (tv.tv_usec / 1000000); } -unsigned long long _gettimeofday_ms(void) +uint64_t _gettimeofday_ms(void) { struct timeval tv; #if (TARGET_OS == OS_WINDOWS) @@ -89,7 +94,7 @@ unsigned long long _gettimeofday_ms(void) #endif return tv.tv_sec * (unsigned long long)1000 + tv.tv_usec / 1000; } -unsigned long long _gettimeofday_us(void) +uint64_t _gettimeofday_us(void) { struct timeval tv; #if (TARGET_OS == OS_WINDOWS) @@ -99,6 +104,46 @@ unsigned long long _gettimeofday_us(void) #endif return tv.tv_sec * (unsigned long long)1000000 + tv.tv_usec; } + +uint64_t getclock_ms(void) +{ +#if (TARGET_OS == OS_WINDOWS) + + LARGE_INTEGER tps; + LARGE_INTEGER time; + double tpms; + QueryPerformanceFrequency (&tps); + QueryPerformanceCounter (&time); + tpms = (double) (tps.QuadPart / 1000); + return (uint64_t) (time.QuadPart / tpms); + +#elif(TARGET_OS == OS_POSIX) + + int rc; + struct timespec tv; + rc = clock_gettime (CLOCK_MONOTONIC, &tv); + return tv.tv_sec * (uint64_t) 1000 + tv.tv_nsec / 1000000; + +#elif(TARGET_OS == OS_DARWIN) + + static mach_timebase_info_data_t nn_clock_timebase_info; + uint64_t ticks; + /* If the global timebase info is not initialised yet, init it. */ + if (uu_slow (!nn_clock_timebase_info.denom)) + mach_timebase_info (&nn_clock_timebase_info); + + ticks = mach_absolute_time (); + return ticks * nn_clock_timebase_info.numer / + nn_clock_timebase_info.denom / 1000000; +#else + + int rc; + struct timeval tv; + rc = gettimeofday (&tv, NULL); + return tv.tv_sec * (uint64_t) 1000 + tv.tv_usec / 1000; + +#endif +} struct tm* _localtime_t(const time_t* timep, struct tm* result) { #if (TARGET_OS == OS_WINDOWS) diff --git a/stdcrt/thread/compat_threadpool.c b/stdcrt/thread/compat_threadpool.c index fe9daf52c3606bde894020ab5fbd6431e5551cac..ab9965a4dd74537155caf21802130032f434d05e 100644 --- a/stdcrt/thread/compat_threadpool.c +++ b/stdcrt/thread/compat_threadpool.c @@ -50,7 +50,6 @@ static int thread_stop(io_thread_t* thread) { int start_threadpool(_threadpool_t* pool) { - unsigned long iloop = 0; rc_assert(pool != NULL, S_ERROR); diff --git a/stdcrt_test/Debug/stdcrt_test.exe.recipe b/stdcrt_test/Debug/stdcrt_test.exe.recipe new file mode 100644 index 0000000000000000000000000000000000000000..ba04e52d5140800433c7fff257aaf0d9bbb4cfae --- /dev/null +++ b/stdcrt_test/Debug/stdcrt_test.exe.recipe @@ -0,0 +1,11 @@ + + + + + C:\app\std_com\Debug\stdcrt_test.exe + + + + + + \ No newline at end of file diff --git a/stdcrt_test/stdcrt_test.vcxproj b/stdcrt_test/stdcrt_test.vcxproj index ae787fadc6755f83841d48c8bbb01adcdd49d0ba..9415b755b0c5c71f87c6b48e31d5edd4c1ffc434 100644 --- a/stdcrt_test/stdcrt_test.vcxproj +++ b/stdcrt_test/stdcrt_test.vcxproj @@ -29,7 +29,7 @@ {DE1B09E4-7F2B-4C9A-8B50-73313929B296} crt Win32Proj - 10.0.17763.0 + 10.0 @@ -41,7 +41,7 @@ Application Unicode - v141 + v141_xp diff --git a/testmain/appviewimpl.cpp b/testmain/appviewimpl.cpp index d0721d5f6ebe2e767261eed40af4c06f0cc4de91..d168dc55b2a9b8e5b4a9e3fa0453b7a118b69caa 100644 --- a/testmain/appviewimpl.cpp +++ b/testmain/appviewimpl.cpp @@ -67,8 +67,6 @@ HRESULT CAppViewImpl::Start(_pinstance hInstance, UINT uType) //m_ISPipe->OpenPipe(&scheme); //m_ISPipe->WaitPipe(); - - //m_IPipe->OpenPipe(&scheme); //CSemHandle sem; @@ -165,28 +163,31 @@ HRESULT CAppViewImpl::InitBus() HRESULT CAppViewImpl::UnInitBus() { - rc_assert(m_pIBroker.m_p != NULL, E_FAIL) - m_pIBroker->Close(); - - rc_assert(m_pIConsumer.m_p != NULL, E_FAIL) - m_pIConsumer->Close(); + if (m_pIBroker.m_p != NULL) + { + m_pIBroker->Close(); + m_pIBroker.dispose(); + } - rc_assert(m_pIProducer.m_p != NULL, E_FAIL) - m_pIProducer->Close(); + if(m_pIConsumer.m_p != NULL) + { + m_pIConsumer->Close(); + m_pIConsumer.dispose(); + } - rc_assert(m_pIAgent.m_p != NULL, E_FAIL) - m_pIAgent->Close(); + if(m_pIProducer.m_p != NULL) + { + m_pIProducer->Close(); + m_pIProducer.dispose(); + } + if(m_pIAgent.m_p != NULL) + { + m_pIAgent->Close(); + m_pIAgent.dispose(); + } m_pIMsgBus.dispose(); - m_pIBroker.dispose(); - - m_pIConsumer.dispose(); - - m_pIAgent.dispose(); - - m_pIProducer.dispose(); - return S_OK; } diff --git a/testmain/main.cpp b/testmain/main.cpp index 3769e9d24001d3e78199617b475514df4a8a931d..7f0edce4f871530e654e70b8be0dbd08cfc76ea2 100644 --- a/testmain/main.cpp +++ b/testmain/main.cpp @@ -14,34 +14,21 @@ int main_t(_pinstance hInstance, int argc, TCHAR* argv[]) GetExecutePath(INSNULL, path, MAX_PATH); size_t plen = tstring_strlen(path); + const char* strguid = "{409C8B8C-8467-47EE-B1BE-4E4112E64926}"; CContainer com; + GUID rid; + rid = StringToGUID(strguid); #if (TARGET_OS == OS_WINDOWS) -// string code = "{\"component\":[\ -//\"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:4\",\ -//\"{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:net:2:4\",\ -//\"{99103D46-735F-44EE-A6F1-2C94DF20901E}:logs:5:4\",\ -//\"{34F9B3BF-6F56-4058-9DCD-04D9A5F0174B}:logs:4:4\",\ -//\"{A8B9F69C-3523-406A-831B-2416421F324E}:logs:6:4\",\ -//\"{51FA8DE1-216F-4A76-B4F4-B986E9F54C27}:mainview:100:4\",\ -//\"{CE065148-7803-45B1-B1D7-874B52B8F5C5}:uibase:10:4\",\ -//\"{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:10:4\"]}"; - string code = "{\"component\":[\ + const char* code = "{\"component\":[\ \"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:4\",\ - \"{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:ÎÒ//net:2:4\",\ + \"{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:net:2:4\",\ \"{99103D46-735F-44EE-A6F1-2C94DF20901E}:logs:5:4\",\ \"{34F9B3BF-6F56-4058-9DCD-04D9A5F0174B}:logs:4:4\",\ \"{A8B9F69C-3523-406A-831B-2416421F324E}:logs:6:4\",\ - \"{51FA8DE1-216F-4A76-B4F4-B986E9F54C27}:mainview:100:4\",\ - \"{CE065148-7803-45B1-B1D7-874B52B8F5C5}:uibase:10:4\",\ \"{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:10:4\"] }"; - #else - //const char* code = "{\"component\":[ \ - // - // - // - std::string code = "{\"component\":[ \ + const char* code = "{\"component\":[ \ \"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:4\",\ \"{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:net:2:4\",\ \"{99103D46-735F-44EE-A6F1-2C94DF20901E}:logs:5:4\",\ @@ -51,65 +38,52 @@ int main_t(_pinstance hInstance, int argc, TCHAR* argv[]) ]}"; #endif - - //int iloop = 0; - //for (iloop = 0; iloop < 1000; iloop++) - //{ - // if (iloop == 2) - // { - // int aa = 1; - // goto end; - // } - // continue; - //end: - // iloop++; - // continue; - //} - SafePStringPtr containerpath; containerpath.ptr = path; containerpath.len = plen; SafeStringPtr containercode; - containercode.ptr = code.c_str(); - containercode.len = code.length(); - - SafeStringPtr appname; - appname.ptr = "app"; - appname.len = s_strlen("app"); + containercode.ptr = code; + containercode.len = s_strlen(code); logi("test_main_LoadContainer"); hr = com.LoadContainer(&containerpath); rc_assert(hr == S_OK, S_ERROR) logi("test_main_CreateContainer"); - hr = com.CreateContainer(&appname, &containerpath, &containercode); + hr = com.CreateContainer(rid, &containerpath, &containercode); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.InitContainer(&appname, hInstance, argv, argc); + hr = com.InitContainer(rid, hInstance, argv, argc); rc_assert(hr == S_OK, S_ERROR) - ULONG count = com.GetCompentCount(&appname); - ULONG Index = com.GetStartIndex(&appname, count - 1); + ULONG count = com.GetCompentCount(rid); + ULONG index = com.GetStartIndex(rid, count - 1); CAppViewImpl *app = ALLOC_NEW CAppViewImpl(); BasePtr pBase; hr = app->QueryInterface(IID_IBase, (void**)&pBase); rc_assert(hr == S_OK, S_ERROR) - hr = com.RegisterComponent(&appname, CLSID_AppView, +#if (TARGET_OS == OS_WINDOWS) + index = index + 1; +#else + index = index + 1; +#endif + + hr = com.RegisterComponent(rid, CLSID_AppView, "AppView.impl.V1", - pBase, Index - 1, "appview", + pBase, index, "appview", STD_COMPOENT | STD_INIT /*| STD_START*/); rc_assert(hr == S_OK, S_ERROR) logi("test_main_RunContainer"); - hr = com.RunContainer(&appname, 0); + hr = com.RunContainer(rid, 0); rc_assert(hr == S_OK, S_ERROR) logi("test_main_InitContainer"); - hr = com.UnInitContainer(&appname); + hr = com.UnInitContainer(rid); rc_assert(hr == S_OK, S_ERROR) logi("test_main_DestroyContainer"); diff --git a/testmain/testmain.vcxproj b/testmain/testmain.vcxproj index 34a1a90bfa949b991db281eef16f3ed4a23547be..c8aab80fc051b5a45ef66a08214a6bfa568b6b88 100644 --- a/testmain/testmain.vcxproj +++ b/testmain/testmain.vcxproj @@ -45,7 +45,6 @@ $(Configuration)\ true - C:\workspace\lbyc\core;$(IncludePath) $(Configuration)\ diff --git a/valagrind_leak.sh b/valagrind_leak.sh new file mode 100755 index 0000000000000000000000000000000000000000..64142d00bb772155e1f8ecaca263d397ef974065 --- /dev/null +++ b/valagrind_leak.sh @@ -0,0 +1,6 @@ +#!/bin/bash +valgrind --log-file="leak.log" --show-reachable=yes --track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=all -v ./libs/testmain +#valgrind --log-file="leak.log" --tool=memcheck --leak-check=yes -v ./libs/testmain + + +#valgrind --tool=callgrind --log-file="call.log" -v ./libs/testmain