-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
47 lines (43 loc) · 1.57 KB
/
main.cpp
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
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: isaad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/08 10:55:16 by oal-tena #+# #+# */
/* Updated: 2022/12/29 08:18:14 by isaad ### ########.fr */
/* */
/* ************************************************************************** */
#include "incl/Server.hpp"
int main(int argc, char **argv)
{
if (argc != 3)
{
std::cout << "Usage: ./ircserv [port] [password]" << std::endl;
return (EXIT_FAILURE);
}
//check password
if (strlen(argv[2]) < 6)
{
std::cout << "Password must be at least 6 characters" << std::endl;
return (EXIT_FAILURE);
}
//check port
for (size_t i = 0; i < strlen(argv[1]); i++)
{
if (!isdigit(argv[1][i]))
{
std::cout << "Port must be a number" << std::endl;
return (EXIT_FAILURE);
}
}
int port = atoi(argv[1]);
if (port < 1024 || port > 65535)
{
std::cout << "Port must be between 1024 and 65535" << std::endl;
return (EXIT_FAILURE);
}
ft::Server server(argv[1], argv[2]);
return 0;
}