From 488c0ad83c492e8fb3f240fa2e0ba352454f7e1a Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sun, 21 Jan 2024 10:40:54 +0100 Subject: [PATCH] yes --- Makefile | 3 ++- includes/channel.hpp | 26 ++++++++++++++++++++++++++ includes/client.hpp | 29 +++++++++++++++++++++++++++++ includes/server.hpp | 11 +++++++++-- srcs/core/channel.cpp | 23 +++++++++++++++++++++++ srcs/core/client.cpp | 23 +++++++++++++++++++++++ srcs/core/main.cpp | 18 ++++++++++++++++-- srcs/core/server.cpp | 12 +++++++++++- 8 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 includes/channel.hpp create mode 100644 includes/client.hpp create mode 100644 srcs/core/channel.cpp create mode 100644 srcs/core/client.cpp diff --git a/Makefile b/Makefile index 1b114d7..964b68c 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: vavaas +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/08/09 15:08:49 by vavaas #+# #+# # -# Updated: 2024/01/21 09:44:11 by maldavid ### ########.fr # +# Updated: 2024/01/21 10:12:04 by maldavid ### ########.fr # # # # **************************************************************************** # @@ -14,6 +14,7 @@ NAME = ircserv SRCS = srcs/core/main.cpp \ srcs/core/logs.cpp \ + srcs/core/server.cpp \ srcs/utils/ansi.cpp \ OBJ_DIR = objs diff --git a/includes/channel.hpp b/includes/channel.hpp new file mode 100644 index 0000000..c073b99 --- /dev/null +++ b/includes/channel.hpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* channel.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */ +/* Updated: 2024/01/21 10:35:49 by maldavid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef __CHANNEL__ +#define __CHANNEL__ + +namespace irc +{ + class Channel + { + public: + + private: + }; +} + +#endif diff --git a/includes/client.hpp b/includes/client.hpp new file mode 100644 index 0000000..3286fb4 --- /dev/null +++ b/includes/client.hpp @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* client.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/21 10:33:17 by maldavid #+# #+# */ +/* Updated: 2024/01/21 10:34:13 by maldavid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef __CLIENT__ +#define __CLIENT__ + +namespace irc +{ + class Client + { + public: + Client(); + + ~Client(); + + private: + }; +} + +#endif diff --git a/includes/server.hpp b/includes/server.hpp index 17fd607..b1c24f5 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -6,23 +6,30 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ -/* Updated: 2024/01/21 09:14:20 by maldavid ### ########.fr */ +/* Updated: 2024/01/21 10:37:58 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef __SERVER_IRC__ #define __SERVER_IRC__ +#include +#include + namespace irc { class Server { public: - Server(); + Server(int port, const std::string& password); ~Server(); private: + std::vector _channels; + const std::string _password; + const int _port; + int _socket; }; } diff --git a/srcs/core/channel.cpp b/srcs/core/channel.cpp new file mode 100644 index 0000000..67387c7 --- /dev/null +++ b/srcs/core/channel.cpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* channel.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ +/* Updated: 2024/01/21 10:36:49 by maldavid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +namespace irc +{ + Channel::Channel() + { + + } + + Channel::~Channel() {} +} diff --git a/srcs/core/client.cpp b/srcs/core/client.cpp new file mode 100644 index 0000000..a9a13df --- /dev/null +++ b/srcs/core/client.cpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* client.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maldavid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/21 10:35:52 by maldavid #+# #+# */ +/* Updated: 2024/01/21 10:36:20 by maldavid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +namespace irc +{ + Client::Client() + { + + } + + Client::~Client() {} +} diff --git a/srcs/core/main.cpp b/srcs/core/main.cpp index 984a5c9..269a18a 100644 --- a/srcs/core/main.cpp +++ b/srcs/core/main.cpp @@ -6,11 +6,16 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/20 09:27:04 by maldavid #+# #+# */ -/* Updated: 2024/01/21 09:30:55 by maldavid ### ########.fr */ +/* Updated: 2024/01/21 10:31:26 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #include +#include +#include +#include +#include +#include int main(int ac, char** av) { @@ -19,6 +24,15 @@ int main(int ac, char** av) irc::logs::report(irc::log_message, "usage './ircserv ', try again dumbass"); return 0; } - (void)av; + + if(av[1] == NULL || av[2] == NULL) + irc::logs::report(irc::log_fatal_error, "invalid argv, one is NULL (wtf)"); + + char* end; + long port = std::strtol(av[1], &end, 10); + if(errno == ERANGE || *end != 0 || port < 0 || port > 0xffff) + irc::logs::report(irc::log_fatal_error, "invalid port"); + + irc::Server server(port, av[2]); return 0; } diff --git a/srcs/core/server.cpp b/srcs/core/server.cpp index d7477d3..43f85a9 100644 --- a/srcs/core/server.cpp +++ b/srcs/core/server.cpp @@ -6,13 +6,23 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */ -/* Updated: 2024/01/21 09:31:28 by maldavid ### ########.fr */ +/* Updated: 2024/01/21 10:38:12 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #include +#include +#include namespace irc { + Server::Server(int port, const std::string& password) : _password(password), _port(port) + { + (void)_port; + (void)_password; + (void)_socket; + (void)_channels; + } + Server::~Server() {} }