Переглянути джерело

Directory structure rework & CMake support

mawinkle 6 роки тому
батько
коміт
8d99c8487c

+ 3 - 0
CMakeLists.txt

@@ -0,0 +1,3 @@
+cmake_minimum_required (VERSION 3.0)
+include_directories(include)
+add_subdirectory(socket_impl)

+ 0 - 0
crypt/BigInt64.hpp → include/BigInt64.hpp


+ 0 - 0
crypt/intrin.hpp → include/intrin.hpp


+ 0 - 0
socketio.hpp → include/socketio.hpp


+ 0 - 0
crypt/uint128_t.h → include/uint128_t.h


+ 0 - 0
crypt/uint128_t.cpp → msc_supp/uint128_t.cpp


+ 7 - 0
socket_impl/CMakeLists.txt

@@ -0,0 +1,7 @@
+cmake_minimum_required (VERSION 3.0)
+if(WIN32)
+	add_library(sio socketio_win32.cpp ../msc_supp/uint128_t.cpp)
+endif()
+if(UNIX)
+        add_library(sio socketio_posix.cpp)
+endif()

+ 0 - 66
socket_impl/socketio.hpp

@@ -1,66 +0,0 @@
-#ifndef SOCKETIO_HPP
-#define SOCKETIO_HPP
-#include <string>
-#include <cstring>
-#include <vector>
-#include <iostream>
-#include <exception>
-#include <cmath>
-#include <stdexcept>
-#ifndef _WIN32
-#include <sys/socket.h>
-#include <netinet/in.h>
-#else
-#define _WINSOCK_DEPRECATED_NO_WARNINGS
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#pragma comment(lib, "ws2_32.lib")
-#endif
-class cppsocket {
-private:
-#ifdef _WIN32
-	WSADATA wsa;
-	SOCKET s;
-#else
-	struct sockaddr_in serv_addr;
-	int sock;
-#endif
-	std::vector<char> buffer;
-public:
-	const static std::size_t buffersize = 1024;
-#ifdef _WIN32
-	cppsocket(WSADATA d, SOCKET _s);
-#else
-	cppsocket(sockaddr_in _serv_addr, int _sock);
-#endif
-	cppsocket();
-	cppsocket(const cppsocket& o) = delete;
-	cppsocket(cppsocket&& o);
-	cppsocket(const std::string& addr, unsigned int PORT);
-	void close();
-	int socket_id();
-	void write(const std::string& message);
-	void write(const std::vector<char>& message);
-	std::vector<char> receive();
-	cppsocket& operator=(cppsocket&& o);
-};
-
-class server_socket {
-private:
-#ifdef _WIN32
-	WSADATA wsaData;
-	int iResult;
-	SOCKET ListenSocket = INVALID_SOCKET;
-#else
-	int port_;
-	int server_fd;
-	struct sockaddr_in address;
-	socklen_t addrlen;
-#endif
-public:
-	int port();
-	server_socket(int _port);
-	cppsocket accept_connection();
-	void close();
-};
-#endif

+ 1 - 1
socket_impl/socketio_posix.cpp

@@ -1,4 +1,4 @@
-#include "socketio.hpp"
+#include <socketio.hpp>
 #include <arpa/inet.h>
 #include <unistd.h>
 #include <cinttypes>

+ 1 - 1
socket_impl/socketio_win32.cpp

@@ -1,4 +1,4 @@
-#include "socketio.hpp"
+#include <socketio.hpp>
 #include <stdio.h>
 #include <cstdint>
 #include <cinttypes>