22a9c839ca81c20fff30dac76f8a3f6edda957f0
[ircu2.10.12-pk.git] / include / querycmds.h
1 #ifndef QUERYCMDS_H
2 #define QUERYCMDS_H
3
4 /*=============================================================================
5  * Structs
6  */
7
8 struct lusers_st {
9   /* Local connections: */
10   unsigned int unknowns;        /* IsUnknown() || IsConnecting() || IsHandshake() */
11   unsigned int local_servers;   /* IsServer() && MyConnect() */
12   unsigned int local_clients;   /* IsUser() && MyConnect() */
13   /* Global counts: */
14   unsigned int servers;         /* IsServer() || IsMe() */
15   unsigned int clients;         /* IsUser() */
16   /* Global user mode changes: */
17   unsigned int inv_clients;     /* IsUser() && IsInvisible() */
18   unsigned int opers;           /* IsUser() && IsOper() */
19   /* Misc: */
20   unsigned int channels;
21 };
22
23 /*=============================================================================
24  * Macros
25  */
26
27 /* Macros for remote connections: */
28 #define Count_newremoteclient(nrof)             (++nrof.clients)
29 #define Count_newremoteserver(nrof)             (++nrof.servers)
30 #define Count_remoteclientquits(nrof)           (--nrof.clients)
31 #define Count_remoteserverquits(nrof)           (--nrof.servers)
32
33 /* Macros for local connections: */
34 #define Count_newunknown(nrof)                  (++nrof.unknowns)
35 #define Count_unknownbecomesclient(cptr, nrof) \
36   do { \
37     --nrof.unknowns; ++nrof.local_clients; ++nrof.clients; \
38     if (match("*" DOMAINNAME, cptr->sockhost) == 0) \
39       ++current_load.local_count; \
40     if (nrof.local_clients > max_client_count) \
41       max_client_count = nrof.local_clients; \
42     if (nrof.local_clients + nrof.local_servers > max_connection_count) \
43     { \
44       max_connection_count = nrof.local_clients + nrof.local_servers; \
45       if (max_connection_count % 10 == 0) \
46         sendto_ops("Maximum connections: %d (%d clients)", \
47             max_connection_count, max_client_count); \
48     } \
49   } while(0)
50 #define Count_unknownbecomesserver(nrof)        do { --nrof.unknowns; ++nrof.local_servers; ++nrof.servers; } while(0)
51 #define Count_clientdisconnects(cptr, nrof) \
52   do \
53   { \
54     --nrof.local_clients; --nrof.clients; \
55     if (match("*" DOMAINNAME, cptr->sockhost) == 0) \
56       --current_load.local_count; \
57   } while(0)
58 #define Count_serverdisconnects(nrof)           do { --nrof.local_servers; --nrof.servers; } while(0)
59 #define Count_unknowndisconnects(nrof)          (--nrof.unknowns)
60
61 /*=============================================================================
62  * Proto types
63  */
64
65 extern int m_version(aClient *cptr, aClient *sptr, int parc, char *parv[]);
66 extern int m_info(aClient *cptr, aClient *sptr, int parc, char *parv[]);
67 extern int m_links(aClient *cptr, aClient *sptr, int parc, char *parv[]);
68 extern int m_help(aClient *cptr, aClient *sptr, int parc, char *parv[]);
69 extern int m_lusers(aClient *cptr, aClient *sptr, int parc, char *parv[]);
70 extern int m_admin(aClient *cptr, aClient *sptr, int parc, char *parv[]);
71 extern int m_motd(aClient *cptr, aClient *sptr, int parc, char *parv[]);
72
73 extern struct lusers_st nrof;
74
75 #endif /* QUERYCMDS_H */