This commit is contained in:
Kbz-8
2024-01-21 10:40:54 +01:00
parent 4374f826ea
commit 488c0ad83c
8 changed files with 139 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
# By: vavaas <vvaas@student.42.fr> +#+ +:+ +#+ # # By: vavaas <vvaas@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2023/08/09 15:08:49 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 = srcs/core/main.cpp \
srcs/core/logs.cpp \ srcs/core/logs.cpp \
srcs/core/server.cpp \
srcs/utils/ansi.cpp \ srcs/utils/ansi.cpp \
OBJ_DIR = objs OBJ_DIR = objs

26
includes/channel.hpp Normal file
View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* channel.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

29
includes/client.hpp Normal file
View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@@ -6,23 +6,30 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:12:28 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__ #ifndef __SERVER_IRC__
#define __SERVER_IRC__ #define __SERVER_IRC__
#include <string>
#include <vector>
namespace irc namespace irc
{ {
class Server class Server
{ {
public: public:
Server(); Server(int port, const std::string& password);
~Server(); ~Server();
private: private:
std::vector<class Channel> _channels;
const std::string _password;
const int _port;
int _socket;
}; };
} }

23
srcs/core/channel.cpp Normal file
View File

@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* channel.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */
/* Updated: 2024/01/21 10:36:49 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <channel.hpp>
namespace irc
{
Channel::Channel()
{
}
Channel::~Channel() {}
}

23
srcs/core/client.cpp Normal file
View File

@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:35:52 by maldavid #+# #+# */
/* Updated: 2024/01/21 10:36:20 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <client.hpp>
namespace irc
{
Client::Client()
{
}
Client::~Client() {}
}

View File

@@ -6,11 +6,16 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/20 09:27:04 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 <logs.hpp> #include <logs.hpp>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cerrno>
#include <server.hpp>
int main(int ac, char** av) int main(int ac, char** av)
{ {
@@ -19,6 +24,15 @@ int main(int ac, char** av)
irc::logs::report(irc::log_message, "usage './ircserv <port> <password>', try again dumbass"); irc::logs::report(irc::log_message, "usage './ircserv <port> <password>', try again dumbass");
return 0; 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; return 0;
} }

View File

@@ -6,13 +6,23 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 09:31:17 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 <server.hpp> #include <server.hpp>
#include <client.hpp>
#include <channel.hpp>
namespace irc namespace irc
{ {
Server::Server(int port, const std::string& password) : _password(password), _port(port)
{
(void)_port;
(void)_password;
(void)_socket;
(void)_channels;
}
Server::~Server() {}
} }