├── Engine ├── LEncode │ ├── blowfish.cpp │ ├── blowfish.h │ ├── md5c.c │ ├── md5c.cpp │ ├── md5c.h │ ├── md5ex.cpp │ ├── md5ex.h │ ├── mycast.cpp │ ├── mycast.h │ ├── mydes.cpp │ ├── mydes.h │ ├── myidea.cpp │ ├── myidea.h │ ├── myrc5.cpp │ └── myrc5.h ├── LMysql │ ├── CMakeLists.txt │ ├── mysqlDB.cpp │ └── mysqlDB.h ├── LNetbase │ ├── Des.cpp │ ├── Des.h │ ├── EncDec.cpp │ ├── EncDec.h │ ├── LCantCopy.h │ ├── LCond.h │ ├── LMutex.h │ ├── LNetService.cpp │ ├── LNetService.h │ ├── LRWLock.h │ ├── LService.cpp │ ├── LService.h │ ├── LSocket.cpp │ ├── LSocket.h │ ├── LTCPClientTask.cpp │ ├── LTCPClientTask.h │ ├── LTCPClientTaskPool.cpp │ ├── LTCPClientTaskPool.h │ ├── LTCPServer.cpp │ ├── LTCPServer.h │ ├── LTCPTask.cpp │ ├── LTCPTask.h │ ├── LTCPTaskPool.cpp │ ├── LTCPTaskPool.h │ ├── LThread.cpp │ ├── LThread.h │ ├── LTime.cpp │ ├── LTime.h │ └── LType.h └── README.md ├── README.md ├── Server1 ├── CMakeLists.txt ├── Engine │ ├── BlockMap │ │ ├── Block.cpp │ │ ├── Block.h │ │ ├── Entry.h │ │ ├── MyMap.cpp │ │ └── MyMap.h │ ├── CMakeLists.txt │ ├── Ext │ │ ├── CMakeLists.txt │ │ ├── base64 │ │ │ ├── base64.cpp │ │ │ └── base64.h │ │ ├── cjson │ │ │ ├── CMakeLists.txt │ │ │ ├── cJSON.c │ │ │ ├── cJSON.h │ │ │ ├── jsonObject.h │ │ │ └── testJson.cpp │ │ ├── g3dlite │ │ │ ├── CMakeLists.txt │ │ │ ├── inc │ │ │ │ ├── AABox.h │ │ │ │ ├── Array.h │ │ │ │ ├── Box.h │ │ │ │ ├── CollisionDetection.h │ │ │ │ ├── CoordinateFrame.h │ │ │ │ ├── Crypto.h │ │ │ │ ├── GCamera.h │ │ │ │ ├── Line.h │ │ │ │ ├── Matrix3.h │ │ │ │ ├── Plane.h │ │ │ │ ├── Quat.h │ │ │ │ ├── Quat.inl │ │ │ │ ├── Ray.h │ │ │ │ ├── RegistryUtil.h │ │ │ │ ├── Sphere.h │ │ │ │ ├── System.h │ │ │ │ ├── Table.h │ │ │ │ ├── Triangle.h │ │ │ │ ├── Vector2.h │ │ │ │ ├── Vector2.inl │ │ │ │ ├── Vector2int16.h │ │ │ │ ├── Vector3.h │ │ │ │ ├── Vector3.inl │ │ │ │ ├── Vector3int16.h │ │ │ │ ├── Vector4.h │ │ │ │ ├── Vector4.inl │ │ │ │ ├── debug.h │ │ │ │ ├── format.h │ │ │ │ ├── g3dmath.h │ │ │ │ ├── g3dmath.inl │ │ │ │ ├── platform.h │ │ │ │ └── stringutils.h │ │ │ └── src │ │ │ │ ├── AABox.cpp │ │ │ │ ├── Box.cpp │ │ │ │ ├── Crypto.cpp │ │ │ │ ├── Matrix3.cpp │ │ │ │ ├── Plane.cpp │ │ │ │ ├── System.cpp │ │ │ │ ├── Triangle.cpp │ │ │ │ ├── Vector3.cpp │ │ │ │ ├── Vector4.cpp │ │ │ │ ├── format.cpp │ │ │ │ └── license.html │ │ ├── libev │ │ │ ├── ev++.h │ │ │ ├── ev.c │ │ │ ├── ev.h │ │ │ ├── ev_epoll.c │ │ │ ├── ev_kqueue.c │ │ │ ├── ev_poll.c │ │ │ ├── ev_port.c │ │ │ ├── ev_select.c │ │ │ ├── ev_vars.h │ │ │ ├── ev_win32.c │ │ │ ├── ev_wrap.h │ │ │ ├── event.c │ │ │ └── event.h │ │ ├── libuv │ │ │ ├── include │ │ │ │ ├── android-ifaddrs.h │ │ │ │ ├── pthread-fixes.h │ │ │ │ ├── stdint-msvc2008.h │ │ │ │ ├── tree.h │ │ │ │ ├── uv-bsd.h │ │ │ │ ├── uv-darwin.h │ │ │ │ ├── uv-errno.h │ │ │ │ ├── uv-linux.h │ │ │ │ ├── uv-sunos.h │ │ │ │ ├── uv-unix.h │ │ │ │ ├── uv-version.h │ │ │ │ ├── uv-win.h │ │ │ │ └── uv.h │ │ │ ├── socks5-proxy │ │ │ │ ├── .gitignore │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── build.gyp │ │ │ │ ├── client.c │ │ │ │ ├── defs.h │ │ │ │ ├── getopt.c │ │ │ │ ├── main.c │ │ │ │ ├── s5.c │ │ │ │ ├── s5.h │ │ │ │ ├── server.c │ │ │ │ └── util.c │ │ │ └── src │ │ │ │ ├── fs-poll.c │ │ │ │ ├── heap-inl.h │ │ │ │ ├── inet.c │ │ │ │ ├── queue.h │ │ │ │ ├── unix │ │ │ │ ├── aix.c │ │ │ │ ├── android-ifaddrs.c │ │ │ │ ├── async.c │ │ │ │ ├── atomic-ops.h │ │ │ │ ├── core.c │ │ │ │ ├── darwin-proctitle.c │ │ │ │ ├── darwin.c │ │ │ │ ├── dl.c │ │ │ │ ├── freebsd.c │ │ │ │ ├── fs.c │ │ │ │ ├── fsevents.c │ │ │ │ ├── getaddrinfo.c │ │ │ │ ├── internal.h │ │ │ │ ├── kqueue.c │ │ │ │ ├── linux-core.c │ │ │ │ ├── linux-inotify.c │ │ │ │ ├── linux-syscalls.c │ │ │ │ ├── linux-syscalls.h │ │ │ │ ├── loop-watcher.c │ │ │ │ ├── loop.c │ │ │ │ ├── netbsd.c │ │ │ │ ├── openbsd.c │ │ │ │ ├── pipe.c │ │ │ │ ├── poll.c │ │ │ │ ├── process.c │ │ │ │ ├── proctitle.c │ │ │ │ ├── pthread-fixes.c │ │ │ │ ├── signal.c │ │ │ │ ├── spinlock.h │ │ │ │ ├── stream.c │ │ │ │ ├── sunos.c │ │ │ │ ├── tcp.c │ │ │ │ ├── thread.c │ │ │ │ ├── threadpool.c │ │ │ │ ├── timer.c │ │ │ │ ├── tty.c │ │ │ │ ├── udp.c │ │ │ │ └── uv-dtrace.d │ │ │ │ ├── uv-common.c │ │ │ │ ├── uv-common.h │ │ │ │ ├── version.c │ │ │ │ └── win │ │ │ │ ├── async.c │ │ │ │ ├── atomicops-inl.h │ │ │ │ ├── core.c │ │ │ │ ├── dl.c │ │ │ │ ├── error.c │ │ │ │ ├── fs-event.c │ │ │ │ ├── fs.c │ │ │ │ ├── getaddrinfo.c │ │ │ │ ├── handle-inl.h │ │ │ │ ├── handle.c │ │ │ │ ├── internal.h │ │ │ │ ├── loop-watcher.c │ │ │ │ ├── pipe.c │ │ │ │ ├── poll.c │ │ │ │ ├── process-stdio.c │ │ │ │ ├── process.c │ │ │ │ ├── req-inl.h │ │ │ │ ├── req.c │ │ │ │ ├── signal.c │ │ │ │ ├── stream-inl.h │ │ │ │ ├── stream.c │ │ │ │ ├── tcp.c │ │ │ │ ├── thread.c │ │ │ │ ├── threadpool.c │ │ │ │ ├── timer.c │ │ │ │ ├── tty.c │ │ │ │ ├── udp.c │ │ │ │ ├── util.c │ │ │ │ ├── winapi.c │ │ │ │ ├── winapi.h │ │ │ │ ├── winsock.c │ │ │ │ └── winsock.h │ │ ├── lua │ │ │ ├── CMakeLists.txt │ │ │ ├── ReadMe.txt │ │ │ ├── lapi.c │ │ │ ├── lapi.h │ │ │ ├── lauxlib.c │ │ │ ├── lauxlib.h │ │ │ ├── lbaselib.c │ │ │ ├── lcode.c │ │ │ ├── lcode.h │ │ │ ├── ldblib.c │ │ │ ├── ldebug.c │ │ │ ├── ldebug.h │ │ │ ├── ldo.c │ │ │ ├── ldo.h │ │ │ ├── ldump.c │ │ │ ├── lfunc.c │ │ │ ├── lfunc.h │ │ │ ├── lgc.c │ │ │ ├── lgc.h │ │ │ ├── linit.c │ │ │ ├── liolib.c │ │ │ ├── llex.c │ │ │ ├── llex.h │ │ │ ├── llimits.h │ │ │ ├── lmathlib.c │ │ │ ├── lmem.c │ │ │ ├── lmem.h │ │ │ ├── loadlib.c │ │ │ ├── lobject.c │ │ │ ├── lobject.h │ │ │ ├── lopcodes.c │ │ │ ├── lopcodes.h │ │ │ ├── loslib.c │ │ │ ├── lparser.c │ │ │ ├── lparser.h │ │ │ ├── lstate.c │ │ │ ├── lstate.h │ │ │ ├── lstring.c │ │ │ ├── lstring.h │ │ │ ├── lstrlib.c │ │ │ ├── ltable.c │ │ │ ├── ltable.h │ │ │ ├── ltablib.c │ │ │ ├── ltm.c │ │ │ ├── ltm.h │ │ │ ├── lua.c │ │ │ ├── lua.h │ │ │ ├── lua.txt │ │ │ ├── lua.vcproj │ │ │ ├── lua.vcxproj │ │ │ ├── lua.vcxproj.filters │ │ │ ├── lua_tinker.cpp │ │ │ ├── lua_tinker.h │ │ │ ├── luac.c │ │ │ ├── luaconf.h │ │ │ ├── lualib.h │ │ │ ├── lundump.c │ │ │ ├── lundump.h │ │ │ ├── lvm.c │ │ │ ├── lvm.h │ │ │ ├── lzio.c │ │ │ ├── lzio.h │ │ │ ├── print.c │ │ │ ├── sample3.cpp │ │ │ └── sample3.lua │ │ ├── md5 │ │ │ ├── CMakeLists.txt │ │ │ ├── md5.cpp │ │ │ ├── md5.h │ │ │ └── test.cpp │ │ ├── netbase │ │ │ ├── CMakeLists.txt │ │ │ └── win │ │ │ │ ├── EncDec.cpp │ │ │ │ ├── EncDec.h │ │ │ │ ├── LCantCopy.h │ │ │ │ ├── LIocp.cpp │ │ │ │ ├── LIocp.h │ │ │ │ ├── LNetService.cpp │ │ │ │ ├── LNetService.h │ │ │ │ ├── LService.cpp │ │ │ │ ├── LService.h │ │ │ │ ├── LSocket.cpp │ │ │ │ ├── LSocket.h │ │ │ │ ├── LTCPClientTask.cpp │ │ │ │ ├── LTCPClientTask.h │ │ │ │ ├── LTCPClientTaskPool.cpp │ │ │ │ ├── LTCPClientTaskPool.h │ │ │ │ ├── LTCPServer.cpp │ │ │ │ ├── LTCPServer.h │ │ │ │ ├── LTCPTask.cpp │ │ │ │ ├── LTCPTask.h │ │ │ │ ├── LTCPTaskPool.cpp │ │ │ │ ├── LTCPTaskPool.h │ │ │ │ ├── LThread.cpp │ │ │ │ ├── LThread.h │ │ │ │ ├── LTime.cpp │ │ │ │ ├── LTime.h │ │ │ │ ├── LType.h │ │ │ │ ├── miniCrypt.c │ │ │ │ └── miniCrypt.h │ │ ├── netdsdk │ │ │ ├── app │ │ │ │ ├── complie.sh │ │ │ │ ├── export_ld.sh │ │ │ │ ├── performance_multi_reactor_server.cpp │ │ │ │ ├── performance_tpepoll_client.cpp │ │ │ │ └── performance_tpepoll_server.cpp │ │ │ ├── code_set │ │ │ │ ├── aio │ │ │ │ │ └── aio.c │ │ │ │ ├── iniparser3.0b │ │ │ │ │ ├── AUTHORS │ │ │ │ │ ├── INSTALL │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── README │ │ │ │ │ ├── html │ │ │ │ │ │ ├── doxygen.css │ │ │ │ │ │ ├── doxygen.png │ │ │ │ │ │ ├── globals_func.html │ │ │ │ │ │ ├── index.html │ │ │ │ │ │ ├── iniparser_8h.html │ │ │ │ │ │ ├── iniparser_8main.html │ │ │ │ │ │ ├── tab_b.gif │ │ │ │ │ │ ├── tab_l.gif │ │ │ │ │ │ ├── tab_r.gif │ │ │ │ │ │ └── tabs.css │ │ │ │ │ ├── src │ │ │ │ │ │ ├── dictionary.c │ │ │ │ │ │ ├── dictionary.h │ │ │ │ │ │ ├── iniparser.c │ │ │ │ │ │ └── iniparser.h │ │ │ │ │ └── test │ │ │ │ │ │ ├── Makefile │ │ │ │ │ │ ├── iniexample.c │ │ │ │ │ │ ├── parse.c │ │ │ │ │ │ ├── twisted-errors.ini │ │ │ │ │ │ ├── twisted-genhuge.py │ │ │ │ │ │ ├── twisted-ofkey.ini │ │ │ │ │ │ ├── twisted-ofval.ini │ │ │ │ │ │ └── twisted.ini │ │ │ │ └── mempoll │ │ │ │ │ ├── main.cpp │ │ │ │ │ ├── mempool.cpp │ │ │ │ │ └── mempool.h │ │ │ ├── include │ │ │ │ ├── Acceptor.h │ │ │ │ ├── AtomicOpt_T.h │ │ │ │ ├── AtomicOpt_T.inl │ │ │ │ ├── Common.h │ │ │ │ ├── Condition.h │ │ │ │ ├── Condition.inl │ │ │ │ ├── ConditionThreadMutex.h │ │ │ │ ├── ConditionThreadMutex.inl │ │ │ │ ├── DateTime.h │ │ │ │ ├── DateTime.inl │ │ │ │ ├── Debug.h │ │ │ │ ├── Debug.inl │ │ │ │ ├── DefaultConstants.h │ │ │ │ ├── EpollReactor.h │ │ │ │ ├── EpollReactor.inl │ │ │ │ ├── EpollTPReactor.h │ │ │ │ ├── EventHandler.h │ │ │ │ ├── EventHandler.inl │ │ │ │ ├── GlobalMacros.h │ │ │ │ ├── Guard_T.h │ │ │ │ ├── Guard_T.inl │ │ │ │ ├── InetAddr.h │ │ │ │ ├── InetAddr.inl │ │ │ │ ├── LogSvr.h │ │ │ │ ├── MessageBlock.h │ │ │ │ ├── MessageBlock.inl │ │ │ │ ├── MessageQueue.h │ │ │ │ ├── MessageQueue.inl │ │ │ │ ├── MultiReactors.h │ │ │ │ ├── NDK.h │ │ │ │ ├── NDK.inl │ │ │ │ ├── Pipe.h │ │ │ │ ├── Pipe.inl │ │ │ │ ├── Post.h │ │ │ │ ├── Pre.h │ │ │ │ ├── RWThreadMutex.h │ │ │ │ ├── Reactor.h │ │ │ │ ├── Reactor.inl │ │ │ │ ├── ReactorImpl.h │ │ │ │ ├── ReactorToken.h │ │ │ │ ├── ReactorToken.inl │ │ │ │ ├── RecursiveThreadMutex.h │ │ │ │ ├── RecursiveThreadMutex.inl │ │ │ │ ├── SelectReactor.h │ │ │ │ ├── Semaphore.h │ │ │ │ ├── Semaphore.inl │ │ │ │ ├── Singleton_T.h │ │ │ │ ├── Singleton_T.inl │ │ │ │ ├── SockAcceptor.h │ │ │ │ ├── SockConnector.h │ │ │ │ ├── SockConnector.inl │ │ │ │ ├── SockStream.h │ │ │ │ ├── SockStream.inl │ │ │ │ ├── Socket.h │ │ │ │ ├── Socket.inl │ │ │ │ ├── SvcHandler.h │ │ │ │ ├── TaskBase.h │ │ │ │ ├── TaskWithMQ.h │ │ │ │ ├── TaskWithMQ.inl │ │ │ │ ├── Thread.h │ │ │ │ ├── Thread.inl │ │ │ │ ├── ThreadManager.h │ │ │ │ ├── ThreadManager.inl │ │ │ │ ├── ThreadMutex.h │ │ │ │ ├── ThreadMutex.inl │ │ │ │ ├── ThreadTimerSvc.h │ │ │ │ ├── TimeValue.h │ │ │ │ ├── TimeValue.inl │ │ │ │ ├── TimerQueue.h │ │ │ │ ├── TimerQueue.inl │ │ │ │ ├── Token.h │ │ │ │ ├── Token.inl │ │ │ │ ├── Trace.h │ │ │ │ ├── Trace.inl │ │ │ │ └── config.h │ │ │ └── src │ │ │ │ ├── Acceptor.cpp │ │ │ │ ├── EpollReactor.cpp │ │ │ │ ├── EpollTPReactor.cpp │ │ │ │ ├── InetAddr.cpp │ │ │ │ ├── LogSvr.cpp │ │ │ │ ├── MessageQueue.cpp │ │ │ │ ├── MessageQueue.cpp_ │ │ │ │ ├── MultiReactors.cpp │ │ │ │ ├── NDK.cpp │ │ │ │ ├── Pipe.cpp │ │ │ │ ├── Reactor.cpp │ │ │ │ ├── ReactorImpl.cpp │ │ │ │ ├── ReactorToken.cpp │ │ │ │ ├── RecursiveThreadMutex.cpp │ │ │ │ ├── SelectReactor.cpp │ │ │ │ ├── SockAcceptor.cpp │ │ │ │ ├── SockConnector.cpp │ │ │ │ ├── SvcHandler.cpp │ │ │ │ ├── TaskBase.cpp │ │ │ │ ├── Thread.cpp │ │ │ │ ├── ThreadManager.cpp │ │ │ │ ├── ThreadTimerSvc.cpp │ │ │ │ ├── TimeValue.cpp │ │ │ │ ├── TimerQueue.cpp │ │ │ │ ├── Token.cpp │ │ │ │ └── Trace.cpp │ │ ├── sqlite3 │ │ │ ├── CMakeLists.txt │ │ │ ├── db.h │ │ │ ├── sqlite3.c │ │ │ ├── sqlite3.h │ │ │ ├── sqlite3ext.h │ │ │ └── testSqite3.cpp │ │ ├── tolua │ │ │ ├── CMakeLists.txt │ │ │ ├── tolua++.h │ │ │ ├── tolua_event.c │ │ │ ├── tolua_event.h │ │ │ ├── tolua_fix.c │ │ │ ├── tolua_fix.h │ │ │ ├── tolua_is.c │ │ │ ├── tolua_map.c │ │ │ ├── tolua_push.c │ │ │ └── tolua_to.c │ │ ├── xml │ │ │ ├── CMakeLists.txt │ │ │ ├── tinyxml2.cpp │ │ │ └── tinyxml2.h │ │ ├── zlib │ │ │ ├── CMakeLists.txt │ │ │ ├── ReadMe.txt │ │ │ ├── adler32.c │ │ │ ├── compress.c │ │ │ ├── crc32.c │ │ │ ├── crc32.h │ │ │ ├── deflate.c │ │ │ ├── deflate.h │ │ │ ├── gzio.c │ │ │ ├── infback.c │ │ │ ├── inffast.c │ │ │ ├── inffast.h │ │ │ ├── inffixed.h │ │ │ ├── inflate.c │ │ │ ├── inflate.h │ │ │ ├── inftrees.c │ │ │ ├── inftrees.h │ │ │ ├── trees.c │ │ │ ├── trees.h │ │ │ ├── uncompr.c │ │ │ ├── zconf.h │ │ │ ├── zlib.h │ │ │ ├── zlib.vcproj │ │ │ ├── zutil.c │ │ │ └── zutil.h │ │ └── zthread │ │ │ ├── CMakeLists.txt │ │ │ ├── src │ │ │ ├── AtomicCount.cxx │ │ │ ├── AtomicCount.h │ │ │ ├── Barrier.h │ │ │ ├── BiasedReadWriteLock.h │ │ │ ├── BlockingQueue.h │ │ │ ├── BoundedQueue.h │ │ │ ├── Cancelable.h │ │ │ ├── ClassLockable.h │ │ │ ├── ConcurrentExecutor.cxx │ │ │ ├── ConcurrentExecutor.h │ │ │ ├── Condition.cxx │ │ │ ├── Condition.h │ │ │ ├── ConditionImpl.h │ │ │ ├── CountedPtr.h │ │ │ ├── CountingSemaphore.cxx │ │ │ ├── CountingSemaphore.h │ │ │ ├── Debug.h │ │ │ ├── DeferredInterruptionScope.h │ │ │ ├── Exceptions.h │ │ │ ├── Executor.h │ │ │ ├── FairReadWriteLock.h │ │ │ ├── FastLock.h │ │ │ ├── FastMutex.cxx │ │ │ ├── FastMutex.h │ │ │ ├── FastRecursiveLock.h │ │ │ ├── FastRecursiveMutex.cxx │ │ │ ├── FastRecursiveMutex.h │ │ │ ├── Guard.h │ │ │ ├── GuardedClass.h │ │ │ ├── IntrusivePtr.h │ │ │ ├── Lockable.h │ │ │ ├── LockedQueue.h │ │ │ ├── Makefile.am │ │ │ ├── Monitor.cxx │ │ │ ├── Monitor.h │ │ │ ├── MonitoredQueue.h │ │ │ ├── Mutex.cxx │ │ │ ├── Mutex.h │ │ │ ├── MutexImpl.h │ │ │ ├── NonCopyable.h │ │ │ ├── PoolExecutor.cxx │ │ │ ├── PoolExecutor.h │ │ │ ├── Priority.h │ │ │ ├── PriorityCondition.cxx │ │ │ ├── PriorityCondition.h │ │ │ ├── PriorityInheritanceMutex.cxx │ │ │ ├── PriorityInheritanceMutex.h │ │ │ ├── PriorityMutex.cxx │ │ │ ├── PriorityMutex.h │ │ │ ├── PrioritySemaphore.cxx │ │ │ ├── PrioritySemaphore.h │ │ │ ├── Queue.h │ │ │ ├── ReadWriteLock.h │ │ │ ├── RecursiveMutex.cxx │ │ │ ├── RecursiveMutex.h │ │ │ ├── RecursiveMutexImpl.cxx │ │ │ ├── RecursiveMutexImpl.h │ │ │ ├── Runnable.h │ │ │ ├── Scheduling.h │ │ │ ├── Semaphore.cxx │ │ │ ├── Semaphore.h │ │ │ ├── SemaphoreImpl.h │ │ │ ├── Singleton.h │ │ │ ├── State.h │ │ │ ├── Status.h │ │ │ ├── SynchronousExecutor.cxx │ │ │ ├── SynchronousExecutor.h │ │ │ ├── TSS.h │ │ │ ├── Task.h │ │ │ ├── Thread.cxx │ │ │ ├── Thread.h │ │ │ ├── ThreadImpl.cxx │ │ │ ├── ThreadImpl.h │ │ │ ├── ThreadLocal.h │ │ │ ├── ThreadLocalImpl.cxx │ │ │ ├── ThreadLocalImpl.h │ │ │ ├── ThreadOps.cxx │ │ │ ├── ThreadOps.h │ │ │ ├── ThreadQueue.cxx │ │ │ ├── ThreadQueue.h │ │ │ ├── ThreadedExecutor.cxx │ │ │ ├── ThreadedExecutor.h │ │ │ ├── Time.cxx │ │ │ ├── Time.h │ │ │ ├── TimeStrategy.h │ │ │ ├── Waitable.h │ │ │ ├── ZThread.h │ │ │ ├── config.h │ │ │ ├── linux │ │ │ │ ├── AtomicCount.cxx │ │ │ │ ├── AtomicFastLock.h │ │ │ │ └── FastRecursiveLock.h │ │ │ ├── macos │ │ │ │ ├── FastLock.h │ │ │ │ ├── Monitor.cxx │ │ │ │ ├── Monitor.h │ │ │ │ ├── TSS.h │ │ │ │ ├── ThreadOps.cxx │ │ │ │ ├── ThreadOps.h │ │ │ │ └── UpTimeStrategy.h │ │ │ ├── posix │ │ │ │ ├── ConditionRecursiveLock.h │ │ │ │ ├── FastLock.h │ │ │ │ ├── FtimeStrategy.h │ │ │ │ ├── GetTimeOfDayStrategy.h │ │ │ │ ├── Monitor.cxx │ │ │ │ ├── Monitor.h │ │ │ │ ├── PriorityOps.h │ │ │ │ ├── TSS.h │ │ │ │ ├── ThreadOps.cxx │ │ │ │ └── ThreadOps.h │ │ │ ├── solaris │ │ │ │ └── FastRecursiveLock.h │ │ │ ├── vanilla │ │ │ │ ├── DualMutexRecursiveLock.h │ │ │ │ ├── SimpleAtomicCount.cxx │ │ │ │ └── SimpleRecursiveLock.h │ │ │ ├── win32 │ │ │ │ ├── AtomicCount.cxx │ │ │ │ ├── AtomicFastLock.h │ │ │ │ ├── AtomicFastRecursiveLock.h │ │ │ │ ├── FastLock.h │ │ │ │ ├── FastRecursiveLock.h │ │ │ │ ├── Monitor.cxx │ │ │ │ ├── Monitor.h │ │ │ │ ├── PerformanceCounterStrategy.h │ │ │ │ ├── TSS.h │ │ │ │ ├── ThreadOps.cxx │ │ │ │ └── ThreadOps.h │ │ │ └── win9x │ │ │ │ ├── AtomicCount.cxx │ │ │ │ └── AtomicFastLock.h │ │ │ └── zthread │ │ │ ├── AtomicCount.h │ │ │ ├── Barrier.h │ │ │ ├── BiasedReadWriteLock.h │ │ │ ├── BlockingQueue.h │ │ │ ├── BoundedQueue.h │ │ │ ├── Cancelable.h │ │ │ ├── ClassLockable.h │ │ │ ├── ConcurrentExecutor.h │ │ │ ├── Condition.h │ │ │ ├── Config.h │ │ │ ├── CountedPtr.h │ │ │ ├── CountingSemaphore.h │ │ │ ├── Exceptions.h │ │ │ ├── Executor.h │ │ │ ├── FairReadWriteLock.h │ │ │ ├── FastMutex.h │ │ │ ├── FastRecursiveMutex.h │ │ │ ├── Guard.h │ │ │ ├── GuardedClass.h │ │ │ ├── Lockable.h │ │ │ ├── LockedQueue.h │ │ │ ├── MonitoredQueue.h │ │ │ ├── Mutex.h │ │ │ ├── NonCopyable.h │ │ │ ├── PoolExecutor.h │ │ │ ├── Priority.h │ │ │ ├── PriorityCondition.h │ │ │ ├── PriorityInheritanceMutex.h │ │ │ ├── PriorityMutex.h │ │ │ ├── PrioritySemaphore.h │ │ │ ├── Queue.h │ │ │ ├── ReadWriteLock.h │ │ │ ├── RecursiveMutex.h │ │ │ ├── Runnable.h │ │ │ ├── Semaphore.h │ │ │ ├── Singleton.h │ │ │ ├── SynchronousExecutor.h │ │ │ ├── Task.h │ │ │ ├── Thread.h │ │ │ ├── ThreadLocal.h │ │ │ ├── ThreadLocalImpl.h │ │ │ ├── ThreadedExecutor.h │ │ │ ├── Time.h │ │ │ ├── Waitable.h │ │ │ └── ZThread.h │ ├── Lang │ │ ├── CMakeLists.txt │ │ ├── Code.cpp │ │ ├── Code.h │ │ ├── LCalc.h │ │ ├── LLib.h │ │ ├── LNode.h │ │ ├── Lang.cpp │ │ ├── Lang.h │ │ ├── LangCode.h │ │ ├── LangScript.h │ │ └── Script.h │ ├── Log │ │ ├── CMakeLists.txt │ │ ├── Logger.cpp │ │ └── Logger.h │ ├── MysqlOO │ │ ├── CMakeLists.txt │ │ ├── mysqlDB.cpp │ │ └── mysqlDB.h │ ├── Net │ │ ├── NetBase │ │ │ ├── connect.cpp │ │ │ ├── connect.h │ │ │ ├── decoder.cpp │ │ │ ├── decoder.h │ │ │ ├── eventpool.cpp │ │ │ ├── eventpool.h │ │ │ ├── mylist.h │ │ │ ├── mynet.h │ │ │ ├── record.h │ │ │ ├── target.h │ │ │ └── win32helper.h │ │ └── Server │ │ │ ├── MyClient.h │ │ │ ├── MyConnection.h │ │ │ ├── MyPool.h │ │ │ ├── MyServer.h │ │ │ ├── MyTick.h │ │ │ ├── MyTime.cpp │ │ │ └── MyTime.h │ ├── Pack │ │ ├── BinPack.h │ │ ├── CMakeLists.txt │ │ ├── FileMsgPack.h │ │ ├── JsonPack.h │ │ ├── MsgPack.h │ │ ├── README.md │ │ ├── TcpMsgPack.h │ │ └── XmlPack.h │ ├── README.md │ ├── Remote │ │ ├── CMakeLists.txt │ │ ├── Net.cpp │ │ ├── Net.h │ │ ├── RemoteObject.h │ │ └── message.h │ ├── Samples │ │ ├── CMakeLists.txt │ │ ├── TestRemote.cpp │ │ ├── testJsonPack.cpp │ │ ├── testMsgFunction.cpp │ │ ├── testMsgPack.cpp │ │ ├── testMysql.cpp │ │ └── testXmlPack.cpp │ └── Thread │ │ ├── Test.cpp │ │ ├── mythread.cpp │ │ ├── mythread.h │ │ ├── mythread_posix.cpp │ │ └── mythread_win.cpp ├── ReadMe.txt └── Severs │ ├── CMakeLists.txt │ └── main.cpp └── TODO.md /Engine/LEncode/blowfish.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _BLOWFISH_H 3 | #define _BLOWFISH_H 4 | 5 | #define BF_ENCRYPT 1 6 | #define BF_DECRYPT 0 7 | 8 | /* 9 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 10 | * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! 11 | * ! BF_LONG_LOG2 has to be defined along. ! 12 | * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 13 | */ 14 | 15 | #define BF_LONG unsigned long 16 | #define BF_LONG_LOG2 3 17 | 18 | 19 | #define BF_ROUNDS 16 20 | #define BF_BLOCK 8 21 | 22 | typedef struct bf_key_st 23 | { 24 | BF_LONG P[BF_ROUNDS+2]; 25 | BF_LONG S[4*256]; 26 | } BF_KEY; 27 | 28 | 29 | void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 30 | 31 | void BF_encrypt(BF_LONG *data,const BF_KEY *key); 32 | void BF_decrypt(BF_LONG *data,const BF_KEY *key); 33 | 34 | 35 | typedef void (* f_BF_set_key)(BF_KEY *key, int len, const unsigned char *data); 36 | typedef void (* f_BF_encrypt)(BF_LONG *data,const BF_KEY *key); 37 | typedef void (* f_BF_decrypt)(BF_LONG *data,const BF_KEY *key); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Engine/LEncode/md5ex.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _USE_ENGINE 2 | //#include "../../engine/include/engine.h" 3 | #endif 4 | 5 | #include "md5c.h" 6 | #include "md5ex.h" 7 | #include 8 | #include 9 | 10 | bool MD5Data(const void* pData,size_t size,unsigned char *pMD5 /* 16 Byte*/) 11 | { 12 | MD5_CTX context; 13 | MD5Init (&context); 14 | MD5Update (&context, (unsigned char*)pData, size); 15 | MD5Final (pMD5, &context); 16 | return true; 17 | } 18 | 19 | #ifdef _USE_ENGINE 20 | 21 | bool MD5Stream(Stream* pStream,unsigned char *pMD5 /* 16 Byte*/) 22 | { 23 | MD5_CTX context; 24 | unsigned char buffer[4096]; 25 | size_t size = pStream->getStreamSize(); 26 | MD5Init (&context); 27 | while(size) 28 | { 29 | size_t readSize = getMin(size,(size_t)4096); 30 | if(!pStream->read(buffer,readSize)) 31 | { 32 | MD5Final (pMD5, &context); 33 | return false; 34 | } 35 | MD5Update (&context, buffer, readSize); 36 | } 37 | MD5Final (pMD5, &context); 38 | return true; 39 | } 40 | 41 | bool MD5File(const char* pszFile,unsigned char *pMD5 /* 16 Byte*/) 42 | { 43 | FileStream stream; 44 | if(!stream.open(pszFile,FileStream::Read)) 45 | return false; 46 | return MD5Stream(&stream,pMD5); 47 | } 48 | 49 | #else 50 | 51 | bool MD5File(const char* pszFile,unsigned char *pMD5 /* 16 Byte*/) 52 | { 53 | FILE* fp = fopen(pszFile,"rb"); 54 | if(!fp) return false; 55 | 56 | unsigned char buffer[8192]; 57 | size_t len; 58 | fseek(fp,0,SEEK_END); 59 | len = ftell(fp); 60 | fseek(fp,0,SEEK_SET); 61 | 62 | MD5_CTX context; 63 | MD5Init (&context); 64 | while( len ) 65 | { 66 | size_t readLen = (len < 8192 ? len : 8192); 67 | if(1 != fread(buffer,readLen,1,fp)) 68 | { 69 | MD5Final (pMD5, &context); 70 | return false; 71 | } 72 | len -= readLen; 73 | MD5Update (&context, buffer, readLen); 74 | } 75 | MD5Final (pMD5, &context); 76 | return true; 77 | } 78 | 79 | #endif 80 | 81 | bool MD5String(const char* string,unsigned char* pMD5 /* 16 Byte*/) 82 | { 83 | size_t size = strlen(string); 84 | return MD5Data(string,size,pMD5); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /Engine/LEncode/md5ex.h: -------------------------------------------------------------------------------- 1 | #ifndef _MD5EX_H 2 | #define _MD5EX_H 3 | 4 | class Stream; 5 | bool MD5Data(const void* pData,int size,unsigned char *pMD5 /* 16 Byte*/); 6 | bool MD5Stream(Stream* pStream,unsigned char *pMD5 /* 16 Byte*/); 7 | bool MD5File(const char* pszFile,unsigned char *pMD5 /* 16 Byte*/); 8 | bool MD5String(const char* string,unsigned char* pMD5 /* 16 Byte*/); 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /Engine/LEncode/mycast.h: -------------------------------------------------------------------------------- 1 | //void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) 2 | #ifndef _MY_CAST_H 3 | #define _MY_CAST_H 4 | 5 | #define CAST_ENCRYPT 1 6 | #define CAST_DECRYPT 0 7 | 8 | #define CAST_LONG unsigned long 9 | 10 | #define CAST_BLOCK 8 11 | #define CAST_KEY_LENGTH 16 12 | 13 | typedef struct cast_key_st 14 | { 15 | CAST_LONG data[32]; 16 | int short_key; /* Use reduced rounds for short key */ 17 | } CAST_KEY; 18 | 19 | #if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) 20 | #define ROTL(a,n) (_lrotl(a,n)) 21 | #else 22 | #define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) 23 | #endif 24 | 25 | extern const CAST_LONG MyCAST_S_table0[256]; 26 | extern const CAST_LONG MyCAST_S_table1[256]; 27 | extern const CAST_LONG MyCAST_S_table2[256]; 28 | extern const CAST_LONG MyCAST_S_table3[256]; 29 | extern const CAST_LONG MyCAST_S_table4[256]; 30 | extern const CAST_LONG MyCAST_S_table5[256]; 31 | extern const CAST_LONG MyCAST_S_table6[256]; 32 | extern const CAST_LONG MyCAST_S_table7[256]; 33 | 34 | #define E_CAST(n,key,L,R,OP1,OP2,OP3) \ 35 | { \ 36 | CAST_LONG a,b,c,d; \ 37 | t=(key[n*2] OP1 R)&0xffffffff; \ 38 | t=ROTL(t,(key[n*2+1])); \ 39 | a=MyCAST_S_table0[(t>> 8)&0xff]; \ 40 | b=MyCAST_S_table1[(t )&0xff]; \ 41 | c=MyCAST_S_table2[(t>>24)&0xff]; \ 42 | d=MyCAST_S_table3[(t>>16)&0xff]; \ 43 | L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \ 44 | } 45 | 46 | 47 | 48 | #define CAST_exp(l,A,a,n) \ 49 | A[n/4]=l; \ 50 | a[n+3]=(l )&0xff; \ 51 | a[n+2]=(l>> 8)&0xff; \ 52 | a[n+1]=(l>>16)&0xff; \ 53 | a[n+0]=(l>>24)&0xff; 54 | 55 | #define S4 MyCAST_S_table4 56 | #define S5 MyCAST_S_table5 57 | #define S6 MyCAST_S_table6 58 | #define S7 MyCAST_S_table7 59 | 60 | 61 | typedef void (* f_CAST_set_key)(CAST_KEY *key, int len, const unsigned char *data); 62 | typedef void (* f_CAST_encrypt)(CAST_LONG *data, CAST_KEY *key); 63 | typedef void (* f_CAST_decrypt)(CAST_LONG *data, CAST_KEY *key); 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /Engine/LEncode/myidea.h: -------------------------------------------------------------------------------- 1 | #ifndef _MY_IDEA_H 2 | #define _MY_IDEA_H 3 | 4 | #define IDEA_INT unsigned int 5 | 6 | typedef struct idea_key_st 7 | { 8 | IDEA_INT data[9][6]; 9 | } IDEA_KEY_SCHEDULE; 10 | 11 | #define idea_mul(r,a,b,ul) \ 12 | ul=(unsigned long)a*b; \ 13 | if (ul != 0) \ 14 | { \ 15 | r=(ul&0xffff)-(ul>>16); \ 16 | r-=((r)>>16); \ 17 | } \ 18 | else \ 19 | r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ 20 | 21 | #define E_IDEA(num) \ 22 | x1&=0xffff; \ 23 | idea_mul(x1,x1,*p,ul); p++; \ 24 | x2+= *(p++); \ 25 | x3+= *(p++); \ 26 | x4&=0xffff; \ 27 | idea_mul(x4,x4,*p,ul); p++; \ 28 | t0=(x1^x3)&0xffff; \ 29 | idea_mul(t0,t0,*p,ul); p++; \ 30 | t1=(t0+(x2^x4))&0xffff; \ 31 | idea_mul(t1,t1,*p,ul); p++; \ 32 | t0+=t1; \ 33 | x1^=t1; \ 34 | x4^=t0; \ 35 | ul=x2^t0; /* do the swap to x3 */ \ 36 | x2=x3^t1; \ 37 | x3=ul; 38 | #define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ 39 | l|=((IDEA_INT)(*((c)++))) ) 40 | 41 | /* taken directly from the 'paper' I'll have a look at it later */ 42 | inline IDEA_INT inverse(unsigned int xin) 43 | { 44 | long n1,n2,q,r,b1,b2,t; 45 | 46 | if (xin == 0) 47 | b2=0; 48 | else 49 | { 50 | n1=0x10001; 51 | n2=xin; 52 | b2=1; 53 | b1=0; 54 | 55 | do { 56 | r=(n1%n2); 57 | q=(n1-r)/n2; 58 | if (r == 0) 59 | { if (b2 < 0) b2=0x10001+b2; } 60 | else 61 | { 62 | n1=n2; 63 | n2=r; 64 | t=b2; 65 | b2=b1-q*b2; 66 | b1=t; 67 | } 68 | } while (r != 0); 69 | } 70 | return((IDEA_INT)b2); 71 | } 72 | 73 | typedef void (* f_idea_set_encrypt_key)(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); 74 | typedef void (* f_idea_set_decrypt_key)(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); 75 | typedef void (* f_idea_encrypt)(unsigned long *d, IDEA_KEY_SCHEDULE *key); 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /Engine/LMysql/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(UNIX) 2 | include_directories( 3 | ${PROJECT_SOURCE_DIR}/MysqlOO 4 | /usr/include/mysql 5 | ) 6 | ENDIF(UNIX) 7 | IF(WIN32) 8 | include_directories( 9 | ${PROJECT_SOURCE_DIR}/MysqlOO 10 | ${PROJECT_SOURCE_DIR}/MysqlOO/include 11 | ) 12 | ENDIF(WIN32) 13 | 14 | set(LIB_HEADERS 15 | mysqlDB.h 16 | ) 17 | set(LIB_SRCS 18 | mysqlDB.cpp 19 | ) 20 | IF(WIN32) 21 | LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib 22 | ${PROJECT_SOURCE_DIR}/MysqlOO/lib/debug) 23 | ENDIF(WIN32) 24 | 25 | add_library(mysqloo ${LIB_SRCS} ${LIB_HEADERS}) 26 | 27 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 28 | target_link_libraries(mysqloo mysqlclient) 29 | set_target_properties(mysqloo PROPERTIES OUTPUT_NAME "mysqloo") 30 | 31 | -------------------------------------------------------------------------------- /Engine/LNetbase/Des.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Des 5 | { 6 | uint32_t m_encKey[32]; 7 | uint32_t m_decKey[32]; 8 | 9 | public: 10 | Des(){} 11 | 12 | void setDes(uint8_t* pkey); 13 | 14 | void decrypt(uint8_t* pblock,int index=0); 15 | 16 | void encrypt(uint8_t* pblock,int index=0); 17 | 18 | void generateWorkingKey(bool encrypting,uint8_t* key,int off, uint32_t* newKey); 19 | 20 | void desFunc(uint32_t* wKey, uint8_t* inp, int inOff,uint8_t* out, int outOff); 21 | }; 22 | -------------------------------------------------------------------------------- /Engine/LNetbase/LCantCopy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LCantCopy.h -------------------------------------------------------------------------------- /Engine/LNetbase/LCond.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LCond.h -------------------------------------------------------------------------------- /Engine/LNetbase/LMutex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LMutex.h -------------------------------------------------------------------------------- /Engine/LNetbase/LNetService.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LNetService.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LNetService.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LNetService.h -------------------------------------------------------------------------------- /Engine/LNetbase/LRWLock.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LRWLock.h -------------------------------------------------------------------------------- /Engine/LNetbase/LService.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LService.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LService.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LService.h -------------------------------------------------------------------------------- /Engine/LNetbase/LSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LSocket.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LSocket.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPClientTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPClientTask.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPClientTask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPClientTask.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPClientTaskPool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPClientTaskPool.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPClientTaskPool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPClientTaskPool.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPServer.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPServer.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPTask.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPTask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPTask.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPTaskPool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPTaskPool.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTCPTaskPool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTCPTaskPool.h -------------------------------------------------------------------------------- /Engine/LNetbase/LThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LThread.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LThread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LThread.h -------------------------------------------------------------------------------- /Engine/LNetbase/LTime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTime.cpp -------------------------------------------------------------------------------- /Engine/LNetbase/LTime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LTime.h -------------------------------------------------------------------------------- /Engine/LNetbase/LType.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Engine/LNetbase/LType.h -------------------------------------------------------------------------------- /Engine/README.md: -------------------------------------------------------------------------------- 1 | 引擎部分 2 | ====== 3 | 4 | 各个目录 5 | ------ 6 | 7 | ### LEncode
8 | 各类编码 9 | 加密 解密算法 10 | ### LLang
11 | 轻量的脚本 12 | ### LMysql
13 | Mysql 封装机制 14 | ### LNetbase
15 | 征途的Socket TCPTask TCPClientTask 机制 16 | ### LPack
17 | 打包机制 包含 ZIP Archive.h 18 | ### LRemote
19 | 消息机制封装 20 | ### LNetwork
21 | 底层使用的网络接口 22 | ### LThread
23 | 征途的线程库 24 | ### LXml
25 | tinyxml2 封装机制 26 | 27 | ### 各个模块可独立编译 使用cmake 组织工程 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 重构征途服务器 2 | ====== 3 | 4 | 编码规范 试行: 5 | ------ 6 | 7 | ### 命名
8 | 类名 全大写 可以看出意义 class LSocket(){}; 9 | 10 | 变量名 首个字母小写 public: int mFeild; private int _mField; 11 | 12 | 函数名字 首个字母小写其他词连接时首个字母大写 sayHello() 13 | 14 | 结构体 前面加st struct stData(){}; 15 | 16 | 命名空间 首字母大写 17 | 18 | 其他见如下 19 | ### 注释 + 实例
20 | #define MAX_NUM //字母全都大写 以_分割 21 | namespace net { // 命名空间名字 全小写 22 | 类注释 23 | /** 24 | * 说明 25 | * 对Socket 的封装 26 | * 提供基本的接法 27 | **/ 28 | class LScoket { // 凡是类型相关的 括号紧跟其后 (class struct enum union) 且名字大写 29 | public: 30 | int mFeild; // 变量注释 31 | 32 | /** 33 | *\berif 构造函数说明 34 | */ 35 | LScoket() 36 | { // 函数的括号放下 37 | 38 | } 39 | 40 | 函数注释 41 | /** 42 | * \brief 说明 43 | * \param in 参数 输入参数 44 | * \parma out 参数 输出参数 45 | * \return int 返回说明 46 | */ 47 | int sayHello(int a,int &b) 48 | { 49 | return 1; 50 | } 51 | 52 | enum Count{ //和类一致的命名方式 53 | MAX_NUM = 1, // 枚举全都大写 和宏一致的命名方式 54 | }; 55 | private: 56 | int _mField; // 变量注释 57 | }; // class LScoket 58 | }; // namespace net 59 | ### 以上试行 -------------------------------------------------------------------------------- /Server1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(Server) 2 | SET(CMAKE_BUILD_TYPE "Debug") 3 | add_subdirectory(Engine) 4 | add_subdirectory(Servers) 5 | -------------------------------------------------------------------------------- /Server1/Engine/BlockMap/Block.cpp: -------------------------------------------------------------------------------- 1 | #include "Entry.h" 2 | #include "Block.h" 3 | 4 | namespace mymap{ 5 | 6 | void Block::addEntry(Entry * entry) 7 | { 8 | _entries.insert(entry); 9 | } 10 | void Block::removeEntry(Entry *entry) 11 | { 12 | ENTRIES_ITER iter = _entries.find(entry); 13 | if (iter != _entries.end()) 14 | { 15 | _entries.erase(iter); 16 | } 17 | } 18 | void Block::execAll(stExecEntry *exec) 19 | { 20 | for (ENTRIES_ITER iter = _entries.begin();iter != _entries.end();++iter) 21 | { 22 | if (*iter) 23 | exec->exec(*iter); 24 | } 25 | } 26 | bool Block::hadEntry(Entry *entry) 27 | { 28 | ENTRIES_ITER iter = _entries.find(entry); 29 | if (iter != _entries.end()) 30 | { 31 | return true; 32 | } 33 | return false; 34 | } 35 | }; -------------------------------------------------------------------------------- /Server1/Engine/BlockMap/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Entry.h" 3 | #include 4 | namespace mymap{ 5 | class Block{ 6 | public: 7 | void addEntry(Entry * entry); 8 | void removeEntry(Entry *entry); 9 | void execAll(stExecEntry *exec); 10 | bool hadEntry(Entry *entry); 11 | unsigned short getPositionX(); 12 | unsigned short getPositionY(); 13 | private: 14 | std::set _entries; 15 | typedef std::set::iterator ENTRIES_ITER; 16 | }; 17 | class stExecBlock{ 18 | public: 19 | virtual void exec(Block *block) = 0; 20 | }; 21 | }; -------------------------------------------------------------------------------- /Server1/Engine/BlockMap/Entry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace mymap{ 3 | class Block; 4 | class Entry{ 5 | public: 6 | virtual void otherEnter(Entry*other) = 0; 7 | virtual void otherLeave(Entry *other) = 0; 8 | virtual void setPosition(unsigned short x,unsigned short y) = 0; 9 | Block *block; 10 | }; 11 | class Position{ 12 | public: 13 | unsigned short x; 14 | unsigned short y; 15 | Position() 16 | { 17 | x = y = 0; 18 | } 19 | }; 20 | class stExecEntry{ 21 | public: 22 | virtual void exec(Entry *entry) = 0; 23 | }; 24 | 25 | }; -------------------------------------------------------------------------------- /Server1/Engine/BlockMap/MyMap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/BlockMap/MyMap.cpp -------------------------------------------------------------------------------- /Server1/Engine/BlockMap/MyMap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/BlockMap/MyMap.h -------------------------------------------------------------------------------- /Server1/Engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(DRAGONNET) 2 | SET(CMAKE_BUILD_TYPE "Debug") 3 | add_subdirectory(Lang) 4 | add_subdirectory(Ext) 5 | add_subdirectory(Pack) 6 | add_subdirectory(Remote) 7 | add_subdirectory(MysqlOO) 8 | 9 | add_subdirectory(Samples) 10 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(zlib) 2 | add_subdirectory(netbase) 3 | add_subdirectory(LServer) 4 | add_subdirectory(xml) 5 | add_subdirectory(cjson) 6 | add_subdirectory(lua) 7 | add_subdirectory(tolua) 8 | add_subdirectory(zthread) 9 | add_subdirectory(g3dlite) 10 | 11 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/cjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | cJSON.h 3 | ) 4 | set(LIB_SRCS 5 | cJSON.c 6 | ) 7 | 8 | add_library(cjson ${LIB_SRCS} ${LIB_HEADERS}) 9 | 10 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 11 | 12 | set_target_properties(cjson PROPERTIES OUTPUT_NAME "cjson") 13 | 14 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/cjson/jsonObject.h: -------------------------------------------------------------------------------- 1 | #include "cJSON.h" 2 | #include "stdio.h" 3 | #include "stdlib.h" 4 | #include 5 | class JSONObject{ 6 | public: 7 | JSONObject(const char *text) 8 | { 9 | root =cJSON_Parse(text); 10 | clearTag = true; 11 | } 12 | JSONObject() 13 | { 14 | clearTag = true; 15 | root=cJSON_CreateObject(); 16 | } 17 | JSONObject(cJSON *temp):root(temp) 18 | { 19 | clearTag = false; 20 | } 21 | void add(const char *name,JSONObject *object) 22 | { 23 | object->clearTag = false; 24 | cJSON_AddItemToObject(root, name,object->root); 25 | } 26 | void add(const char *name,const char *value) 27 | { 28 | cJSON_AddStringToObject(root,name,value); 29 | } 30 | void add(const char *name,int value) 31 | { 32 | cJSON_AddNumberToObject(root,name,value); 33 | } 34 | ~JSONObject() 35 | { 36 | if (clearTag) 37 | cJSON_Delete(root); 38 | } 39 | std::string get() 40 | { 41 | char *out=cJSON_Print(root); 42 | std::string tempstr = out; 43 | free(out); 44 | return tempstr; 45 | } 46 | std::string get(const char *name) 47 | { 48 | cJSON * temp = cJSON_GetObjectItem(root,name); 49 | if (temp) 50 | { 51 | char *out=cJSON_Print(temp); 52 | std::string tempstr = out; 53 | free(out); 54 | return tempstr; 55 | } 56 | return ""; 57 | } 58 | JSONObject getChild(const char *name) 59 | { 60 | JSONObject object(cJSON_GetObjectItem(root,name)); 61 | return object; 62 | } 63 | bool isValid(){return root;} 64 | bool clearTag; 65 | cJSON *root; 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/cjson/testJson.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/cjson/testJson.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | inc/AABox.h 3 | inc/Array.h 4 | inc/Box.h 5 | inc/CollisionDetection.h 6 | inc/CoordinateFrame.h 7 | inc/Crypto.h 8 | inc/debug.h 9 | inc/format.h 10 | inc/g3dmath.h 11 | inc/g3dmath.inl 12 | inc/GCamera.h 13 | inc/Line.h 14 | inc/Matrix3.h 15 | inc/Plane.h 16 | inc/platform.h 17 | inc/Quat.h 18 | inc/Quat.inl 19 | inc/Ray.h 20 | inc/RegistryUtil.h 21 | inc/Sphere.h 22 | inc/stringutils.h 23 | inc/System.h 24 | inc/Table.h 25 | inc/Triangle.h 26 | inc/Vector2.h 27 | inc/Vector2.inl 28 | inc/Vector2int16.h 29 | inc/Vector3.h 30 | inc/Vector3.inl 31 | inc/Vector3int16.h 32 | inc/Vector4.h 33 | inc/Vector4.inl 34 | ) 35 | set(LIB_SRCS 36 | src/AABox.cpp 37 | src/Box.cpp 38 | src/Crypto.cpp 39 | src/format.cpp 40 | src/license.html 41 | src/Matrix3.cpp 42 | src/Plane.cpp 43 | src/System.cpp 44 | src/Triangle.cpp 45 | src/Vector3.cpp 46 | src/Vector4.cpp 47 | ) 48 | include_directories( 49 | inc 50 | ) 51 | add_library(g3dlite ${LIB_SRCS} ${LIB_HEADERS}) 52 | 53 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 54 | 55 | set_target_properties(g3dlite PROPERTIES OUTPUT_NAME "g3dlite") 56 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/Crypto.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file Crypto.h 3 | 4 | @maintainer Morgan McGuire, matrix@graphics3d.com 5 | 6 | 7 | @created 2006-03-29 8 | @edited 2006-04-06 9 | */ 10 | 11 | #ifndef G3D_CRYPTO_H 12 | #define G3D_CRYPTO_H 13 | 14 | #include "platform.h" 15 | #include "g3dmath.h" 16 | #include 17 | 18 | namespace G3D { 19 | 20 | /** Cryptography and hashing helper functions */ 21 | class Crypto { 22 | public: 23 | 24 | /** 25 | Computes the CRC32 value of a byte array. CRC32 is designed to be a hash 26 | function that produces different values for similar strings. 27 | 28 | This implementation is compatible with PKZIP and GZIP. 29 | 30 | Based on http://www.gamedev.net/reference/programming/features/crc32/ 31 | */ 32 | static uint32 crc32(const void* bytes, size_t numBytes); 33 | 34 | /** 35 | Returns the nth prime less than 2000 in constant time. The first prime has index 36 | 0 and is the number 2. 37 | */ 38 | static int smallPrime(int n); 39 | 40 | /** Returns 1 + the largest value that can be passed to smallPrime. */ 41 | static int numSmallPrimes(); 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/Quat.inl: -------------------------------------------------------------------------------- 1 | /** 2 | Quat.inl 3 | 4 | @cite Quaternion implementation based on Watt & Watt page 363. 5 | Thanks to Max McGuire for slerp optimizations. 6 | 7 | @maintainer Morgan McGuire, matrix@graphics3d.com 8 | 9 | @created 2002-01-23 10 | @edited 2004-03-04 11 | */ 12 | 13 | namespace G3D { 14 | 15 | inline float& Quat::operator[] (int i) { 16 | debugAssert(i >= 0); 17 | debugAssert(i < 4); 18 | return ((float*)this)[i]; 19 | } 20 | 21 | inline const float& Quat::operator[] (int i) const { 22 | debugAssert(i >= 0); 23 | debugAssert(i < 4); 24 | return ((float*)this)[i]; 25 | } 26 | 27 | 28 | 29 | inline Quat Quat::operator-(const Quat& other) const { 30 | return Quat(x - other.x, y - other.y, z - other.z, w - other.w); 31 | } 32 | 33 | inline Quat Quat::operator+(const Quat& other) const { 34 | return Quat(x + other.x, y + other.y, z + other.z, w + other.w); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/Vector2.inl: -------------------------------------------------------------------------------- 1 | /** 2 | @file Vector2.inl 3 | 4 | @maintainer Morgan McGuire, matrix@graphics3d.com 5 | @cite Portions by Laura Wollstadt, graphics3d.com 6 | 7 | @cite Portions based on Dave Eberly'x Magic Software Library 8 | at http://www.magic-software.com 9 | 10 | 11 | @created 2001-06-02 12 | @edited 2006-01-14 13 | 14 | Copyright 2000-2006, Morgan McGuire. 15 | All rights reserved. 16 | */ 17 | 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/Vector2int16.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file Vector2int16.h 3 | 4 | @maintainer Morgan McGuire, matrix@brown.edu 5 | 6 | @created 2003-08-09 7 | @edited 2004-01-03 8 | 9 | Copyright 2000-2006, Morgan McGuire. 10 | All rights reserved. 11 | */ 12 | 13 | #ifndef VECTOR2INT16_H 14 | #define VECTOR2INT16_H 15 | 16 | #include "platform.h" 17 | #include "g3dmath.h" 18 | 19 | namespace G3D { 20 | 21 | /** 22 | A Vector2 that packs its fields into uint16s. 23 | */ 24 | #ifdef G3D_WIN32 25 | // Switch to tight alignment 26 | #pragma pack(push, 2) 27 | #endif 28 | 29 | class Vector2int16 { 30 | private: 31 | // Hidden operators 32 | bool operator<(const Vector2int16&) const; 33 | bool operator>(const Vector2int16&) const; 34 | bool operator<=(const Vector2int16&) const; 35 | bool operator>=(const Vector2int16&) const; 36 | 37 | public: 38 | G3D::int16 x; 39 | G3D::int16 y; 40 | 41 | Vector2int16() : x(0), y(0) {} 42 | Vector2int16(G3D::int16 _x, G3D::int16 _y) : x(_x), y(_y){} 43 | Vector2int16(const class Vector2& v); 44 | 45 | inline G3D::int16& operator[] (int i) { 46 | debugAssert(((unsigned int)i) <= 1); 47 | return ((G3D::int16*)this)[i]; 48 | } 49 | 50 | inline const G3D::int16& operator[] (int i) const { 51 | debugAssert(((unsigned int)i) <= 1); 52 | return ((G3D::int16*)this)[i]; 53 | } 54 | 55 | 56 | inline bool operator== (const Vector2int16& rkVector) const { 57 | return ((int32*)this)[0] == ((int32*)&rkVector)[0]; 58 | } 59 | 60 | inline bool operator!= (const Vector2int16& rkVector) const { 61 | return ((int32*)this)[0] != ((int32*)&rkVector)[0]; 62 | } 63 | 64 | } 65 | #if defined(G3D_LINUX) || defined(G3D_OSX) 66 | __attribute((aligned(1))) 67 | #endif 68 | ; 69 | 70 | #ifdef G3D_WIN32 71 | #pragma pack(pop) 72 | #endif 73 | 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/Vector3int16.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file Vector3int16.h 3 | 4 | @maintainer Morgan McGuire, matrix@brown.edu 5 | 6 | @created 2003-04-07 7 | @edited 2003-06-24 8 | Copyright 2000-2004, Morgan McGuire. 9 | All rights reserved. 10 | */ 11 | 12 | #ifndef VECTOR3INT16_H 13 | #define VECTOR3INT16_H 14 | 15 | #include "platform.h" 16 | #include "g3dmath.h" 17 | 18 | namespace G3D { 19 | 20 | /** 21 | A Vector3 that packs its fields into uint16s. 22 | */ 23 | #ifdef G3D_WIN32 24 | // Switch to tight alignment 25 | #pragma pack(push, 2) 26 | #endif 27 | 28 | class Vector3int16 { 29 | private: 30 | // Hidden operators 31 | bool operator<(const Vector3int16&) const; 32 | bool operator>(const Vector3int16&) const; 33 | bool operator<=(const Vector3int16&) const; 34 | bool operator>=(const Vector3int16&) const; 35 | 36 | public: 37 | G3D::int16 x; 38 | G3D::int16 y; 39 | G3D::int16 z; 40 | 41 | Vector3int16() : x(0), y(0), z(0) {} 42 | Vector3int16(G3D::int16 _x, G3D::int16 _y, G3D::int16 _z) : x(_x), y(_y), z(_z) {} 43 | Vector3int16(const class Vector3& v); 44 | } 45 | #if defined(G3D_LINUX) || defined(G3D_OSX) 46 | __attribute((aligned(1))) 47 | #endif 48 | ; 49 | 50 | #ifdef G3D_WIN32 51 | #pragma pack(pop) 52 | #endif 53 | 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/debug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef G3D_LITE_DEBUG_H 3 | #define G3D_LITE_DEBUG_H 4 | 5 | #define debugStatement(x) 6 | #define debugAssert(x) 7 | #define debugAssertM(x, y) 8 | #define alwaysAssertM(x, y) 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/g3dlite/inc/format.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file format.h 3 | 4 | @maintainer Morgan McGuire, matrix@graphics3d.com 5 | 6 | @author 2000-09-09 7 | @edited 2005-11-03 8 | 9 | Copyright 2000-2005, Morgan McGuire. 10 | All rights reserved. 11 | */ 12 | 13 | #ifndef G3D_FORMAT_H 14 | #define G3D_FORMAT_H 15 | 16 | #include "platform.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | #ifndef G3D_WIN32 22 | // Don't include varargs.h for some random 23 | // gcc reason 24 | //#include 25 | #include 26 | #endif 27 | 28 | #ifndef _MSC_VER 29 | #ifndef __cdecl 30 | #define __cdecl __attribute__((cdecl)) 31 | #endif 32 | #endif 33 | 34 | namespace G3D { 35 | 36 | /** 37 | Produces a string from arguments of the style of printf. This avoids 38 | problems with buffer overflows when using sprintf and makes it easy 39 | to use the result functionally. This function is fast when the resulting 40 | string is under 160 characters (not including terminator) and slower 41 | when the string is longer. 42 | */ 43 | std::string format( 44 | const char* fmt 45 | ...) G3D_CHECK_PRINTF_ARGS; 46 | 47 | /** 48 | Like format, but can be called with the argument list from a ... function. 49 | */ 50 | std::string vformat( 51 | const char* fmt, 52 | va_list argPtr) G3D_CHECK_VPRINTF_ARGS; 53 | 54 | 55 | }; // namespace 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/include/uv-bsd.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_BSD_H 23 | #define UV_BSD_H 24 | 25 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 26 | uv__io_t event_watcher; \ 27 | 28 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 29 | int rcount; \ 30 | int wcount; \ 31 | 32 | #define UV_HAVE_KQUEUE 1 33 | 34 | #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS 35 | 36 | #endif /* UV_BSD_H */ 37 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/include/uv-linux.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_H 23 | #define UV_LINUX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | uv__io_t inotify_read_watcher; \ 27 | void* inotify_watchers; \ 28 | int inotify_fd; \ 29 | 30 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 31 | void* watchers[2]; \ 32 | int wd; \ 33 | 34 | #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS 35 | 36 | #endif /* UV_LINUX_H */ 37 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/include/uv-version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_VERSION_H 23 | #define UV_VERSION_H 24 | 25 | /* 26 | * Versions with an even minor version (e.g. 0.6.1 or 1.0.4) are API and ABI 27 | * stable. When the minor version is odd, the API can change between patch 28 | * releases. Make sure you update the -soname directives in configure.ac 29 | * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but 30 | * not UV_VERSION_PATCH.) 31 | */ 32 | 33 | #define UV_VERSION_MAJOR 0 34 | #define UV_VERSION_MINOR 11 35 | #define UV_VERSION_PATCH 25 36 | #define UV_VERSION_IS_RELEASE 0 37 | 38 | #endif /* UV_VERSION_H */ 39 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/socks5-proxy/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright StrongLoop, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to 5 | # deal in the Software without restriction, including without limitation the 6 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | # sell copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | # IN THE SOFTWARE. 20 | 21 | /build/ 22 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/socks5-proxy/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright StrongLoop, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to 5 | # deal in the Software without restriction, including without limitation the 6 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | # sell copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | # IN THE SOFTWARE. 20 | 21 | BUILDTYPE ?= Debug 22 | BUILDDIR ?= build 23 | GYP ?= gyp 24 | V ?= 25 | 26 | SOURCES := client.c defs.h getopt.c main.c s5.c s5.h server.c util.c 27 | 28 | .PHONY: all clean 29 | 30 | all: $(BUILDDIR)/$(BUILDTYPE)/s5-proxy 31 | 32 | clean: 33 | $(RM) $(BUILDDIR) 34 | 35 | $(BUILDDIR)/$(BUILDTYPE)/s5-proxy: $(BUILDDIR)/Makefile $(SOURCES) 36 | $(MAKE) -C $(BUILDDIR) V=$(V) 37 | 38 | $(BUILDDIR)/Makefile: ../../common.gypi build.gyp 39 | $(GYP) \ 40 | -Duv_library=static_library \ 41 | -Goutput_dir=. \ 42 | -I../../common.gypi \ 43 | -f make \ 44 | --depth=. \ 45 | --generator-output=$(BUILDDIR) \ 46 | build.gyp 47 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/socks5-proxy/build.gyp: -------------------------------------------------------------------------------- 1 | # Copyright StrongLoop, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to 5 | # deal in the Software without restriction, including without limitation the 6 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | # sell copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | # IN THE SOFTWARE. 20 | 21 | { 22 | 'targets': [ 23 | { 24 | 'dependencies': ['../../uv.gyp:libuv'], 25 | 'target_name': 's5-proxy', 26 | 'type': 'executable', 27 | 'sources': [ 28 | 'client.c', 29 | 'defs.h', 30 | 'main.c', 31 | 's5.c', 32 | 's5.h', 33 | 'server.c', 34 | 'util.c', 35 | ], 36 | 'conditions': [ 37 | ['OS=="win"', { 38 | 'defines': ['HAVE_UNISTD_H=0'], 39 | 'sources': ['getopt.c'] 40 | }, { 41 | 'defines': ['HAVE_UNISTD_H=1'] 42 | }] 43 | ] 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/src/unix/uv-dtrace.d: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | provider uv { 23 | probe tick__start(void* loop, int mode); 24 | probe tick__stop(void* loop, int mode); 25 | }; 26 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/src/version.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | 24 | #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ 25 | (UV_VERSION_MINOR << 8) | \ 26 | (UV_VERSION_PATCH)) 27 | 28 | #define UV_STRINGIFY(v) UV_STRINGIFY_HELPER(v) 29 | #define UV_STRINGIFY_HELPER(v) #v 30 | 31 | #define UV_VERSION_STRING_BASE UV_STRINGIFY(UV_VERSION_MAJOR) "." \ 32 | UV_STRINGIFY(UV_VERSION_MINOR) "." \ 33 | UV_STRINGIFY(UV_VERSION_PATCH) 34 | 35 | #if UV_VERSION_IS_RELEASE 36 | # define UV_VERSION_STRING UV_VERSION_STRING_BASE 37 | #else 38 | # define UV_VERSION_STRING UV_VERSION_STRING_BASE "-pre" 39 | #endif 40 | 41 | 42 | unsigned int uv_version(void) { 43 | return UV_VERSION; 44 | } 45 | 46 | 47 | const char* uv_version_string(void) { 48 | return UV_VERSION_STRING; 49 | } 50 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/src/win/fs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/libuv/src/win/fs.c -------------------------------------------------------------------------------- /Server1/Engine/Ext/libuv/src/win/req.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "uv.h" 25 | #include "internal.h" 26 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | lapi.h 3 | lauxlib.h 4 | lcode.h 5 | ldebug.h 6 | ldo.h 7 | lfunc.h 8 | lgc.h 9 | llex.h 10 | llimits.h 11 | lmem.h 12 | lobject.h 13 | lopcodes.h 14 | lparser.h 15 | lstate.h 16 | lstring.h 17 | ltable.h 18 | ltm.h 19 | luaconf.h 20 | lua.h 21 | lualib.h 22 | lua_tinker.h 23 | lundump.h 24 | lvm.h 25 | lzio.h 26 | ) 27 | set(LIB_SRCS 28 | lapi.c 29 | lauxlib.c 30 | lbaselib.c 31 | lcode.c 32 | ldblib.c 33 | ldebug.c 34 | ldo.c 35 | ldump.c 36 | lfunc.c 37 | lgc.c 38 | linit.c 39 | liolib.c 40 | llex.c 41 | lmathlib.c 42 | lmem.c 43 | loadlib.c 44 | lobject.c 45 | lopcodes.c 46 | loslib.c 47 | lparser.c 48 | lstate.c 49 | lstring.c 50 | lstrlib.c 51 | ltable.c 52 | ltablib.c 53 | ltm.c 54 | lua.c 55 | luac.c 56 | lundump.c 57 | lvm.c 58 | lzio.c 59 | print.c 60 | lua_tinker.cpp 61 | ) 62 | 63 | add_library(lua ${LIB_SRCS} ${LIB_HEADERS}) 64 | 65 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 66 | 67 | set_target_properties(lua PROPERTIES OUTPUT_NAME "lua") -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:lua 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 lua 库项目。 6 | 7 | 没有为此项目创建源文件。 8 | 9 | 10 | lua.vcproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件, 12 | 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | 其他注释: 16 | 17 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | 23 | const char *const luaT_typenames[] = { 24 | "nil", "boolean", "userdata", "number", 25 | "string", "table", "function", "userdata", "thread", 26 | "proto", "upval" 27 | }; 28 | 29 | 30 | void luaT_init (lua_State *L) { 31 | static const char *const luaT_eventname[] = { /* ORDER TM */ 32 | "__index", "__newindex", 33 | "__gc", "__mode", "__eq", 34 | "__add", "__sub", "__mul", "__div", "__mod", 35 | "__pow", "__unm", "__len", "__lt", "__le", 36 | "__concat", "__call" 37 | }; 38 | int i; 39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 42 | } 43 | } 44 | 45 | 46 | /* 47 | ** function to be used with macro "fasttm": optimized for absence of 48 | ** tag methods 49 | */ 50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 51 | const TValue *tm = luaH_getstr(events, ename); 52 | lua_assert(event <= TM_EQ); 53 | if (ttisnil(tm)) { /* no tag method? */ 54 | events->flags |= cast_byte(1u<metatable; 66 | break; 67 | case LUA_TUSERDATA: 68 | mt = uvalue(o)->metatable; 69 | break; 70 | default: 71 | mt = G(L)->mt[ttype(o)]; 72 | } 73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lua.txt: -------------------------------------------------------------------------------- 1 | 服务器使用lua 脚本编写 从lua启动 2 | 3 | function Service(resquest [json],response[json]) 4 | { 5 | //构建json 返回 字符串 6 | response.write(str); 7 | } 8 | 9 | // req(path,args); // 10 | 11 | CmdObject(2) 为Lua脚本调用系列 12 | 13 | cplusnet:req("path",json); // 传入字符串 14 | 15 | LuaCmdObject(2) 16 | { 17 | std::sting path; // 路径 18 | std::sting jsonStr; // json脚本 发送的客户端 19 | } -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lua.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/lua/lua.vcproj -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) return EOZ; 29 | z->n = size - 1; 30 | z->p = buff; 31 | return char2int(*(z->p++)); 32 | } 33 | 34 | 35 | int luaZ_lookahead (ZIO *z) { 36 | if (z->n == 0) { 37 | if (luaZ_fill(z) == EOZ) 38 | return EOZ; 39 | else { 40 | z->n++; /* luaZ_fill removed first byte; put back it */ 41 | z->p--; 42 | } 43 | } 44 | return char2int(*z->p); 45 | } 46 | 47 | 48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 49 | z->L = L; 50 | z->reader = reader; 51 | z->data = data; 52 | z->n = 0; 53 | z->p = NULL; 54 | } 55 | 56 | 57 | /* --------------------------------------------------------------- read --- */ 58 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 59 | while (n) { 60 | size_t m; 61 | if (luaZ_lookahead(z) == EOZ) 62 | return n; /* return number of missing bytes */ 63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 64 | memcpy(b, z->p, m); 65 | z->n -= m; 66 | z->p += m; 67 | b = (char *)b + m; 68 | n -= m; 69 | } 70 | return 0; 71 | } 72 | 73 | /* ------------------------------------------------------------------------ */ 74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 75 | if (n > buff->buffsize) { 76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 77 | luaZ_resizebuffer(L, buff, n); 78 | } 79 | return buff->buffer; 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | 46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 50 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; 60 | void* data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/sample3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/lua/sample3.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/lua/sample3.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/lua/sample3.lua -------------------------------------------------------------------------------- /Server1/Engine/Ext/md5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | md5.h 3 | ) 4 | set(LIB_SRCS 5 | md5.cpp 6 | ) 7 | 8 | add_library(md5 ${LIB_SRCS} ${LIB_HEADERS}) 9 | 10 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 11 | 12 | set_target_properties(md5 PROPERTIES OUTPUT_NAME "md5") 13 | 14 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/md5/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef MD5_H 2 | #define MD5_H 3 | 4 | #include 5 | #include 6 | 7 | /* Type define */ 8 | typedef unsigned char byte; 9 | typedef unsigned long ulong; 10 | 11 | using std::string; 12 | using std::ifstream; 13 | 14 | /* MD5 declaration. */ 15 | class MD5 { 16 | public: 17 | MD5(); 18 | MD5(const void *input, size_t length); 19 | MD5(const string &str); 20 | MD5(ifstream &in); 21 | void update(const void *input, size_t length); 22 | void update(const string &str); 23 | void update(ifstream &in); 24 | const byte* digest(); 25 | string toString(); 26 | void reset(); 27 | private: 28 | void update(const byte *input, size_t length); 29 | void final(); 30 | void transform(const byte block[64]); 31 | void encode(const ulong *input, byte *output, size_t length); 32 | void decode(const byte *input, ulong *output, size_t length); 33 | string bytesToHexString(const byte *input, size_t length); 34 | 35 | /* class uncopyable */ 36 | MD5(const MD5&); 37 | MD5& operator=(const MD5&); 38 | private: 39 | ulong _state[4]; /* state (ABCD) */ 40 | ulong _count[2]; /* number of bits, modulo 2^64 (low-order word first) */ 41 | byte _buffer[64]; /* input buffer */ 42 | byte _digest[16]; /* message digest */ 43 | bool _finished; /* calculate finished ? */ 44 | 45 | static const byte PADDING[64]; /* padding for calculate */ 46 | static const char HEX[16]; 47 | static const size_t BUFFER_SIZE = 1024; 48 | }; 49 | 50 | #endif/*MD5_H*/ 51 | 52 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/md5/test.cpp: -------------------------------------------------------------------------------- 1 | #include "md5.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | void PrintMD5(const string &str, MD5 &md5) { 7 | cout << "MD5(\"" << str << "\") = " << md5.toString() << endl; 8 | } 9 | 10 | string FileDigest(const string &file) { 11 | 12 | ifstream in(file.c_str(), ios::binary); 13 | if (!in) 14 | return ""; 15 | 16 | MD5 md5; 17 | std::streamsize length; 18 | char buffer[1024]; 19 | while (!in.eof()) { 20 | in.read(buffer, 1024); 21 | length = in.gcount(); 22 | if (length > 0) 23 | md5.update(buffer, length); 24 | } 25 | in.close(); 26 | return md5.toString(); 27 | } 28 | 29 | int main() { 30 | 31 | cout << MD5("abc").toString() << endl; 32 | cout << MD5(ifstream("D:\\test.txt")).toString() << endl; 33 | cout << MD5(ifstream("D:\\test.exe", ios::binary)).toString() << endl; 34 | cout << FileDigest("D:\\test.exe") << endl; 35 | 36 | MD5 md5; 37 | md5.update(""); 38 | PrintMD5("", md5); 39 | 40 | md5.update("a"); 41 | PrintMD5("a", md5); 42 | 43 | md5.update("bc"); 44 | PrintMD5("abc", md5); 45 | 46 | md5.update("defghijklmnopqrstuvwxyz"); 47 | PrintMD5("abcdefghijklmnopqrstuvwxyz", md5); 48 | 49 | md5.reset(); 50 | md5.update("message digest"); 51 | PrintMD5("message digest", md5); 52 | 53 | md5.reset(); 54 | md5.update(ifstream("D:\\test.txt")); 55 | PrintMD5("D:\\test.txt", md5); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(UNIX) 2 | include_directories( 3 | ${PROJECT_SOURCE_DIR}/Engine/Ext/zlib 4 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/inc 5 | ) 6 | ENDIF(UNIX) 7 | IF(WIN32) 8 | include_directories( 9 | ${PROJECT_SOURCE_DIR}/Engine/Ext/zlib 10 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/win 11 | ) 12 | ENDIF(WIN32) 13 | IF(WIN32) 14 | set(LIB_HEADERS 15 | win/EncDec.h 16 | win/LNetService.h 17 | win/LService.h 18 | win/LSocket.h 19 | win/LTCPClientTask.h 20 | win/LTCPClientTaskPool.h 21 | win/LTCPServer.h 22 | win/LTCPTask.h 23 | win/LTCPTaskPool.h 24 | win/LThread.h 25 | win/LTime.h 26 | win/miniCrypt.h 27 | win/LIocp.h 28 | win/LType.h 29 | ) 30 | ENDIF(WIN32) 31 | IF(UNIX) 32 | set(LIB_SRCS 33 | src/LDesEnc.cpp 34 | src/LNetService.cpp 35 | src/LService.cpp 36 | src/LSocket.cpp 37 | src/LTCPClientTask.cpp 38 | src/LTCPClientTaskPool.cpp 39 | src/LTCPServer.cpp 40 | src/LTCPTask.cpp 41 | src/LTCPTaskPool.cpp 42 | src/LThread.cpp 43 | src/LTime.cpp 44 | ) 45 | ENDIF(UNIX) 46 | IF(WIN32) 47 | set(LIB_SRCS 48 | win/EncDec.cpp 49 | win/LNetService.cpp 50 | win/LService.cpp 51 | win/LSocket.cpp 52 | win/LTCPClientTask.cpp 53 | win/LTCPClientTaskPool.cpp 54 | win/LTCPServer.cpp 55 | win/LTCPTask.cpp 56 | win/LTCPTaskPool.cpp 57 | win/LThread.cpp 58 | win/LTime.cpp 59 | win/miniCrypt.c 60 | win/LIocp.cpp 61 | ) 62 | 63 | ENDIF(WIN32) 64 | 65 | add_library(Netbase ${LIB_SRCS} ${LIB_HEADERS}) 66 | 67 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 68 | target_link_libraries(Netbase zlib ) 69 | set_target_properties(Netbase PROPERTIES OUTPUT_NAME "Netbase") 70 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/EncDec.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "LType.h" 3 | #include "LCantCopy.h" 4 | #include "miniCrypt.h" 5 | class CEncrypt 6 | { 7 | public: 8 | CEncrypt(); 9 | enum encMethod 10 | { 11 | ENCDEC_NONE, 12 | ENCDEC_DES, 13 | ENCDEC_RC5 14 | }; 15 | void random_key_des(ZES_cblock *ret); 16 | void set_key_des(const_ZES_cblock *key); 17 | void set_key_rc5(const BYTE *data,int nLen,int rounds); 18 | int encdec(void *data,DWORD nLen,bool enc); 19 | 20 | void setEncMethod(encMethod method); 21 | encMethod getEncMethod() const; 22 | 23 | private: 24 | void ZES_random_key(ZES_cblock *ret); 25 | void ZES_set_key(const_ZES_cblock *key,ZES_key_schedule *schedule); 26 | void ZES_encrypt1(ZES_LONG *data,ZES_key_schedule *ks,int enc); 27 | 28 | void RC5_32_set_key(RC5_32_KEY *key,int len,const BYTE *data,int rounds); 29 | void RC5_32_encrypt(RC5_32_INT *d,RC5_32_KEY *key); 30 | void RC5_32_decrypt(RC5_32_INT *d,RC5_32_KEY *key); 31 | 32 | int encdec_des(BYTE *data,DWORD nLen,bool enc); 33 | int encdec_rc5(BYTE *data,DWORD nLen,bool enc); 34 | 35 | ZES_key_schedule key_des; 36 | RC5_32_KEY key_rc5; 37 | bool haveKey_des; 38 | bool haveKey_rc5; 39 | 40 | encMethod method; 41 | 42 | }; -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LCantCopy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LCantCopy.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LIocp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LIocp.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LIocp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LIocp.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LNetService.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LNetService.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LNetService.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LNetService.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LService.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LService.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LService.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LService.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LSocket.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LSocket.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPClientTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPClientTask.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPClientTask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPClientTask.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPClientTaskPool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPClientTaskPool.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPClientTaskPool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPClientTaskPool.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPServer.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPServer.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPTask.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPTask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPTask.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPTaskPool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPTaskPool.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTCPTaskPool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTCPTaskPool.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LThread.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LThread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LThread.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTime.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LTime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LTime.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/LType.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netbase/win/LType.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netbase/win/miniCrypt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __cplusplus 3 | #define MINI_RC5 1 4 | extern "C" { 5 | #endif //__cplusplus 6 | 7 | #ifdef MINI_RC5 8 | #define RC5_ENCRYPT 1 9 | #define RC5_DECRYPT 0 10 | 11 | /* 32 bit. For Alpha,things may get weird */ 12 | typedef DWORD RC5_32_INT; 13 | 14 | #define RC5_32_BLOCK 8 15 | #define RC5_32_KEY_LENGTH 16 /* This is a default,max is 255 */ 16 | 17 | /* This are the only values supported. Tweak the code if you want more 18 | * * The most supported modes will be 19 | * * RC5-32/12/16 20 | * * RC5-32/16/8 21 | * */ 22 | #define RC5_8_ROUNDS 8 23 | #define RC5_12_ROUNDS 12 24 | #define RC5_16_ROUNDS 16 25 | 26 | typedef struct rc5_key_st 27 | { 28 | /* Number of rounds */ 29 | int rounds; 30 | RC5_32_INT data[2*(RC5_16_ROUNDS+1)]; 31 | } RC5_32_KEY; 32 | 33 | void RC5_32_set_key(RC5_32_KEY *key,int len,const BYTE *data,int rounds); 34 | void RC5_32_encrypt(RC5_32_INT *d,RC5_32_KEY *key); 35 | void RC5_32_decrypt(RC5_32_INT *d,RC5_32_KEY *key); 36 | #endif //MINI_RC5 37 | 38 | #define ZES_ENCRYPT 1 39 | #define ZES_DECRYPT 0 40 | 41 | //#define ZES_LONG unsigned long 42 | typedef DWORD ZES_LONG; 43 | typedef BYTE ZES_cblock[8]; 44 | typedef /* const */ BYTE const_ZES_cblock[8]; 45 | 46 | /* With "const",gcc 2.8.1 on Solaris thinks that ZES_cblock * 47 | * * and const_ZES_cblock * are incompatible pointer types. */ 48 | 49 | typedef struct ZES_ks 50 | { 51 | union 52 | { 53 | ZES_cblock cblock; 54 | /* make sure things are correct size on machines with 55 | * * 8 byte longs */ 56 | ZES_LONG deslong[2]; 57 | } ks[16]; 58 | } ZES_key_schedule; 59 | 60 | void ZES_random_key(ZES_cblock *ret); 61 | void ZES_set_key(const_ZES_cblock *key,ZES_key_schedule *schedule); 62 | void ZES_encrypt1(ZES_LONG *data,ZES_key_schedule *ks,int enc); 63 | void ZES_encrypt3(ZES_LONG *data,ZES_key_schedule *ks1,ZES_key_schedule *ks2,ZES_key_schedule *ks3); 64 | void ZES_decrypt3(ZES_LONG *data,ZES_key_schedule *ks1,ZES_key_schedule *ks2,ZES_key_schedule *ks3); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif //__cplusplus 69 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/app/complie.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | g++ -DNDK_DEBUG $1 -g -o ${1%.cpp} -I../include -I../src -L../bin -lnetdkit -lpthread -lrt 4 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/app/export_ld.sh: -------------------------------------------------------------------------------- 1 | export LD_LIBRARY_PATH=../bin:$LD_LIBRARY_PATH 2 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/AUTHORS: -------------------------------------------------------------------------------- 1 | Author: Nicolas Devillard 2 | 3 | Many thanks to the many people who contributed ideas, code, suggestions, 4 | corrections, enhancements. 5 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/INSTALL: -------------------------------------------------------------------------------- 1 | 2 | iniParser installation instructions 3 | ----------------------------------- 4 | 5 | - Modify the Makefile to suit your environment. 6 | - Type 'make' to make the library. 7 | - Type 'make check' to make the test program. 8 | - Type 'test/iniexample' to launch the test program. 9 | - Type 'test/parse' to launch torture tests. 10 | 11 | 12 | 13 | Enjoy! 14 | N. Devillard 15 | Thu Jan 3 19:36:38 CET 2008 16 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2000-2007 by Nicolas Devillard. 2 | MIT License 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a 5 | copy of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # iniparser Makefile 3 | # 4 | 5 | # Compiler settings 6 | CC = gcc 7 | CFLAGS = -O2 -fPIC -Wall -ansi -pedantic 8 | 9 | # Ar settings to build the library 10 | AR = ar 11 | ARFLAGS = rcv 12 | 13 | SHLD = ${CC} ${CFLAGS} 14 | LDSHFLAGS = -shared -Wl,-Bsymbolic -Wl,-rpath -Wl,/usr/lib -Wl,-rpath,/usr/lib 15 | LDFLAGS = -Wl,-rpath -Wl,/usr/lib -Wl,-rpath,/usr/lib 16 | 17 | # Set RANLIB to ranlib on systems that require it (Sun OS < 4, Mac OSX) 18 | # RANLIB = ranlib 19 | RANLIB = true 20 | 21 | RM = rm -f 22 | 23 | 24 | # Implicit rules 25 | 26 | SUFFIXES = .o .c .h .a .so .sl 27 | 28 | COMPILE.c=$(CC) $(CFLAGS) -c 29 | .c.o: 30 | @(echo "compiling $< ...") 31 | @($(COMPILE.c) -o $@ $<) 32 | 33 | 34 | SRCS = src/iniparser.c \ 35 | src/dictionary.c 36 | 37 | OBJS = $(SRCS:.c=.o) 38 | 39 | 40 | default: libiniparser.a libiniparser.so 41 | 42 | libiniparser.a: $(OBJS) 43 | @($(AR) $(ARFLAGS) libiniparser.a $(OBJS)) 44 | @($(RANLIB) libiniparser.a) 45 | 46 | libiniparser.so: $(OBJS) 47 | @$(SHLD) $(LDSHFLAGS) -o $@.0 $(OBJS) $(LDFLAGS) \ 48 | -Wl,-soname=`basename $@`.0 49 | 50 | clean: 51 | $(RM) $(OBJS) 52 | 53 | veryclean: 54 | $(RM) $(OBJS) libiniparser.a libiniparser.so* 55 | rm -rf ./html ; mkdir html 56 | cd test ; $(MAKE) veryclean 57 | 58 | docs: 59 | @(cd doc ; $(MAKE)) 60 | 61 | check: 62 | @(cd test ; $(MAKE)) 63 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/README: -------------------------------------------------------------------------------- 1 | 2 | Welcome to iniParser -- version 3.0b (beta) 3 | released 03 Jan 2008 4 | 5 | This modules offers parsing of ini files from the C level. 6 | See a complete documentation in HTML format, from this directory 7 | open the file html/index.html with any HTML-capable browser. 8 | 9 | Enjoy! 10 | 11 | N.Devillard 12 | Thu Jan 3 19:36:31 CET 2008 13 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/doxygen.png -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/iniparser_8main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | iniparser: iniparser.main File Reference 4 | 5 | 6 | 7 | 8 |

iniparser.main File Reference

9 | 10 |
11 |
Generated on Thu Jan 3 19:45:34 2008 for iniparser by  12 | 13 | doxygen 1.5.3
14 | 15 | 16 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_b.gif -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_l.gif -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/html/tab_r.gif -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/test/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # iniparser tests Makefile 3 | # 4 | 5 | CC = gcc 6 | CFLAGS = -g -I../src 7 | LFLAGS = -L.. -liniparser 8 | AR = ar 9 | ARFLAGS = rcv 10 | RM = rm -f 11 | 12 | 13 | default: all 14 | 15 | all: iniexample parse 16 | 17 | iniexample: iniexample.c 18 | $(CC) $(CFLAGS) -o iniexample iniexample.c -I../src -L.. -liniparser 19 | 20 | parse: parse.c 21 | $(CC) $(CFLAGS) -o parse parse.c -I../src -L.. -liniparser 22 | 23 | clean veryclean: 24 | $(RM) iniexample example.ini parse 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/test/parse.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "iniparser.h" 7 | 8 | int main(int argc, char * argv[]) 9 | { 10 | dictionary * ini ; 11 | char * ini_name ; 12 | 13 | if (argc<2) { 14 | ini_name = "twisted.ini"; 15 | } else { 16 | ini_name = argv[1] ; 17 | } 18 | 19 | ini = iniparser_load(ini_name); 20 | iniparser_dump(ini, stdout); 21 | iniparser_freedict(ini); 22 | 23 | return 0 ; 24 | } 25 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/test/twisted-errors.ini: -------------------------------------------------------------------------------- 1 | # 2 | # All of these should trigger syntax errors 3 | # 4 | [section] 5 | hello 6 | world 7 | hello \ 8 | world 9 | a + b ; 10 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/test/twisted-genhuge.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import sys 4 | 5 | if __name__=="__main__": 6 | f=open('twisted-massive.ini', 'w') 7 | for i in range(100): 8 | f.write('[%03d]\n' % i) 9 | for j in range(100): 10 | f.write('key-%03d=1;\n' % j) 11 | f.close() 12 | 13 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/iniparser3.0b/test/twisted.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Twisted.ini 3 | # This file is meant for regression tests 4 | 5 | # Different blank settings around the equal sign 6 | [blanks] 7 | a=1 8 | b=1; 9 | c=1; comment 10 | d=1# comment 11 | 12 | e =1 13 | f =1; 14 | g =1; comment 15 | h =1# comment 16 | 17 | i= 1 18 | j= 1; 19 | k= 1; comment 20 | l= 1# comment 21 | 22 | m = 1 23 | n = 1; 24 | o = 1; comment 25 | p = 1# comment 26 | 27 | q=1 ; 28 | r=1 ; comment 29 | s=1 ;comment 30 | t=1 #comment 31 | 32 | # Empty values 33 | [empty] 34 | a = '' 35 | b = "" 36 | 37 | c = '' ; 38 | d = "" ; 39 | 40 | e = '' ; comment 41 | f = "" ; comment 42 | 43 | g = 44 | h = ; 45 | i = ; comment 46 | j = # comment 47 | 48 | k= 49 | l=; 50 | m=;comment 51 | n=# 52 | 53 | # Peculiar values 54 | [peculiar] 55 | a=';'; 56 | b='#'# 57 | c=';';comment 58 | d='#'#comment 59 | e=\; 60 | f=\# 61 | g=\;comment 62 | h=\#comment 63 | i=;; 64 | j=## 65 | k=;;;;;;;;;; 66 | l=########## 67 | 68 | # Quotes 69 | [quotes] 70 | s1=' 71 | s2='' 72 | s3=''' 73 | s4='''' 74 | 75 | d1=" 76 | d2="" 77 | d3=""" 78 | d4="""" 79 | 80 | m1='"' 81 | m2="'" 82 | 83 | h1=hello'world 84 | h2='hello'world 85 | h3='hello'world' 86 | 87 | h4=hello"world 88 | h5="hello"world 89 | h6="hello"world" 90 | 91 | # Section names 92 | [a] 93 | [ b] 94 | [c ] 95 | [ d ] 96 | [ begin end ] 97 | [ open[ ] 98 | 99 | # Multi-line inputs 100 | [multi] 101 | a = begin\ 102 | end 103 | b = begin \ 104 | end 105 | c = begin \ 106 | end 107 | d = 1\ 108 | 2\ 109 | 3\ 110 | 4 111 | e = 1 \ 112 | 2 \ 113 | 3 \ 114 | 4 115 | f = 1 ; \ 116 | hidden = because of the preceding backslash multi-lining the comment ; 117 | visible = 1 118 | g = 1 #\ 119 | and now this comment is hidden too \ 120 | and this one too 121 | h = 1 122 | multi \ 123 | line \ 124 | key = 1 125 | multi \ 126 | line \ 127 | key = \ 128 | multi \ 129 | line \ 130 | value ; 131 | # end of file 132 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/mempoll/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/mempoll/main.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/mempoll/mempool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/mempoll/mempool.cpp -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/code_set/mempoll/mempool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/netdsdk/code_set/mempoll/mempool.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMMON_H_ 2 | #define _COMMMON_H_ 3 | #include "Pre.h" 4 | 5 | /** 6 | * This helps prevent some "unused variable" warnings under, for instance 7 | */ 8 | template inline void unused_arg (const T&) { } 9 | 10 | 11 | #include "Post.h" 12 | #endif 13 | 14 | 15 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Condition.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-05 18:36 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _CONDITION_H_ 9 | #define _CONDITION_H_ 10 | #include "Pre.h" 11 | 12 | #include "NDK.h" 13 | #include "Thread.h" // For Thread::yield () 14 | #include "TimeValue.h" 15 | 16 | #include 17 | 18 | /** 19 | * @class Condition 20 | * 21 | * @brief 22 | */ 23 | template 24 | class Condition 25 | { 26 | public: 27 | // Constructor 28 | Condition (MUTEX &m); 29 | 30 | // Destory cond 31 | ~Condition (); 32 | 33 | /** 34 | * block until wakeup by signal 35 | * return 0: wakeup by signal 36 | * return -1: error 37 | */ 38 | int wait (void); 39 | 40 | /** 41 | * block until timeout 42 | * return 0: wakeup by signal 43 | * return -1: error or timeout 44 | * : errno == ETIMEDOUT means timeout 45 | */ 46 | int wait (const TimeValue *timeout); 47 | 48 | /** 49 | * signal one waiting thread. 50 | * 53 | * return 0: signal succ 54 | * return -1: failed 55 | */ 56 | int signal (void); 57 | 58 | /** 59 | * signal *all* waiting threads. 60 | * return 0: succ 61 | * return -1: failed 62 | */ 63 | int broadcast (void); 64 | 65 | // Return the reference of mutex 66 | MUTEX &mutex (void); 67 | private: 68 | // Mutex 69 | MUTEX &mutex_; 70 | 71 | // Condition 72 | pthread_cond_t cond_; 73 | }; 74 | 75 | #include "Condition.inl" 76 | #include "Post.h" 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Condition.inl: -------------------------------------------------------------------------------- 1 | template inline 2 | Condition::Condition (MUTEX &m) 3 | : mutex_ (m) 4 | { 5 | ::pthread_cond_init (&this->cond_, NULL); 6 | } 7 | template inline 8 | Condition::~Condition () 9 | { 10 | int retry = 0; 11 | while ((::pthread_cond_destroy (&this->cond_) == EBUSY) 12 | && retry++ < 3) 13 | { 14 | this->broadcast (); 15 | Thread::yield (); 16 | } 17 | } 18 | template inline 19 | int Condition::wait () 20 | { 21 | SET_ERRNO_RETURN (::pthread_cond_wait (&this->cond_, 22 | const_cast(&this->mutex_.lock ()))); 23 | } 24 | template inline 25 | int Condition::wait (const TimeValue *timeout) 26 | { 27 | if (timeout == 0) 28 | return this->wait (); 29 | 30 | #if 0 31 | struct timespec timeout; 32 | struct timeval tp; 33 | ::gettimeofday (&tp, NULL); 34 | timeout.tv_sec = (msec / 1000) + tp.tv_sec; 35 | timeout.tv_nsec = ((msec % 1000) * 1000000) + (tp.tv_usec * 1000); 36 | while (timeout.tv_nsec >= 1000000000) 37 | { 38 | timeout.tv_nsec -= 1000000000; 39 | timeout.tv_sec++; 40 | } 41 | #endif 42 | struct timespec ts; 43 | ts = NDK::gettimeofday () + *timeout; 44 | // shall not return an error code of [EINTR] 45 | SET_ERRNO_RETURN (::pthread_cond_timedwait (&this->cond_, 46 | const_cast(&this->mutex_.lock ()), 47 | &ts)); 48 | } 49 | template inline 50 | int Condition::signal () 51 | { 52 | SET_ERRNO_RETURN (::pthread_cond_signal (&this->cond_)); 53 | } 54 | template inline 55 | int Condition::broadcast () 56 | { 57 | SET_ERRNO_RETURN (::pthread_cond_broadcast (&this->cond_)); 58 | } 59 | template inline 60 | MUTEX &Condition::mutex () 61 | { 62 | return this->mutex_; 63 | } 64 | 65 | 66 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ConditionThreadMutex.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-02-20 20:48 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _CONDITIONTHREADMUTEX_H_ 9 | #define _CONDITIONTHREADMUTEX_H_ 10 | #include "Pre.h" 11 | 12 | #include 13 | 14 | #include "NDK.h" 15 | #include "Thread.h" 16 | #include "TimeValue.h" 17 | #include "ThreadMutex.h" 18 | 19 | /** 20 | * @class ConditionThreadMutex 21 | * 22 | * @brief 23 | */ 24 | class ConditionThreadMutex 25 | { 26 | public: 27 | // 28 | ConditionThreadMutex (ThreadMutex &mutex); 29 | 30 | // 31 | ~ConditionThreadMutex (); 32 | 33 | /** 34 | * block until wakeup by signal 35 | * return 0: wakeup by signal 36 | * return -1: error 37 | */ 38 | int wait (); 39 | 40 | /** 41 | * block until timeout 42 | * return 0: wakeup by signal 43 | * return -1: error or timeout 44 | * : errno == EWOULDBLOCK means timeout 45 | */ 46 | int wait (const TimeValue *timeout); 47 | // 48 | int signal (); 49 | 50 | // 51 | int broadcast (); 52 | 53 | // Return the reference of mutex 54 | ThreadMutex &mutex (void); 55 | private: 56 | ThreadMutex &mutex_; 57 | pthread_cond_t cond_; 58 | }; 59 | 60 | #include "ConditionThreadMutex.inl" 61 | #include "Post.h" 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ConditionThreadMutex.inl: -------------------------------------------------------------------------------- 1 | inline 2 | ConditionThreadMutex::ConditionThreadMutex (ThreadMutex &mutex) 3 | : mutex_ (mutex) 4 | { 5 | ::pthread_cond_init (&this->cond_, NULL); 6 | } 7 | inline 8 | ConditionThreadMutex::~ConditionThreadMutex () 9 | { 10 | int retry = 0; 11 | while ((::pthread_cond_destroy (&this->cond_) == EBUSY) 12 | && retry++ < 3) 13 | { 14 | this->broadcast (); 15 | Thread::yield (); 16 | } 17 | } 18 | inline 19 | int ConditionThreadMutex::wait () 20 | { 21 | SET_ERRNO_RETURN (::pthread_cond_wait (&this->cond_, 22 | const_cast(&this->mutex_.lock ()))); 23 | } 24 | inline 25 | int ConditionThreadMutex::wait (const TimeValue *timeout) 26 | { 27 | if (timeout == 0) 28 | return this->wait (); 29 | #if 0 30 | struct timespec timeout; 31 | struct timeval tp; 32 | ::gettimeofday (&tp, NULL); 33 | timeout.tv_sec = (msec / 1000) + tp.tv_sec; 34 | timeout.tv_nsec = ((msec % 1000) * 1000000) + (tp.tv_usec * 1000); 35 | while (timeout.tv_nsec >= 1000000000) 36 | { 37 | timeout.tv_nsec -= 1000000000; 38 | timeout.tv_sec++; 39 | } 40 | #endif 41 | struct timespec ts; 42 | ts = NDK::gettimeofday () + *timeout; 43 | // shall not return an error code of [EINTR] 44 | SET_ERRNO_RETURN (::pthread_cond_timedwait (&this->cond_, 45 | const_cast(&this->mutex_.lock ()), 46 | &ts)); 47 | } 48 | inline 49 | int ConditionThreadMutex::signal () 50 | { 51 | SET_ERRNO_RETURN (::pthread_cond_signal (&this->cond_)); 52 | } 53 | inline 54 | int ConditionThreadMutex::broadcast () 55 | { 56 | SET_ERRNO_RETURN (::pthread_cond_broadcast (&this->cond_)); 57 | } 58 | inline 59 | ThreadMutex &ConditionThreadMutex::mutex () 60 | { 61 | return this->mutex_; 62 | } 63 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Debug.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-03-31 11:03 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _DEBUG_H_ 9 | #define _DEBUG_H_ 10 | #include "Pre.h" 11 | 12 | #include "LogSvr.h" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /** 19 | * @class Debug 20 | * 21 | * @brief 22 | */ 23 | class Debug : public LogSvr 24 | { 25 | friend class Singleton_T; 26 | protected: 27 | Debug (); 28 | ~Debug (); 29 | }; 30 | 31 | typedef Singleton_T NDK_DEBUG_; 32 | 33 | #ifdef NDK_DEBUG 34 | # define NDK_DBG(x) NDK_DEBUG_::instance ()->put (LOG_DEBUG, x\ 35 | " [errno = %d][errdes = %s]\n", errno, strerror (errno)) 36 | # define NDK_INF(x, ...) NDK_DEBUG_::instance ()->put (LOG_RINFO,\ 37 | x, ##__VA_ARGS__) 38 | #else 39 | # define NDK_DBG(x) 40 | # define NDK_INF(x, ...) 41 | #endif 42 | 43 | #include "Debug.inl" 44 | #include "Post.h" 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Debug.inl: -------------------------------------------------------------------------------- 1 | inline 2 | Debug::Debug () 3 | { 4 | open ("dbglog"); 5 | } 6 | inline 7 | Debug::~Debug () 8 | { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/DefaultConstants.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-04-3 18:12 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _DEFAULT_CONSTANTS_H_ 9 | #define _DEFAULT_CONSTANTS_H_ 10 | #include "Pre.h" 11 | 12 | #define MAX_DEFAULT_PORT 65535 13 | 14 | #include "Post.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/EventHandler.inl: -------------------------------------------------------------------------------- 1 | inline 2 | EventHandler::EventHandler () 3 | : reactor_ (0) 4 | { 5 | } 6 | inline 7 | EventHandler::~EventHandler () 8 | { 9 | 10 | } 11 | inline 12 | int EventHandler::handle_input (NDK_HANDLE /* = NDK_INVALID_HANDLE*/) 13 | { 14 | return -1; 15 | } 16 | inline 17 | int EventHandler::handle_output (NDK_HANDLE /* = NDK_INVALID_HANDLE*/) 18 | { 19 | return -1; 20 | } 21 | inline 22 | int EventHandler::handle_exception (NDK_HANDLE /* = NDK_INVALID_HANDLE*/) 23 | { 24 | return -1; 25 | } 26 | inline 27 | int EventHandler::handle_timeout (const void *, const TimeValue &) 28 | { 29 | return -1; 30 | } 31 | inline 32 | int EventHandler::handle_close (NDK_HANDLE , ReactorMask ) 33 | { 34 | return -1; 35 | } 36 | inline 37 | int EventHandler::handle_close (const void *, ReactorMask ) 38 | { 39 | return -1; 40 | } 41 | inline 42 | NDK_HANDLE EventHandler::handle () const 43 | { 44 | return NDK_INVALID_HANDLE; 45 | } 46 | inline 47 | void EventHandler::handle (NDK_HANDLE) 48 | { 49 | } 50 | inline 51 | Reactor *EventHandler::reactor () const 52 | { 53 | return this->reactor_; 54 | } 55 | inline 56 | void EventHandler::reactor (Reactor *r) 57 | { 58 | this->reactor_ = r; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Guard_T.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-05 18:35 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _GUARD_T_H_ 9 | #define _GUARD_T_H_ 10 | #include "Pre.h" 11 | 12 | /** 13 | * @class Guard_T 14 | * 15 | * @brief 16 | */ 17 | template 18 | class Guard_T 19 | { 20 | public: 21 | // auto lock 22 | Guard_T (LOCK &lock); 23 | 24 | // auto unlock 25 | ~Guard_T (); 26 | // 27 | int acquire (void); 28 | 29 | // 30 | int release (void); 31 | 32 | // 33 | int tryacquire (); 34 | private: 35 | LOCK &lock_; 36 | }; 37 | 38 | #include "Guard_T.inl" 39 | #include "Post.h" 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Guard_T.inl: -------------------------------------------------------------------------------- 1 | template inline 2 | Guard_T::Guard_T (LOCK &lock) 3 | :lock_ (lock) 4 | { 5 | lock_.acquire (); 6 | } 7 | template inline 8 | Guard_T::~Guard_T () 9 | { 10 | lock_.release (); 11 | } 12 | template inline 13 | int Guard_T::acquire () 14 | { 15 | return lock_.acquire (); 16 | } 17 | template inline 18 | int Guard_T::tryacquire () 19 | { 20 | return lock_.tryacquire (); 21 | } 22 | template inline 23 | int Guard_T::release () 24 | { 25 | return lock_.release (); 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/LogSvr.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2007-12-18 20:28 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _LOGSVR_H_ 9 | #define _LOGSVR_H_ 10 | #include "Pre.h" 11 | 12 | #include "DateTime.h" 13 | #include "TimeValue.h" 14 | #include "Singleton_T.h" 15 | #include "ThreadMutex.h" 16 | 17 | #define LOG_TIME_STR_LEN 32 18 | #define MAX_LOGSTR_LEN 511 19 | #define MAX_LOGFILE_NAME_LEN 31 20 | 21 | enum { 22 | LOG_TRACE = 0, 23 | LOG_DEBUG, 24 | LOG_RINFO, 25 | LOG_ERROR, 26 | LOG_ITEMS 27 | }; 28 | 29 | /** 30 | * @class LogSvr 31 | * 32 | * @brief Spawn (1) thread to write log , use thread avoid to block write 33 | */ 34 | class LogSvr 35 | { 36 | friend class Singleton_T; 37 | public: 38 | /// create log file and dir 39 | int open (const char *log_dir); 40 | 41 | /// logtype : LOG_TRACE LOG_DEBUG LOG_RINFO LOG_ERROR 42 | void put (size_t log_type, const char *format, ...); 43 | protected: 44 | LogSvr (); 45 | ~LogSvr (); 46 | 47 | /// check logtime for one day one log-file, 48 | void check_log_time (); 49 | private: 50 | int log_handle_; 51 | char* log_buff_; 52 | char* log_dir_; 53 | char* log_file_name_; 54 | char* log_time_; 55 | char* log_items_[LOG_ITEMS]; 56 | time_t day_start_time_; 57 | DateTime current_dtime_; 58 | TimeValue current_time_; 59 | typedef ThreadMutex MUTEX; 60 | MUTEX log_mutex_; 61 | }; 62 | 63 | #include "Post.h" 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/MessageBlock.inl: -------------------------------------------------------------------------------- 1 | inline 2 | MessageBlock::MessageBlock (const size_t size) 3 | : mb_base_ (0) 4 | , release_base_ (0) 5 | , mb_size_ (size) 6 | , mb_type_ (MB_DATA) 7 | , prev_ (0) 8 | , next_ (0) 9 | { 10 | mb_base_ = (char*)::malloc((sizeof(char) * size)); 11 | release_base_ = 1; 12 | } 13 | inline 14 | MessageBlock::MessageBlock (const char *pdata, const size_t size) 15 | : mb_base_ (const_cast(pdata)) 16 | , release_base_ (0) 17 | , mb_size_ (size) 18 | , mb_type_ (MB_DATA) 19 | , prev_ (0) 20 | , next_ (0) 21 | { 22 | } 23 | inline 24 | MessageBlock::~MessageBlock () 25 | { 26 | //this->release (); 27 | } 28 | inline 29 | char *MessageBlock::base () 30 | { 31 | return this->mb_base_; 32 | } 33 | inline 34 | size_t MessageBlock::size () 35 | { 36 | return this->mb_size_; 37 | } 38 | inline 39 | size_t MessageBlock::data_type () 40 | { 41 | return this->mb_type_; 42 | } 43 | inline 44 | void MessageBlock::data_type (size_t type) 45 | { 46 | NDK_SET_BITS (this->mb_type_, type); 47 | } 48 | inline 49 | MessageBlock *MessageBlock::next () const 50 | { 51 | return this->next_; 52 | } 53 | inline 54 | void MessageBlock::next (MessageBlock *mb) 55 | { 56 | this->next_ = mb; 57 | } 58 | inline 59 | MessageBlock *MessageBlock::prev () const 60 | { 61 | return this->prev_; 62 | } 63 | inline 64 | void MessageBlock::prev (MessageBlock *mb) 65 | { 66 | this->prev_ = mb; 67 | } 68 | inline 69 | void MessageBlock::release () 70 | { 71 | MessageBlock *mb = this; 72 | MessageBlock *tmp = 0; 73 | for (; mb != 0;) 74 | { 75 | tmp = mb; 76 | mb = mb->next (); 77 | tmp->clean (); 78 | delete tmp; 79 | } 80 | } 81 | inline 82 | void MessageBlock::clean () 83 | { 84 | if (this->mb_base_ && this->release_base_) 85 | { 86 | ::free (this->mb_base_); 87 | this->mb_base_ = 0; 88 | this->mb_size_ = 0; 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/MessageQueue.inl: -------------------------------------------------------------------------------- 1 | inline 2 | MessageQueue::MessageQueue () 3 | : mb_count_ (0) 4 | , head_ (0) 5 | , tail_ (0) 6 | , not_empty_cond_ (queue_mutex_) 7 | { 8 | } 9 | inline 10 | size_t MessageQueue::size () 11 | { 12 | Guard_T g (this->queue_mutex_); 13 | return mb_count_; 14 | } 15 | inline 16 | bool MessageQueue::is_empty () 17 | { 18 | Guard_T g (this->queue_mutex_); 19 | return this->is_empty_i (); 20 | } 21 | inline 22 | bool MessageQueue::is_empty_i () 23 | { 24 | return this->tail_ == 0; 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Pipe.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-02-14 13:24 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _PIPE_H_ 9 | #define _PIPE_H_ 10 | #include "Pre.h" 11 | 12 | #include "GlobalMacros.h" 13 | 14 | /** 15 | * @class Pipe 16 | * 17 | * @brief 18 | */ 19 | class Pipe 20 | { 21 | public: 22 | Pipe (); 23 | ~Pipe (); 24 | 25 | // 26 | int open (); 27 | 28 | // 29 | int close (); 30 | // 31 | NDK_HANDLE read_handle (); 32 | 33 | // 34 | NDK_HANDLE write_handle (); 35 | 36 | private: 37 | NDK_HANDLE handles_[2]; 38 | }; 39 | 40 | #include "Pipe.inl" 41 | #include "Post.h" 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Pipe.inl: -------------------------------------------------------------------------------- 1 | inline 2 | NDK_HANDLE Pipe::read_handle () 3 | { 4 | return this->handles_[0]; 5 | } 6 | inline 7 | NDK_HANDLE Pipe::write_handle () 8 | { 9 | return this->handles_[1]; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Post.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-02-14 13:24 5 | */ 6 | //======================================================================== 7 | // No header guard 8 | 9 | #if defined (_MSC_VER) 10 | # pragma pack (pop) 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Pre.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-02-14 13:24 5 | */ 6 | //======================================================================== 7 | // No header guard 8 | 9 | #if defined (_MSC_VER) 10 | # pragma warning (disable:4103) 11 | # pragma pack (push, 8) 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/RWThreadMutex.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-06 15:07 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _RWTHREADMUTEX_H_ 9 | #define _RWTHREADMUTEX_H_ 10 | #include "Pre.h" 11 | 12 | /** 13 | * @class RWThreadMutex 14 | * 15 | * @brief 16 | */ 17 | class RWThreadMutex 18 | { 19 | public: 20 | RWThreadMutex (); 21 | ~RWThreadMutex (); 22 | private: 23 | }; 24 | #include "Post.h" 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Reactor.inl: -------------------------------------------------------------------------------- 1 | inline 2 | void Reactor::implementation (ReactorImpl *impl) 3 | { 4 | this->implementation_ = impl; 5 | } 6 | inline 7 | ReactorImpl* Reactor::implementation () 8 | { 9 | return this->implementation_; 10 | } 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ReactorToken.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-02-15 15:41 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _REACTORGUARD_H_ 9 | #define _REACTORGUARD_H_ 10 | #include "Pre.h" 11 | 12 | #include "Trace.h" 13 | #include "Debug.h" 14 | #include "Token.h" 15 | 16 | class ReactorImpl; 17 | /** 18 | * @class ReactorToken 19 | * 20 | * @brief 21 | */ 22 | class ReactorToken : public Token 23 | { 24 | public: 25 | ReactorToken (ReactorImpl *r, 26 | int s_queue = Token::FIFO); 27 | virtual ~ReactorToken (); 28 | 29 | // Get the reacotr implementation 30 | ReactorImpl *reactor (void); 31 | 32 | // Set the reacotr implementation 33 | void reactor (ReactorImpl *); 34 | 35 | // 36 | virtual void sleep_hook (void); 37 | private: 38 | // Reactor implement 39 | ReactorImpl *reactor_; 40 | }; 41 | 42 | #include "ReactorToken.inl" 43 | #include "Post.h" 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ReactorToken.inl: -------------------------------------------------------------------------------- 1 | inline 2 | ReactorToken::ReactorToken (ReactorImpl *r, 3 | int s_queue/* = Token::FIFO*/) 4 | : Token (s_queue) 5 | , reactor_ (r) 6 | { 7 | } 8 | inline 9 | ReactorToken::~ReactorToken () 10 | { 11 | } 12 | inline 13 | ReactorImpl *ReactorToken::reactor () 14 | { 15 | return this->reactor_; 16 | } 17 | inline 18 | void ReactorToken::reactor (ReactorImpl *r) 19 | { 20 | this->reactor_ = r; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/RecursiveThreadMutex.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-27 14:35 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _RECURSIVETHREADMUTEX_H_ 9 | #define _RECURSIVETHREADMUTEX_H_ 10 | #include "Pre.h" 11 | 12 | #include 13 | 14 | #include "GlobalMacros.h" 15 | 16 | /** 17 | * @class RecursiveThreadMutex 18 | * 19 | * @brief 20 | */ 21 | class RecursiveThreadMutex 22 | { 23 | public: 24 | RecursiveThreadMutex (); 25 | ~RecursiveThreadMutex (); 26 | // 27 | int acquire (void); 28 | 29 | // acquire lock ownership in msec period 30 | int acquire (int msec); 31 | 32 | // not block if someone already had the lock , errno is EBUSY 33 | int tryacquire (void); 34 | 35 | // release lock ownership 36 | int release (void); 37 | 38 | // return mutex_t 39 | const pthread_mutex_t &lock () const; 40 | private: 41 | // 42 | int nesting_level_; 43 | 44 | // 45 | thread_t owner_thr_; 46 | 47 | pthread_mutex_t mutex_; 48 | }; 49 | 50 | #include "RecursiveThreadMutex.inl" 51 | #include "Post.h" 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/RecursiveThreadMutex.inl: -------------------------------------------------------------------------------- 1 | inline 2 | RecursiveThreadMutex::RecursiveThreadMutex () 3 | : nesting_level_ (0) 4 | , owner_thr_ (0) 5 | { 6 | ::pthread_mutex_init (&this->mutex_, NULL); 7 | } 8 | inline 9 | RecursiveThreadMutex::~RecursiveThreadMutex () 10 | { 11 | ::pthread_mutex_destroy (&this->mutex_); 12 | } 13 | inline 14 | const pthread_mutex_t &RecursiveThreadMutex::lock () const 15 | { 16 | return mutex_; 17 | } 18 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Semaphore.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-05 18:36 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _SEMAPHORE_H_ 9 | #define _SEMAPHORE_H_ 10 | #include "Pre.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "NDK.h" 16 | #include "Thread.h" // For Thread::yield () 17 | #include "TimeValue.h" 18 | 19 | /** 20 | * @class Semaphore 21 | * 22 | * @brief 23 | */ 24 | class Semaphore 25 | { 26 | public: 27 | Semaphore (int init_num = 0); 28 | ~Semaphore (); 29 | 30 | // block until wakeup by sem 31 | // return -1: error 32 | // return 0: wakeup by sem 33 | int wait (void); 34 | 35 | // block until timeout 36 | // return 0: wakeup by sem 37 | // return -1: error 38 | // : errno = EWOULDBLOCK means timeout 39 | int wait (const TimeValue *timeout); 40 | 41 | // return 0: sem count > 0 42 | // return -1: sem count = 0 43 | int trywait (); 44 | 45 | // return -1: failed 46 | // return 0: succ 47 | int post (); 48 | 49 | // return -1: failed 50 | // other : post count successfully 51 | int post (int post_count); 52 | private: 53 | sem_t sem_; 54 | }; 55 | 56 | #include "Semaphore.inl" 57 | #include "Post.h" 58 | #endif 59 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Semaphore.inl: -------------------------------------------------------------------------------- 1 | inline 2 | Semaphore::Semaphore (int init_num/* = 0*/) 3 | { 4 | ::sem_init (&sem_, 0, init_num); 5 | } 6 | inline 7 | Semaphore::~Semaphore () 8 | { 9 | size_t retry = 0; 10 | while ((::sem_destroy (&sem_) == -1) && retry < 3) 11 | { 12 | if (errno == EBUSY) 13 | { 14 | retry ++; 15 | this->post (); 16 | Thread::yield (); 17 | }else 18 | break; 19 | } 20 | } 21 | inline 22 | int Semaphore::wait () 23 | { 24 | int ret = -1; 25 | do{ 26 | ret = ::sem_wait (&sem_); 27 | }while (ret == -1 && errno == EINTR); 28 | return ret; 29 | } 30 | inline 31 | int Semaphore::wait (const TimeValue *timeout) 32 | { 33 | if (timeout == 0) 34 | return this->wait (); 35 | #if 0 36 | struct timespec timeout; 37 | struct timeval tp; 38 | ::gettimeofday (&tp, 0); 39 | timeout.tv_sec = (msec / 1000) + tp.tv_sec; 40 | timeout.tv_nsec = ((msec % 1000) * 1000000) + (tp.tv_usec * 1000); 41 | while (timeout.tv_nsec >= 1000000000) 42 | { 43 | timeout.tv_nsec -= 1000000000; 44 | timeout.tv_sec++; 45 | } 46 | #endif 47 | struct timespec ts; 48 | ts = NDK::gettimeofday () + *timeout; 49 | int ret = -1; 50 | do{ 51 | ret = ::sem_timedwait (&sem_, &ts); 52 | }while (ret == -1 && errno == EINTR); 53 | return ret; 54 | } 55 | inline 56 | int Semaphore::trywait () 57 | { 58 | return ::sem_trywait (&sem_); 59 | } 60 | inline 61 | int Semaphore::post () 62 | { 63 | return ::sem_post (&sem_); 64 | } 65 | inline 66 | int Semaphore::post (int post_count) 67 | { 68 | int ret = 0; 69 | int n = post_count; 70 | while (n-- > 0) 71 | if (::sem_post (&sem_) == 0) ret++; 72 | return post_count != ret ? -1 : ret; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Singleton_T.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-05 18:11 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _SINGLETON_H_ 9 | #define _SINGLETON_H_ 10 | #include "Pre.h" 11 | 12 | #include "Guard_T.h" 13 | 14 | /** 15 | * @class Singleton_T 16 | * 17 | * @brief 18 | */ 19 | class ThreadMutex; 20 | 21 | template 22 | class Singleton_T 23 | { 24 | public: 25 | static TYPE *instance (); 26 | protected: 27 | Singleton_T (); 28 | ~Singleton_T (); 29 | private: 30 | static TYPE *instance_; 31 | static LOCK *lock_; 32 | }; 33 | 34 | #include "Singleton_T.inl" 35 | #include "Post.h" 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Singleton_T.inl: -------------------------------------------------------------------------------- 1 | template 2 | TYPE *Singleton_T::instance_ = 0; 3 | template 4 | LOCK *Singleton_T::lock_ = new LOCK; 5 | 6 | template inline 7 | TYPE *Singleton_T::instance () 8 | { 9 | if (instance_ == 0) 10 | { 11 | Guard_T lock (*lock_); 12 | if (instance_ == 0) 13 | instance_ = new TYPE; 14 | } 15 | return instance_; 16 | } 17 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/SockAcceptor.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-09 12:20 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _SOCKACCEPTOR_H_ 9 | #define _SOCKACCEPTOR_H_ 10 | #include "Pre.h" 11 | 12 | #include "config.h" 13 | #include "Socket.h" 14 | #include "InetAddr.h" 15 | #include "SockStream.h" 16 | 17 | /** 18 | * @class SockAcceptor 19 | * 20 | * @brief 21 | */ 22 | class SockAcceptor : public Socket 23 | { 24 | public: 25 | SockAcceptor (); 26 | ~SockAcceptor (); 27 | 28 | /** 29 | * Initialize a passive-mode BSD-style acceptor socket 30 | * is the address that we're going to listen for 31 | * connections on. If is 1 then we'll use the 32 | * to reuse this address. Returns 0 on success and 33 | * -1 on failure. 34 | */ 35 | int open (const InetAddr &local_addr, 36 | int reuse_addr = 1, 37 | size_t revbuf_size = 0, 38 | int protocol_family = AF_INET, 39 | int backlog = NDK_DEFAULT_BACKLOG); 40 | 41 | /** 42 | * Accept a new SockStream connection. timeout_msec is 0 43 | * means non-block, = -1 means block forever, > 0 means timeout 44 | */ 45 | int accept (SockStream &new_stream, 46 | InetAddr *remote_addr = 0, 47 | const TimeValue *timeout = 0); 48 | }; 49 | 50 | #include "Post.h" 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/SockConnector.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-09 12:20 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _SOCKCONNECTOR_H_ 9 | #define _SOCKCONNECTOR_H_ 10 | #include "Pre.h" 11 | 12 | #include "Trace.h" 13 | #include "InetAddr.h" 14 | #include "SockStream.h" 15 | 16 | /** 17 | * @class SockConnector 18 | * 19 | * @brief 20 | */ 21 | class SockConnector 22 | { 23 | public: 24 | SockConnector (); 25 | ~SockConnector (); 26 | 27 | /** 28 | * actively connect to a peer, producing a connected SockStream 29 | * object if the connection succeeds. 30 | * 31 | * return 0: success 32 | * return -1: timeout or error 33 | */ 34 | int connect (SockStream &new_stream, 35 | const InetAddr &remote_addr, 36 | const TimeValue *timeout = 0, 37 | const InetAddr &local_addr = InetAddr::addr_any, 38 | int protocol_family = AF_INET, 39 | size_t sendbuf_size = 0); 40 | protected: 41 | /** 42 | * perform operations that ensure the socket is opened 43 | */ 44 | int shared_open (SockStream &new_stream, int protocol_family); 45 | 46 | /** 47 | * non-block connect 48 | */ 49 | int nb_connect (SockStream &new_stream, 50 | const InetAddr &remote_addr, 51 | const TimeValue *timeout); 52 | private: 53 | }; 54 | 55 | #include "SockConnector.inl" 56 | #include "Post.h" 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/SockConnector.inl: -------------------------------------------------------------------------------- 1 | inline 2 | SockConnector::SockConnector () 3 | { 4 | } 5 | inline 6 | SockConnector::~SockConnector () 7 | { 8 | } 9 | inline 10 | int SockConnector::shared_open (SockStream &new_stream, 11 | int protocol_family) 12 | { 13 | TRACE ("SockConnector"); 14 | if (new_stream.handle () == NDK_INVALID_HANDLE 15 | && new_stream.open (SOCK_STREAM, protocol_family) == -1) 16 | return -1; 17 | return 0; 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Socket.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-04 18:15 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _SOCKET_H_ 9 | #define _SOCKET_H_ 10 | #include "Pre.h" 11 | 12 | #include "NDK.h" 13 | #include "InetAddr.h" 14 | #include "GlobalMacros.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | /** 21 | * @class Socket 22 | * 23 | * @brief 24 | */ 25 | class Socket 26 | { 27 | public: 28 | ~Socket (); 29 | // 30 | int open (int sock_type, int protocol_family); 31 | 32 | // 33 | int close (); 34 | 35 | // 36 | NDK_HANDLE handle () const; 37 | 38 | // 39 | void handle (NDK_HANDLE handle); 40 | 41 | // 42 | int get_local_addr (InetAddr &); 43 | protected: 44 | Socket (); 45 | 46 | // socket handle 47 | NDK_HANDLE handle_; 48 | private: 49 | }; 50 | 51 | #include "Socket.inl" 52 | #include "Post.h" 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Socket.inl: -------------------------------------------------------------------------------- 1 | inline 2 | Socket::Socket () 3 | :handle_ (NDK_INVALID_HANDLE) 4 | { 5 | } 6 | inline 7 | Socket::~Socket () 8 | { 9 | } 10 | inline 11 | int Socket::open (int sock_type, int protocol_family) 12 | { 13 | NDK_HANDLE handle = ::socket (protocol_family, sock_type, 0); 14 | if (handle == NDK_INVALID_HANDLE) return -1; 15 | this->handle (handle); 16 | return 0; 17 | } 18 | inline 19 | int Socket::close () 20 | { 21 | int ret_val = ::close (this->handle_); 22 | this->handle_ = NDK_INVALID_HANDLE; 23 | return ret_val; 24 | } 25 | inline 26 | NDK_HANDLE Socket::handle () const 27 | { 28 | return this->handle_; 29 | } 30 | inline 31 | void Socket::handle (NDK_HANDLE handle) 32 | { 33 | this->handle_ = handle; 34 | } 35 | inline 36 | int Socket::get_local_addr (InetAddr &local_addr) 37 | { 38 | int len = local_addr.get_addr_size (); 39 | sockaddr *addr = reinterpret_cast (local_addr.get_addr ()); 40 | if (::getsockname (this->handle (), 41 | addr, 42 | reinterpret_cast(&len)) == -1) 43 | return -1; 44 | local_addr.set_type (addr->sa_family); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/TaskWithMQ.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-04-01 11:08 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _TASKWITHMQ_H_ 9 | #define _TASKWITHMQ_H_ 10 | #include "Pre.h" 11 | 12 | #include "TaskBase.h" 13 | #include "MessageQueue.h" 14 | 15 | /** 16 | * @class TaskWithMQ 17 | * 18 | * @brief 19 | */ 20 | class TaskWithMQ : public TaskBase 21 | { 22 | public: 23 | /** 24 | * Initialize a Task, supplying a thread manager and a message 25 | * queue. If the user doesn't supply a ACE_Message_Queue pointer 26 | * then we'll allocate one dynamically. Otherwise, we'll use the 27 | * one passed as a parameter. 28 | */ 29 | TaskWithMQ (ThreadManager *thr_mgr = 0, 30 | MessageQueue *mq = 0); 31 | 32 | // Destructor 33 | virtual ~TaskWithMQ (); 34 | 35 | // Gets the message queue associated with this task. 36 | MessageQueue *msg_queue (void); 37 | 38 | // Sets the message queue associated with this task. 39 | void msg_queue (MessageQueue *); 40 | 41 | // Insert message into the message queue tail. 42 | int putq (MessageBlock *, const TimeValue* timeout = 0); 43 | 44 | // Extract the first message from the queue. 45 | int getq (MessageBlock *&, const TimeValue* timeout = 0); 46 | 47 | // Extract n message from the queue head; 48 | int getq_n (MessageBlock *&, int number = -1, const TimeValue* timeout = 0); 49 | 50 | // Return a message to the queue. 51 | int ungetq (MessageBlock *, const TimeValue* timeout = 0); 52 | protected: 53 | // 1 if should delete MessageQueue, 0 otherwise. 54 | int delete_msg_queue_; 55 | 56 | // Queue of messages on the Task 57 | MessageQueue *msg_queue_; 58 | }; 59 | 60 | #include "TaskWithMQ.inl" 61 | 62 | #include "Post.h" 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/TaskWithMQ.inl: -------------------------------------------------------------------------------- 1 | inline 2 | TaskWithMQ::TaskWithMQ (ThreadManager *thr_mgr/* = 0*/, 3 | MessageQueue *mq/* = 0*/) 4 | : TaskBase (thr_mgr) 5 | , delete_msg_queue_ (0) 6 | , msg_queue_ (0) 7 | { 8 | if (mq == 0) 9 | { 10 | mq = new MessageQueue; 11 | if (mq) 12 | delete_msg_queue_ = 1; 13 | } 14 | if (mq) 15 | msg_queue_ = mq; 16 | } 17 | inline 18 | TaskWithMQ::~TaskWithMQ () 19 | { 20 | if (this->delete_msg_queue_) 21 | delete this->msg_queue_; 22 | this->delete_msg_queue_ = 0; 23 | } 24 | inline 25 | MessageQueue *TaskWithMQ::msg_queue () 26 | { 27 | return this->msg_queue_; 28 | } 29 | inline 30 | void TaskWithMQ::msg_queue (MessageQueue *msg_queue) 31 | { 32 | if (this->delete_msg_queue_) 33 | { 34 | delete this->msg_queue_; 35 | this->delete_msg_queue_ = 0; 36 | } 37 | this->msg_queue_ = msg_queue; 38 | } 39 | inline 40 | int TaskWithMQ::putq (MessageBlock *mb, 41 | const TimeValue* timeout/*= 0*/) 42 | { 43 | return this->msg_queue_->enqueue_tail (mb, timeout); 44 | } 45 | inline 46 | int TaskWithMQ::getq (MessageBlock *&mb, 47 | const TimeValue* timeout/*= 0*/) 48 | { 49 | return this->msg_queue_->dequeue_head (mb, timeout); 50 | } 51 | inline 52 | int TaskWithMQ::getq_n (MessageBlock *&mb, int number/* = -1*/, 53 | const TimeValue* timeout/*= 0*/) 54 | { 55 | return this->msg_queue_->dequeue_head_n (mb,number, timeout); 56 | } 57 | inline 58 | int TaskWithMQ::ungetq (MessageBlock *mb, 59 | const TimeValue* timeout/*= 0*/) 60 | { 61 | return this->msg_queue_->enqueue_head (mb, timeout); 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Thread.inl: -------------------------------------------------------------------------------- 1 | inline 2 | int Thread::spawn_n (size_t thr_num, 3 | THREAD_FUNC_T func, 4 | void *arg/* = 0*/, 5 | thread_t *thr_id/* = 0*/, 6 | int flags/* = THR_JOIN*/, 7 | size_t stack_size/* = 0*/) 8 | { 9 | thread_t tid = 0; 10 | size_t i; 11 | for (i = 0; i < thr_num; ++i) 12 | { 13 | if (Thread::spawn (func, arg, &tid, flags, stack_size) == 0) 14 | { 15 | if (thr_id != 0 && tid != 0) 16 | thr_id[i] = tid; 17 | }else 18 | break; 19 | } 20 | return i; 21 | } 22 | inline 23 | int Thread::join (thread_t thr_id) 24 | { 25 | SET_ERRNO_RETURN (::pthread_join (thr_id, NULL)); 26 | } 27 | inline 28 | int Thread::detach (thread_t thr_id) 29 | { 30 | SET_ERRNO_RETURN (::pthread_detach (thr_id)); 31 | } 32 | inline 33 | thread_t Thread::self () 34 | { 35 | return ::pthread_self (); 36 | } 37 | inline 38 | int Thread::thr_equal (thread_t thr_id_1, thread_t thr_id_2) 39 | { 40 | return ::pthread_equal (thr_id_1, thr_id_2); 41 | } 42 | inline 43 | int Thread::kill (thread_t thr_id, int signum) 44 | { 45 | SET_ERRNO_RETURN (::pthread_kill (thr_id, signum)); 46 | } 47 | inline 48 | void Thread::yield () 49 | { 50 | ::sched_yield (); 51 | } 52 | inline 53 | int Thread::cancel (thread_t thr_id) 54 | { 55 | SET_ERRNO_RETURN (::pthread_cancel (thr_id)); 56 | } 57 | inline 58 | void Thread::testcancel () 59 | { 60 | ::pthread_testcancel (); 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ThreadMutex.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-05 18:35 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _THREADMUTEX_H_ 9 | #define _THREADMUTEX_H_ 10 | #include "Pre.h" 11 | 12 | #include "GlobalMacros.h" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /** 19 | * @class ThreadMutex 20 | * 21 | * @brief 22 | */ 23 | class ThreadMutex 24 | { 25 | public: 26 | ThreadMutex (); 27 | ~ThreadMutex (); 28 | // 29 | int acquire (void); 30 | 31 | // acquire lock ownership in msec period 32 | int acquire (int msec); 33 | 34 | // not block if someone already had the lock , errno is EBUSY 35 | int tryacquire (void); 36 | 37 | // release lock ownership 38 | int release (void); 39 | 40 | // return mutex_t 41 | const pthread_mutex_t &lock () const; 42 | private: 43 | pthread_mutex_t mutex_; 44 | }; 45 | 46 | #include "ThreadMutex.inl" 47 | #include "Post.h" 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/ThreadMutex.inl: -------------------------------------------------------------------------------- 1 | inline 2 | ThreadMutex::ThreadMutex () 3 | { 4 | ::pthread_mutex_init (&mutex_, NULL); 5 | } 6 | inline 7 | ThreadMutex::~ThreadMutex () 8 | { 9 | ::pthread_mutex_destroy (&mutex_); 10 | } 11 | inline 12 | int ThreadMutex::acquire () 13 | { 14 | SET_ERRNO_RETURN (::pthread_mutex_lock (&mutex_)); 15 | } 16 | inline 17 | int ThreadMutex::acquire (int msec) 18 | { 19 | struct timespec ts; 20 | struct timeval tv; 21 | ::gettimeofday (&tv, NULL); 22 | ts.tv_sec = (msec / 1000) + tv.tv_sec; 23 | ts.tv_nsec = ((msec % 1000) * 1000000) + (tv.tv_usec * 1000); 24 | while (ts.tv_nsec >= 1000000000) 25 | { 26 | ts.tv_nsec -= 1000000000; 27 | ts.tv_sec++; 28 | } 29 | SET_ERRNO_RETURN (::pthread_mutex_timedlock (&mutex_, &ts)); 30 | } 31 | inline 32 | int ThreadMutex::tryacquire () 33 | { 34 | SET_ERRNO_RETURN (::pthread_mutex_trylock (&mutex_)); 35 | } 36 | inline 37 | int ThreadMutex::release () 38 | { 39 | SET_ERRNO_RETURN (::pthread_mutex_unlock (&mutex_)); 40 | } 41 | inline 42 | const pthread_mutex_t &ThreadMutex::lock () const 43 | { 44 | return mutex_; 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Token.inl: -------------------------------------------------------------------------------- 1 | inline 2 | int Token::acquire (void (*sleep_hook_func)(void *), 3 | void *arg/* = 0*/, 4 | const TimeValue *timeout/* = 0*/) 5 | { 6 | return this->shared_acquire (sleep_hook_func, arg, timeout, WRITE_TOKEN); 7 | } 8 | inline 9 | int Token::acquire (const TimeValue *timeout/* = 0*/) 10 | { 11 | return this->shared_acquire (0, 0, timeout, WRITE_TOKEN); 12 | } 13 | inline 14 | int Token::acquire_read (void (*sleep_hook_func)(void *), 15 | void *arg, 16 | const TimeValue *timeout/* = 0*/) 17 | { 18 | return this->shared_acquire (sleep_hook_func, arg, timeout, READ_TOKEN); 19 | } 20 | inline 21 | void Token::sleep_hook () 22 | { 23 | return ; 24 | } 25 | inline 26 | int Token::tryacquire () 27 | { 28 | return this->shared_acquire (0, 0, 0, WRITE_TOKEN); 29 | } 30 | inline 31 | int Token::waiters () 32 | { 33 | Guard_T g (this->lock_); 34 | return this->waiters_; 35 | } 36 | inline 37 | thread_t Token::current_owner () 38 | { 39 | Guard_T g (this->lock_); 40 | return this->owner_; 41 | } 42 | //---------------------------------------------------------------------- 43 | inline 44 | Token::TokenQueueEntry::TokenQueueEntry (ThreadMutex &lock, 45 | thread_t thr_id) 46 | : runable_ (0) 47 | , next_ (0) 48 | , thread_id_ (thr_id) 49 | , cond_ (lock) 50 | { 51 | TRACE ("Token::TokenQueueEntry"); 52 | } 53 | inline 54 | int Token::TokenQueueEntry::wait (const TimeValue *timeout) 55 | { 56 | return this->cond_.wait (timeout); 57 | } 58 | inline 59 | int Token::TokenQueueEntry::signal () 60 | { 61 | return this->cond_.signal (); 62 | } 63 | //---------------------------------------------------------------------- 64 | inline 65 | Token::TokenQueue::TokenQueue () 66 | : head_ (0) 67 | , tail_ (0) 68 | { 69 | TRACE ("Token::TokenQueue"); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Trace.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | /** 3 | * Author : cuisw 4 | * Date : 2008-01-10 23:38 5 | */ 6 | //======================================================================== 7 | 8 | #ifndef _TRACE_H__ 9 | #define _TRACE_H__ 10 | #include "Pre.h" 11 | 12 | #include "Thread.h" 13 | 14 | #include 15 | 16 | /** 17 | * @class Trace 18 | * 19 | * @brief 20 | */ 21 | class Trace 22 | { 23 | public: 24 | Trace (const char *file, const char *func, int line); 25 | ~Trace (); 26 | private: 27 | int line_; 28 | const char* file_; 29 | const char* func_; 30 | static int count_; 31 | }; 32 | #ifdef NDK_TRACE 33 | # define TRACE(X) Trace ____ (__FILE__, __PRETTY_FUNCTION__, __LINE__) 34 | #else 35 | # define TRACE(X) 36 | #endif 37 | 38 | #include "Trace.inl" 39 | #include "Post.h" 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/Trace.inl: -------------------------------------------------------------------------------- 1 | inline 2 | Trace::Trace (const char *file, const char *func, int line) 3 | :line_ (line) 4 | ,file_ (file) 5 | ,func_ (func) 6 | { 7 | Trace::count_++; 8 | std::fprintf (stderr, ": "); 9 | for (int i = 0; i < count_ * 2; i++) 10 | std::fprintf (stderr, " "); 11 | std::fprintf (stderr, "(%d)<%lu>calling `%s` in file `%s` on line `%d`\n", 12 | Trace::count_, Thread::self (), 13 | func_, file_, line_); 14 | } 15 | inline 16 | Trace::~Trace () 17 | { 18 | std::fprintf (stderr, ": "); 19 | for (int i = 0; i < count_ * 2; i++) 20 | std::fprintf (stderr, " "); 21 | std::fprintf (stderr, "(%d)<%lu>leaving `%s`\n", 22 | Trace::count_, Thread::self (), func_); 23 | Trace::count_--; 24 | } 25 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_H__1 2 | #define __CONFIG_H__1 3 | #include "Pre.h" 4 | 5 | #define NDK_DEFAULT_BACKLOG 1024 6 | #define NDK_DEFAULT_TIMERS 32 7 | #include "Post.h" 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/ReactorImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "ReactorImpl.h" 2 | #include "Trace.h" 3 | 4 | ReactorImpl::ReactorImpl () 5 | { 6 | TRACE ("ReactorImpl"); 7 | } 8 | ReactorImpl::~ReactorImpl () 9 | { 10 | TRACE ("ReactorImpl"); 11 | } 12 | // --------------------------------------------------------------------------- 13 | NotificationBuffer::NotificationBuffer () 14 | { 15 | TRACE ("NotificationBuffer"); 16 | } 17 | NotificationBuffer::NotificationBuffer (EventHandler *eh, 18 | ReactorMask mask) 19 | : eh_ (eh) 20 | , mask_ (mask) 21 | { 22 | TRACE ("NotificationBuffer"); 23 | } 24 | NotificationBuffer::~NotificationBuffer () 25 | { 26 | TRACE ("NotificationBuffer"); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/ReactorToken.cpp: -------------------------------------------------------------------------------- 1 | #include "ReactorToken.h" 2 | #include "ReactorImpl.h" 3 | 4 | void ReactorToken::sleep_hook () 5 | { 6 | TRACE ("ReactorToken"); 7 | if (this->reactor_->notify () != 0) 8 | NDK_DBG ("ReactorToken::sleep_hook failed"); 9 | } 10 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/SelectReactor.cpp: -------------------------------------------------------------------------------- 1 | #include "SelectReactor.h" 2 | #include "TimerQueue.h" 3 | #include "Guard_T.h" 4 | #include "Reactor.h" 5 | #include "Common.h" 6 | #include "Debug.h" 7 | #include "Trace.h" 8 | #include "NDK.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | SelectReactor::SelectReactor () 15 | { 16 | 17 | } 18 | SelectReactor::~SelectReactor () 19 | { 20 | 21 | } 22 | 23 | thread_t SelectReactor::owner () 24 | { 25 | Guard_T g (this->token_); 26 | return this->owner_; 27 | } 28 | void SelectReactor::owner (thread_t thr_id) 29 | { 30 | Guard_T g (this->token_); 31 | this->owner_ = thr_id; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/SvcHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "SvcHandler.h" 2 | #include "Trace.h" 3 | #include "Debug.h" 4 | 5 | SvcHandler::SvcHandler (Reactor *r/* = Reactor::instance ()*/) 6 | : closed_ (0) 7 | { 8 | this->reactor (r); 9 | } 10 | SvcHandler::~SvcHandler () 11 | { 12 | if (this->closed_ == 0) 13 | { 14 | this->closed_ = 1; 15 | this->shutdown (); 16 | } 17 | } 18 | // example code 19 | int SvcHandler::open (void *arg/* = 0*/) 20 | { 21 | unused_arg(arg); 22 | if (this->reactor () 23 | && this->reactor ()->register_handler 24 | (this, 25 | EventHandler::READ_MASK) == -1) 26 | { 27 | NDK_INF ("register handler %d failed\n", this->handle ()); 28 | return -1; 29 | } 30 | return 0; 31 | } 32 | int SvcHandler::close () 33 | { 34 | return this->handle_close (); 35 | } 36 | int SvcHandler::handle_close (NDK_HANDLE, ReactorMask) 37 | { 38 | this->destroy (); 39 | return 0; 40 | } 41 | SockStream &SvcHandler::peer () const 42 | { 43 | return (SockStream &)this->peer_; 44 | } 45 | NDK_HANDLE SvcHandler::handle () const 46 | { 47 | return this->peer_.handle (); 48 | } 49 | void SvcHandler::handle (NDK_HANDLE handle) 50 | { 51 | this->peer_.handle (handle); 52 | } 53 | void SvcHandler::destroy () 54 | { 55 | if (this->closed_ == 0) 56 | { 57 | // Will call the destructor, which automatically calls 58 | // . 59 | // is allocate by Acceptor or Connector 60 | delete this; 61 | } 62 | } 63 | void SvcHandler::shutdown (void) 64 | { 65 | if (this->reactor ()) 66 | { 67 | ReactorMask mask = EventHandler::ALL_EVENTS_MASK 68 | | EventHandler::DONT_CALL; 69 | 70 | if (this->peer ().handle () != NDK_INVALID_HANDLE) 71 | this->reactor ()->remove_handler (this, mask); 72 | } 73 | this->peer ().close (); 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/Thread.cpp: -------------------------------------------------------------------------------- 1 | #include "Thread.h" 2 | #include "Debug.h" 3 | #include "GlobalMacros.h" 4 | 5 | #include 6 | 7 | int Thread::spawn (THREAD_FUNC_T func, 8 | void *arg/* = NULL*/, 9 | thread_t *thr_id/* = 0*/, 10 | int flags/* = THR_JOIN*/, 11 | size_t stack_size/* = 0*/) 12 | { 13 | int ret_val = 0; 14 | // default thread stack size is 2M 15 | pthread_attr_t attr; 16 | // init 17 | if (::pthread_attr_init (&attr) != 0) return -1; 18 | if (stack_size != 0) 19 | { 20 | if (stack_size < PTHREAD_STACK_MIN) 21 | stack_size = PTHREAD_STACK_MIN; 22 | 23 | if (::pthread_attr_setstacksize (&attr, stack_size) != 0) 24 | { 25 | NDK_DBG ("set stacksize failed"); 26 | ::pthread_attr_destroy (&attr); 27 | return -1; 28 | } 29 | } 30 | thread_t id; 31 | if (thr_id == 0) 32 | thr_id = &id; 33 | if (::pthread_create (thr_id, &attr, func, arg) == 0) 34 | { 35 | if (NDK_BIT_ENABLED (flags, THR_DETACH)) 36 | ::pthread_detach (*thr_id); 37 | }else 38 | { 39 | NDK_DBG ("create pthread failed"); 40 | ret_val = -1; 41 | } 42 | // release 43 | ::pthread_attr_destroy (&attr); 44 | return ret_val; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/TimeValue.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeValue.h" 2 | 3 | const TimeValue TimeValue::zero; 4 | 5 | void TimeValue::normalize () 6 | { 7 | if (this->tv_.tv_usec >= 1000000) 8 | { 9 | do 10 | { 11 | ++this->tv_.tv_sec; 12 | this->tv_.tv_usec -= 1000000; 13 | }while (this->tv_.tv_usec >= 1000000); 14 | }else if (this->tv_.tv_usec <= -1000000) 15 | { 16 | do 17 | { 18 | --this->tv_.tv_sec; 19 | this->tv_.tv_usec += 1000000; 20 | }while (this->tv_.tv_usec <= -1000000); 21 | } 22 | 23 | if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0) 24 | { 25 | --this->tv_.tv_sec; 26 | this->tv_.tv_usec += 1000000; 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/netdsdk/src/Trace.cpp: -------------------------------------------------------------------------------- 1 | #include "Trace.h" 2 | 3 | int Trace::count_ = -1; 4 | 5 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/sqlite3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | db.h 3 | sqlite3.h 4 | sqlite3ext.h 5 | ) 6 | set(LIB_SRCS 7 | sqlite3.c 8 | ) 9 | 10 | add_library(sqlite3 ${LIB_SRCS} ${LIB_HEADERS}) 11 | 12 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 13 | 14 | set_target_properties(sqlite3 PROPERTIES OUTPUT_NAME "sqlite3") 15 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/sqlite3/db.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/sqlite3/db.h -------------------------------------------------------------------------------- /Server1/Engine/Ext/sqlite3/testSqite3.cpp: -------------------------------------------------------------------------------- 1 | #include "db.h" 2 | 3 | 4 | class TestMyTable:public Table{ 5 | public: 6 | int id; 7 | // int id1; 8 | std::string name; 9 | std::vector content; 10 | DEC_TABLE 11 | }; 12 | 13 | TABLE_BEGIN(TestMyTable) 14 | FIELD(id); 15 | // FIELD(id1); 16 | FIELD(name); 17 | FIELD(content); 18 | TABLE_END 19 | 20 | int main() 21 | { 22 | DB db; 23 | db.init("test"); 24 | 25 | TestMyTable *my = NULL; 26 | if (db.create(my)) 27 | { 28 | my->load(db," where id = 100"); 29 | //my->id = 100; 30 | //my->id1 = 1000111; 31 | //my->name = "hello0"; 32 | //my->content.push_back(100); 33 | //my->content.push_back(200); 34 | //my->update(db); 35 | } 36 | } -------------------------------------------------------------------------------- /Server1/Engine/Ext/tolua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${PROJECT_SOURCE_DIR}/Ext/lua 3 | ) 4 | set(LIB_HEADERS 5 | tolua_event.h 6 | tolua++.h 7 | tolua_fix.h 8 | ) 9 | set(LIB_SRCS 10 | tolua_event.c 11 | tolua_is.c 12 | tolua_map.c 13 | tolua_push.c 14 | tolua_to.c 15 | tolua_fix.c 16 | ) 17 | 18 | add_library(tolua ${LIB_SRCS} ${LIB_HEADERS}) 19 | 20 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 21 | 22 | set_target_properties(tolua PROPERTIES OUTPUT_NAME "tolua") 23 | 24 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/tolua/tolua_event.h: -------------------------------------------------------------------------------- 1 | /* tolua: event functions 2 | ** Support code for Lua bindings. 3 | ** Written by Waldemar Celes 4 | ** TeCGraf/PUC-Rio 5 | ** Apr 2003 6 | ** $Id: $ 7 | */ 8 | 9 | /* This code is free software; you can redistribute it and/or modify it. 10 | ** The software provided hereunder is on an "as is" basis, and 11 | ** the author has no obligation to provide maintenance, support, updates, 12 | ** enhancements, or modifications. 13 | */ 14 | 15 | #ifndef TOLUA_EVENT_H 16 | #define TOLUA_EVENT_H 17 | 18 | #include "tolua++.h" 19 | 20 | TOLUA_API void tolua_moduleevents (lua_State* L); 21 | TOLUA_API int tolua_ismodulemetatable (lua_State* L); 22 | TOLUA_API void tolua_classevents (lua_State* L); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/tolua/tolua_fix.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TOLUA_FIX_H_ 3 | #define __TOLUA_FIX_H_ 4 | 5 | #include "tolua++.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" 9 | { 10 | #endif 11 | 12 | #define TOLUA_REFID_PTR_MAPPING "toluafix_refid_ptr_mapping" 13 | #define TOLUA_REFID_TYPE_MAPPING "toluafix_refid_type_mapping" 14 | #define TOLUA_REFID_FUNCTION_MAPPING "toluafix_refid_function_mapping" 15 | 16 | TOLUA_API void toluafix_open(lua_State* L); 17 | TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, 18 | int uid, 19 | int* p_refid, 20 | void* ptr, 21 | const char* type); 22 | TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid); 23 | TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def); 24 | TOLUA_API void toluafix_get_function_by_refid(lua_State* L, int refid); 25 | TOLUA_API void toluafix_remove_function_by_refid(lua_State* L, int refid); 26 | TOLUA_API int toluafix_isfunction(lua_State* L, int lo, const char* type, int def, tolua_Error* err); 27 | TOLUA_API int toluafix_totable(lua_State* L, int lo, int def); 28 | TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err); 29 | TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | 35 | #endif // __TOLUA_FIX_H_ 36 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/xml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | tinyxml2.h 3 | ) 4 | set(LIB_SRCS 5 | tinyxml2.cpp 6 | ) 7 | 8 | add_library(xml ${LIB_SRCS} ${LIB_HEADERS}) 9 | 10 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 11 | 12 | set_target_properties(xml PROPERTIES OUTPUT_NAME "xml") 13 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | crc32.h 3 | deflate.h 4 | inffast.h 5 | inffixed.h 6 | inflate.h 7 | inftrees.h 8 | trees.h 9 | zconf.h 10 | zlib.h 11 | zutil.h 12 | ) 13 | set(LIB_SRCS 14 | adler32.c 15 | compress.c 16 | crc32.c 17 | deflate.c 18 | gzio.c 19 | infback.c 20 | inffast.c 21 | inflate.c 22 | inftrees.c 23 | trees.c 24 | uncompr.c 25 | zutil.c 26 | ) 27 | 28 | add_library(zlib ${LIB_SRCS} ${LIB_HEADERS}) 29 | 30 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 31 | 32 | set_target_properties(zlib PROPERTIES OUTPUT_NAME "zlib") -------------------------------------------------------------------------------- /Server1/Engine/Ext/zlib/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:zlib 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 zlib 库项目。 6 | 7 | 没有为此项目创建源文件。 8 | 9 | 10 | zlib.vcproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件, 12 | 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | 其他注释: 16 | 17 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /Server1/Engine/Ext/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zlib/zlib.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Ext/zlib/zlib.vcproj -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | ) 3 | set(LIB_SRCS 4 | src/AtomicCount.cxx 5 | src/Condition.cxx 6 | src/ConcurrentExecutor.cxx 7 | src/CountingSemaphore.cxx 8 | src/FastMutex.cxx 9 | src/FastRecursiveMutex.cxx 10 | src/Mutex.cxx 11 | src/RecursiveMutexImpl.cxx 12 | src/RecursiveMutex.cxx 13 | src/Monitor.cxx 14 | src/PoolExecutor.cxx 15 | src/PriorityCondition.cxx 16 | src/PriorityInheritanceMutex.cxx 17 | src/PriorityMutex.cxx 18 | src/PrioritySemaphore.cxx 19 | src/Semaphore.cxx 20 | src/SynchronousExecutor.cxx 21 | src/Thread.cxx 22 | src/ThreadedExecutor.cxx 23 | src/ThreadImpl.cxx 24 | src/ThreadLocalImpl.cxx 25 | src/ThreadQueue.cxx 26 | src/Time.cxx 27 | src/ThreadOps.cxx 28 | ) 29 | include_directories( 30 | . 31 | ) 32 | add_library(zthread ${LIB_SRCS} ${LIB_HEADERS}) 33 | 34 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 35 | 36 | set_target_properties(zthread PROPERTIES OUTPUT_NAME "zthread") 37 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/ConcurrentExecutor.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/ConcurrentExecutor.h" 24 | 25 | namespace ZThread { 26 | 27 | ConcurrentExecutor::ConcurrentExecutor() 28 | : _executor(1) {} 29 | 30 | void ConcurrentExecutor::interrupt() { 31 | _executor.interrupt(); 32 | } 33 | 34 | void ConcurrentExecutor::execute(const Task& task) { 35 | _executor.execute(task); 36 | } 37 | 38 | void ConcurrentExecutor::cancel() { 39 | _executor.cancel(); 40 | } 41 | 42 | bool ConcurrentExecutor::isCanceled() { 43 | return _executor.isCanceled(); 44 | } 45 | 46 | void ConcurrentExecutor::wait() { 47 | _executor.wait(); 48 | } 49 | 50 | bool ConcurrentExecutor::wait(unsigned long timeout) { 51 | return _executor.wait(timeout); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef ZTDEBUG 24 | 25 | #ifndef NDEBUG 26 | # include 27 | # define ZTDEBUG printf 28 | #else 29 | # define ZTDEBUG(x) 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/FastMutex.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/FastMutex.h" 24 | #include "FastLock.h" 25 | 26 | namespace ZThread { 27 | 28 | FastMutex::FastMutex() : _lock(new FastLock) { } 29 | 30 | FastMutex::~FastMutex() { 31 | delete _lock; 32 | } 33 | 34 | 35 | void FastMutex::acquire() { 36 | 37 | _lock->acquire(); 38 | 39 | } 40 | 41 | bool FastMutex::tryAcquire(unsigned long timeout) { 42 | 43 | return _lock->tryAcquire(timeout); 44 | 45 | } 46 | 47 | void FastMutex::release() { 48 | 49 | _lock->release(); 50 | 51 | } 52 | 53 | } // namespace ZThread 54 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/FastRecursiveMutex.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/FastRecursiveMutex.h" 24 | #include "FastRecursiveLock.h" 25 | 26 | namespace ZThread { 27 | 28 | FastRecursiveMutex::FastRecursiveMutex() 29 | : _lock(new FastRecursiveLock) { } 30 | 31 | FastRecursiveMutex::~FastRecursiveMutex() 32 | { delete _lock; } 33 | 34 | 35 | void FastRecursiveMutex::acquire() { 36 | 37 | _lock->acquire(); 38 | 39 | } 40 | 41 | bool FastRecursiveMutex::tryAcquire(unsigned long timeout) { 42 | 43 | return _lock->tryAcquire(timeout); 44 | 45 | } 46 | 47 | void FastRecursiveMutex::release() { 48 | 49 | _lock->release(); 50 | 51 | } 52 | 53 | } // namespace ZThread 54 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Monitor.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTMONITORIMPLSELECT_CXX__ 24 | #define __ZTMONITORIMPLSELECT_CXX__ 25 | 26 | #include "Monitor.h" 27 | 28 | // This file will select an implementation for a Monitor based on 29 | // what Monitor.h selects. This method is for selecting the 30 | // source files, to improve portability. Currently, the project is 31 | // based on the autoconf tool-set, which doesn't support conditional 32 | // compilation well. Additionally, this should make the library 33 | // easier to port since its working around conditional compilation 34 | // by using C++ features and people won't have to fiddle around with 35 | // their make tool as much to compile the source 36 | 37 | #include ZT_MONITOR_IMPLEMENTATION 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Mutex.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/Mutex.h" 24 | #include "MutexImpl.h" 25 | 26 | namespace ZThread { 27 | 28 | class FifoMutexImpl : public MutexImpl { }; 29 | 30 | 31 | Mutex::Mutex() { 32 | 33 | _impl = new FifoMutexImpl(); 34 | 35 | } 36 | 37 | Mutex::~Mutex() { 38 | 39 | if(_impl != 0) 40 | delete _impl; 41 | } 42 | 43 | // P 44 | void Mutex::acquire() { 45 | 46 | _impl->acquire(); 47 | 48 | } 49 | 50 | 51 | // P 52 | bool Mutex::tryAcquire(unsigned long ms) { 53 | 54 | return _impl->tryAcquire(ms); 55 | 56 | } 57 | 58 | // V 59 | void Mutex::release() { 60 | 61 | _impl->release(); 62 | 63 | } 64 | 65 | 66 | 67 | } // namespace ZThread 68 | 69 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Priority.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTPRIORITY_H__ 24 | #define __ZTPRIORITY_H__ 25 | 26 | namespace ZThread { 27 | 28 | //! Priorities 29 | typedef enum { 30 | 31 | Low, 32 | Medium = Low + 1, 33 | High = Low + 2 34 | 35 | } Priority; 36 | 37 | } 38 | 39 | #endif // __ZTPRIORITY_H__ 40 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/PriorityMutex.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/PriorityMutex.h" 24 | #include "MutexImpl.h" 25 | #include "ThreadOps.h" 26 | 27 | 28 | namespace ZThread { 29 | 30 | class PriorityMutexImpl : public MutexImpl { }; 31 | 32 | PriorityMutex::PriorityMutex() { 33 | 34 | _impl = new PriorityMutexImpl(); 35 | 36 | } 37 | 38 | PriorityMutex::~PriorityMutex() { 39 | 40 | if(_impl != 0) 41 | delete _impl; 42 | 43 | } 44 | 45 | // P 46 | void PriorityMutex::acquire() { 47 | 48 | _impl->acquire(); 49 | 50 | } 51 | 52 | 53 | // P 54 | bool PriorityMutex::tryAcquire(unsigned long ms) { 55 | 56 | return _impl->tryAcquire(ms); 57 | 58 | } 59 | 60 | // V 61 | void PriorityMutex::release() { 62 | 63 | _impl->release(); 64 | 65 | } 66 | 67 | 68 | } // namespace ZThread 69 | 70 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/RecursiveMutex.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/RecursiveMutex.h" 24 | #include "RecursiveMutexImpl.h" 25 | 26 | namespace ZThread { 27 | 28 | RecursiveMutex::RecursiveMutex() { 29 | 30 | _impl = new RecursiveMutexImpl(); 31 | 32 | } 33 | 34 | RecursiveMutex::~RecursiveMutex() { 35 | 36 | if(_impl != (RecursiveMutexImpl*)0 ) 37 | delete _impl; 38 | 39 | } 40 | 41 | 42 | void RecursiveMutex::acquire() { 43 | 44 | _impl->acquire(); 45 | 46 | } 47 | 48 | 49 | bool RecursiveMutex::tryAcquire(unsigned long ms) { 50 | 51 | return _impl->tryAcquire(ms); 52 | 53 | } 54 | 55 | void RecursiveMutex::release() { 56 | 57 | _impl->release(); 58 | 59 | } 60 | 61 | } // namespace ZThread 62 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Runnable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | 24 | #ifndef __ZTRUNNABLE_H__ 25 | #define __ZTRUNNABLE_H__ 26 | 27 | #include "zthread/Config.h" 28 | 29 | namespace ZThread { 30 | 31 | /** 32 | * @class Runnable 33 | * 34 | * @author Eric Crahen 35 | * @date <2003-07-16T17:45:35-0400> 36 | * @version 2.2.11 37 | * 38 | * Encapsulates a Runnable task. 39 | */ 40 | class Runnable { 41 | public: 42 | 43 | /** 44 | * Runnables should never throw in their destructors 45 | */ 46 | virtual ~Runnable() {} 47 | 48 | /** 49 | * Task to be performed in another thread of execution 50 | */ 51 | virtual void run() = 0; 52 | 53 | }; 54 | 55 | 56 | } 57 | 58 | #endif // __ZTRUNNABLE_H__ 59 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/TSS.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTTSSSELECT_H__ 24 | #define __ZTTSSSELECT_H__ 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | // Select the correct TSS implementation based on 31 | // what the compilation environment has defined 32 | 33 | #if defined(ZT_POSIX) 34 | 35 | #include "posix/TSS.h" 36 | 37 | #elif defined(ZT_WIN32) || defined(ZT_WIN9X) 38 | 39 | #include "win32/TSS.h" 40 | 41 | #elif defined(ZT_MACOS) 42 | 43 | #include "macos/TSS.h" 44 | 45 | #endif 46 | 47 | 48 | #ifndef __ZTTSS_H__ 49 | #error "No TSS implementation could be selected" 50 | #endif 51 | 52 | #endif // __ZTTSSSELECT_H__ 53 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/Time.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #include "zthread/Time.h" 24 | #include "TimeStrategy.h" 25 | 26 | 27 | using namespace ZThread; 28 | 29 | Time::Time() { 30 | 31 | // System startup time 32 | static TimeStrategy firstHelper; 33 | TimeStrategy helper; 34 | 35 | Time then(firstHelper.seconds(), firstHelper.milliseconds()); 36 | Time now(helper.seconds(), helper.milliseconds()); 37 | 38 | now -= then; 39 | 40 | _seconds = now.seconds(); 41 | _milliseconds = now.milliseconds(); 42 | 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/posix/PriorityOps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTPRIORITYOPS_H__ 24 | #define __ZTPRIORITYOPS_H__ 25 | 26 | #include "zthread/Priority.h" 27 | #include "../ThreadOps.h" 28 | 29 | namespace ZThread { 30 | 31 | /** 32 | * @class PriorityOps 33 | * @author Eric Crahen 34 | * @date <2003-07-16T23:30:00-0400> 35 | * @version 2.2.0 36 | * 37 | * This class is an abstraction used to perform various operations on a 38 | * native POSIX thread. 39 | */ 40 | class PriorityOps { 41 | 42 | 43 | public: 44 | 45 | 46 | }; 47 | 48 | 49 | } // namespace ZThread 50 | 51 | #endif // __ZTPRIORITYOPS_H__ 52 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/src/win32/AtomicCount.cxx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTATOMICCOUNTIMPL_H__ 24 | #define __ZTATOMICCOUNTIMPL_H__ 25 | 26 | #include 27 | #include 28 | 29 | namespace ZThread { 30 | 31 | 32 | AtomicCount::AtomicCount() { 33 | 34 | _value = reinterpret_cast(new LONG(0)); 35 | 36 | } 37 | 38 | AtomicCount::~AtomicCount() { 39 | 40 | assert(*reinterpret_cast(_value) == 0); 41 | delete reinterpret_cast(_value); 42 | 43 | } 44 | 45 | void AtomicCount::increment() { 46 | 47 | ::InterlockedIncrement(reinterpret_cast(_value)); 48 | 49 | } 50 | 51 | bool AtomicCount::decrement() { 52 | 53 | LONG v = ::InterlockedDecrement(reinterpret_cast(_value)); 54 | return static_cast(v) == 0; 55 | 56 | } 57 | 58 | }; 59 | 60 | #endif // __ZTATOMICCOUNTIMPL_H__ 61 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/zthread/Priority.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | #ifndef __ZTPRIORITY_H__ 24 | #define __ZTPRIORITY_H__ 25 | 26 | namespace ZThread { 27 | 28 | //! Priorities 29 | typedef enum { 30 | 31 | Low, 32 | Medium = Low + 1, 33 | High = Low + 2 34 | 35 | } Priority; 36 | 37 | } 38 | 39 | #endif // __ZTPRIORITY_H__ 40 | -------------------------------------------------------------------------------- /Server1/Engine/Ext/zthread/zthread/Runnable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, Eric Crahen 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is furnished 9 | * to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | */ 22 | 23 | 24 | #ifndef __ZTRUNNABLE_H__ 25 | #define __ZTRUNNABLE_H__ 26 | 27 | #include "zthread/Config.h" 28 | 29 | namespace ZThread { 30 | 31 | /** 32 | * @class Runnable 33 | * 34 | * @author Eric Crahen 35 | * @date <2003-07-16T17:45:35-0400> 36 | * @version 2.2.11 37 | * 38 | * Encapsulates a Runnable task. 39 | */ 40 | class Runnable { 41 | public: 42 | 43 | /** 44 | * Runnables should never throw in their destructors 45 | */ 46 | virtual ~Runnable() {} 47 | 48 | /** 49 | * Task to be performed in another thread of execution 50 | */ 51 | virtual void run() = 0; 52 | 53 | }; 54 | 55 | 56 | } 57 | 58 | #endif // __ZTRUNNABLE_H__ 59 | -------------------------------------------------------------------------------- /Server1/Engine/Lang/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | Code.h 3 | LangCode.h 4 | Lang.h 5 | LangScript.h 6 | LCalc.h 7 | LLib.h 8 | LNode.h 9 | Script.h 10 | ) 11 | set(LIB_SRCS 12 | Code.cpp 13 | Lang.cpp 14 | ) 15 | 16 | add_library(lang ${LIB_SRCS} ${LIB_HEADERS}) 17 | 18 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 19 | 20 | set_target_properties(lang PROPERTIES OUTPUT_NAME "lang") 21 | -------------------------------------------------------------------------------- /Server1/Engine/Lang/Code.cpp: -------------------------------------------------------------------------------- 1 | #include "Code.h" 2 | 3 | #include "Lang.h" 4 | 5 | Code * Code::clone() 6 | { 7 | Code * code = new Code(); 8 | *code = *this; 9 | return code; 10 | } 11 | bool Code::execFile(const char *fileName,Args *args) 12 | { 13 | CodeNode *code = readFromFile(fileName); 14 | if (code) 15 | { 16 | args->codeEnv = this; 17 | code->exec(args); 18 | delete code; 19 | destroy(); 20 | return true; 21 | } 22 | destroy(); 23 | return false; 24 | } 25 | 26 | int Code::exec(Args *args) 27 | { 28 | args->codeEnv = this; 29 | if (code) 30 | return code->exec(args); 31 | return CodeState::NO; 32 | } 33 | 34 | void Code::destroy() 35 | { 36 | for (ACTIONS_ITER iter = actions.begin(); iter != actions.end();++iter) 37 | { 38 | if (iter->second) delete iter->second; 39 | } 40 | actions.clear(); 41 | for (ACTIONS_ITER iter = innerVars.begin(); iter != innerVars.end();++iter) 42 | { 43 | if (iter->second) delete iter->second; 44 | } 45 | innerVars.clear(); 46 | for (CONDITIONS_ITER iter = conditions.begin();iter != conditions.end();++iter) 47 | { 48 | if (iter->second) delete iter->second; 49 | } 50 | conditions.clear(); 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Server1/Engine/Lang/LCalc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Lang/LCalc.h -------------------------------------------------------------------------------- /Server1/Engine/Lang/LLib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LangScript.h" 4 | #include "LCalc.h" 5 | 6 | -------------------------------------------------------------------------------- /Server1/Engine/Lang/LNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Lang/LNode.h -------------------------------------------------------------------------------- /Server1/Engine/Lang/Lang.cpp: -------------------------------------------------------------------------------- 1 | #include "Lang.h" 2 | 3 | int Args::exec() 4 | { 5 | if (!nowNode) return CodeState::NO; 6 | return nowNode->execChild(this); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Server1/Engine/Lang/Lang.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Lang/Lang.h -------------------------------------------------------------------------------- /Server1/Engine/Lang/LangCode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Lang/LangCode.h -------------------------------------------------------------------------------- /Server1/Engine/Lang/Script.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************** 2 | * Author jijinlong Date 2014/3/30 3 | * email:jjl_2009_hi@163.com 4 | */ 5 | #pragma once 6 | 7 | #include "Code.h" 8 | 9 | class Script{ 10 | public: 11 | std::map codes; 12 | typedef std::map::iterator CODES_ITER; 13 | void clearCodes() 14 | { 15 | for (CODES_ITER iter = codes.begin(); iter != codes.end();++iter) 16 | { 17 | if (iter->second) delete iter->second; 18 | } 19 | codes.clear(); 20 | } 21 | virtual void readFromFile(const std::string & fileName){} 22 | Code * findCode(const char *name) 23 | { 24 | CODES_ITER iter = codes.find(name); 25 | if (iter != codes.end()) return iter->second; 26 | return NULL; 27 | } 28 | template 29 | static CLASS & getMe(){ 30 | static CLASS me; 31 | return me; 32 | } 33 | void exec(const char *name,Args*args) 34 | { 35 | Code * code = findCode(name); 36 | if (code) 37 | { 38 | code->exec(args); 39 | } 40 | } 41 | std::map libs; 42 | Code * generate(const char *name) 43 | { 44 | if (!name ) return NULL; 45 | CODES_ITER iter = libs.find(name); 46 | if (iter != libs.end()) 47 | { 48 | return iter->second->clone(); 49 | } 50 | return NULL; 51 | } 52 | void addLib(const std::string &name,Code *code) 53 | { 54 | libs[name] = code; 55 | } 56 | virtual ~Script() 57 | { 58 | for (CODES_ITER iter = libs.begin(); iter != libs.end();++iter) 59 | { 60 | if (iter->second) delete iter->second; 61 | } 62 | for (CODES_ITER iter = codes.begin(); iter != codes.end();++iter) 63 | { 64 | if (iter->second) delete iter->second; 65 | } 66 | libs.clear(); 67 | codes.clear(); 68 | } 69 | }; 70 | 71 | -------------------------------------------------------------------------------- /Server1/Engine/Log/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( 3 | ${PROJECT_SOURCE_DIR}/Log 4 | ${PROJECT_SOURCE_DIR}/Log/Log4cxx/include 5 | ) 6 | 7 | 8 | set(LIB_HEADERS 9 | Logger.h 10 | ) 11 | set(LIB_SRCS 12 | Logger.cpp 13 | ) 14 | 15 | add_library(logger ${LIB_SRCS} ${LIB_HEADERS}) 16 | 17 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 18 | 19 | 20 | set_target_properties(logger PROPERTIES OUTPUT_NAME "logger") 21 | 22 | -------------------------------------------------------------------------------- /Server1/Engine/Log/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "Logger.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace log4cxx; 8 | using namespace log4cxx::helpers; 9 | 10 | #define msgFormatA(buf,msg)\ 11 | do{\ 12 | va_list ap;\ 13 | va_start(ap, msg);\ 14 | vsprintf_s(buf,sizeof(buf),msg,ap);\ 15 | va_end(ap);\ 16 | }while(0) 17 | 18 | class Log4xcc_Logger:public LoggerInterface{ 19 | public: 20 | LoggerPtr rootLogger; 21 | Log4xcc_Logger() 22 | { 23 | rootLogger = Logger::getRootLogger(); 24 | log4cxx::PropertyConfigurator::configure("log4cxx.properties"); 25 | } 26 | virtual void debug(const char * pattern, ...) 27 | { 28 | char buf[1024] = {0}; 29 | msgFormatA(buf,pattern); 30 | LOG4CXX_DEBUG(rootLogger,buf); 31 | } 32 | virtual void info(const char * pattern, ...) 33 | { 34 | char buf[1024] = {0}; 35 | msgFormatA(buf,pattern); 36 | LOG4CXX_INFO(rootLogger,buf); 37 | } 38 | virtual void error(const char * pattern, ...) 39 | { 40 | char buf[1024] = {0}; 41 | msgFormatA(buf, pattern); 42 | LOG4CXX_ERROR(rootLogger,buf); 43 | } 44 | virtual void warn(const char * pattern, ...) 45 | { 46 | char buf[1024] = {0}; 47 | msgFormatA(buf, pattern); 48 | LOG4CXX_WARN(rootLogger,buf); 49 | } 50 | }; 51 | 52 | Log4xcc_Logger logger; 53 | LoggerInterface * GetLogger() 54 | { 55 | return &logger; 56 | } -------------------------------------------------------------------------------- /Server1/Engine/Log/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class LoggerInterface{ 3 | public: 4 | virtual void debug(const char * pattern, ...) = 0; 5 | virtual void info(const char * pattern, ...) = 0; 6 | virtual void error(const char * pattern, ...) = 0; 7 | virtual void warn(const char * pattern, ...) = 0; 8 | }; 9 | 10 | extern LoggerInterface * GetLogger(); -------------------------------------------------------------------------------- /Server1/Engine/MysqlOO/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(UNIX) 2 | include_directories( 3 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO 4 | /usr/include/mysql 5 | ) 6 | ENDIF(UNIX) 7 | IF(WIN32) 8 | include_directories( 9 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO 10 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO/include 11 | ) 12 | ENDIF(WIN32) 13 | 14 | set(LIB_HEADERS 15 | mysqlDB.h 16 | ) 17 | set(LIB_SRCS 18 | mysqlDB.cpp 19 | ) 20 | IF(WIN32) 21 | LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib 22 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO/lib/debug) 23 | ENDIF(WIN32) 24 | 25 | add_library(mysqloo ${LIB_SRCS} ${LIB_HEADERS}) 26 | 27 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 28 | target_link_libraries(mysqloo mysqlclient) 29 | set_target_properties(mysqloo PROPERTIES OUTPUT_NAME "mysqloo") 30 | 31 | -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/connect.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Net/NetBase/connect.h -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/eventpool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace mynet{ 3 | class Target; 4 | enum EVENT_TYPE{ 5 | ACCEPT_EVT = 1 << 0, 6 | OUT_EVT = 1 << 1, 7 | IN_EVT =1 << 2, 8 | ERR_EVT = 1 << 3, 9 | }; 10 | 11 | 12 | /** 13 | * EevntBase */ 14 | class EventBase{ 15 | public: 16 | Target * target; // Target 17 | int eventType; // 18 | unsigned dataLen; // 19 | virtual void deal() = 0; 20 | 21 | EventBase(Target * target):target(target) 22 | { 23 | dataLen = 0; 24 | } 25 | virtual unsigned int getPeerHandle() {return 0;} 26 | 27 | bool isIn() 28 | { 29 | return eventType &IN_EVT; 30 | } 31 | bool isOut() 32 | { 33 | return eventType & OUT_EVT; 34 | } 35 | bool isErr() 36 | { 37 | return eventType & ERR_EVT; 38 | } 39 | bool isAccept() 40 | { 41 | return eventType & ACCEPT_EVT; 42 | } 43 | virtual void redo() = 0; 44 | static const unsigned int MAX_BUFFER_LEN = 9000; 45 | }; 46 | 47 | /** 48 | * EventPool 49 | **/ 50 | class EventPool { 51 | public: 52 | EventPool() 53 | { 54 | 55 | } 56 | bool init(); 57 | void* poolHandle; 58 | void bindEvent(Target *target,int eventType); 59 | EventBase* pullEvent(); 60 | }; 61 | }; -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/mynet.h: -------------------------------------------------------------------------------- 1 | #include "connect.h" 2 | 3 | #include "eventpool.h" 4 | 5 | #include "mylist.h" 6 | 7 | -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/record.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | /** 6 | * windows network epoll 7 | */ 8 | namespace mynet{ 9 | /** 10 | * Record 11 | */ 12 | class Record{ 13 | public: 14 | Record(void *cmd,unsigned int len) 15 | { 16 | contents = new unsigned char[len]; 17 | memcpy(contents,cmd,len); 18 | contentSize = len; 19 | offset = 0; 20 | } 21 | Record() 22 | { 23 | offset = 0; 24 | contentSize = 0; 25 | contents = NULL; 26 | } 27 | ~Record() 28 | { 29 | if (contents) delete contents; 30 | contents = NULL; 31 | } 32 | virtual unsigned int recv(void *buffer,unsigned int len) 33 | { 34 | if (empty()) return 0; 35 | len = leftsize() < len ? leftsize(): len; 36 | memcpy(buffer,contents + offset,len); 37 | offset += len; 38 | return len; 39 | } 40 | unsigned int leftsize() 41 | { 42 | return contentSize - offset; 43 | } 44 | template 45 | bool sendOver(CONNECTION *connection) 46 | { 47 | unsigned int leftSize = leftsize(); 48 | if ( 0 == leftSize) return true; 49 | int sendLen = connection->send(contents + offset,leftSize); 50 | offset += sendLen; 51 | if (sendLen < leftSize) return false; 52 | return true; 53 | } 54 | unsigned int offset; 55 | bool empty() 56 | { 57 | return offset == contentSize; 58 | } 59 | unsigned int contentSize; 60 | unsigned char *contents; 61 | }; 62 | }; -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/target.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mynet{ 4 | class EventBase; 5 | /** 6 | * Target */ 7 | class Target{ 8 | public: 9 | virtual unsigned long getHandle() = 0; 10 | virtual unsigned long getPeerHandle() {return 0;} 11 | EventBase *inEvt; 12 | EventBase *outEvt; 13 | Target() 14 | { 15 | inEvt = outEvt = NULL; 16 | } 17 | virtual void destroy() 18 | { 19 | if (inEvt) 20 | delete inEvt; 21 | if (outEvt) 22 | delete outEvt; 23 | inEvt = NULL; 24 | outEvt = NULL; 25 | } 26 | virtual void doSend(EventBase *evt,bool over = true){}; 27 | }; 28 | }; -------------------------------------------------------------------------------- /Server1/Engine/Net/NetBase/win32helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #pragma comment(lib,"ws2_32.lib") 6 | class AcceptHelper{ 7 | public: 8 | AcceptHelper(){initLib = false;} 9 | void init(unsigned int socket) 10 | { 11 | if (initLib) return; 12 | initLib = true; 13 | GUID GuidAcceptEx = WSAID_ACCEPTEX; 14 | DWORD dwBytes = 0; 15 | if(SOCKET_ERROR == WSAIoctl( 16 | socket, 17 | SIO_GET_EXTENSION_FUNCTION_POINTER, 18 | &GuidAcceptEx, 19 | sizeof(GuidAcceptEx), 20 | &m_lpfnAcceptEx, 21 | sizeof(m_lpfnAcceptEx), 22 | &dwBytes, 23 | NULL, 24 | NULL)) 25 | { 26 | initLib = false; 27 | } 28 | } 29 | static AcceptHelper &getMe() 30 | { 31 | static AcceptHelper helper; 32 | return helper; 33 | } 34 | void doAccept(SOCKET socket,SOCKET handle,WSABUF *lbuf,OVERLAPPED *lp) 35 | { 36 | init(socket); 37 | DWORD dwBytes = 0; 38 | if(FALSE == (m_lpfnAcceptEx)(socket, 39 | handle, 40 | lbuf->buf,0, 41 | sizeof(SOCKADDR_IN)+16, sizeof(SOCKADDR_IN)+16, &dwBytes, lp)) 42 | { 43 | 44 | } 45 | } 46 | bool initLib; 47 | LPFN_ACCEPTEX m_lpfnAcceptEx; 48 | }; -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyClient.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Net/Server/MyClient.h -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyConnection.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Net/Server/MyConnection.h -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "mynet.h" 3 | #include "pointer.h" 4 | #include "MyTick.h" 5 | #include "MyConnection.h" 6 | #include 7 | class MyPool:public mynet::EventPool,public MyTick{ 8 | public: 9 | static MyPool& getMe() 10 | { 11 | static MyPool pool; 12 | return pool; 13 | } 14 | MyPool() 15 | { 16 | theTick.addTick(this); 17 | } 18 | void add(mynet::Connection *conn) 19 | { 20 | for (POINTERS_ITER iter = pointers.begin(); iter != pointers.end();++iter) 21 | { 22 | if (conn == iter->pointer()) return; 23 | } 24 | pointers.push_back(Pointer(conn)); 25 | } 26 | void remove(mynet::Connection *conn) 27 | { 28 | for (POINTERS_ITER iter = pointers.begin(); iter != pointers.end();++iter) 29 | { 30 | if (conn == iter->pointer()) 31 | { 32 | pointers.erase(iter); 33 | return; 34 | } 35 | } 36 | } 37 | std::list > pointers; 38 | typedef std::list >::iterator POINTERS_ITER; 39 | 40 | void tick() 41 | { 42 | for (POINTERS_ITER iter = pointers.begin(); iter != pointers.end();) 43 | { 44 | MyConnection *tick = (MyConnection*)iter->pointer(); 45 | if (tick && tick->checkActive()) 46 | { 47 | tick->tick(); 48 | } 49 | ++iter; 50 | } 51 | } 52 | ~MyPool() 53 | { 54 | theTick.removeTick(this); 55 | } 56 | }; 57 | 58 | #define thePool MyPool::getMe() -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Net/Server/MyServer.h -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyTime.cpp: -------------------------------------------------------------------------------- 1 | #include "MyTime.h" 2 | #include 3 | #ifdef WIN32 4 | # include 5 | #else 6 | # include 7 | #endif 8 | 9 | #ifdef WIN32 10 | int gettimeofday(struct timeval *tp, void *tzp) 11 | { 12 | time_t clock; 13 | struct tm tm; 14 | SYSTEMTIME wtm; 15 | 16 | GetLocalTime(&wtm); 17 | tm.tm_year = wtm.wYear - 1900; 18 | tm.tm_mon = wtm.wMonth - 1; 19 | tm.tm_mday = wtm.wDay; 20 | tm.tm_hour = wtm.wHour; 21 | tm.tm_min = wtm.wMinute; 22 | tm.tm_sec = wtm.wSecond; 23 | tm. tm_isdst = -1; 24 | clock = mktime(&tm); 25 | tp->tv_sec = clock; 26 | tp->tv_usec = wtm.wMilliseconds * 1000; 27 | 28 | return (0); 29 | } 30 | #endif 31 | 32 | 33 | double MyTime::getNowSecs() 34 | { 35 | struct timeval tv; 36 | gettimeofday(&tv,NULL); 37 | return tv.tv_sec; 38 | } 39 | double MyTime::getNowMSecs() 40 | { 41 | struct timeval tv; 42 | gettimeofday(&tv,NULL); 43 | return tv.tv_sec * 1000 + tv.tv_usec/1000; 44 | } -------------------------------------------------------------------------------- /Server1/Engine/Net/Server/MyTime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MyTime{ 4 | public: 5 | static double getNowSecs(); 6 | static double getNowMSecs(); 7 | }; -------------------------------------------------------------------------------- /Server1/Engine/Pack/BinPack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Pack/BinPack.h -------------------------------------------------------------------------------- /Server1/Engine/Pack/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_HEADERS 2 | BinPack.h 3 | jsonPack.h 4 | MsgPack.h 5 | XmlPack.h 6 | TcpMsgPack.h 7 | ) 8 | -------------------------------------------------------------------------------- /Server1/Engine/Pack/FileMsgPack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Pack/FileMsgPack.h -------------------------------------------------------------------------------- /Server1/Engine/Pack/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Pack/README.md -------------------------------------------------------------------------------- /Server1/Engine/Pack/TcpMsgPack.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Pack/TcpMsgPack.h -------------------------------------------------------------------------------- /Server1/Engine/README.md: -------------------------------------------------------------------------------- 1 | LExt ZTCPTASK JSON ZLIB XML2 Sqlite3 LUA CJSON BASE64 2 | 3 | NetWork MINE 4 | 5 | Lang MINE Script System 6 | 7 | Pack MINE MSGPACK BINPACK XML2 JSON 8 | 9 | Remote 10 | 11 | MysqlOO MINE OO FOR DATABASE 12 | 13 | Thread MINE 14 | 15 | Time MINE 16 | 17 | Log LOG->INTERFACE 18 | 19 | ENGINE 1.LOG 2.NETWORK 3.TIME 4.THREAD 5.SCRIPT 6.ARICHIVE 7.DES 8.DATABASE 9.ZLIB 10.CONFILE  20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Server1/Engine/Remote/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(WIN32) 2 | include_directories( 3 | ${PROJECT_SOURCE_DIR}/Engine/Pack 4 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/win 5 | ${PROJECT_SOURCE_DIR}/Engine/Ext/zlib 6 | ) 7 | ENDIF(WIN32) 8 | IF(UNIX) 9 | include_directories( 10 | ${PROJECT_SOURCE_DIR}/Engine/Pack 11 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/inc 12 | ${PROJECT_SOURCE_DIR}/Engine/Ext/zlib 13 | ) 14 | ENDIF(UNIX) 15 | set(LIB_HEADERS 16 | Net.h 17 | RemoteObject.h 18 | message.h 19 | ) 20 | set(LIB_SRCS 21 | Net.cpp 22 | ) 23 | 24 | add_library(Remote ${LIB_SRCS} ${LIB_HEADERS}) 25 | 26 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 27 | 28 | set_target_properties(Remote PROPERTIES OUTPUT_NAME "Remote") 29 | -------------------------------------------------------------------------------- /Server1/Engine/Remote/Net.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Remote/Net.h -------------------------------------------------------------------------------- /Server1/Engine/Remote/message.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Remote/message.h -------------------------------------------------------------------------------- /Server1/Engine/Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | IF(UNIX) 3 | include_directories( 4 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/inc 5 | ${PROJECT_SOURCE_DIR}/Engine/Ext/xml 6 | ${PROJECT_SOURCE_DIR}/Engine/Ext/cjson 7 | ${PROJECT_SOURCE_DIR}/Engine/Pack 8 | ${PROJECT_SOURCE_DIR}/Engine/Remote 9 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO 10 | /usr/include/mysql 11 | ) 12 | ENDIF(UNIX) 13 | IF(WIN32) 14 | include_directories( 15 | ${PROJECT_SOURCE_DIR}/Engine/Ext/netbase/win 16 | ${PROJECT_SOURCE_DIR}/Engine/Ext/xml 17 | ${PROJECT_SOURCE_DIR}/Engine/Ext/cjson 18 | ${PROJECT_SOURCE_DIR}/Engine/Pack 19 | ${PROJECT_SOURCE_DIR}/Engine/Remote 20 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO 21 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO/include 22 | ) 23 | ENDIF(WIN32) 24 | 25 | IF(UNIX) 26 | LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib /usr/lib64/mysql/) 27 | ENDIF(UNIX) 28 | 29 | IF(WIN32) 30 | LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib 31 | ${PROJECT_SOURCE_DIR}/Engine/MysqlOO/lib/debug) 32 | ENDIF(WIN32) 33 | 34 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 35 | add_executable(TestXmlPack testXmlPack.cpp) 36 | target_link_libraries(TestXmlPack xml) 37 | 38 | add_executable(TestJsonPack testJsonPack.cpp) 39 | target_link_libraries(TestJsonPack cjson) 40 | 41 | add_executable(TestMsgPack testMsgPack.cpp) 42 | 43 | 44 | add_executable(TestRemote TestRemote.cpp) 45 | IF(UNIX) 46 | target_link_libraries(TestRemote Remote Netbase pthread) 47 | ENDIF(UNIX) 48 | IF(WIN32) 49 | target_link_libraries(TestRemote Remote Netbase) 50 | ENDIF(WIN32) 51 | 52 | add_executable(TestMysql testMysql.cpp) 53 | IF(UNIX) 54 | target_link_libraries(TestMysql pthread mysqlclient dl rt zlib ssl mysqloo) 55 | ENDIF(UNIX) 56 | 57 | IF(WIN32) 58 | target_link_libraries(TestMysql mysqloo mysqlclient) 59 | ENDIF(WIN32) 60 | 61 | 62 | add_executable(TestMsgFunction testMsgFunction.cpp) -------------------------------------------------------------------------------- /Server1/Engine/Samples/TestRemote.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Engine/Samples/TestRemote.cpp -------------------------------------------------------------------------------- /Server1/Engine/Samples/testJsonPack.cpp: -------------------------------------------------------------------------------- 1 | #include "JsonPack.h" 2 | 3 | class Object1{ 4 | public: 5 | std::string a; 6 | int b; 7 | std::vector cs; 8 | std::map ds; 9 | }; 10 | 11 | IMP_JSON_OBJECT(Object1) 12 | { 13 | JSONBIND(a); 14 | JSONBIND(b); 15 | JSONBIND(cs); 16 | JSONBIND(ds); 17 | } 18 | 19 | int main() 20 | { 21 | JsonPack p; 22 | Object1 o; 23 | o.b = 1000; 24 | o.cs.push_back(1); 25 | o.cs.push_back(2); 26 | o.ds["1"] = "2"; 27 | o.ds["2"] = "3"; 28 | p.write(o,"tt"); 29 | 30 | std::string tt = p.toString().c_str(); 31 | printf("json:%s\n",tt.c_str()); 32 | 33 | Object1 o2; 34 | p.read(o2,"tt"); 35 | printf("o2.a=%d\n",o2.b); 36 | } 37 | -------------------------------------------------------------------------------- /Server1/Engine/Samples/testMsgFunction.cpp: -------------------------------------------------------------------------------- 1 | #include "message.h" 2 | #include "string.h" 3 | class Object1{ 4 | public: 5 | void init() 6 | { 7 | printf("hello,world\n"); 8 | } 9 | void sayHello(int a) 10 | { 11 | printf("o sayHello :%u\n",a); 12 | } 13 | void doArg2(int a,const std::string &b) 14 | { 15 | printf("o doArg2 %u %s\n",a,b.c_str()); 16 | } 17 | void doArg3(int a,const std::string &b,float c) 18 | { 19 | printf("o doArg3 %u %s %f\n",a,b.c_str(),c); 20 | } 21 | 22 | void doArg4(int a,const std::string &b,float c,int d) 23 | { 24 | printf("o doArg4 %u %s %f %d\n",a,b.c_str(),c,d); 25 | } 26 | }; 27 | 28 | void init() 29 | { 30 | printf("hello,world2\n"); 31 | } 32 | 33 | void sayHello(int a) 34 | { 35 | printf("sayHello :%u\n",a); 36 | } 37 | 38 | int main() 39 | { 40 | Object1 object; 41 | msg::call(&object,msg::bind(&Object1::init)); 42 | 43 | msg::call(msg::bind(init)); 44 | 45 | msg::call(msg::bind(sayHello),100); 46 | 47 | msg::call(&object,msg::bind(&Object1::sayHello),100); 48 | 49 | 50 | msg::call(&object,msg::bind(&Object1::doArg2),100,"test2"); 51 | 52 | msg::call(&object,msg::bind(&Object1::doArg3),100,"test3",(float)1000.1); 53 | 54 | msg::call(&object,msg::bind(&Object1::doArg4),100,"test4",(float)1000.1,5000); 55 | 56 | return 0; 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Server1/Engine/Samples/testMsgPack.cpp: -------------------------------------------------------------------------------- 1 | #include "MsgPack.h" 2 | 3 | struct Test{ 4 | int a; 5 | Test() 6 | { 7 | a = 0; 8 | } 9 | Test(int c):a(c){} 10 | }; 11 | 12 | struct MSG{ 13 | int b; 14 | std::vector tests; 15 | int c; 16 | char a[100]; 17 | }; 18 | 19 | IMP_MSG_OBJECT(Test) 20 | { 21 | MSGBIND(a); 22 | } 23 | 24 | IMP_MSG_OBJECT(MSG) 25 | { 26 | MSGBIND(b); 27 | MSGBIND(tests); 28 | MSGBIND(c); 29 | MSGBIND(a); 30 | } 31 | 32 | 33 | int main() 34 | { 35 | std::string content; 36 | MsgPack pack(content); 37 | MSG msg1; 38 | msg1.b = 1001; 39 | msg1.c = 1002; 40 | msg1.tests.push_back(Test(1)); 41 | msg1.tests.push_back(Test(2)); 42 | strncpy(msg1.a,"helloworld",11); 43 | pack.write(msg1); 44 | 45 | 46 | MSG msg2; 47 | pack.read(msg2); 48 | printf("%d %d\n",msg2.b,msg2.c); 49 | } 50 | -------------------------------------------------------------------------------- /Server1/Engine/Samples/testMysql.cpp: -------------------------------------------------------------------------------- 1 | #include "mysqlDB.h" 2 | class Object:public mysql::Table{ 3 | public: 4 | int id; 5 | std::string name; 6 | std::vector buffer; 7 | char name1[10]; 8 | DEC_TABLE 9 | }; 10 | 11 | TABLE_BEGIN(Object) 12 | FIELD(id); 13 | FIELD(name); 14 | FIELD(name1); 15 | FIELD(buffer); 16 | TABLE_END 17 | 18 | 19 | class Test1:public mysql::Table{ 20 | public: 21 | int a; 22 | int b; 23 | int c; 24 | DEC_TABLE 25 | }; 26 | TABLE_BEGIN(Test1) 27 | FIELD(a); 28 | FIELD(b); 29 | FIELD(c); 30 | TABLE_END 31 | int main() 32 | { 33 | 34 | mysql::DB db; 35 | db.init("127.0.0.1","test","root","123456"); 36 | Object *object = NULL; 37 | if (db.create(object)) 38 | { 39 | #if (0) 40 | printf("create object success\n"); 41 | object->name = "hello"; 42 | object->id = 10001; 43 | object->buffer.resize(10); 44 | strncpy(object->name1,"jin",4); 45 | strncpy(&object->buffer[0],"jhewewe",8); 46 | object->add(db); 47 | #else 48 | object->load(db,"where `a`=10001"); 49 | #endif 50 | delete object; 51 | } 52 | 53 | Test1 * test1 = NULL; 54 | if (db.create(test1)) 55 | { 56 | #if (0) 57 | test1->a = test1->b = test1->c = 10001; 58 | test1->add(db); 59 | #else 60 | test1->load(db,""); 61 | #endif 62 | delete test1; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Server1/Engine/Samples/testXmlPack.cpp: -------------------------------------------------------------------------------- 1 | #include "XmlPack.h" 2 | class Object1{ 3 | public: 4 | int d; 5 | Object1() 6 | { 7 | d = 0; 8 | } 9 | }; 10 | 11 | class Object{ 12 | public: 13 | int a; 14 | int c; 15 | Object1 object1; 16 | Object() 17 | { 18 | a = 1; 19 | c = 2; 20 | } 21 | std::string d; 22 | std::vector es; 23 | std::vector os; 24 | std::map ms; 25 | }; 26 | IMP_XML_OBJECT(Object1) 27 | { 28 | XMLBIND(d); 29 | } 30 | IMP_XML_OBJECT(Object) 31 | { 32 | XMLBIND(a); 33 | XMLBIND(object1); 34 | XMLBIND(c); 35 | XMLBIND(d); 36 | XMLBIND(es); 37 | XMLBIND(os); 38 | XMLBIND(ms); 39 | } 40 | 41 | int main() 42 | { 43 | XmlPack p("tt"); 44 | Object o; 45 | o.es.push_back(2); 46 | o.os.push_back(Object1()); 47 | o.ms["tt"] = Object1(); 48 | o.ms["tt1"] = Object1(); 49 | p.WRITE(o); 50 | 51 | Object o1; 52 | p.read(o1,"o1"); 53 | p.save(); 54 | } 55 | -------------------------------------------------------------------------------- /Server1/Engine/Thread/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "mythread.h" 2 | 3 | class MyRun:public mythread::Runnable{ 4 | public: 5 | MyRun() 6 | { 7 | tag = true; 8 | } 9 | void start() 10 | { 11 | tag = true; 12 | } 13 | void run() 14 | { 15 | int index = 0; 16 | while(isAlive()) 17 | { 18 | mythread::mysleep(1); 19 | printf("%d\n",index++); 20 | if (index == 4) break; 21 | } 22 | } 23 | bool isAlive() 24 | { 25 | return tag; 26 | } 27 | void stop() 28 | { 29 | tag = false; 30 | } 31 | bool tag; 32 | }; 33 | 34 | int main() 35 | { 36 | mythread::Thread thread; 37 | thread.start(); 38 | // thread.stop(); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Server1/Engine/Thread/mythread.cpp: -------------------------------------------------------------------------------- 1 | #include "platfrom.h" 2 | 3 | #ifdef PLATFORM == PLATFORM_WIN32 4 | #include "mythread_win.cpp" 5 | #else 6 | #include "mythread_posix.cpp" 7 | #endif -------------------------------------------------------------------------------- /Server1/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/ReadMe.txt -------------------------------------------------------------------------------- /Server1/Severs/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Severs/CMakeLists.txt -------------------------------------------------------------------------------- /Server1/Severs/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lang4/server/e3c178db3b6c6552c60b007cac8ffaa6d3c43c10/Server1/Severs/main.cpp -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | 要做的 2 | ====== 3 | 4 | ### remote优化
5 | 1.完善的PACK(1)消息机制 6 | 2.完善的MSGPack 机制 7 | 3.完善的函数机制 8 | 4.完善的面向消息的编程机制 9 | ### 代码规范化 10 | 1.命名规范 11 | 2.注释规范 12 | ### mysqloo优化 13 | 1.支撑严格的字段类型定义 14 | 2.更好的变更更新算法 15 | 3.支撑原生的API封装 使“封装太深原始的API不能用” 的限制取消 16 | ### libuv的植入 17 | 1.使用libuv 代替zt的网络层 18 | --------------------------------------------------------------------------------