-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (44 loc) · 780 Bytes
/
main.cpp
File metadata and controls
49 lines (44 loc) · 780 Bytes
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
46
47
48
#include <string>
#include <string.h>
#include <poll.h>
#include <iostream>
#include <vector>
#include <map>
#include "ServerClass.hpp"
#include "Channel.hpp"
bool is_number(char *argv)
{
int i = -1;
while (argv[++i])
{
if (!isdigit(argv[i]))
return false;
}
return true;
}
void display_usage(void)
{
cout << "usage:\n ";
cout << "./ircserv <port> <password>" << endl;
}
int main(int argc, char **argv)
{
int port;
std::string password;
if (argc != 3)
{
display_usage();
cout << "error:\n wrong argument number" << endl;
return 1;
}
if (!is_number(argv[1]))
{
display_usage();
cout << "error:\n <port> must be an integer" << endl;
return 2;
}
port = atoi(argv[1]);
password = argv[2];
Server server(port, password);
server.launch();
}