added bot/ircop mark to cmd_nicklist
[NeonServV5.git] / src / ClientSocket.h
1 /* ClientSocket.h - NeonServ v5.5
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17 #ifndef _ClientSocket_h
18 #define _ClientSocket_h
19
20 #include "main.h"
21
22 #define SOCKET_FLAG_DEAD           0x01
23 #define SOCKET_FLAG_CONNECTED      0x02
24 #define SOCKET_FLAG_READY          0x04
25 #define SOCKET_FLAG_PREFERRED      0x08 /* prefered bot to send datas to the IRC World (NOTICE's WHO's etc pp) */
26 #define SOCKET_FLAG_USE_QUEUE      0x10
27 #define SOCKET_FLAG_RECONNECT      0x20
28 #define SOCKET_FLAG_SSL            0x40
29 #define SOCKET_FLAG_HAVE_SSL       0x80
30 #define SOCKET_FLAG_QUITTED        0x100
31 #define SOCKET_FLAG_FAST_JUMP      0x200
32 #define SOCKET_FLAG_SILENT         0x400
33 #define SOCKET_FLAG_CHANGENICK     0x800
34 #define SOCKET_FLAG_REQUEST_INVITE 0x1000
35 #define SOCKET_FLAG_REQUEST_OP     0x2000
36 #define SOCKET_FLAG_SECRET_BOT     0x4000
37
38 #define SOCKET_HAVE_BOTCLASSVALUE1 0x10000000
39 #define SOCKET_HAVE_BOTCLASSVALUE2 0x20000000
40 #define SOCKET_HAVE_BOTCLASSVALUE3 0x40000000
41
42 #define BUF_SIZ 512
43
44 struct UserNode;
45 struct trigger_cache;
46 struct SSLConnection;
47
48 struct ClientSocket {
49     int sock;
50     unsigned int flags;
51     char buffer[BUF_SIZ*2]; //we need to store up to 2 full commands at once
52     unsigned int bufferpos;
53     char *host;
54     int port;
55     char *bind;
56     char *pass;
57     char *nick;
58     char *ident;
59     char *realname;
60     struct UserNode *user;
61     char *network_name;
62     unsigned long traffic_in;
63     unsigned long traffic_out;
64     time_t connection_time;
65     struct SSLConnection *sslconn;
66     
67     struct BotQueue *queue;
68     
69     struct WHOQueueEntry *whoqueue_first;
70     struct WHOQueueEntry *whoqueue_last;
71     
72     struct HandleInfoQueueEntry *handleinfo_first;
73     struct HandleInfoQueueEntry *handleinfo_last;
74         
75         int botid : 16;
76     int clientid : 16;
77     
78     void *botclassvalue1;
79     void *botclassvalue2;
80     void *botclassvalue3;
81     
82     void *changenick_channels; //parted channels due raw 437
83     
84     struct ClientSocket *next;
85 };
86
87 #ifndef DND_FUNCTIONS
88 /* MODULAR ACCESSIBLE */ struct ClientSocket* create_socket(char *host, int port, char *bindto, char *pass, char *nick, char *ident, char *realname);
89 /* MODULAR ACCESSIBLE */ int connect_socket(struct ClientSocket *client);
90 /* MODULAR ACCESSIBLE */ int close_socket(struct ClientSocket *client);
91 /* MODULAR ACCESSIBLE */ int disconnect_socket(struct ClientSocket *client);
92 int write_socket_force(struct ClientSocket *client, char* msg, int len);
93 /* MODULAR ACCESSIBLE */ int write_socket(struct ClientSocket *client, char* msg, int len);
94 #ifdef HAVE_THREADS
95 int clientsocket_parseorder_top(unsigned int tid);
96 #endif
97 int socket_loop(int timeout_seconds);
98 /* MODULAR ACCESSIBLE */ void putsock(struct ClientSocket *client, const char *text, ...) PRINTF_LIKE(2, 3);
99 /* MODULAR ACCESSIBLE */ struct ClientSocket* getBots(int flags, struct ClientSocket* last_bot);
100 void init_sockets();
101 void free_sockets();
102 #endif
103 #endif