2000-12-11 Kevin L. Mitchell <klmitch@mit.edu>
+ * ircd/hash.c: use struct Client accessor macros
+
+ * ircd/gline.c: use struct Client accessor macros
+
+ * ircd/crule.c: use struct Client accessor macros
+
+ * ircd/client.c: use struct Client accessor macros; remove some
+ dead code
+
+ * ircd/class.c: use struct Client accessor macros
+
+ * ircd/channel.c: use struct Client accessor macros; remove some
+ dead code
+
+ * ircd/IPcheck.c: use struct Client accessor macros
+
+ * include/numnicks.h: use struct Client accessor macros
+
+ * include/client.h: first step to divorcing struct Client and
+ struct Connection--define accessor macros and use them
+
* ircd/gline.c: When Uworld removed Uworld-set G-lines, only the
uplink would remove them. This is because the removal protocol
message wasn't being sent to the uplinks. This is fixed by fixing
caused this clients socket to be `dead' */
};
+#define cli_next(cli) ((cli)->next)
+#define cli_prev(cli) ((cli)->prev)
+#define cli_hnext(cli) ((cli)->hnext)
+#define cli_from(cli) ((cli)->from)
+#define cli_user(cli) ((cli)->user)
+#define cli_serv(cli) ((cli)->serv)
+#define cli_whowas(cli) ((cli)->whowas)
+#define cli_yxx(cli) ((cli)->yxx)
+#define cli_lasttime(cli) ((cli)->lasttime)
+#define cli_since(cli) ((cli)->since)
+#define cli_firsttime(cli) ((cli)->firsttime)
+#define cli_lastnick(cli) ((cli)->lastnick)
+#define cli_marker(cli) ((cli)->marker)
+#define cli_flags(cli) ((cli)->flags)
+#define cli_hopcount(cli) ((cli)->hopcount)
+#define cli_ip(cli) ((cli)->ip)
+#define cli_status(cli) ((cli)->status)
+#define cli_local(cli) ((cli)->local)
+#define cli_name(cli) ((cli)->name)
+#define cli_username(cli) ((cli)->username)
+#define cli_info(cli) ((cli)->info)
+
+#define con_count(con) ((con)->count)
+#define con_fd(con) ((con)->fd)
+#define con_error(con) ((con)->error)
+#define con_snomask(con) ((con)->snomask)
+#define con_nextnick(con) ((con)->nextnick)
+#define con_nexttarget(con) ((con)->nexttarget)
+#define con_cookie(con) ((con)->cookie)
+#define con_sendQ(con) ((con)->sendQ)
+#define con_recvQ(con) ((con)->recvQ)
+#define con_sendM(con) ((con)->sendM)
+#define con_sendK(con) ((con)->sendK)
+#define con_receiveM(con) ((con)->receiveM)
+#define con_receiveK(con) ((con)->receiveK)
+#define con_sendB(con) ((con)->sendB)
+#define con_receiveB(con) ((con)->receiveB)
+#define con_listener(con) ((con)->listener)
+#define con_confs(con) ((con)->confs)
+#define con_handler(con) ((con)->handler)
+#define con_dns_reply(con) ((con)->dns_reply)
+#define con_listing(con) ((con)->listing)
+#define con_max_sendq(con) ((con)->max_sendq)
+#define con_ping_freq(con) ((con)->ping_freq)
+#define con_lastsq(con) ((con)->lastsq)
+#define con_port(con) ((con)->port)
+#define con_targets(con) ((con)->targets)
+#define con_sock_ip(con) ((con)->sock_ip)
+#define con_sockhost(con) ((con)->sockhost)
+#define con_passwd(con) ((con)->passwd)
+#define con_buffer(con) ((con)->buffer)
#define STAT_CONNECTING 0x001 /* connecting to another server */
#define STAT_HANDSHAKE 0x002 /* pass - server sent */
/*
* status macros.
*/
-#define IsRegistered(x) ((x)->status & (STAT_SERVER | STAT_USER))
-#define IsConnecting(x) ((x)->status == STAT_CONNECTING)
-#define IsHandshake(x) ((x)->status == STAT_HANDSHAKE)
-#define IsMe(x) ((x)->status == STAT_ME)
-#define IsUnknown(x) ((x)->status & \
+#define IsRegistered(x) (cli_status(x) & (STAT_SERVER | STAT_USER))
+#define IsConnecting(x) (cli_status(x) == STAT_CONNECTING)
+#define IsHandshake(x) (cli_status(x) == STAT_HANDSHAKE)
+#define IsMe(x) (cli_status(x) == STAT_ME)
+#define IsUnknown(x) (cli_status(x) & \
(STAT_UNKNOWN | STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER))
-#define IsServerPort(x) ((x)->status == STAT_UNKNOWN_SERVER )
-#define IsUserPort(x) ((x)->status == STAT_UNKNOWN_USER )
-#define IsClient(x) ((x)->status & \
+#define IsServerPort(x) (cli_status(x) == STAT_UNKNOWN_SERVER )
+#define IsUserPort(x) (cli_status(x) == STAT_UNKNOWN_USER )
+#define IsClient(x) (cli_status(x) & \
(STAT_HANDSHAKE | STAT_ME | STAT_UNKNOWN |\
STAT_UNKNOWN_USER | STAT_UNKNOWN_SERVER | STAT_SERVER | STAT_USER))
-#define IsTrusted(x) ((x)->status & \
+#define IsTrusted(x) (cli_status(x) & \
(STAT_CONNECTING | STAT_HANDSHAKE | STAT_ME | STAT_SERVER))
-#define IsServer(x) ((x)->status == STAT_SERVER)
-#define IsUser(x) ((x)->status == STAT_USER)
+#define IsServer(x) (cli_status(x) == STAT_SERVER)
+#define IsUser(x) (cli_status(x) == STAT_USER)
-#define SetConnecting(x) ((x)->status = STAT_CONNECTING)
-#define SetHandshake(x) ((x)->status = STAT_HANDSHAKE)
-#define SetServer(x) ((x)->status = STAT_SERVER)
-#define SetMe(x) ((x)->status = STAT_ME)
-#define SetUser(x) ((x)->status = STAT_USER)
+#define SetConnecting(x) (cli_status(x) = STAT_CONNECTING)
+#define SetHandshake(x) (cli_status(x) = STAT_HANDSHAKE)
+#define SetServer(x) (cli_status(x) = STAT_SERVER)
+#define SetMe(x) (cli_status(x) = STAT_ME)
+#define SetUser(x) (cli_status(x) = STAT_USER)
-#define MyConnect(x) ((x)->from == (x))
+#define MyConnect(x) (cli_from(x) == (x))
#define MyUser(x) (MyConnect(x) && IsUser(x))
#define MyOper(x) (MyConnect(x) && IsOper(x))
-#define Protocol(x) ((x)->serv->prot)
+#define Protocol(x) ((cli_serv(x))->prot)
-#define PARSE_AS_SERVER(x) ((x)->status & \
+#define PARSE_AS_SERVER(x) (cli_status(x) & \
(STAT_SERVER | STAT_CONNECTING | STAT_HANDSHAKE))
/*
/*
* flags macros.
*/
-#define DoAccess(x) ((x)->flags & FLAGS_CHKACCESS)
-#define IsAnOper(x) ((x)->flags & (FLAGS_OPER|FLAGS_LOCOP))
-#define IsBlocked(x) ((x)->flags & FLAGS_BLOCKED)
-#define IsBurst(x) ((x)->flags & FLAGS_BURST)
-#define IsBurstAck(x) ((x)->flags & FLAGS_BURST_ACK)
-#define IsBurstOrBurstAck(x) ((x)->flags & (FLAGS_BURST|FLAGS_BURST_ACK))
-#define IsChannelService(x) ((x)->flags & FLAGS_CHSERV)
-#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET)
-#define IsDeaf(x) ((x)->flags & FLAGS_DEAF)
-#define IsIPChecked(x) ((x)->flags & FLAGS_IPCHECK)
-#define IsIdented(x) ((x)->flags & FLAGS_GOTID)
-#define IsInvisible(x) ((x)->flags & FLAGS_INVISIBLE)
-#define IsJunction(x) ((x)->flags & FLAGS_JUNCTION)
-#define IsLocOp(x) ((x)->flags & FLAGS_LOCOP)
-#define IsLocal(x) ((x)->flags & FLAGS_LOCAL)
-#define IsOper(x) ((x)->flags & FLAGS_OPER)
-#define IsUPing(x) ((x)->flags & FLAGS_UPING)
-#define NoNewLine(x) ((x)->flags & FLAGS_NONL)
-#define SendDebug(x) ((x)->flags & FLAGS_DEBUG)
-#define SendServNotice(x) ((x)->flags & FLAGS_SERVNOTICE)
-#define SendWallops(x) ((x)->flags & FLAGS_WALLOP)
+#define DoAccess(x) (cli_flags(x) & FLAGS_CHKACCESS)
+#define IsAnOper(x) (cli_flags(x) & (FLAGS_OPER|FLAGS_LOCOP))
+#define IsBlocked(x) (cli_flags(x) & FLAGS_BLOCKED)
+#define IsBurst(x) (cli_flags(x) & FLAGS_BURST)
+#define IsBurstAck(x) (cli_flags(x) & FLAGS_BURST_ACK)
+#define IsBurstOrBurstAck(x) (cli_flags(x) & (FLAGS_BURST|FLAGS_BURST_ACK))
+#define IsChannelService(x) (cli_flags(x) & FLAGS_CHSERV)
+#define IsDead(x) (cli_flags(x) & FLAGS_DEADSOCKET)
+#define IsDeaf(x) (cli_flags(x) & FLAGS_DEAF)
+#define IsIPChecked(x) (cli_flags(x) & FLAGS_IPCHECK)
+#define IsIdented(x) (cli_flags(x) & FLAGS_GOTID)
+#define IsInvisible(x) (cli_flags(x) & FLAGS_INVISIBLE)
+#define IsJunction(x) (cli_flags(x) & FLAGS_JUNCTION)
+#define IsLocOp(x) (cli_flags(x) & FLAGS_LOCOP)
+#define IsLocal(x) (cli_flags(x) & FLAGS_LOCAL)
+#define IsOper(x) (cli_flags(x) & FLAGS_OPER)
+#define IsUPing(x) (cli_flags(x) & FLAGS_UPING)
+#define NoNewLine(x) (cli_flags(x) & FLAGS_NONL)
+#define SendDebug(x) (cli_flags(x) & FLAGS_DEBUG)
+#define SendServNotice(x) (cli_flags(x) & FLAGS_SERVNOTICE)
+#define SendWallops(x) (cli_flags(x) & FLAGS_WALLOP)
#define IsPrivileged(x) (IsAnOper(x) || IsServer(x))
-#define SetAccess(x) ((x)->flags |= FLAGS_CHKACCESS)
-#define SetBurst(x) ((x)->flags |= FLAGS_BURST)
-#define SetBurstAck(x) ((x)->flags |= FLAGS_BURST_ACK)
-#define SetChannelService(x) ((x)->flags |= FLAGS_CHSERV)
-#define SetDeaf(x) ((x)->flags |= FLAGS_DEAF)
-#define SetDebug(x) ((x)->flags |= FLAGS_DEBUG)
-#define SetGotId(x) ((x)->flags |= FLAGS_GOTID)
-#define SetIPChecked(x) ((x)->flags |= FLAGS_IPCHECK)
-#define SetInvisible(x) ((x)->flags |= FLAGS_INVISIBLE)
-#define SetJunction(x) ((x)->flags |= FLAGS_JUNCTION)
-#define SetLocOp(x) ((x)->flags |= FLAGS_LOCOP)
-#define SetOper(x) ((x)->flags |= FLAGS_OPER)
-#define SetUPing(x) ((x)->flags |= FLAGS_UPING)
-#define SetWallops(x) ((x)->flags |= FLAGS_WALLOP)
-
-#define ClearAccess(x) ((x)->flags &= ~FLAGS_CHKACCESS)
-#define ClearBurst(x) ((x)->flags &= ~FLAGS_BURST)
-#define ClearBurstAck(x) ((x)->flags &= ~FLAGS_BURST_ACK)
-#define ClearChannelService(x) ((x)->flags &= ~FLAGS_CHSERV)
-#define ClearDeaf(x) ((x)->flags &= ~FLAGS_DEAF)
-#define ClearDebug(x) ((x)->flags &= ~FLAGS_DEBUG)
-#define ClearIPChecked(x) ((x)->flags &= ~FLAGS_IPCHECK)
-#define ClearInvisible(x) ((x)->flags &= ~FLAGS_INVISIBLE)
-#define ClearLocOp(x) ((x)->flags &= ~FLAGS_LOCOP)
-#define ClearOper(x) ((x)->flags &= ~FLAGS_OPER)
-#define ClearUPing(x) ((x)->flags &= ~FLAGS_UPING)
-#define ClearWallops(x) ((x)->flags &= ~FLAGS_WALLOP)
+#define SetAccess(x) (cli_flags(x) |= FLAGS_CHKACCESS)
+#define SetBurst(x) (cli_flags(x) |= FLAGS_BURST)
+#define SetBurstAck(x) (cli_flags(x) |= FLAGS_BURST_ACK)
+#define SetChannelService(x) (cli_flags(x) |= FLAGS_CHSERV)
+#define SetDeaf(x) (cli_flags(x) |= FLAGS_DEAF)
+#define SetDebug(x) (cli_flags(x) |= FLAGS_DEBUG)
+#define SetGotId(x) (cli_flags(x) |= FLAGS_GOTID)
+#define SetIPChecked(x) (cli_flags(x) |= FLAGS_IPCHECK)
+#define SetInvisible(x) (cli_flags(x) |= FLAGS_INVISIBLE)
+#define SetJunction(x) (cli_flags(x) |= FLAGS_JUNCTION)
+#define SetLocOp(x) (cli_flags(x) |= FLAGS_LOCOP)
+#define SetOper(x) (cli_flags(x) |= FLAGS_OPER)
+#define SetUPing(x) (cli_flags(x) |= FLAGS_UPING)
+#define SetWallops(x) (cli_flags(x) |= FLAGS_WALLOP)
+
+#define ClearAccess(x) (cli_flags(x) &= ~FLAGS_CHKACCESS)
+#define ClearBurst(x) (cli_flags(x) &= ~FLAGS_BURST)
+#define ClearBurstAck(x) (cli_flags(x) &= ~FLAGS_BURST_ACK)
+#define ClearChannelService(x) (cli_flags(x) &= ~FLAGS_CHSERV)
+#define ClearDeaf(x) (cli_flags(x) &= ~FLAGS_DEAF)
+#define ClearDebug(x) (cli_flags(x) &= ~FLAGS_DEBUG)
+#define ClearIPChecked(x) (cli_flags(x) &= ~FLAGS_IPCHECK)
+#define ClearInvisible(x) (cli_flags(x) &= ~FLAGS_INVISIBLE)
+#define ClearLocOp(x) (cli_flags(x) &= ~FLAGS_LOCOP)
+#define ClearOper(x) (cli_flags(x) &= ~FLAGS_OPER)
+#define ClearUPing(x) (cli_flags(x) &= ~FLAGS_UPING)
+#define ClearWallops(x) (cli_flags(x) &= ~FLAGS_WALLOP)
/* server notice stuff */
*/
#ifndef INCLUDED_numnicks_h
#define INCLUDED_numnicks_h
+#ifndef INCLUDED_client_h
+#include "client.h"
+#endif
#ifndef INCLUDED_sys_types_h
#include <sys/types.h>
#define INCLUDED_sys_types_h
/*
* Use this macro as follows: sprintf(buf, "%s%s ...", NumNick(cptr), ...);
*/
-#define NumNick(c) (c)->user->server->yxx, (c)->yxx
+#define NumNick(c) cli_yxx((cli_user(c))->server), cli_yxx(c)
/*
* Use this macro as follows: sprintf(buf, "%s ...", NumServ(cptr), ...);
*/
-#define NumServ(c) (c)->yxx
+#define NumServ(c) cli_yxx(c)
/*
* Use this macro as follows: sprintf(buf, "%s%s ...", NumServCap(cptr), ...);
*/
-#define NumServCap(c) (c)->yxx, (c)->serv->nn_capacity
+#define NumServCap(c) cli_yxx(c), (cli_serv(c))->nn_capacity
/*
* Structures
*/
int ip_registry_check_remote(struct Client* cptr, int is_burst)
{
- struct IPRegistryEntry* entry = ip_registry_find(cptr->ip.s_addr);
+ struct IPRegistryEntry* entry = ip_registry_find((cli_ip(cptr)).s_addr);
/*
* Mark that we did add/update an IPregistry entry
SetIPChecked(cptr);
if (0 == entry) {
entry = ip_registry_new_entry();
- entry->addr = cptr->ip.s_addr;
+ entry->addr = (cli_ip(cptr)).s_addr;
if (is_burst)
entry->attempts = 0;
ip_registry_add(entry);
{
const char* tr = "";
unsigned int free_targets = STARTTARGETS;
- struct IPRegistryEntry* entry = ip_registry_find(cptr->ip.s_addr);
+ struct IPRegistryEntry* entry = ip_registry_find((cli_ip(cptr)).s_addr);
if (!entry) {
- Debug((DEBUG_ERROR, "Missing registry entry for: %s", cptr->sock_ip));
+ Debug((DEBUG_ERROR, "Missing registry entry for: %s", con_sock_ip(cptr)));
return;
}
if (entry->target) {
- memcpy(cptr->targets, entry->target->targets, MAXTARGETS);
+ memcpy(con_targets(cptr), entry->target->targets, MAXTARGETS);
free_targets = entry->target->count;
tr = " tr";
}
*/
void ip_registry_disconnect(struct Client *cptr)
{
- struct IPRegistryEntry* entry = ip_registry_find(cptr->ip.s_addr);
+ struct IPRegistryEntry* entry = ip_registry_find((cli_ip(cptr)).s_addr);
if (0 == entry) {
/*
* trying to find an entry for a server causes this to happen,
}
assert(0 != entry->target);
- memcpy(entry->target->targets, cptr->targets, MAXTARGETS);
+ memcpy(entry->target->targets, con_targets(cptr), MAXTARGETS);
/*
* This calculation can be pretty unfair towards large multi-user hosts, but
* there is "nothing" we can do without also allowing spam bots to send more
* ALL should get no free targets when reconnecting. We'd need to store an entry
* per client (instead of per IP number) to avoid this.
*/
- if (cptr->nexttarget < CurrentTime) {
+ if (con_nexttarget(cptr) < CurrentTime) {
/*
* Number of free targets
*/
- free_targets = (CurrentTime - cptr->nexttarget) / TARGET_DELAY + 1;
+ free_targets = (CurrentTime - con_nexttarget(cptr)) / TARGET_DELAY + 1;
}
else
free_targets = 0;
/*
* Add bonus, this is pretty fuzzy, but it will help in some cases.
*/
- if ((CurrentTime - cptr->firsttime) > 600)
+ if ((CurrentTime - cli_firsttime(cptr)) > 600)
/*
* Was longer then 10 minutes online?
*/
- free_targets += (CurrentTime - cptr->firsttime - 600) / TARGET_DELAY;
+ free_targets += (CurrentTime - cli_firsttime(cptr) - 600) / TARGET_DELAY;
/*
* Finally, store smallest value for Judgement Day
*/
* and 99% are on 10 or less.
*/
else {
- m = cptr->user->channel;
+ m = (cli_user(cptr))->channel;
while (m) {
assert(m->user == cptr);
if (m->channel == chptr)
return ipbuf;
}
-#if 0
-static int DoesOp(const char* modebuf)
-{
- assert(0 != modebuf);
- while (*modebuf) {
- if (*modebuf == 'o' || *modebuf == 'v')
- return 1;
- ++modebuf;
- }
- return 0;
-}
-
-/*
- * This function should be removed when all servers are 2.10
- */
-static void sendmodeto_one(struct Client* cptr, const char* from,
- const char* name, const char* mode,
- const char* param, time_t creationtime)
-{
- if (IsServer(cptr) && DoesOp(mode) && creationtime)
- sendto_one(cptr, ":%s MODE %s %s %s " TIME_T_FMT, /* XXX DEAD */
- from, name, mode, param, creationtime);
- else
- sendto_one(cptr, ":%s MODE %s %s %s", from, name, mode, param); /* XXX DEAD */
-}
-#endif /* 0 */
-
/*
* Subtract one user from channel i (and free channel
* block, if channel became empty).
for (i = 0; i <= HighestFd; i++)
{
struct Client *acptr = 0;
- if ((acptr = LocalClientArray[i]) && acptr->listing &&
- acptr->listing->chptr == chptr)
+ if ((acptr = LocalClientArray[i]) && con_listing(acptr) &&
+ (con_listing(acptr))->chptr == chptr)
{
list_next_channels(acptr, 1);
break; /* Only one client can list a channel */
assert(0 != ban->value.ban.banstr);
strcpy(ban->value.ban.banstr, banid);
- ban->value.ban.who = (char*) MyMalloc(strlen(cptr->name) + 1);
+ ban->value.ban.who = (char*) MyMalloc(strlen(cli_name(cptr)) + 1);
assert(0 != ban->value.ban.who);
- strcpy(ban->value.ban.who, cptr->name);
+ strcpy(ban->value.ban.who, cli_name(cptr));
ban->value.ban.when = TStime();
ban->flags = CHFL_BAN; /* This bit is never used I think... */
if (member && IsBanValid(member))
return IsBanned(member);
- s = make_nick_user_host(cptr->name, cptr->user->username, cptr->user->host);
+ s = make_nick_user_host(cli_name(cptr), (cli_user(cptr))->username,
+ (cli_user(cptr))->host);
for (tmp = chptr->banlist; tmp; tmp = tmp->next) {
if ((tmp->flags & CHFL_BAN_IPMASK)) {
if (!ip_s)
- ip_s = make_nick_user_ip(cptr->name, cptr->user->username, cptr->ip);
+ ip_s = make_nick_user_ip(cli_name(cptr), (cli_user(cptr))->username,
+ cli_ip(cptr));
if (match(tmp->value.ban.banstr, ip_s) == 0)
break;
}
assert(0 != chptr);
assert(0 != who);
- if (who->user) {
+ if (cli_user(who)) {
struct Membership* member = membershipFreeList;
if (member)
member->prev_member = 0;
chptr->members = member;
- member->next_channel = who->user->channel;
+ member->next_channel = (cli_user(who))->channel;
if (member->next_channel)
member->next_channel->prev_channel = member;
member->prev_channel = 0;
- who->user->channel = member;
+ (cli_user(who))->channel = member;
++chptr->users;
- ++who->user->joined;
+ ++((cli_user(who))->joined);
}
}
if (member->prev_channel)
member->prev_channel->next_channel = member->next_channel;
else
- member->user->user->channel = member->next_channel;
+ (cli_user(member->user))->channel = member->next_channel;
- --member->user->user->joined;
+ --(cli_user(member->user))->joined;
member->next_member = membershipFreeList;
membershipFreeList = member;
assert(0 != cptr);
assert(0 != cptr->user);
- while ((chan = cptr->user->channel))
+ while ((chan = (cli_user(cptr))->channel))
remove_user_from_channel(cptr, chan->channel);
}
{
if (MyUser(cptr)) {
struct Membership* member;
- for (member = cptr->user->channel; member; member = member->next_channel) {
+ for (member = (cli_user(cptr))->channel; member;
+ member = member->next_channel) {
if (!IsVoicedOrOpped(member) && is_banned(cptr, member->channel, member))
return member->channel->chname;
}
*mbuf = '\0';
}
-#if 0
-static int send_mode_list(struct Client *cptr, char *chname,
- time_t creationtime, struct SLink *top,
- int mask, char flag)
-{
- struct SLink* lp;
- char* cp;
- char* name;
- int count = 0;
- int send = 0;
- int sent = 0;
-
- cp = modebuf + strlen(modebuf);
- if (*parabuf) /* mode +l or +k xx */
- count = 1;
- for (lp = top; lp; lp = lp->next)
- {
- if (!(lp->flags & mask))
- continue;
- if (mask == CHFL_BAN)
- name = lp->value.ban.banstr;
- else
- name = lp->value.cptr->name;
- if (strlen(parabuf) + strlen(name) + 11 < MODEBUFLEN)
- {
- strcat(parabuf, " ");
- strcat(parabuf, name);
- count++;
- *cp++ = flag;
- *cp = '\0';
- }
- else if (*parabuf)
- send = 1;
- if (count == 6)
- send = 1;
- if (send)
- {
- /* cptr is always a server! So we send creationtimes */
- sendmodeto_one(cptr, me.name, chname, modebuf, parabuf, creationtime);
- sent = 1;
- send = 0;
- *parabuf = '\0';
- cp = modebuf;
- *cp++ = '+';
- if (count != 6)
- {
- strcpy(parabuf, name);
- *cp++ = flag;
- }
- count = 0;
- *cp = '\0';
- }
- }
- return sent;
-}
-
-#endif /* 0 */
-
/*
* send "cptr" a full list of the modes for channel chptr.
*/
* Now a user CAN escape anything if invited -- Isomer
*/
- for (lp = sptr->user->invited; lp; lp = lp->next)
+ for (lp = (cli_user(sptr))->invited; lp; lp = lp->next)
if (lp->value.chptr == chptr)
return 0;
/*
* Delete last link in chain if the list is max length
*/
- assert(list_length(cptr->user->invited) == cptr->user->invites);
- if (cptr->user->invites>=MAXCHANNELSPERUSER)
- del_invite(cptr, cptr->user->invited->value.chptr);
+ assert(list_length((cli_user(cptr))->invited) == (cli_user(cptr))->invites);
+ if ((cli_user(cptr))->invites>=MAXCHANNELSPERUSER)
+ del_invite(cptr, (cli_user(cptr))->invited->value.chptr);
/*
* Add client to channel invite list
*/
/*
* Add channel to the end of the client invite list
*/
- for (tmp = &(cptr->user->invited); *tmp; tmp = &((*tmp)->next));
+ for (tmp = &((cli_user(cptr))->invited); *tmp; tmp = &((*tmp)->next));
inv = make_link();
inv->value.chptr = chptr;
inv->next = NULL;
(*tmp) = inv;
- cptr->user->invites++;
+ (cli_user(cptr))->invites++;
}
/*
*inv = tmp->next;
free_link(tmp);
tmp = 0;
- cptr->user->invites--;
+ (cli_user(cptr))->invites--;
break;
}
- for (inv = &(cptr->user->invited); (tmp = *inv); inv = &tmp->next)
+ for (inv = &((cli_user(cptr))->invited); (tmp = *inv); inv = &tmp->next)
if (tmp->value.chptr == chptr)
{
*inv = tmp->next;
/* List and skip all channels that are listen */
void list_next_channels(struct Client *cptr, int nr)
{
- struct ListingArgs *args = cptr->listing;
+ struct ListingArgs *args = con_listing(cptr);
struct Channel *chptr = args->chptr;
chptr->mode.mode &= ~MODE_LISTED;
while (is_listed(chptr) || --nr >= 0)
{
for (; chptr; chptr = chptr->next)
{
- if (!cptr->user || (SecretChannel(chptr) && !find_channel_member(cptr, chptr)))
+ if (!cli_user(cptr) || (SecretChannel(chptr) && !find_channel_member(cptr, chptr)))
continue;
if (chptr->users > args->min_users && chptr->users < args->max_users &&
chptr->creationtime > args->min_time &&
}
if (!chptr)
{
- MyFree(cptr->listing);
- cptr->listing = NULL;
+ MyFree(con_listing(cptr));
+ con_listing(cptr) = NULL;
send_reply(cptr, RPL_LISTEND);
break;
}
}
if (chptr)
{
- cptr->listing->chptr = chptr;
+ (con_listing(cptr))->chptr = chptr;
chptr->mode.mode |= MODE_LISTED;
}
}
remove_user_from_channel(who, chptr);
return;
}
- if (who->from == cptr) /* True on servers 1, 5 and 6 */
+ if (cli_from(who) == cptr) /* True on servers 1, 5 and 6 */
{
- struct Client *acptr = IsServer(sptr) ? sptr : sptr->user->server;
- for (; acptr != &me; acptr = acptr->serv->up)
- if (acptr == who->user->server) /* Case d) (server 5) */
+ struct Client *acptr = IsServer(sptr) ? sptr : (cli_user(sptr))->server;
+ for (; acptr != &me; acptr = (cli_serv(acptr))->up)
+ if (acptr == (cli_user(who))->server) /* Case d) (server 5) */
{
remove_user_from_channel(who, chptr);
return;
/* Ok, if we were given the OPMODE flag, hide the source if its a user */
if (mbuf->mb_dest & MODEBUF_DEST_OPMODE && !IsServer(mbuf->mb_source))
- app_source = mbuf->mb_source->user->server;
+ app_source = (cli_user(mbuf->mb_source))->server;
else
app_source = mbuf->mb_source;
}
if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE)) {
- tmp = strlen(MB_CLIENT(mbuf, i)->name);
+ tmp = strlen(cli_name(MB_CLIENT(mbuf, i)));
if ((totalbuflen - IRCD_MAX(5, tmp)) <= 0) /* don't overflow buffer */
MB_TYPE(mbuf, i) |= MODE_SAVE; /* save for later */
/* deal with clients... */
if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE))
- build_string(strptr, strptr_i, MB_CLIENT(mbuf, i)->name, 0, ' ');
+ build_string(strptr, strptr_i, cli_name(MB_CLIENT(mbuf, i)), 0, ' ');
/* deal with strings... */
else if (MB_TYPE(mbuf, i) & (MODE_KEY | MODE_BAN))
/* send the messages off to their destination */
if (mbuf->mb_dest & MODEBUF_DEST_HACK2) {
sendto_opmask_butone(0, SNO_HACK2, "HACK(2): %s MODE %s %s%s%s%s%s%s "
- "[%Tu]", app_source->name, mbuf->mb_channel->chname,
+ "[%Tu]", cli_name(app_source),
+ mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf, addbuf_i ? "+" : "",
addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
sendcmdto_serv_butone(&me, CMD_DESYNCH, mbuf->mb_connect,
":HACK: %s MODE %s %s%s%s%s%s%s [%Tu]",
- app_source->name, mbuf->mb_channel->chname,
+ cli_name(app_source), mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf,
addbuf_i ? "+" : "", addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
if (mbuf->mb_dest & MODEBUF_DEST_HACK3)
sendto_opmask_butone(0, SNO_HACK3, "BOUNCE or HACK(3): %s MODE %s "
- "%s%s%s%s%s%s [%Tu]", app_source->name,
+ "%s%s%s%s%s%s [%Tu]", cli_name(app_source),
mbuf->mb_channel->chname, rembuf_i ? "-" : "",
rembuf, addbuf_i ? "+" : "", addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
if (mbuf->mb_dest & MODEBUF_DEST_HACK4)
sendto_opmask_butone(0, SNO_HACK4, "HACK(4): %s MODE %s %s%s%s%s%s%s "
- "[%Tu]", app_source->name, mbuf->mb_channel->chname,
+ "[%Tu]", cli_name(app_source),
+ mbuf->mb_channel->chname,
rembuf_i ? "-" : "", rembuf, addbuf_i ? "+" : "",
addbuf, remstr, addstr,
mbuf->mb_channel->creationtime);
(MyUser(state->sptr) && IsZombie(member))) {
if (MyUser(state->sptr))
send_reply(state->sptr, ERR_USERNOTINCHANNEL,
- state->cli_change[i].client->name, state->chptr->chname);
+ cli_name(state->cli_change[i].client),
+ state->chptr->chname);
continue;
}
if (state->flags & MODE_PARSE_FORCE) /* it was forced */
sendto_opmask_butone(0, SNO_HACK4, "Deop of +k user on %H by %s",
state->chptr,
- (IsServer(state->sptr) ? state->sptr->name :
- state->sptr->user->server->name));
+ (IsServer(state->sptr) ? cli_name(state->sptr) :
+ cli_name((cli_user(state->sptr))->server)));
else if (MyUser(state->sptr) && state->flags & MODE_PARSE_SET) {
send_reply(state->sptr, ERR_ISCHANSERVICE,
- state->cli_change[i].client->name, state->chptr->chname);
+ cli_name(state->cli_change[i].client),
+ state->chptr->chname);
continue;
}
}
IsOperOnLocalChannel(state->cli_change[i].client,
state->chptr->chname)) {
send_reply(state->sptr, ERR_ISOPERLCHAN,
- state->cli_change[i].client->name, state->chptr->chname);
+ cli_name(state->cli_change[i].client),
+ state->chptr->chname);
continue;
}
#endif
struct ConnectionClass *cl;
unsigned int retc = BAD_CLIENT_CLASS;
- if (acptr && !IsMe(acptr) && (acptr->confs))
- for (tmp = acptr->confs; tmp; tmp = tmp->next)
+ if (acptr && !IsMe(acptr) && (con_confs(acptr)))
+ for (tmp = con_confs(acptr); tmp; tmp = tmp->next)
{
if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class))
continue;
retc = ConClass(cl);
}
- Debug((DEBUG_DEBUG, "Returning Class %d For %s", retc, acptr->name));
+ Debug((DEBUG_DEBUG, "Returning Class %d For %s", retc, cli_name(acptr)));
return (retc);
}
struct ConfItem *aconf;
struct SLink *link;
- link = acptr->confs;
+ link = con_confs(acptr);
if (link) {
while (link) {
}
else {
ping = PINGFREQUENCY;
- Debug((DEBUG_DEBUG, "No Attached Confs for: %s", acptr->name));
+ Debug((DEBUG_DEBUG, "No Attached Confs for: %s", cli_name(acptr)));
}
if (ping <= 0)
ping = PINGFREQUENCY;
- Debug((DEBUG_DEBUG, "Client %s Ping %d", acptr->name, ping));
+ Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
return (ping);
}
assert(0 != cptr);
assert(0 != cptr->local);
- if (cptr->max_sendq)
- return cptr->max_sendq;
+ if (con_max_sendq(cptr))
+ return con_max_sendq(cptr);
- else if (cptr->confs) {
+ else if (con_confs(cptr)) {
struct SLink* tmp;
struct ConnectionClass* cl;
- for (tmp = cptr->confs; tmp; tmp = tmp->next) {
+ for (tmp = con_confs(cptr); tmp; tmp = tmp->next) {
if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class))
continue;
if (ConClass(cl) != BAD_CLIENT_CLASS) {
- cptr->max_sendq = MaxSendq(cl);
- return cptr->max_sendq;
+ con_max_sendq(cptr) = MaxSendq(cl);
+ return con_max_sendq(cptr);
}
}
}
struct ConfItem* aconf;
struct SLink* link;
- for (link = acptr->confs; link; link = link->next) {
+ for (link = con_confs(acptr); link; link = link->next) {
aconf = link->value.aconf;
if (aconf->status & (CONF_CLIENT | CONF_SERVER)) {
int tmp = get_conf_ping(aconf);
if (0 == ping)
ping = PINGFREQUENCY;
- Debug((DEBUG_DEBUG, "Client %s Ping %d", acptr->name, ping));
+ Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
return ping;
}
-
-#if 0
-#define BAD_CONF_CLASS ((unsigned int)-1)
-#define BAD_CLIENT_CLASS ((unsigned int)-3)
-
-unsigned int get_client_class(struct Client* acptr)
-{
- struct SLink *tmp;
- struct ConnectionClass *cl;
- unsigned int retc = BAD_CLIENT_CLASS;
-
- if (acptr && !IsMe(acptr) && (acptr->confs))
- for (tmp = acptr->confs; tmp; tmp = tmp->next)
- {
- if (!tmp->value.aconf || !(cl = tmp->value.aconf->confClass))
- continue;
- if (ConClass(cl) > retc || retc == BAD_CLIENT_CLASS)
- retc = ConClass(cl);
- }
-
- Debug((DEBUG_DEBUG, "Returning Class %d For %s", retc, acptr->name));
-
- return (retc);
-}
-
-unsigned int get_sendq(struct Client *cptr)
-{
- assert(0 != cptr);
- assert(0 != cptr->local);
-
- if (cptr->max_sendq)
- return cptr->max_sendq;
-
- else if (cptr->confs) {
- struct SLink* tmp;
- struct ConnectionClass* cl;
-
- for (tmp = cptr->confs; tmp; tmp = tmp->next) {
- if (!tmp->value.aconf || !(cl = tmp->value.aconf->confClass))
- continue;
- if (ConClass(cl) != BAD_CLIENT_CLASS) {
- cptr->max_sendq = MaxSendq(cl);
- return cptr->max_sendq;
- }
- }
- }
- return DEFAULTMAXSENDQLENGTH;
-}
-#endif
{
if (!IsServer(acptr) && !IsMe(acptr))
continue;
- if (match((char *)crulearg[0], acptr->name))
+ if (match((char *)crulearg[0], cli_name(acptr)))
continue;
return (1);
}
{
if (!(acptr = LocalClientArray[i]) || !IsServer(acptr))
continue;
- if (match((char *)crulearg[0], acptr->name))
+ if (match((char *)crulearg[0], cli_name(acptr)))
continue;
return (1);
}
{
if (!IsServer(acptr) && !IsMe(acptr))
continue;
- if (match((char *)crulearg[1], acptr->name))
+ if (match((char *)crulearg[1], cli_name(acptr)))
continue;
- if (match((char *)crulearg[0], (LocalClientArray[acptr->from->fd])->name))
+ if (match((char *)crulearg[0],
+ cli_name(LocalClientArray[(cli_from(acptr))->fd])))
continue;
return (1);
}
* get the users!
*/
if ((acptr = LocalClientArray[fd])) {
- if (!acptr->user)
+ if (!cli_user(acptr))
continue;
if (acptr->user->username &&
- match (gline->gl_user, acptr->user->username) != 0)
+ match (gline->gl_user, (cli_user(acptr))->username) != 0)
continue;
if (GlineIsIpMask(gline)) {
- Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",cptr->ip.s_addr,gline->ipnum.s_addr,gline->bits));
- if ((acptr->ip.s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
+ Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
+ if (((cli_ip(acptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
continue;
}
else {
/* Inform ops... */
sendto_opmask_butone(0, SNO_GLINE, "%s adding %s %s for %s, expiring at "
- "%Tu: %s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "%Tu: %s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
flags & GLINE_LOCAL ? "local" : "global",
flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
expire + TSoffset, reason);
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
- "expiring at %Tu: %s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "expiring at %Tu: %s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
- "%s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ "%s", IsServer(sptr) ? cli_name(sptr) :
+ cli_name((cli_user(sptr))->server),
msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
(flags & GLINE_LASTMOD && !gline->gl_lastmod))
continue;
- if (match(gline->gl_user, cptr->user->username) != 0)
+ if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
continue;
if (GlineIsIpMask(gline)) {
- Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",cptr->ip.s_addr,gline->ipnum.s_addr,gline->bits));
- if ((cptr->ip.s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
+ Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
+ if (((cli_ip(cptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
continue;
}
else {
- if (match(gline->gl_host, cptr->user->host) != 0)
+ if (match(gline->gl_host, (cli_user(cptr))->host) != 0)
continue;
}
return gline;
*/
int hAddClient(struct Client *cptr)
{
- HASHREGS hashv = strhash(cptr->name);
+ HASHREGS hashv = strhash(cli_name(cptr));
- cptr->hnext = clientTable[hashv];
+ cli_hnext(cptr) = clientTable[hashv];
clientTable[hashv] = cptr;
return 0;
*/
int hRemClient(struct Client *cptr)
{
- HASHREGS hashv = strhash(cptr->name);
+ HASHREGS hashv = strhash(cli_name(cptr));
struct Client *tmp = clientTable[hashv];
if (tmp == cptr) {
- clientTable[hashv] = cptr->hnext;
- cptr->hnext = cptr;
+ clientTable[hashv] = cli_hnext(cptr);
+ cli_hnext(cptr) = cptr;
return 0;
}
while (tmp) {
- if (tmp->hnext == cptr) {
- tmp->hnext = tmp->hnext->hnext;
- cptr->hnext = cptr;
+ if (cli_hnext(tmp) == cptr) {
+ cli_hnext(tmp) = cli_hnext(cli_hnext(tmp));
+ cli_hnext(cptr) = cptr;
return 0;
}
- tmp = tmp->hnext;
+ tmp = cli_hnext(tmp);
}
return -1;
}
struct Client *cptr = clientTable[hashv];
if (cptr) {
- if (0 == (cptr->status & TMask) || 0 != ircd_strcmp(name, cptr->name)) {
+ if (0 == (cli_status(cptr) & TMask) || 0 != ircd_strcmp(name, cli_name(cptr))) {
struct Client* prev;
while (prev = cptr, cptr = cptr->hnext) {
- if ((cptr->status & TMask) && (0 == ircd_strcmp(name, cptr->name))) {
- prev->hnext = cptr->hnext;
- cptr->hnext = clientTable[hashv];
+ if ((cli_status(cptr) & TMask) && (0 == ircd_strcmp(name, cli_name(cptr)))) {
+ cli_hnext(prev) = cli_hnext(cptr);
+ cli_hnext(cptr) = clientTable[hashv];
clientTable[hashv] = cptr;
break;
}
if ((cl = clientTable[i])) {
int len = 0;
++buckets;
- for ( ; cl; cl = cl->hnext)
+ for ( ; cl; cl = cli_hnext(cl))
++len;
if (len > max_chain)
max_chain = len;