-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_irc.hpp
More file actions
132 lines (115 loc) · 4.28 KB
/
ft_irc.hpp
File metadata and controls
132 lines (115 loc) · 4.28 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef FT_IRC_HPP
# define FT_IRC_HPP
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <poll.h>
#include <unistd.h>
#include <netdb.h>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <csignal>
#include <cctype>
#include <ctime>
#include <errno.h>
#include <fcntl.h>
#include <vector>
#include <map>
#define SERV_NAME "ircserv"
#define PART_MESSAGE "Leaving"
#define KICK_MESSAGE "Kicked"
//Channel modes
#define KEY 'k'
#define INVITE 'i'
#define LIMIT 'l'
#define MODERATE 'm'
#define NO_EXTERN 'n'
#define SECRET 's'
#define TOPIC 't'
#define BAN 'b'
#define CHANOP 'o'
//Channel permissions
#define OPERATOR 'o'
//Client modes
#define INVISIBLE 'i'
#define WALLOP 'w'
#define OPERATOR 'o'
#define CHANMODES "kilmnstbo"
#define CLIENTMODES "iwo"
#define CHANLIMIT 10
#define CHANTYPES "#"
#define NICKLEN 9
#define MAX_INT 2147483647
class Client ;
class Command ;
class Ircserv ;
int fatal_error(int fd, std::string message);
int error(std::string message);
int syscall_error(std::string message);
std::string ft_itoa(int nb);
std::string convert_code(int nb);
std::string convert_time(std::time_t time);
std::string reply_prefix(const std::string& source, int code, const std::string& target);
int reply(int code, Client* client, Ircserv& serv, Command& params, const std::string& param = std::string());
int is_valid_nickname(const std::string& nickname);
char is_add_or_remove_mode(const std::string& mode);
int is_valid_client_mode(const char& mode);
int is_valid_mode(const std::string& mode);
int is_valid_channel(const std::string& chan);
int is_chan_mode(char mode);
int is_param_mode(char mode);
bool sharing_channel(Client* client1, Client* client2);
void print_log(const std::string& message);
std::vector<std::string> split(std::string param, char c);
#define RPL_WELCOME 001
#define RPL_YOURHOST 002
#define RPL_CREATED 003
#define RPL_MYINFO 004
#define RPL_ISUPPORT 005
#define RPL_UMODEIS 221
#define RPL_WHOISUSER 311
#define RPL_ENDOFWHO 315
#define RPL_ENDOFWHOIS 318
#define RPL_LISTSTART 321
#define RPL_LIST 322
#define RPL_LISTEND 323
#define RPL_CHANNELMODEIS 324
#define RPL_NOTOPIC 331
#define RPL_TOPIC 332
#define RPL_TOPICWHOTIME 333
#define RPL_INVITING 341
#define RPL_WHOREPLY 352
#define RPL_NAMREPLY 353
#define RPL_ENDOFNAMES 366
#define RPL_BANLIST 367
#define RPL_ENDOFBANLIST 368
#define RPL_YOUREOPER 381
#define ERR_NOSUCHNICK 401
#define ERR_NOSUCHCHANNEL 403
#define ERR_CANNOTSENDTOCHAN 404
#define ERR_TOOMANYCHANNELS 405
#define ERR_TOOMANYTARGETS 407
#define ERR_NORECIPIENT 411
#define ERR_NOTEXTTOSEND 412
#define ERR_UNKNOWNCOMMAND 421
#define ERR_NONICKNAMEGIVEN 431
#define ERR_ERRONEUSNICKNAME 432
#define ERR_NICKNAMEINUSE 433
#define ERR_USERNOTINCHANNEL 441
#define ERR_NOTONCHANNEL 442
#define ERR_USERONCHANNEL 443
#define ERR_NEEDMOREPARAMS 461
#define ERR_ALREADYREGISTERED 462
#define ERR_PASSWDMISMATCH 464
#define ERR_CHANNELISFULL 471
#define ERR_INVITEONLYCHAN 473
#define ERR_BANNEDFROMCHAN 474
#define ERR_BADCHANNELKEY 475
#define ERR_NOPRIVILEGES 481
#define ERR_CHANOPRIVISNEEDED 482
#define ERR_UMODEUNKNOWNFLAG 501
#define ERR_USERSDONTMATCH 502
#endif