qtcreator stuff
This commit is contained in:
parent
58ede88190
commit
6944f7cf56
128
.cproject
128
.cproject
@ -1,128 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.1175022483" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.233708494" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/metacall/Debug}" id="cdt.managedbuild.builder.gnu.cross.77822387" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1563166260" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.56775548" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.36655726" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.925199005" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.386912535" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1808849438" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1643821916" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1503435504" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.307941657" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1154407111" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1151373719" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.release.1378669920">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.release.1378669920" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.release.1378669920" name="Release" parent="cdt.managedbuild.config.gnu.cross.exe.release">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.1378669920." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.release.1571773667" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.8512467" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/metacall/Release}" id="cdt.managedbuild.builder.gnu.cross.619419963" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1711542176" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.255760720" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.372638906" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.369561120" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1123653474" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1438013040" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1873574586" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1277666674" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1616239286" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.606927276" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1785581864" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="metacall.cdt.managedbuild.target.gnu.cross.exe.746250292" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853;cdt.managedbuild.config.gnu.cross.exe.debug.1289067853.;cdt.managedbuild.tool.gnu.cross.c.compiler.1563166260;cdt.managedbuild.tool.gnu.c.compiler.input.925199005">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1378669920;cdt.managedbuild.config.gnu.cross.exe.release.1378669920.;cdt.managedbuild.tool.gnu.cross.c.compiler.1711542176;cdt.managedbuild.tool.gnu.c.compiler.input.369561120">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1378669920;cdt.managedbuild.config.gnu.cross.exe.release.1378669920.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1123653474;cdt.managedbuild.tool.gnu.cpp.compiler.input.1277666674">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1890384068;cdt.managedbuild.config.gnu.cross.exe.release.1890384068.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.187617083;cdt.managedbuild.tool.gnu.cpp.compiler.input.1953693897">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1514346646;cdt.managedbuild.config.gnu.cross.exe.release.1514346646.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.505708923;cdt.managedbuild.tool.gnu.cpp.compiler.input.998082989">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1514346646;cdt.managedbuild.config.gnu.cross.exe.release.1514346646.;cdt.managedbuild.tool.gnu.cross.c.compiler.1220077519;cdt.managedbuild.tool.gnu.c.compiler.input.2006934583">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1271011940;cdt.managedbuild.config.gnu.cross.exe.debug.1271011940.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.844727412;cdt.managedbuild.tool.gnu.cpp.compiler.input.1897811097">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1051251775;cdt.managedbuild.config.gnu.cross.exe.debug.1051251775.;cdt.managedbuild.tool.gnu.cross.c.compiler.1211335789;cdt.managedbuild.tool.gnu.c.compiler.input.1410285400">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1289067853;cdt.managedbuild.config.gnu.cross.exe.debug.1289067853.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.386912535;cdt.managedbuild.tool.gnu.cpp.compiler.input.1503435504">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1271011940;cdt.managedbuild.config.gnu.cross.exe.debug.1271011940.;cdt.managedbuild.tool.gnu.cross.c.compiler.1395125617;cdt.managedbuild.tool.gnu.c.compiler.input.1032269321">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1890384068;cdt.managedbuild.config.gnu.cross.exe.release.1890384068.;cdt.managedbuild.tool.gnu.cross.c.compiler.843888494;cdt.managedbuild.tool.gnu.c.compiler.input.245439060">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1051251775;cdt.managedbuild.config.gnu.cross.exe.debug.1051251775.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.872625146;cdt.managedbuild.tool.gnu.cpp.compiler.input.696180559">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
Debug
|
||||
Release
|
||||
*.pyc
|
||||
*.user
|
||||
|
89
.project
89
.project
@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>metacall</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/metacall/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?>
|
||||
|
||||
<pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
</pydev_project>
|
2
main.cpp
2
main.cpp
@ -67,7 +67,7 @@ static void serverTest1(const char str[], int num) {
|
||||
// Program entry
|
||||
//
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int, char *[]) {
|
||||
const int port = 1234;
|
||||
|
||||
Server server;
|
||||
|
@ -140,7 +140,7 @@ bool Socket::connect(const char name[], int port) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sockaddr_in host = { 0 };
|
||||
sockaddr_in host;
|
||||
host.sin_port = htons(static_cast<unsigned short>(port));
|
||||
host.sin_family = AF_INET;
|
||||
host.sin_addr.s_addr = address;
|
||||
@ -156,7 +156,7 @@ bool Socket::connect(const char name[], int port) {
|
||||
bool Socket::bind(int port) {
|
||||
ASSERT(opened());
|
||||
|
||||
sockaddr_in host = { 0 };
|
||||
sockaddr_in host;
|
||||
host.sin_family = AF_INET;
|
||||
host.sin_addr.s_addr = INADDR_ANY;
|
||||
host.sin_port = htons(static_cast<unsigned short>(port));
|
||||
@ -262,8 +262,9 @@ bool Socket::wait(unsigned mask, int seconds) const {
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
timeval timeoutVal = { 0 };
|
||||
timeval timeoutVal;
|
||||
timeoutVal.tv_sec = seconds;
|
||||
timeoutVal.tv_usec = 0;
|
||||
|
||||
timeval* const timeoutPtr = seconds < 0 ? NULL : &timeoutVal;
|
||||
const int result = select(
|
||||
@ -303,7 +304,7 @@ const char* Socket::hostname() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sockaddr_in host = { 0 };
|
||||
sockaddr_in host;
|
||||
socklen_t hostSize = sizeof(host);
|
||||
sockaddr* const hostPtr = reinterpret_cast<sockaddr*>(&host);
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace metacall {
|
||||
|
||||
template <typename T>
|
||||
Stream::State Stream::send(const T& packet) {
|
||||
if (!socket_->connected()) {
|
||||
if (!m_socket->connected()) {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ Stream::State Stream::send(const T& packet) {
|
||||
serializerTemp.offset()
|
||||
);
|
||||
|
||||
Serializer serializerSend(&buffSend_);
|
||||
Serializer serializerSend(&m_buffSend);
|
||||
serializerSend.write(header);
|
||||
serializerSend.writeRaw(buffTemp.data(), buffTemp.bytes());
|
||||
|
||||
@ -51,7 +51,7 @@ Stream::State Stream::send(const T& packet) {
|
||||
|
||||
template <typename T>
|
||||
Stream::State Stream::receive(T* packet) {
|
||||
if (!socket_->connected()) {
|
||||
if (!m_socket->connected()) {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
@ -63,14 +63,14 @@ Stream::State Stream::receive(T* packet) {
|
||||
return state;
|
||||
}
|
||||
|
||||
buffRecv_.removeFromFront(NULL, headerSize);
|
||||
m_buffRecv.removeFromFront(NULL, headerSize);
|
||||
|
||||
Deserializer deserializer(&buffRecv_);
|
||||
Deserializer deserializer(&m_buffRecv);
|
||||
const bool success =
|
||||
deserializer.read(packet) &&
|
||||
deserializer.offset() == static_cast<int>(header.size);
|
||||
|
||||
buffRecv_.removeFromFront(NULL, header.size);
|
||||
m_buffRecv.removeFromFront(NULL, header.size);
|
||||
|
||||
return success ? STATE_READY : STATE_ERROR_PROTOCOL;
|
||||
}
|
||||
|
@ -43,31 +43,31 @@ enum {
|
||||
//
|
||||
|
||||
Stream::Stream(Socket* socket) :
|
||||
socket_(socket)
|
||||
m_socket(socket)
|
||||
{
|
||||
}
|
||||
|
||||
Stream::State Stream::advance() {
|
||||
if (!socket_->connected()) {
|
||||
if (!m_socket->connected()) {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
if (buffSend_.bytes() > 0 && socket_->wait(Socket::MASK_WRITE, 0)) {
|
||||
const int bytesSent = socket_->send(
|
||||
buffSend_.data(),
|
||||
buffSend_.bytes()
|
||||
if (m_buffSend.bytes() > 0 && m_socket->wait(Socket::MASK_WRITE, 0)) {
|
||||
const int bytesSent = m_socket->send(
|
||||
m_buffSend.data(),
|
||||
m_buffSend.bytes()
|
||||
);
|
||||
|
||||
if (bytesSent <= 0) {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
buffSend_.removeFromFront(NULL, bytesSent);
|
||||
m_buffSend.removeFromFront(NULL, bytesSent);
|
||||
}
|
||||
|
||||
if (socket_->wait(Socket::MASK_READ, 0)) {
|
||||
if (m_socket->wait(Socket::MASK_READ, 0)) {
|
||||
byte buffRecv[SOCKET_BUFFER_SIZE];
|
||||
const int bytesRecv = socket_->receive(
|
||||
const int bytesRecv = m_socket->receive(
|
||||
buffRecv,
|
||||
sizeof(buffRecv)
|
||||
);
|
||||
@ -76,23 +76,23 @@ Stream::State Stream::advance() {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
buffRecv_.addToBack(buffRecv, bytesRecv);
|
||||
m_buffRecv.addToBack(buffRecv, bytesRecv);
|
||||
}
|
||||
|
||||
return STATE_READY;
|
||||
}
|
||||
|
||||
void Stream::reset() {
|
||||
buffSend_.clear();
|
||||
buffRecv_.clear();
|
||||
m_buffSend.clear();
|
||||
m_buffRecv.clear();
|
||||
}
|
||||
|
||||
Stream::State Stream::peek(PacketHeader* header, int* headerSize) {
|
||||
if (!socket_->connected()) {
|
||||
if (!m_socket->connected()) {
|
||||
return STATE_ERROR_CONNECTION;
|
||||
}
|
||||
|
||||
Deserializer deserializer(&buffRecv_);
|
||||
Deserializer deserializer(&m_buffRecv);
|
||||
if (!deserializer.read(header)) {
|
||||
return STATE_PENDING_PACKET_HEADER;
|
||||
}
|
||||
@ -104,7 +104,7 @@ Stream::State Stream::peek(PacketHeader* header, int* headerSize) {
|
||||
*headerSize = deserializer.offset();
|
||||
|
||||
const int packetSize = static_cast<int>(header->size) + *headerSize;
|
||||
if (buffRecv_.bytes() < packetSize) {
|
||||
if (m_buffRecv.bytes() < packetSize) {
|
||||
return STATE_PENDING_PACKET_BODY;
|
||||
}
|
||||
|
||||
@ -112,11 +112,11 @@ Stream::State Stream::peek(PacketHeader* header, int* headerSize) {
|
||||
}
|
||||
|
||||
const Socket* Stream::socket() const {
|
||||
return socket_;
|
||||
return m_socket;
|
||||
}
|
||||
|
||||
Socket* Stream::socket() {
|
||||
return socket_;
|
||||
return m_socket;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,22 +44,22 @@ class Stream {
|
||||
|
||||
Stream(Socket* socket);
|
||||
|
||||
State advance ();
|
||||
void reset ();
|
||||
State advance();
|
||||
void reset();
|
||||
|
||||
template <typename T>
|
||||
State send (const T& packet);
|
||||
State send(const T& packet);
|
||||
template <typename T>
|
||||
State receive (T* packet);
|
||||
State peek (PacketHeader* header, int* headerSize);
|
||||
State receive(T* packet);
|
||||
State peek(PacketHeader* header, int* headerSize);
|
||||
|
||||
const Socket* socket () const;
|
||||
Socket* socket ();
|
||||
const Socket* socket() const;
|
||||
Socket* socket();
|
||||
|
||||
private:
|
||||
Socket* socket_;
|
||||
Buffer buffRecv_;
|
||||
Buffer buffSend_;
|
||||
Socket* m_socket;
|
||||
Buffer m_buffRecv;
|
||||
Buffer m_buffSend;
|
||||
};
|
||||
|
||||
|
||||
|
12
mc_token.cpp
12
mc_token.cpp
@ -34,25 +34,27 @@ namespace metacall {
|
||||
//
|
||||
|
||||
Token::Token(const char value[]) :
|
||||
value_(hash(value))
|
||||
m_value(hash(value))
|
||||
{
|
||||
}
|
||||
|
||||
Token::Token(unsigned value) :
|
||||
value_(value)
|
||||
Token::Token(const unsigned value) :
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
Token::operator unsigned() const {
|
||||
return value_;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
unsigned Token::hash(const char str[]) {
|
||||
// djb2 string hash, see http://www.cse.yorku.ca/~oz/hash.html
|
||||
// metacall uses the djb2 string hash, see
|
||||
// http://www.cse.yorku.ca/~oz/hash.html
|
||||
unsigned hash = 5381;
|
||||
for (const char* ptr = str; *ptr != 0; ++ptr) {
|
||||
hash = (hash << 5) + hash + *ptr;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
private:
|
||||
static unsigned hash(const char str[]);
|
||||
|
||||
unsigned value_;
|
||||
unsigned m_value;
|
||||
};
|
||||
|
||||
|
||||
|
39
metacall.pro
Normal file
39
metacall.pro
Normal file
@ -0,0 +1,39 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES += main.cpp \
|
||||
mc_token.cpp \
|
||||
mc_stream.cpp \
|
||||
mc_socket.cpp \
|
||||
mc_server.cpp \
|
||||
mc_serial.cpp \
|
||||
mc_protocol.cpp \
|
||||
mc_client.cpp \
|
||||
mc_buffer.cpp \
|
||||
mc_binding.cpp
|
||||
|
||||
OTHER_FILES += \
|
||||
metacall.py \
|
||||
metacall.pro.user
|
||||
|
||||
HEADERS += \
|
||||
metacall.hpp \
|
||||
mc_token.hpp \
|
||||
mc_stream.hpp \
|
||||
mc_stream-inl.hpp \
|
||||
mc_socket.hpp \
|
||||
mc_server.hpp \
|
||||
mc_serial.hpp \
|
||||
mc_serial-inl.hpp \
|
||||
mc_protocol.hpp \
|
||||
mc_protocol-inl.hpp \
|
||||
mc_packet.hpp \
|
||||
mc_meta.hpp \
|
||||
mc_functor.hpp \
|
||||
mc_common.hpp \
|
||||
mc_client.hpp \
|
||||
mc_buffer.hpp \
|
||||
mc_binding.hpp \
|
||||
mc_binding-inl.hpp
|
||||
|
Loading…
Reference in New Issue
Block a user