forked from Huakfy/ft_irc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (30 loc) · 1.48 KB
/
main.cpp
File metadata and controls
34 lines (30 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mjourno <mjourno@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/18 11:56:32 by mjourno #+# #+# */
/* Updated: 2023/11/24 14:33:20 by mjourno ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_irc.hpp"
#include "Server.hpp"
int main(int argc, char **argv) {
if (argc != 3)
return print_error(__FILE__, __LINE__, "Needs two arguments ex: ./ircserv <port> <password>", 1);
unsigned int i = 0;
while (argv[1][i])
if (!std::isdigit(argv[1][i++]))
break;
if (i != std::strlen(argv[1]) || std::atoi(argv[1]) > 65535 || std::atoi(argv[1]) < 0)
return print_error(__FILE__, __LINE__, "Port needs to be a postive integer between 0 and 65535", 1);
try {
Server server(argv[1], argv[2]);
server.Launch();
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}