2 * IRC - Internet Relay Chat, include/struct.h
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
5 * Copyright (C) 1996 -1997 Carlo Wood
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <netinet/in.h> /* Needed for struct in_addr */
26 #include "whowas.h" /* Needed for whowas struct */
28 #ifndef INCLUDED_dbuf_h
33 /*=============================================================================
42 #define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */
44 #define STARTTARGETS 10
45 #define RESERVEDTARGETS 12
47 /*-----------------------------------------------------------------------------
51 #define CLIENT_LOCAL_SIZE sizeof(aClient)
52 #define CLIENT_REMOTE_SIZE offsetof(aClient, count)
54 #define MyConnect(x) ((x)->from == (x))
55 #define MyUser(x) (MyConnect(x) && IsUser(x))
56 #define MyOper(x) (MyConnect(x) && IsOper(x))
57 #define Protocol(x) ((x)->serv->prot)
59 /*=============================================================================
62 * Only put structures here that are being used in a very large number of
63 * source files. Other structures go in the header file of there corresponding
64 * source file, or in the source file itself (when only used in that file).
68 struct Client *next, *prev, *hnext;
69 struct User *user; /* ...defined, if this is a User */
70 struct Server *serv; /* ...defined, if this is a server */
71 struct Whowas *whowas; /* Pointer to ww struct to be freed on quit */
72 char yxx[4]; /* Numeric Nick: YMM if this is a server,
73 XX0 if this is a user */
74 time_t lasttime; /* ...should be only LOCAL clients? --msa */
75 time_t firsttime; /* time client was created */
76 time_t since; /* last time we parsed something */
77 time_t lastnick; /* TimeStamp on nick */
78 int marker; /* /who processing marker */
79 unsigned int flags; /* client flags */
80 struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
81 int fd; /* >= 0, for local clients */
82 unsigned int hopcount; /* number of servers to this 0 = local */
83 short status; /* Client type */
84 struct in_addr ip; /* Real ip# - NOT defined for remote servers! */
85 char name[HOSTLEN + 1]; /* Unique name of the client, nick or host */
86 char username[USERLEN + 1]; /* username here now for auth stuff */
87 char info[REALLEN + 1]; /* Free form additional client information */
89 * The following fields are allocated only for local clients
90 * (directly connected to *this* server with a socket.
91 * The first of them *MUST* be the "count"--it is the field
92 * to which the allocation is tied to! *Never* refer to
93 * these fields, if (from != self).
95 unsigned int count; /* Amount of data in buffer, DON'T PUT
96 variables ABOVE this one! */
97 snomask_t snomask; /* mask for server messages */
98 char buffer[BUFSIZE]; /* Incoming message buffer; or the error that
99 caused this clients socket to be `dead' */
100 unsigned short int lastsq; /* # of 2k blocks when sendqueued called last */
101 time_t nextnick; /* Next time that a nick change is allowed */
102 time_t nexttarget; /* Next time that a target change is allowed */
103 unsigned char targets[MAXTARGETS]; /* Hash values of current targets */
104 unsigned int cookie; /* Random number the user must PONG */
105 struct DBuf sendQ; /* Outgoing message queue--if socket full */
106 struct DBuf recvQ; /* Hold for data incoming yet to be parsed */
107 unsigned int sendM; /* Statistics: protocol messages send */
108 unsigned int sendK; /* Statistics: total k-bytes send */
109 unsigned int receiveM; /* Statistics: protocol messages received */
110 unsigned int receiveK; /* Statistics: total k-bytes received */
111 unsigned short int sendB; /* counters to count upto 1-k lots of bytes */
112 unsigned short int receiveB; /* sent and received. */
113 struct Client *acpt; /* listening client which we accepted from */
114 struct SLink *confs; /* Configuration record associated */
115 int authfd; /* fd for rfc931 authentication */
116 unsigned short int port; /* and the remote port# too :-) */
117 struct hostent *hostp;
118 struct ListingArgs *listing;
122 char sockhost[HOSTLEN + 1]; /* This is the host name from the socket and
123 after which the connection was accepted. */
124 char passwd[PASSWDLEN + 1];
128 struct Server *nexts;
129 struct Client *up; /* Server one closer to me */
130 struct DSlink *down; /* List with downlink servers */
131 struct DSlink *updown; /* own Dlink in up->serv->down struct */
132 aClient **client_list; /* List with client pointers on this server */
133 struct User *user; /* who activated this connection */
134 struct ConfItem *nline; /* N-line pointer for this server */
135 time_t timestamp; /* Remotely determined connect try time */
136 time_t ghost; /* Local time at which a new server
138 unsigned short prot; /* Major protocol */
139 unsigned short nn_last; /* Last numeric nick for p9 servers only */
140 unsigned int nn_mask; /* [Remote] FD_SETSIZE - 1 */
141 char nn_capacity[4]; /* numeric representation of server capacity */
143 struct Client *bcptr;
145 char *last_error_msg; /* Allocated memory with last message receive with an ERROR */
146 char by[NICKLEN + 1];
151 struct Client *server; /* client structure of server */
152 struct SLink *channel; /* chain of channel pointer blocks */
153 struct SLink *invited; /* chain of invite pointer blocks */
154 struct SLink *silence; /* chain of silence pointer blocks */
155 char *away; /* pointer to away message */
157 unsigned int refcnt; /* Number of times this block is referenced */
158 unsigned int joined; /* number of channels joined */
159 char username[USERLEN + 1];
160 char host[HOSTLEN + 1];
162 struct Client *bcptr;
166 #endif /* STRUCT_H */