added get_userlist function to WHOHandler.c and wrote some test code
[NeonServV5.git] / ClientSocket.h
1 #ifndef _ClientSocket_h
2 #define _ClientSocket_h
3
4 #include "main.h"
5
6 #define SOCKET_FLAG_DEAD      0x01
7 #define SOCKET_FLAG_CONNECTED 0x02
8 #define SOCKET_FLAG_READY     0x04
9 #define SOCKET_FLAG_NOWHO     0x08
10
11 #define BUF_SIZ 512
12
13 struct UserNode;
14
15 struct ClientSocket {
16     int sock;
17     unsigned char flags;
18     char buffer[BUF_SIZ*2]; //we need to store up to 2 full commands at once
19     unsigned int bufferpos;
20     char *host;
21     int port;
22     char *pass;
23     struct UserNode *user;
24     
25     struct ClientSocket *next;
26 };
27
28 struct ClientSocket* create_socket(char *host, int port, char *pass, struct UserNode *user);
29 int connect_socket(struct ClientSocket *client);
30 int close_socket(struct ClientSocket *client);
31 int write_socket(struct ClientSocket *client, char* msg, int len);
32 void socket_loop(int timeout_seconds);
33 void putsock(struct ClientSocket *client, const char *text, ...) PRINTF_LIKE(2, 3);
34 struct ClientSocket* getBots(int flags, struct ClientSocket* last_bot);
35
36 #endif