]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/client.h
Add Client_HasFlag() to check if a client has certain flag
[ngircd-alex.git] / src / ngircd / client.h
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2012 Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  */
11
12 #ifndef __client_h__
13 #define __client_h__
14
15 /**
16  * @file
17  * Client management (header)
18  */
19
20 #define CLIENT_UNKNOWN 1                /* connection of unknown type */
21 #define CLIENT_GOTPASS 2                /* client did send PASS */
22 #define CLIENT_GOTNICK 4                /* client did send NICK */
23 #define CLIENT_GOTUSER 8                /* client did send USER */
24 #define CLIENT_USER 16                  /* client is an IRC user */
25 #define CLIENT_SERVER 32                /* client is a server */
26 #define CLIENT_SERVICE 64               /* client is a service */
27 #define CLIENT_UNKNOWNSERVER 128        /* unregistered server connection */
28 #define CLIENT_GOTPASS_2813 256         /* client did send PASS, RFC 2813 style */
29 #ifndef STRICT_RFC
30 # define CLIENT_WAITAUTHPING 512        /* waiting for AUTH PONG from client */
31 #endif
32 #define CLIENT_WAITCAPEND 1024          /* waiting for "CAP END" command */
33
34 #define CLIENT_TYPE int
35
36 #include "defines.h"
37
38 #if defined(__client_c__) | defined(__client_cap_c__) | defined(S_SPLINT_S)
39
40 typedef struct _CLIENT
41 {
42         time_t starttime;               /* Start time of link */
43         char id[CLIENT_ID_LEN];         /* nick (user) / ID (server) */
44         UINT32 hash;                    /* hash of lower-case ID */
45         POINTER *next;                  /* pointer to next client structure */
46         CLIENT_TYPE type;               /* type of client, see CLIENT_xxx */
47         CONN_ID conn_id;                /* ID of the connection (if local) or NONE (remote) */
48         struct _CLIENT *introducer;     /* ID of the servers which the client is connected to */
49         struct _CLIENT *topserver;      /* toplevel servers (only valid if client is a server) */
50         char host[CLIENT_HOST_LEN];     /* hostname of the client */
51         char cloaked[CLIENT_HOST_LEN];  /* cloaked hostname of the client */
52         char user[CLIENT_USER_LEN];     /* user name ("login") */
53 #if defined(PAM) && defined(IDENTAUTH)
54         char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */
55 #endif
56         char info[CLIENT_INFO_LEN];     /* long user name (user) / info text (server) */
57         char modes[CLIENT_MODE_LEN];    /* client modes */
58         int hops, token, mytoken;       /* "hops" and "Token" (see SERVER command) */
59         bool oper_by_me;                /* client is local IRC operator on this server? */
60         char away[CLIENT_AWAY_LEN];     /* AWAY text (valid if mode 'a' is set) */
61         char flags[CLIENT_FLAGS_LEN];   /* flags of the client */
62         int capabilities;               /* enabled IRC capabilities */
63 } CLIENT;
64
65 #else
66
67 typedef POINTER CLIENT;
68
69 #endif
70
71
72 typedef struct _WHOWAS
73 {
74         time_t time;                    /* time stamp of entry or 0 if unused */
75         char id[CLIENT_NICK_LEN];       /* client nickname */
76         char host[CLIENT_HOST_LEN];     /* hostname of the client */
77         char user[CLIENT_USER_LEN];     /* user name ("login") */
78         char info[CLIENT_INFO_LEN];     /* long user name */
79         char server[CLIENT_HOST_LEN];   /* server name */
80 } WHOWAS;
81
82
83 GLOBAL void Client_Init PARAMS(( void ));
84 GLOBAL void Client_Exit PARAMS(( void ));
85
86 GLOBAL CLIENT *Client_NewLocal PARAMS(( CONN_ID Idx, const char *Hostname, int Type, bool Idented ));
87 GLOBAL CLIENT *Client_NewRemoteServer PARAMS(( CLIENT *Introducer, const char *Hostname, CLIENT *TopServer, int Hops, int Token, const char *Info, bool Idented ));
88 GLOBAL CLIENT *Client_NewRemoteUser PARAMS(( CLIENT *Introducer, const char *Nick, int Hops, const char *User, const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented ));
89
90 GLOBAL void Client_Destroy PARAMS(( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit ));
91
92 GLOBAL CLIENT *Client_ThisServer PARAMS(( void ));
93
94 GLOBAL CLIENT *Client_GetFromToken PARAMS(( CLIENT *Client, int Token ));
95
96 GLOBAL bool Client_Announce PARAMS(( CLIENT *Client, CLIENT *Prefix, CLIENT *User ));
97
98 GLOBAL CLIENT *Client_Search PARAMS(( const char *ID ));
99 GLOBAL CLIENT *Client_SearchServer PARAMS(( const char *ID ));
100 GLOBAL CLIENT *Client_First PARAMS(( void ));
101 GLOBAL CLIENT *Client_Next PARAMS(( CLIENT *c ));
102
103 GLOBAL int Client_Type PARAMS(( CLIENT *Client ));
104 GLOBAL CONN_ID Client_Conn PARAMS(( CLIENT *Client ));
105 GLOBAL char *Client_ID PARAMS(( CLIENT *Client ));
106 GLOBAL char *Client_Mask PARAMS(( CLIENT *Client ));
107 GLOBAL char *Client_MaskCloaked PARAMS(( CLIENT *Client ));
108 GLOBAL char *Client_Info PARAMS(( CLIENT *Client ));
109 GLOBAL char *Client_User PARAMS(( CLIENT *Client ));
110 #ifdef PAM
111 GLOBAL char *Client_OrigUser PARAMS(( CLIENT *Client ));
112 #endif
113 GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client ));
114 GLOBAL char *Client_HostnameCloaked PARAMS((CLIENT *Client));
115 GLOBAL char *Client_HostnameDisplayed PARAMS(( CLIENT *Client ));
116 GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
117 GLOBAL char *Client_Flags PARAMS(( CLIENT *Client ));
118 GLOBAL CLIENT *Client_Introducer PARAMS(( CLIENT *Client ));
119 GLOBAL bool Client_OperByMe PARAMS(( CLIENT *Client ));
120 GLOBAL int Client_Hops PARAMS(( CLIENT *Client ));
121 GLOBAL int Client_Token PARAMS(( CLIENT *Client ));
122 GLOBAL int Client_MyToken PARAMS(( CLIENT *Client ));
123 GLOBAL CLIENT *Client_TopServer PARAMS(( CLIENT *Client ));
124 GLOBAL CLIENT *Client_NextHop PARAMS(( CLIENT *Client ));
125 GLOBAL char *Client_Away PARAMS(( CLIENT *Client ));
126 GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client ));
127
128 GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
129 GLOBAL bool Client_HasFlag PARAMS(( CLIENT *Client, char Flag ));
130
131 GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
132 GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
133 GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
134 GLOBAL void Client_SetOrigUser PARAMS(( CLIENT *Client, const char *User ));
135 GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
136 GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
137 GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
138 GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
139 GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe ));
140 GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, const char *Modes ));
141 GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, const char *Flags ));
142 GLOBAL void Client_SetIntroducer PARAMS(( CLIENT *Client, CLIENT *Introducer ));
143 GLOBAL void Client_SetAway PARAMS(( CLIENT *Client, const char *Txt ));
144
145 GLOBAL bool Client_ModeAdd PARAMS(( CLIENT *Client, char Mode ));
146 GLOBAL bool Client_ModeDel PARAMS(( CLIENT *Client, char Mode ));
147
148 GLOBAL bool Client_CheckNick PARAMS(( CLIENT *Client, char *Nick ));
149 GLOBAL bool Client_CheckID PARAMS(( CLIENT *Client, char *ID ));
150
151 GLOBAL long Client_UserCount PARAMS(( void ));
152 GLOBAL long Client_ServiceCount PARAMS(( void ));
153 GLOBAL long Client_ServerCount PARAMS(( void ));
154 GLOBAL unsigned long Client_OperCount PARAMS(( void ));
155 GLOBAL unsigned long Client_UnknownCount PARAMS(( void ));
156 GLOBAL long Client_MyUserCount PARAMS(( void ));
157 GLOBAL long Client_MyServiceCount PARAMS(( void ));
158 GLOBAL unsigned long Client_MyServerCount PARAMS(( void ));
159 GLOBAL long Client_MaxUserCount PARAMS((  void ));
160 GLOBAL long Client_MyMaxUserCount PARAMS((  void ));
161
162 GLOBAL bool Client_IsValidNick PARAMS(( const char *Nick ));
163
164 GLOBAL WHOWAS *Client_GetWhowas PARAMS(( void ));
165 GLOBAL int Client_GetLastWhowasIndex PARAMS(( void ));
166
167 GLOBAL void Client_RegisterWhowas PARAMS(( CLIENT *Client ));
168
169 GLOBAL const char *Client_TypeText PARAMS((CLIENT *Client));
170
171 GLOBAL void Client_Reject PARAMS((CLIENT *Client, const char *Reason,
172                                   bool InformClient));
173 GLOBAL void Client_Introduce PARAMS((CLIENT *From, CLIENT *Client, int Type));
174
175 GLOBAL void Client_UpdateCloakedHostname PARAMS((CLIENT *Client,
176                                                  CLIENT *Originator,
177                                                  const char *hostname));
178
179
180 #ifdef DEBUG
181 GLOBAL void Client_DebugDump PARAMS((void));
182 #endif
183
184 #endif
185
186 /* -eof- */