+2000-12-12 Kevin L. Mitchell <klmitch@mit.edu>
+
+ * ircd/whowas.c: use new struct Client accessor macros
+
+ * ircd/whocmds.c: use new struct Client accessor macros
+
+ * ircd/send.c: use new struct Client accessor macros
+
+ * ircd/s_user.c: use new struct Client accessor macros; removed
+ some dead code
+
+ * ircd/s_serv.c: use new struct Client accessor macros; removed
+ some dead code
+
+ * ircd/s_numeric.c: use new struct Client accessor macros
+
+ * ircd/s_misc.c: use new struct Client accessor macros
+
+ * ircd/s_debug.c: use new struct Client accessor macros
+
+ * ircd/s_conf.c: use new struct Client accessor macros
+
+ * ircd/s_bsd.c: use new struct Client accessor macros
+
+ * ircd/s_auth.c: use new struct Client accessor macros
+
+ * ircd/parse.c: use new struct Client accessor macros
+
+ * ircd/packet.c: use new struct Client accessor macros
+
+ * ircd/numnicks.c: use new struct Client accessor macros
+
+ * ircd/motd.c: use new struct Client accessor macros
+
+ * ircd/listener.c: use new struct Client accessor macros
+
+ * ircd/list.c: use new struct Client accessor macros
+
+ * ircd/jupe.c: use new struct Client accessor macros
+
+ * ircd/ircd_snprintf.c: use new struct Client accessor macros
+
+ * ircd/ircd_reply.c: use new struct Client accessor macros
+
+ * ircd/ircd_relay.c: use new struct Client accessor macros
+
+ * ircd/ircd.c: use new struct Client accessor macros
+
+ * ircd/gline.c: catch some instances of me.<stuff> I missed
+ previously
+
+ * ircd/client.c: use cli_ instead of con_
+
+ * ircd/class.c: use cli_ instead of con_
+
+ * ircd/channel.c: use cli_ instead of con_
+
+ * ircd/IPcheck.c: use cli_ instead of con_; catch some instances
+ of me.<stuff> I missed previously
+
+ * include/client.h: use cli_ instead of con_...seemed like a good
+ idea at the time *shrug*
+
2000-12-11 Kevin L. Mitchell <klmitch@mit.edu>
* ircd/hash.c: use struct Client accessor macros
#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 cli_count(cli) ((cli)->count)
+#define cli_fd(cli) ((cli)->fd)
+#define cli_error(cli) ((cli)->error)
+#define cli_snomask(cli) ((cli)->snomask)
+#define cli_nextnick(cli) ((cli)->nextnick)
+#define cli_nexttarget(cli) ((cli)->nexttarget)
+#define cli_cookie(cli) ((cli)->cookie)
+#define cli_sendQ(cli) ((cli)->sendQ)
+#define cli_recvQ(cli) ((cli)->recvQ)
+#define cli_sendM(cli) ((cli)->sendM)
+#define cli_sendK(cli) ((cli)->sendK)
+#define cli_receiveM(cli) ((cli)->receiveM)
+#define cli_receiveK(cli) ((cli)->receiveK)
+#define cli_sendB(cli) ((cli)->sendB)
+#define cli_receiveB(cli) ((cli)->receiveB)
+#define cli_listener(cli) ((cli)->listener)
+#define cli_confs(cli) ((cli)->confs)
+#define cli_handler(cli) ((cli)->handler)
+#define cli_dns_reply(cli) ((cli)->dns_reply)
+#define cli_listing(cli) ((cli)->listing)
+#define cli_max_sendq(cli) ((cli)->max_sendq)
+#define cli_ping_freq(cli) ((cli)->ping_freq)
+#define cli_lastsq(cli) ((cli)->lastsq)
+#define cli_port(cli) ((cli)->port)
+#define cli_targets(cli) ((cli)->targets)
+#define cli_sock_ip(cli) ((cli)->sock_ip)
+#define cli_sockhost(cli) ((cli)->sockhost)
+#define cli_passwd(cli) ((cli)->passwd)
+#define cli_buffer(cli) ((cli)->buffer)
#define STAT_CONNECTING 0x001 /* connecting to another server */
#define STAT_HANDSHAKE 0x002 /* pass - server sent */
if (next_target_out)
*next_target_out = CurrentTime - (TARGET_DELAY * free_targets - 1);
}
- else if ((CurrentTime - me.since) > IPCHECK_CLONE_DELAY) {
+ else if ((CurrentTime - cli_since(&me)) > IPCHECK_CLONE_DELAY) {
/*
* Don't refuse connection when we just rebooted the server
*/
struct IPRegistryEntry* entry = ip_registry_find((cli_ip(cptr)).s_addr);
if (!entry) {
- Debug((DEBUG_ERROR, "Missing registry entry for: %s", con_sock_ip(cptr)));
+ Debug((DEBUG_ERROR, "Missing registry entry for: %s", cli_sock_ip(cptr)));
return;
}
if (entry->target) {
- memcpy(con_targets(cptr), entry->target->targets, MAXTARGETS);
+ memcpy(cli_targets(cptr), entry->target->targets, MAXTARGETS);
free_targets = entry->target->count;
tr = " tr";
}
}
assert(0 != entry->target);
- memcpy(entry->target->targets, con_targets(cptr), MAXTARGETS);
+ memcpy(entry->target->targets, cli_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 (con_nexttarget(cptr) < CurrentTime) {
+ if (cli_nexttarget(cptr) < CurrentTime) {
/*
* Number of free targets
*/
- free_targets = (CurrentTime - con_nexttarget(cptr)) / TARGET_DELAY + 1;
+ free_targets = (CurrentTime - cli_nexttarget(cptr)) / TARGET_DELAY + 1;
}
else
free_targets = 0;
for (i = 0; i <= HighestFd; i++)
{
struct Client *acptr = 0;
- if ((acptr = LocalClientArray[i]) && con_listing(acptr) &&
- (con_listing(acptr))->chptr == chptr)
+ if ((acptr = LocalClientArray[i]) && cli_listing(acptr) &&
+ (cli_listing(acptr))->chptr == chptr)
{
list_next_channels(acptr, 1);
break; /* Only one client can list a channel */
/* List and skip all channels that are listen */
void list_next_channels(struct Client *cptr, int nr)
{
- struct ListingArgs *args = con_listing(cptr);
+ struct ListingArgs *args = cli_listing(cptr);
struct Channel *chptr = args->chptr;
chptr->mode.mode &= ~MODE_LISTED;
while (is_listed(chptr) || --nr >= 0)
}
if (!chptr)
{
- MyFree(con_listing(cptr));
- con_listing(cptr) = NULL;
+ MyFree(cli_listing(cptr));
+ cli_listing(cptr) = NULL;
send_reply(cptr, RPL_LISTEND);
break;
}
}
if (chptr)
{
- (con_listing(cptr))->chptr = chptr;
+ (cli_listing(cptr))->chptr = chptr;
chptr->mode.mode |= MODE_LISTED;
}
}
struct ConnectionClass *cl;
unsigned int retc = BAD_CLIENT_CLASS;
- if (acptr && !IsMe(acptr) && (con_confs(acptr)))
- for (tmp = con_confs(acptr); tmp; tmp = tmp->next)
+ if (acptr && !IsMe(acptr) && (cli_confs(acptr)))
+ for (tmp = cli_confs(acptr); tmp; tmp = tmp->next)
{
if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class))
continue;
struct ConfItem *aconf;
struct SLink *link;
- link = con_confs(acptr);
+ link = cli_confs(acptr);
if (link) {
while (link) {
assert(0 != cptr);
assert(0 != cptr->local);
- if (con_max_sendq(cptr))
- return con_max_sendq(cptr);
+ if (cli_max_sendq(cptr))
+ return cli_max_sendq(cptr);
- else if (con_confs(cptr)) {
+ else if (cli_confs(cptr)) {
struct SLink* tmp;
struct ConnectionClass* cl;
- for (tmp = con_confs(cptr); tmp; tmp = tmp->next) {
+ for (tmp = cli_confs(cptr); tmp; tmp = tmp->next) {
if (!tmp->value.aconf || !(cl = tmp->value.aconf->conn_class))
continue;
if (ConClass(cl) != BAD_CLIENT_CLASS) {
- con_max_sendq(cptr) = MaxSendq(cl);
- return con_max_sendq(cptr);
+ cli_max_sendq(cptr) = MaxSendq(cl);
+ return cli_max_sendq(cptr);
}
}
}
struct ConfItem* aconf;
struct SLink* link;
- for (link = con_confs(acptr); link; link = link->next) {
+ for (link = cli_confs(acptr); link; link = link->next) {
aconf = link->value.aconf;
if (aconf->status & (CONF_CLIENT | CONF_SERVER)) {
int tmp = get_conf_ping(aconf);
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
} else {
for (gline = GlobalGlineList; gline; gline = sgline) {
else
send_reply(sptr, RPL_GLIST, gline->gl_user, "@", gline->gl_host,
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
else
send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
gline->gl_expire + TSoffset,
- GlineIsLocal(gline) ? me.name : "*",
+ GlineIsLocal(gline) ? cli_name(&me) : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
}
/* Remove dead clients. */
if (IsDead(cptr)) {
- exit_client(cptr, cptr, &me, cptr->info);
+ exit_client(cptr, cptr, &me, cli_info(cptr));
continue;
}
max_ping = IsRegistered(cptr) ? client_get_ping(cptr) : CONNECTTIMEOUT;
Debug((DEBUG_DEBUG, "check_pings(%s)=status:%s limit: %d current: %d",
- cptr->name, (cptr->flags & FLAGS_PINGSENT) ? "[Ping Sent]" : "[]",
- max_ping, (int)(CurrentTime - cptr->lasttime)));
+ cli_name(cptr), (cli_flags(cptr) & FLAGS_PINGSENT) ? "[Ping Sent]" : "[]",
+ max_ping, (int)(CurrentTime - cli_lasttime(cptr))));
/* Ok, the thing that will happen most frequently, is that someone will
* have sent something recently. Cover this first for speed.
*/
- if (CurrentTime-cptr->lasttime < max_ping) {
- expire = cptr->lasttime + max_ping;
+ if (CurrentTime-cli_lasttime(cptr) < max_ping) {
+ expire = cli_lasttime(cptr) + max_ping;
if (expire < next_check)
next_check = expire;
continue;
}
/* Quit the client after max_ping*2 - they should have answered by now */
- if (CurrentTime-cptr->lasttime >= (max_ping*2) ) {
+ if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) ) {
/* If it was a server, then tell ops about it. */
if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
sendto_opmask_butone(0, SNO_OLDSNO,
- "No response from %s, closing link", cptr->name);
+ "No response from %s, closing link", cli_name(cptr));
exit_client_msg(cptr, cptr, &me, "Ping timeout");
continue;
}
/* Display message if they have sent a NICK and a USER but no
* nospoof PONG.
*/
- if (*cptr->name && cptr->user && *cptr->user->username) {
+ if (*(cli_name(cptr)) && cli_user(cptr) && *(cli_user(cptr))->username) {
send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
":Your client may not be compatible with this server.");
send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
continue;
}
- if (!(cptr->flags & FLAGS_PINGSENT)) {
+ if (!(cli_flags(cptr) & FLAGS_PINGSENT)) {
/* If we havent PINGed the connection and we havent heard from it in a
* while, PING it to make sure it is still alive.
*/
- cptr->flags |= FLAGS_PINGSENT;
+ cli_flags(cptr) |= FLAGS_PINGSENT;
/* If we're late in noticing don't hold it against them :) */
- cptr->lasttime = CurrentTime - max_ping;
+ cli_lasttime(cptr) = CurrentTime - max_ping;
if (IsUser(cptr))
- sendrawto_one(cptr, MSG_PING " :%s", me.name);
+ sendrawto_one(cptr, MSG_PING " :%s", cli_name(&me));
else
- sendcmdto_one(&me, CMD_PING, cptr, ":%s", me.name);
+ sendcmdto_one(&me, CMD_PING, cptr, ":%s", cli_name(&me));
}
- expire = cptr->lasttime + max_ping * 2;
+ expire = cli_lasttime(cptr) + max_ping * 2;
if (expire < next_check)
next_check=expire;
}
case 't': thisServer.bootopt |= BOOT_TTY; break;
case 'd': dpath = optarg; break;
case 'f': configfile = optarg; break;
- case 'h': ircd_strncpy(me.name, optarg, HOSTLEN); break;
+ case 'h': ircd_strncpy(cli_name(&me), optarg, HOSTLEN); break;
case 'v': printf("ircd %s\n", version); exit(0);
case 'x':
umask(077); /* better safe than sorry --SRB */
memset(&me, 0, sizeof(me));
- me.fd = -1;
+ cli_fd(&me) = -1;
parse_command_line(argc, argv);
CurrentTime = time(NULL);
SetMe(&me);
- me.from = &me;
+ cli_from(&me) = &me;
make_server(&me);
- me.serv->timestamp = TStime(); /* Abuse own link timestamp as start TS */
- me.serv->prot = atoi(MAJOR_PROTOCOL);
- me.serv->up = &me;
- me.serv->down = NULL;
- me.handler = SERVER_HANDLER;
+ cli_serv(&me)->timestamp = TStime(); /* Abuse own link timestamp as start TS */
+ cli_serv(&me)->prot = atoi(MAJOR_PROTOCOL);
+ cli_serv(&me)->up = &me;
+ cli_serv(&me)->down = NULL;
+ cli_handler(&me) = SERVER_HANDLER;
SetYXXCapacity(&me, MAXCLIENTS);
- me.lasttime = me.since = me.firsttime = CurrentTime;
+ cli_lasttime(&me) = cli_since(&me) = cli_firsttime(&me) = CurrentTime;
hAddClient(&me);
check_target_limit(sptr, chptr, chptr->chname, 0))
return;
- sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, sptr->from,
+ sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr),
SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
}
check_target_limit(sptr, chptr, chptr->chname, 0))
return;
- sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, sptr->from,
+ sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr),
SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
}
* Servers may have channel services, need to check for it here
*/
if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) {
- sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, sptr->from,
+ sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr),
SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
}
else
* Servers may have channel services, need to check for it here
*/
if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) {
- sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, sptr->from,
+ sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr),
SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
}
}
*host++ = '\0';
if (!(acptr = FindUser(name)) || !MyUser(acptr) ||
- (!EmptyString(host) && 0 != match(host, acptr->user->host))) {
+ (!EmptyString(host) && 0 != match(host, cli_user(acptr)->host))) {
send_reply(sptr, ERR_NOSUCHNICK, name);
return;
}
*host++ = '\0';
if (!(acptr = FindUser(name)) || !MyUser(acptr) ||
- (!EmptyString(host) && 0 != match(host, acptr->user->host)))
+ (!EmptyString(host) && 0 != match(host, cli_user(acptr)->host)))
return;
*server = '@';
send_reply(sptr, ERR_NOSUCHNICK, name);
return;
}
- if (check_target_limit(sptr, acptr, acptr->name, 0) ||
+ if (check_target_limit(sptr, acptr, cli_name(acptr), 0) ||
is_silenced(sptr, acptr))
return;
/*
* send away message if user away
*/
- if (acptr->user && acptr->user->away)
- send_reply(sptr, RPL_AWAY, acptr->name, acptr->user->away);
+ if (cli_user(acptr) && cli_user(acptr)->away)
+ send_reply(sptr, RPL_AWAY, cli_name(acptr), cli_user(acptr)->away);
/*
* deliver the message
*/
if (0 == (acptr = FindUser(name)))
return;
- if (check_target_limit(sptr, acptr, acptr->name, 0) ||
+ if (check_target_limit(sptr, acptr, cli_name(acptr), 0) ||
is_silenced(sptr, acptr))
return;
/*
}
sendcmdto_match_butone(sptr, CMD_PRIVATE, s,
- IsServer(sptr->from) ? sptr->from : 0,
+ IsServer(cli_from(sptr)) ? cli_from(sptr) : 0,
host_mask ? MATCH_HOST : MATCH_SERVER,
"%s :%s", mask, text);
}
}
sendcmdto_match_butone(sptr, CMD_NOTICE, s,
- IsServer(sptr->from) ? sptr->from : 0,
+ IsServer(cli_from(sptr)) ? cli_from(sptr) : 0,
host_mask ? MATCH_HOST : MATCH_SERVER,
"%s :%s", mask, text);
}
++s;
}
sendcmdto_match_butone(sptr, CMD_PRIVATE, s,
- IsServer(sptr->from) ? sptr->from : 0,
+ IsServer(cli_from(sptr)) ? cli_from(sptr) : 0,
host_mask ? MATCH_HOST : MATCH_SERVER,
"%s :%s", mask, text);
}
++s;
}
sendcmdto_match_butone(sptr, CMD_NOTICE, s,
- IsServer(sptr->from) ? sptr->from : 0,
+ IsServer(cli_from(sptr)) ? cli_from(sptr) : 0,
host_mask ? MATCH_HOST : MATCH_SERVER,
"%s :%s", mask, text);
}
va_start(vd.vd_args, pattern);
sendcmdto_flag_butone(&me, CMD_DESYNCH, NULL, FLAGS_DEBUG,
- ":Protocol Violation from %s: %v", cptr->name, &vd);
+ ":Protocol Violation from %s: %v", cli_name(cptr), &vd);
va_end(vd.vd_args);
return 0;
assert(0 != vd.vd_format);
/* build buffer */
- mb = msgq_make(to->from, "%:#C %s %C %v", &me, num->str, to, &vd);
+ mb = msgq_make(cli_from(to), "%:#C %s %C %v", &me, num->str, to, &vd);
va_end(vd.vd_args);
const struct LocalConf* admin = conf_get_local();
assert(0 != sptr);
- send_reply(sptr, RPL_ADMINME, me.name);
+ send_reply(sptr, RPL_ADMINME, cli_name(&me));
send_reply(sptr, RPL_ADMINLOC1, admin->location1);
send_reply(sptr, RPL_ADMINLOC2, admin->location2);
send_reply(sptr, RPL_ADMINEMAIL, admin->contact);
/* &me is used if it's not a definite server */
if (dest && (IsServer(dest) || IsMe(dest))) {
if (IsServer(cptr) || IsMe(cptr))
- str1 = cptr->yxx;
+ str1 = cli_yxx(cptr);
else {
- str1 = cptr->user->server->yxx;
- str2 = cptr->yxx;
+ str1 = cli_yxx(cli_user(cptr)->server);
+ str2 = cli_yxx(cptr);
}
fld_s.flags &= ~(FLAG_ALT | FLAG_COLON);
} else {
- str1 = *cptr->name ? cptr->name : "*";
+ str1 = *cli_name(cptr) ? cli_name(cptr) : "*";
if (!IsServer(cptr) && !IsMe(cptr) && fld_s.flags & FLAG_ALT) {
- assert(0 != cptr->user);
- assert(0 != *cptr->name);
- str2 = cptr->user->username;
- str3 = cptr->user->host;
+ assert(0 != cli_user(cptr));
+ assert(0 != *(cli_name(cptr)));
+ str2 = cli_user(cptr)->username;
+ str3 = cli_user(cptr)->host;
} else
fld_s.flags &= ~FLAG_ALT;
}
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_NETWORK, "%s adding %sJUPE 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 & JUPE_LOCAL ? "local " : "", server,
expire + TSoffset, reason);
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_NETWORK, "%s activating JUPE for %s, expiring "
"at %Tu: %s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ IsServer(sptr) ? cli_name(sptr) : cli_name(cli_user(sptr)->server),
jupe->ju_server, jupe->ju_expire + TSoffset,
jupe->ju_reason);
/* Inform ops and log it */
sendto_opmask_butone(0, SNO_NETWORK, "%s %s JUPE for %s, expiring at %Tu: "
"%s",
- IsServer(sptr) ? sptr->name : sptr->user->server->name,
+ IsServer(sptr) ? cli_name(sptr) : cli_name(cli_user(sptr)->server),
JupeIsLocal(jupe) ? "removing local" : "deactivating",
jupe->ju_server, jupe->ju_expire + TSoffset,
jupe->ju_reason);
/* send jupe information along */
send_reply(sptr, RPL_JUPELIST, jupe->ju_server, jupe->ju_expire + TSoffset,
- JupeIsLocal(jupe) ? me.name : "*",
+ JupeIsLocal(jupe) ? cli_name(&me) : "*",
JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
} else {
for (jupe = GlobalJupeList; jupe; jupe = sjupe) { /* go through jupes */
else /* send jupe information along */
send_reply(sptr, RPL_JUPELIST, jupe->ju_server,
jupe->ju_expire + TSoffset,
- JupeIsLocal(jupe) ? me.name : "*",
+ JupeIsLocal(jupe) ? cli_name(&me) : "*",
JupeIsActive(jupe) ? '+' : '-', jupe->ju_reason);
}
}
*/
for (i = 0; i < MAXCONNECTIONS; ++i) {
cptr = (struct Client*) MyMalloc(CLIENT_LOCAL_SIZE);
- cptr->next = localClientFreeList;
+ cli_next(cptr) = localClientFreeList;
localClientFreeList = cptr;
++localClientAllocCount;
}
* remote client
*/
if ((cptr = remoteClientFreeList))
- remoteClientFreeList = cptr->next;
+ remoteClientFreeList = cli_next(cptr);
else {
cptr = (struct Client*) MyMalloc(CLIENT_REMOTE_SIZE);
++remoteClientAllocCount;
* structure being zeroed out
*/
memset(cptr, 0, CLIENT_REMOTE_SIZE); /* All variables are 0 by default */
- cptr->from = from;
+ cli_from(cptr) = from;
}
else {
/*
* local client
*/
if ((cptr = localClientFreeList))
- localClientFreeList = cptr->next;
+ localClientFreeList = cli_next(cptr);
else {
cptr = (struct Client*) MyMalloc(CLIENT_LOCAL_SIZE);
++localClientAllocCount;
* structure being zeroed out
*/
memset(cptr, 0, CLIENT_LOCAL_SIZE); /* All variables are 0 by default */
- cptr->fd = -1;
- cptr->local = 1;
- cptr->since = cptr->lasttime = cptr->firsttime = CurrentTime;
- cptr->lastnick = TStime();
- cptr->nextnick = CurrentTime - NICK_DELAY;
- cptr->nexttarget = CurrentTime - (TARGET_DELAY * (STARTTARGETS - 1));
- cptr->handler = UNREGISTERED_HANDLER;
- cptr->from = cptr; /* 'from' of local client is self! */
+ cli_fd(cptr) = -1;
+ cli_local(cptr) = 1;
+ cli_since(cptr) = cli_lasttime(cptr) = cli_firsttime(cptr) = CurrentTime;
+ cli_lastnick(cptr) = TStime();
+ cli_nextnick(cptr) = CurrentTime - NICK_DELAY;
+ cli_nexttarget(cptr) = CurrentTime - (TARGET_DELAY * (STARTTARGETS - 1));
+ cli_handler(cptr) = UNREGISTERED_HANDLER;
+ cli_from(cptr) = cptr; /* 'from' of local client is self! */
}
- cptr->status = status;
- cptr->hnext = cptr;
- strcpy(cptr->username, "unknown");
+ cli_status(cptr) = status;
+ cli_hnext(cptr) = cptr;
+ strcpy(cli_username(cptr), "unknown");
#ifdef DEBUGMODE
if (from)
/*
* forget to remove the client from the hash table?
*/
- assert(cptr->hnext == cptr);
+ assert(cli_hnext(cptr) == cptr);
#ifdef DEBUGMODE
- if (cptr->local)
+ if (cli_local(cptr))
--cloc.inuse;
else
--crem.inuse;
#endif
- if (cptr->local) {
+ if (cli_local(cptr)) {
/*
* make sure we have cleaned up local resources
*/
- if (cptr->dns_reply)
- --cptr->dns_reply->ref_count;
- if (-1 < cptr->fd) {
- close(cptr->fd);
+ if (cli_dns_reply(cptr))
+ --(cli_dns_reply(cptr))->ref_count;
+ if (-1 < cli_fd(cptr)) {
+ close(cli_fd(cptr));
}
- MsgQClear(&cptr->sendQ);
- DBufClear(&cptr->recvQ);
- if (cptr->listener)
- release_listener(cptr->listener);
- cptr->next = localClientFreeList;
+ MsgQClear(&(cli_sendQ(cptr)));
+ DBufClear(&(cli_recvQ(cptr)));
+ if (cli_listener(cptr))
+ release_listener(cli_listener(cptr));
+ cli_next(cptr) = localClientFreeList;
localClientFreeList = cptr;
}
else {
- cptr->next = remoteClientFreeList;
+ cli_next(cptr) = remoteClientFreeList;
remoteClientFreeList = cptr;
}
}
struct Server *make_server(struct Client *cptr)
{
- struct Server *serv = cptr->serv;
+ struct Server *serv = cli_serv(cptr);
if (!serv)
{
#ifdef DEBUGMODE
servs.inuse++;
#endif
- cptr->serv = serv;
- cptr->serv->lag = 60000;
+ cli_serv(cptr) = serv;
+ cli_serv(cptr)->lag = 60000;
*serv->by = '\0';
DupString(serv->last_error_msg, "<>"); /* String must be non-empty */
}
- return cptr->serv;
+ return cli_serv(cptr);
}
/*
*/
void remove_client_from_list(struct Client *cptr)
{
- if (cptr->prev)
- cptr->prev->next = cptr->next;
+ if (cli_prev(cptr))
+ cli_next(cli_prev(cptr)) = cli_next(cptr);
else {
- GlobalClientList = cptr->next;
- GlobalClientList->prev = 0;
+ GlobalClientList = cli_next(cptr);
+ cli_prev(GlobalClientList) = 0;
}
- if (cptr->next)
- cptr->next->prev = cptr->prev;
+ if (cli_next(cptr))
+ cli_prev(cli_next(cptr)) = cli_prev(cptr);
- cptr->next = cptr->prev = 0;
+ cli_next(cptr) = cli_prev(cptr) = 0;
- if (IsUser(cptr) && cptr->user) {
+ if (IsUser(cptr) && cli_user(cptr)) {
add_history(cptr, 0);
off_history(cptr);
}
- if (cptr->user) {
- free_user(cptr->user);
- cptr->user = 0;
+ if (cli_user(cptr)) {
+ free_user(cli_user(cptr));
+ cli_user(cptr) = 0;
}
- if (cptr->serv) {
- if (cptr->serv->user) {
- free_user(cptr->serv->user);
- cptr->serv->user = 0;
+ if (cli_serv(cptr)) {
+ if (cli_serv(cptr)->user) {
+ free_user(cli_serv(cptr)->user);
+ cli_serv(cptr)->user = 0;
}
- if (cptr->serv->client_list)
- MyFree(cptr->serv->client_list);
- MyFree(cptr->serv->last_error_msg);
- MyFree(cptr->serv);
+ if (cli_serv(cptr)->client_list)
+ MyFree(cli_serv(cptr)->client_list);
+ MyFree(cli_serv(cptr)->last_error_msg);
+ MyFree(cli_serv(cptr));
#ifdef DEBUGMODE
--servs.inuse;
#endif
* this should mean the "me" is the bottom most item in the list.
* XXX - don't always count on the above, things change
*/
- cptr->prev = 0;
- cptr->next = GlobalClientList;
+ cli_prev(cptr) = 0;
+ cli_next(cptr) = GlobalClientList;
GlobalClientList = cptr;
- if (cptr->next)
- cptr->next->prev = cptr;
+ if (cli_next(cptr))
+ cli_prev(cli_next(cptr)) = cptr;
}
/*
{
static char buf[HOSTLEN + PORTNAMELEN + 4];
assert(0 != listener);
- sprintf_irc(buf, "%s:%u", me.name, listener->port);
+ sprintf_irc(buf, "%s:%u", cli_name(&me), listener->port);
return buf;
}
if (ptr->type == MOTD_CLASS && ptr->id.class == class)
return ptr;
else if (ptr->type == MOTD_HOSTMASK &&
- !match(ptr->id.hostmask, cptr->sockhost))
+ !match(ptr->id.hostmask, cli_sockhost(cptr)))
return ptr;
}
return send_reply(cptr, ERR_NOMOTD);
/* send the motd */
- send_reply(cptr, RPL_MOTDSTART, me.name);
+ send_reply(cptr, RPL_MOTDSTART, cli_name(&me));
send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":- %d-%d-%d %d:%02d",
cache->modtime.tm_year + 1900, cache->modtime.tm_mon + 1,
cache->modtime.tm_mday, cache->modtime.tm_hour,
cache = motd_cache(motd_lookup(cptr));
#ifdef NODEFAULTMOTD
- send_reply(cptr, RPL_MOTDSTART, me.name);
+ send_reply(cptr, RPL_MOTDSTART, cli_name(&me));
send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":\002Type /MOTD to read the AUP "
"before continuing using this service.\002");
send_reply(cptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was last "
if (5 == strlen(yxx)) {
if (0 != (server = FindXNServer(yxx))) {
Debug((DEBUG_DEBUG, "findNUser: %s(%d)", yxx,
- base64toint(yxx + 2) & server->serv->nn_mask));
- return server->serv->client_list[base64toint(yxx + 2) & server->serv->nn_mask];
+ base64toint(yxx + 2) & cli_serv(server)->nn_mask));
+ return cli_serv(server)->client_list[base64toint(yxx + 2) & cli_serv(server)->nn_mask];
}
}
else if (0 != (server = FindNServer(yxx))) {
Debug((DEBUG_DEBUG, "findNUser: %s(%d)",
- yxx, base64toint(yxx + 1) & server->serv->nn_mask));
- return server->serv->client_list[base64toint(yxx + 1) & server->serv->nn_mask];
+ yxx, base64toint(yxx + 1) & cli_serv(server)->nn_mask));
+ return cli_serv(server)->client_list[base64toint(yxx + 1) & cli_serv(server)->nn_mask];
}
return 0;
}
assert(0 != yxx);
if (*yxx) {
Debug((DEBUG_DEBUG, "RemoveYXXClient: %s(%d)", yxx,
- base64toint(yxx) & server->serv->nn_mask));
- server->serv->client_list[base64toint(yxx) & server->serv->nn_mask] = 0;
+ base64toint(yxx) & cli_serv(server)->nn_mask));
+ cli_serv(server)->client_list[base64toint(yxx) & cli_serv(server)->nn_mask] = 0;
}
}
{
unsigned int index;
if (5 == strlen(yxx)) {
- ircd_strncpy(server->yxx, yxx, 2);
- ircd_strncpy(server->serv->nn_capacity, yxx + 2, 3);
+ ircd_strncpy(cli_yxx(server), yxx, 2);
+ ircd_strncpy(cli_serv(server)->nn_capacity, yxx + 2, 3);
}
else {
- server->yxx[0] = yxx[0];
- server->serv->nn_capacity[0] = yxx[1];
- server->serv->nn_capacity[1] = yxx[2];
+ (cli_yxx(server))[0] = yxx[0];
+ cli_serv(server)->nn_capacity[0] = yxx[1];
+ cli_serv(server)->nn_capacity[1] = yxx[2];
}
- server->serv->nn_mask = base64toint(server->serv->nn_capacity);
+ cli_serv(server)->nn_mask = base64toint(cli_serv(server)->nn_capacity);
- index = base64toint(server->yxx);
+ index = base64toint(cli_yxx(server));
if (index >= lastNNServer)
lastNNServer = index + 1;
server_list[index] = server;
/* Note, exit_one_client uses the fact that `client_list' != NULL to
* determine that SetServerYXX has been called - and then calls
* ClearServerYXX. However, freeing the allocation happens in free_client() */
- server->serv->client_list =
- (struct Client**) MyCalloc(server->serv->nn_mask + 1, sizeof(struct Client*));
+ cli_serv(server)->client_list =
+ (struct Client**) MyCalloc(cli_serv(server)->nn_mask + 1, sizeof(struct Client*));
}
void SetYXXCapacity(struct Client* c, unsigned int capacity)
}
--max_clients;
#if defined(EXTENDED_NUMERICS)
- inttobase64(c->serv->nn_capacity, max_clients, 3);
+ inttobase64(cli_serv(c)->nn_capacity, max_clients, 3);
#else
- inttobase64(c->serv->nn_capacity, max_clients, 2);
+ inttobase64(cli_serv(c)->nn_capacity, max_clients, 2);
#endif
- c->serv->nn_mask = max_clients; /* Our Numeric Nick mask */
- c->serv->client_list = (struct Client**) MyCalloc(max_clients + 1,
+ cli_serv(c)->nn_mask = max_clients; /* Our Numeric Nick mask */
+ cli_serv(c)->client_list = (struct Client**) MyCalloc(max_clients + 1,
sizeof(struct Client*));
- server_list[base64toint(c->yxx)] = c;
+ server_list[base64toint(cli_yxx(c))] = c;
}
void SetYXXServerName(struct Client* c, unsigned int numeric)
assert(numeric < NN_MAX_SERVER);
#if defined(EXTENDED_NUMERICS)
- inttobase64(c->yxx, numeric, 2);
+ inttobase64(cli_yxx(c), numeric, 2);
#else
assert(numeric < NUMNICKBASE);
- c->yxx[0] = convert2y[numeric];
+ (cli_yxx(c))[0] = convert2y[numeric];
#endif
if (numeric >= lastNNServer)
lastNNServer = numeric + 1;
void ClearServerYXX(const struct Client *server)
{
- unsigned int index = base64toint(server->yxx);
+ unsigned int index = base64toint(cli_yxx(server));
if (server_list[index] == server) /* Sanity check */
server_list[index] = 0;
}
void SetRemoteNumNick(struct Client* acptr, const char *yxx)
{
struct Client** acptrp;
- struct Client* server = acptr->user->server;
+ struct Client* server = cli_user(acptr)->server;
if (5 == strlen(yxx)) {
- strcpy(acptr->yxx, yxx + 2);
+ strcpy(cli_yxx(acptr), yxx + 2);
}
else {
- acptr->yxx[0] = *++yxx;
- acptr->yxx[1] = *++yxx;
- acptr->yxx[2] = 0;
+ (cli_yxx(acptr))[0] = *++yxx;
+ (cli_yxx(acptr))[1] = *++yxx;
+ (cli_yxx(acptr))[2] = 0;
}
- Debug((DEBUG_DEBUG, "SetRemoteNumNick: %s(%d)", acptr->yxx,
- base64toint(acptr->yxx) & server->serv->nn_mask));
+ Debug((DEBUG_DEBUG, "SetRemoteNumNick: %s(%d)", cli_yxx(acptr),
+ base64toint(cli_yxx(acptr)) & cli_serv(server)->nn_mask));
- acptrp = &server->serv->client_list[base64toint(acptr->yxx) & server->serv->nn_mask];
+ acptrp = &(cli_serv(server))->client_list[base64toint(cli_yxx(acptr)) & cli_serv(server)->nn_mask];
if (*acptrp) {
/*
* this exits the old client in the array, not the client
* that is being set
*/
- exit_client(acptr->from, *acptrp, server, "Numeric nick collision (Ghost)");
+ exit_client(cli_from(acptr), *acptrp, server, "Numeric nick collision (Ghost)");
}
*acptrp = acptr;
}
int SetLocalNumNick(struct Client *cptr)
{
static unsigned int last_nn = 0;
- struct Client** client_list = me.serv->client_list;
- unsigned int mask = me.serv->nn_mask;
+ struct Client** client_list = cli_serv(&me)->client_list;
+ unsigned int mask = cli_serv(&me)->nn_mask;
unsigned int count = 0;
- assert(cptr->user->server == &me);
+ assert(cli_user(cptr)->server == &me);
while (client_list[last_nn & mask]) {
if (++count == NN_MAX_CLIENT) {
client_list[last_nn & mask] = cptr; /* Reserve the numeric ! */
#if defined(EXTENDED_NUMERICS)
- inttobase64(cptr->yxx, last_nn, 3);
+ inttobase64(cli_yxx(cptr), last_nn, 3);
#else
- inttobase64(cptr->yxx, last_nn, 2);
+ inttobase64(cli_yxx(cptr), last_nn, 2);
#endif
if (++last_nn == NN_MAX_CLIENT)
last_nn = 0;
for (i = 0; i < lastNNServer; i++) {
if ((acptr = server_list[i])) {
- if (matchexec(acptr->name, cmask, minlen))
- acptr->flags &= ~FLAGS_MAP;
+ if (matchexec(cli_name(acptr), cmask, minlen))
+ cli_flags(acptr) &= ~FLAGS_MAP;
else {
- acptr->flags |= FLAGS_MAP;
+ cli_flags(acptr) |= FLAGS_MAP;
cnt++;
}
}
if (!(BadPtr(mask))) {
collapse(mask);
for (i = 0; i < lastNNServer; i++) {
- if ((acptr = server_list[i]) && (!match(mask, acptr->name)))
+ if ((acptr = server_list[i]) && (!match(mask, cli_name(acptr))))
return acptr;
}
}
static void update_bytes_received(struct Client* cptr, unsigned int length)
{
- me.receiveB += length; /* Update bytes received */
- cptr->receiveB += length;
+ cli_receiveB(&me) += length; /* Update bytes received */
+ cli_receiveB(cptr) += length;
- if (cptr->receiveB > 1023) {
- cptr->receiveK += (cptr->receiveB >> 10);
- cptr->receiveB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
+ if (cli_receiveB(cptr) > 1023) {
+ cli_receiveK(cptr) += (cli_receiveB(cptr) >> 10);
+ cli_receiveB(cptr) &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
}
- if (me.receiveB > 1023) {
- me.receiveK += (me.receiveB >> 10);
- me.receiveB &= 0x03ff;
+ if (cli_receiveB(&me) > 1023) {
+ cli_receiveK(&me) += (cli_receiveB(&me) >> 10);
+ cli_receiveB(&me) &= 0x03ff;
}
}
static void update_messages_received(struct Client* cptr)
{
- ++me.receiveM;
- ++cptr->receiveM;
+ ++(cli_receiveM(&me));
+ ++(cli_receiveM(cptr));
}
/*
update_bytes_received(cptr, length);
- client_buffer = cptr->buffer;
- endp = client_buffer + cptr->count;
+ client_buffer = cli_buffer(cptr);
+ endp = client_buffer + cli_count(cptr);
src = buffer;
while (length-- > 0) {
update_messages_received(cptr);
- if (parse_server(cptr, cptr->buffer, endp) == CPTR_KILLED)
+ if (parse_server(cptr, cli_buffer(cptr), endp) == CPTR_KILLED)
return CPTR_KILLED;
/*
* Socket is dead so exit
*/
if (IsDead(cptr))
- return exit_client(cptr, cptr, &me, cptr->info);
+ return exit_client(cptr, cptr, &me, cli_info(cptr));
endp = client_buffer;
}
else if (endp < client_buffer + BUFSIZE)
++endp; /* There is always room for the null */
}
- cptr->count = endp - cptr->buffer;
+ cli_count(cptr) = endp - cli_buffer(cptr);
return 1;
}
update_bytes_received(cptr, length);
update_messages_received(cptr);
- if (CPTR_KILLED == parse_client(cptr, cptr->buffer, cptr->buffer + length))
+ if (CPTR_KILLED == parse_client(cptr, cli_buffer(cptr), cli_buffer(cptr) + length))
return CPTR_KILLED;
else if (IsDead(cptr))
- return exit_client(cptr, cptr, &me, cptr->info);
+ return exit_client(cptr, cptr, &me, cli_info(cptr));
return 1;
}
if (IsDead(cptr))
return 0;
- para[0] = from->name;
+ para[0] = cli_name(from);
for (ch = buffer; *ch == ' '; ch++); /* Eat leading spaces */
if (*ch == ':') /* Is any client doing this ? */
{
{
ServerStats->is_empt++;
Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
- cptr->name, from->name));
+ cli_name(cptr), cli_name(from)));
return (-1);
}
}
para[++i] = NULL;
++mptr->count;
-#if 0
- /*
- * The "unregistered command check" was ugly and mildly inefficient.
- * I fixed it. :) --Shadow
- */
- if (!IsUser(cptr) && 0 == (mptr->flags & MFLG_UNREG)) {
- if (0 == (mptr->flags & MFLG_IGNORE))
- sendto_one(from, ":%s %d * %s :Register first.", /* XXX DEAD */
- me.name, ERR_NOTREGISTERED, ch);
- return -1;
- }
-#endif
- handler = mptr->handlers[cptr->handler];
+
+ handler = mptr->handlers[cli_handler(cptr)];
assert(0 != handler);
#ifndef IDLE_FROM_MSG
if (IsUser(cptr) && handler != m_ping && handler != m_ignore)
- from->user->last = CurrentTime;
+ cli_user(from)->last = CurrentTime;
#endif
return (*handler) (cptr, from, i, para);
if (IsDead(cptr))
return 0;
- para[0] = from->name;
+ para[0] = cli_name(from);
/*
* A server ALWAYS sends a prefix. When it starts with a ':' it's the
if (!from)
{
Debug((DEBUG_NOTICE, "Unknown prefix (%s)(%s) from (%s)",
- para[0], buffer, cptr->name));
+ para[0], buffer, cli_name(cptr)));
++ServerStats->is_unpf;
while (*ch == ' ')
ch++;
*/
if (ch[1] == 'Q')
{
- para[0] = cptr->name;
+ para[0] = cli_name(cptr);
from = cptr;
}
else
return 0;
}
- else if (from->from != cptr)
+ else if (cli_from(from) != cptr)
{
++ServerStats->is_wrdi;
Debug((DEBUG_NOTICE, "Fake direction: Message (%s) coming from (%s)",
- buffer, cptr->name));
+ buffer, cli_name(cptr)));
return 0;
}
}
struct Client *server;
/* Kill the unknown numeric prefix upstream if
* it's server still exists: */
- if ((server = FindNServer(numeric_prefix)) && server->from == cptr)
+ if ((server = FindNServer(numeric_prefix)) && cli_from(server) == cptr)
sendcmdto_one(&me, CMD_KILL, cptr, "%s :%s (Unknown numeric nick)",
- numeric_prefix, me.name);
+ numeric_prefix, cli_name(&me));
}
/*
* Things that must be allowed to travel
}
/* Let para[0] point to the name of the sender */
- para[0] = from->name;
+ para[0] = cli_name(from);
- if (from->from != cptr)
+ if (cli_from(from) != cptr)
{
ServerStats->is_wrdi++;
Debug((DEBUG_NOTICE, "Fake direction: Message (%s) coming from (%s)",
- buffer, cptr->name));
+ buffer, cli_name(cptr)));
return 0;
}
}
{
ServerStats->is_empt++;
Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
- cptr->name, from->name));
+ cli_name(cptr), cli_name(from)));
return (-1);
}
return (do_numeric(numeric, (*buffer != ':'), cptr, from, i, para));
mptr->count++;
- return (*mptr->handlers[cptr->handler]) (cptr, from, i, para);
+ return (*mptr->handlers[cli_handler(cptr)]) (cptr, from, i, para);
}
static void release_auth_client(struct Client* client)
{
assert(0 != client);
- client->lasttime = client->since = CurrentTime;
- if (client->fd > HighestFd)
- HighestFd = client->fd;
- LocalClientArray[client->fd] = client;
+ cli_lasttime(client) = cli_since(client) = CurrentTime;
+ if (cli_fd(client) > HighestFd)
+ HighestFd = cli_fd(client);
+ LocalClientArray[cli_fd(client)] = client;
add_client_to_list(client);
Debug((DEBUG_INFO, "Auth: release_auth_client %s@%s[%s]",
- client->username, client->sockhost, client->sock_ip));
+ cli_username(client), cli_sockhost(client), cli_sock_ip(client)));
}
static void auth_kill_client(struct AuthRequest* auth)
* the ip#(s) for the socket is listed for the host.
*/
for (i = 0; hp->h_addr_list[i]; ++i) {
- if (0 == memcmp(hp->h_addr_list[i], &auth->client->ip,
+ if (0 == memcmp(hp->h_addr_list[i], &(cli_ip(auth->client)),
sizeof(struct in_addr)))
break;
}
if (IsUserPort(auth->client))
sendheader(auth->client, REPORT_IP_MISMATCH);
sendto_opmask_butone(0, SNO_IPMISMATCH, "IP# Mismatch: %s != %s[%s]",
- auth->client->sock_ip, hp->h_name,
+ cli_sock_ip(auth->client), hp->h_name,
ircd_ntoa(hp->h_addr_list[0]));
#if defined(KILL_IPMISMATCH)
auth_kill_client(auth);
}
else {
++reply->ref_count;
- auth->client->dns_reply = reply;
- ircd_strncpy(auth->client->sockhost, hp->h_name, HOSTLEN);
+ cli_dns_reply(auth->client) = reply;
+ ircd_strncpy(cli_sockhost(auth->client), hp->h_name, HOSTLEN);
if (IsUserPort(auth->client))
sendheader(auth->client, REPORT_FIN_DNS);
}
* and machines with multiple IP addresses are common now
*/
memset(&local_addr, 0, sizeof(struct sockaddr_in));
- os_get_sockname(auth->client->fd, &local_addr);
+ os_get_sockname(cli_fd(auth->client), &local_addr);
local_addr.sin_port = htons(0);
if (bind(fd, (struct sockaddr*) &local_addr, sizeof(struct sockaddr_in))) {
return 0;
}
- remote_addr.sin_addr.s_addr = auth->client->ip.s_addr;
+ remote_addr.sin_addr.s_addr = (cli_ip(auth->client)).s_addr;
remote_addr.sin_port = htons(113);
remote_addr.sin_family = AF_INET;
assert(0 != auth);
#if !defined(NODNS)
- if (LOOPBACK == inet_netof(client->ip)) {
- strcpy(client->sockhost, me.name);
+ if (LOOPBACK == inet_netof(cli_ip(client))) {
+ strcpy(client->sockhost, cli_name(&me));
}
else {
struct DNSQuery query;
if (IsUserPort(auth->client))
sendheader(client, REPORT_DO_DNS);
- client->dns_reply = gethost_byaddr((const char*) &client->ip, &query);
+ client->dns_reply = gethost_byaddr((const char*) &(cli_ip(client)), &query);
- if (client->dns_reply) {
- ++client->dns_reply->ref_count;
- ircd_strncpy(client->sockhost, client->dns_reply->hp->h_name, HOSTLEN);
+ if (cli_dns_reply(client)) {
+ ++(cli_dns_reply(client))->ref_count;
+ ircd_strncpy(cli_sockhost(client), cli_dns_reply(client)->hp->h_name, HOSTLEN);
if (IsUserPort(auth->client))
sendheader(client, REPORT_FIN_DNSC);
}
assert(0 != auth);
assert(0 != auth->client);
- if (!os_get_sockname(auth->client->fd, &us) ||
- !os_get_peername(auth->client->fd, &them)) {
+ if (!os_get_sockname(cli_fd(auth->client), &us) ||
+ !os_get_peername(cli_fd(auth->client), &them)) {
auth_error(auth, 1);
return;
}
ClearAuth(auth);
if (!EmptyString(username)) {
- ircd_strncpy(auth->client->username, username, USERLEN);
+ ircd_strncpy(cli_username(auth->client), username, USERLEN);
/*
* Not needed, struct is zeroed by memset
* auth->client->username[USERLEN] = '\0';
else {
++ServerStats->is_abad;
#if 0
- strcpy(auth->client->username, "unknown");
+ strcpy(cli_username(auth->client), "unknown");
#endif
}
unlink_auth_request(auth, &AuthPollList);
* Might as well get sockhost from here, the connection is attempted
* with it so if it fails its useless.
*/
- cptr->fd = socket(AF_INET, SOCK_STREAM, 0);
- if (-1 == cptr->fd) {
- cptr->error = errno;
- report_error(SOCKET_ERROR_MSG, cptr->name, errno);
+ cli_fd(cptr) = socket(AF_INET, SOCK_STREAM, 0);
+ if (-1 == cli_fd(cptr)) {
+ cli_error(cptr) = errno;
+ report_error(SOCKET_ERROR_MSG, cli_name(cptr), errno);
return 0;
}
- if (cptr->fd >= MAXCLIENTS) {
- report_error(CONNLIMIT_ERROR_MSG, cptr->name, 0);
- close(cptr->fd);
- cptr->fd = -1;
+ if (cli_fd(cptr) >= MAXCLIENTS) {
+ report_error(CONNLIMIT_ERROR_MSG, cli_name(cptr), 0);
+ close(cli_fd(cptr));
+ cli_fd(cptr) = -1;
return 0;
}
/*
* explicitly bind it, it will default to IN_ADDR_ANY and we lose
* due to the other server not allowing our base IP --smg
*/
- if (bind(cptr->fd, (struct sockaddr*) &VirtualHost, sizeof(VirtualHost))) {
- report_error(BIND_ERROR_MSG, cptr->name, errno);
+ if (bind(cli_fd(cptr), (struct sockaddr*) &VirtualHost, sizeof(VirtualHost))) {
+ report_error(BIND_ERROR_MSG, cli_name(cptr), errno);
return 0;
}
#endif
/*
* save connection info in client
*/
- cptr->ip.s_addr = aconf->ipnum.s_addr;
- cptr->port = aconf->port;
- ircd_ntoa_r(cptr->sock_ip, (const char*) &cptr->ip);
+ (cli_ip(cptr)).s_addr = aconf->ipnum.s_addr;
+ cli_port(cptr) = aconf->port;
+ ircd_ntoa_r(cli_sock_ip(cptr), (const char*) &(cli_ip(cptr)));
/*
* we want a big buffer for server connections
*/
- if (!os_set_sockbufs(cptr->fd, SERVER_TCP_WINDOW)) {
- cptr->error = errno;
- report_error(SETBUFS_ERROR_MSG, cptr->name, errno);
+ if (!os_set_sockbufs(cli_fd(cptr), SERVER_TCP_WINDOW)) {
+ cli_error(cptr) = errno;
+ report_error(SETBUFS_ERROR_MSG, cli_name(cptr), errno);
return 0;
}
/*
* ALWAYS set sockets non-blocking
*/
- if (!os_set_nonblocking(cptr->fd)) {
- cptr->error = errno;
- report_error(NONB_ERROR_MSG, cptr->name, errno);
+ if (!os_set_nonblocking(cli_fd(cptr))) {
+ cli_error(cptr) = errno;
+ report_error(NONB_ERROR_MSG, cli_name(cptr), errno);
return 0;
}
- if (!os_connect_nonb(cptr->fd, &sin)) {
- cptr->error = errno;
- report_error(CONNECT_ERROR_MSG, cptr->name, errno);
+ if (!os_connect_nonb(cli_fd(cptr), &sin)) {
+ cli_error(cptr) = errno;
+ report_error(CONNECT_ERROR_MSG, cli_name(cptr), errno);
return 0;
}
return 1;
unsigned int bytes_count = 0;
assert(0 != cptr);
- switch (os_sendv_nonb(cptr->fd, buf, &bytes_count, &bytes_written)) {
+ switch (os_sendv_nonb(cli_fd(cptr), buf, &bytes_count, &bytes_written)) {
case IO_SUCCESS:
- cptr->flags &= ~FLAGS_BLOCKED;
+ cli_flags(cptr) &= ~FLAGS_BLOCKED;
- cptr->sendB += bytes_written;
- me.sendB += bytes_written;
- if (cptr->sendB > 1023) {
- cptr->sendK += (cptr->sendB >> 10);
- cptr->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
+ cli_sendB(cptr) += bytes_written;
+ cli_sendB(&me) += bytes_written;
+ if (cli_sendB(cptr) > 1023) {
+ cli_sendK(cptr) += (cli_sendB(cptr) >> 10);
+ cli_sendB(cptr) &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
}
- if (me.sendB > 1023) {
- me.sendK += (me.sendB >> 10);
- me.sendB &= 0x03ff;
+ if (cli_sendB(&me) > 1023) {
+ cli_sendK(&me) += (cli_sendB(&me) >> 10);
+ cli_sendB(&me) &= 0x03ff;
}
/*
* XXX - hrmm.. set blocked here? the socket didn't
* say it was blocked
*/
if (bytes_written < bytes_count)
- cptr->flags |= FLAGS_BLOCKED;
+ cli_flags(cptr) |= FLAGS_BLOCKED;
break;
case IO_BLOCKED:
- cptr->flags |= FLAGS_BLOCKED;
+ cli_flags(cptr) |= FLAGS_BLOCKED;
break;
case IO_FAILURE:
- cptr->error = errno;
- cptr->flags |= FLAGS_DEADSOCKET;
+ cli_error(cptr) = errno;
+ cli_flags(cptr) |= FLAGS_DEADSOCKET;
break;
}
return bytes_written;
assert(0 != cptr);
assert(MyConnect(cptr));
- if (cptr->dns_reply) {
- assert(0 < cptr->dns_reply->ref_count);
- --cptr->dns_reply->ref_count;
- cptr->dns_reply = 0;
+ if (cli_dns_reply(cptr)) {
+ assert(0 < cli_dns_reply(cptr)->ref_count);
+ --(cli_dns_reply(cptr))->ref_count;
+ cli_dns_reply(cptr) = 0;
}
}
* get the socket status from the fd first to check if
* connection actually succeeded
*/
- if ((cptr->error = os_get_sockerr(cptr->fd))) {
- const char* msg = strerror(cptr->error);
+ if ((cli_error(cptr) = os_get_sockerr(cli_fd(cptr)))) {
+ const char* msg = strerror(cli_error(cptr));
if (!msg)
msg = "Unknown error";
sendto_opmask_butone(0, SNO_OLDSNO, "Connection failed to %s: %s",
- cptr->name, msg);
+ cli_name(cptr), msg);
return 0;
}
- if (!(aconf = find_conf_byname(cptr->confs, cptr->name, CONF_SERVER))) {
- sendto_opmask_butone(0, SNO_OLDSNO, "Lost Server Line for %s", cptr->name);
+ if (!(aconf = find_conf_byname(cli_confs(cptr), cli_name(cptr), CONF_SERVER))) {
+ sendto_opmask_butone(0, SNO_OLDSNO, "Lost Server Line for %s", cli_name(cptr));
return 0;
}
if (!EmptyString(aconf->passwd))
sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd);
-#if 0
- /* dead code, already done in connect_server */
- make_server(cptr);
-#endif
/*
* Create a unique timestamp
*/
for (i = HighestFd; i > -1; --i) {
if ((acptr = LocalClientArray[i]) &&
(IsServer(acptr) || IsHandshake(acptr))) {
- if (acptr->serv->timestamp >= newts)
- newts = acptr->serv->timestamp + 1;
+ if (cli_serv(acptr)->timestamp >= newts)
+ newts = cli_serv(acptr)->timestamp + 1;
}
}
- assert(0 != cptr->serv);
+ assert(0 != cli_serv(cptr));
- cptr->serv->timestamp = newts;
+ cli_serv(cptr)->timestamp = newts;
SetHandshake(cptr);
/*
* Make us timeout after twice the timeout for DNS look ups
*/
- cptr->lasttime = CurrentTime;
- cptr->flags |= FLAGS_PINGSENT;
+ cli_lasttime(cptr) = CurrentTime;
+ cli_flags(cptr) |= FLAGS_PINGSENT;
sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s",
- me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL,
- NumServCap(&me), me.info);
+ cli_name(&me), cli_serv(&me)->timestamp, newts, MAJOR_PROTOCOL,
+ NumServCap(&me), cli_info(&me));
return (IsDead(cptr)) ? 0 : 1;
}
if (IsServer(cptr)) {
ServerStats->is_sv++;
- ServerStats->is_sbs += cptr->sendB;
- ServerStats->is_sbr += cptr->receiveB;
- ServerStats->is_sks += cptr->sendK;
- ServerStats->is_skr += cptr->receiveK;
- ServerStats->is_sti += CurrentTime - cptr->firsttime;
+ ServerStats->is_sbs += cli_sendB(cptr);
+ ServerStats->is_sbr += cli_receiveB(cptr);
+ ServerStats->is_sks += cli_sendK(cptr);
+ ServerStats->is_skr += cli_receiveK(cptr);
+ ServerStats->is_sti += CurrentTime - cli_firsttime(cptr);
if (ServerStats->is_sbs > 1023) {
ServerStats->is_sks += (ServerStats->is_sbs >> 10);
ServerStats->is_sbs &= 0x3ff;
* If the connection has been up for a long amount of time, schedule
* a 'quick' reconnect, else reset the next-connect cycle.
*/
- if ((aconf = find_conf_exact(cptr->name, 0, cptr->sockhost, CONF_SERVER))) {
+ if ((aconf = find_conf_exact(cli_name(cptr), 0, cli_sockhost(cptr), CONF_SERVER))) {
/*
* Reschedule a faster reconnect, if this was a automaticly
* connected configuration entry. (Note that if we have had
}
else if (IsUser(cptr)) {
ServerStats->is_cl++;
- ServerStats->is_cbs += cptr->sendB;
- ServerStats->is_cbr += cptr->receiveB;
- ServerStats->is_cks += cptr->sendK;
- ServerStats->is_ckr += cptr->receiveK;
- ServerStats->is_cti += CurrentTime - cptr->firsttime;
+ ServerStats->is_cbs += cli_sendB(cptr);
+ ServerStats->is_cbr += cli_receiveB(cptr);
+ ServerStats->is_cks += cli_sendK(cptr);
+ ServerStats->is_ckr += cli_receiveK(cptr);
+ ServerStats->is_cti += CurrentTime - cli_firsttime(cptr);
if (ServerStats->is_cbs > 1023) {
ServerStats->is_cks += (ServerStats->is_cbs >> 10);
ServerStats->is_cbs &= 0x3ff;
else
ServerStats->is_ni++;
- if (-1 < cptr->fd) {
+ if (-1 < cli_fd(cptr)) {
flush_connections(cptr);
- LocalClientArray[cptr->fd] = 0;
- close(cptr->fd);
- cptr->fd = -1;
+ LocalClientArray[cli_fd(cptr)] = 0;
+ close(cli_fd(cptr));
+ cli_fd(cptr) = -1;
}
- cptr->flags |= FLAGS_DEADSOCKET;
+ cli_flags(cptr) |= FLAGS_DEADSOCKET;
- MsgQClear(&cptr->sendQ);
- DBufClear(&cptr->recvQ);
- memset(cptr->passwd, 0, sizeof(cptr->passwd));
+ MsgQClear(&(cli_sendQ(cptr)));
+ DBufClear(&(cli_recvQ(cptr)));
+ memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr)));
set_snomask(cptr, 0, SNO_SET);
det_confs_butmask(cptr, 0);
- if (cptr->listener) {
- release_listener(cptr->listener);
- cptr->listener = 0;
+ if (cli_listener(cptr)) {
+ release_listener(cli_listener(cptr));
+ cli_listener(cptr) = 0;
}
for ( ; HighestFd > 0; --HighestFd) {
* Copy ascii address to 'sockhost' just in case. Then we have something
* valid to put into error messages...
*/
- ircd_ntoa_r(new_client->sock_ip, (const char*) &addr.sin_addr);
- strcpy(new_client->sockhost, new_client->sock_ip);
- new_client->ip.s_addr = addr.sin_addr.s_addr;
- new_client->port = ntohs(addr.sin_port);
+ ircd_ntoa_r(cli_sock_ip(new_client), (const char*) &addr.sin_addr);
+ strcpy(cli_sockhost(new_client), cli_sock_ip(new_client));
+ (cli_ip(new_client)).s_addr = addr.sin_addr.s_addr;
+ cli_port(new_client) = ntohs(addr.sin_port);
if (next_target)
- new_client->nexttarget = next_target;
+ cli_nexttarget(new_client) = next_target;
- new_client->fd = fd;
- new_client->listener = listener;
+ cli_fd(new_client) = fd;
+ cli_listener(new_client) = listener;
++listener->ref_count;
Count_newunknown(UserStats);
unsigned int dolen = 0;
unsigned int length = 0;
- if (socket_ready && !(IsUser(cptr) && DBufLength(&cptr->recvQ) > CLIENT_FLOOD)) {
- switch (os_recv_nonb(cptr->fd, readbuf, sizeof(readbuf), &length)) {
+ if (socket_ready && !(IsUser(cptr) && DBufLength(&(cli_recvQ(cptr))) > CLIENT_FLOOD)) {
+ switch (os_recv_nonb(cli_fd(cptr), readbuf, sizeof(readbuf), &length)) {
case IO_SUCCESS:
if (length) {
- cptr->lasttime = CurrentTime;
- if (cptr->lasttime > cptr->since)
- cptr->since = cptr->lasttime;
- cptr->flags &= ~(FLAGS_PINGSENT | FLAGS_NONL);
+ cli_lasttime(cptr) = CurrentTime;
+ if (cli_lasttime(cptr) > cli_since(cptr))
+ cli_since(cptr) = cli_lasttime(cptr);
+ cli_flags(cptr) &= ~(FLAGS_PINGSENT | FLAGS_NONL);
}
break;
case IO_BLOCKED:
break;
case IO_FAILURE:
- cptr->error = errno;
+ cli_error(cptr) = errno;
/* cptr->flags |= FLAGS_DEADSOCKET; */
return 0;
}
* it on the end of the receive queue and do it when its
* turn comes around.
*/
- if (length > 0 && 0 == dbuf_put(&cptr->recvQ, readbuf, length)) {
+ if (length > 0 && 0 == dbuf_put(&(cli_recvQ(cptr)), readbuf, length)) {
return exit_client(cptr, cptr, &me, "dbuf_put fail");
}
#ifndef NOFLOODCONTROL
/*
* XXX - cptr will always be a user or unregistered
*/
- if (IsUser(cptr) && DBufLength(&cptr->recvQ) > CLIENT_FLOOD)
+ if (IsUser(cptr) && DBufLength(&(cli_recvQ(cptr))) > CLIENT_FLOOD)
return exit_client(cptr, cptr, &me, "Excess Flood");
- while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr) &&
- (IsTrusted(cptr) || cptr->since - CurrentTime < 10))
+ while (DBufLength(&(cli_recvQ(cptr))) && !NoNewLine(cptr) &&
+ (IsTrusted(cptr) || cli_since(cptr) - CurrentTime < 10))
#else
- while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr))
+ while (DBufLength(&(cli_recvQ(cptr))) && !NoNewLine(cptr))
#endif
{
/*
* then skip the per-message parsing below.
*/
if (IsServer(cptr)) {
- dolen = dbuf_get(&cptr->recvQ, readbuf, sizeof(readbuf));
+ dolen = dbuf_get(&(cli_recvQ(cptr)), readbuf, sizeof(readbuf));
return (dolen) ? server_dopacket(cptr, readbuf, dolen) : 1;
}
- dolen = dbuf_getmsg(&cptr->recvQ, cptr->buffer, BUFSIZE);
+ dolen = dbuf_getmsg(&(cli_recvQ(cptr)), cli_buffer(cptr), BUFSIZE);
/*
* Devious looking...whats it do ? well..if a client
* sends a *long* message without any CR or LF, then
* -avalon
*/
if (0 == dolen) {
- if (DBufLength(&cptr->recvQ) < 510)
+ if (DBufLength(&(cli_recvQ(cptr))) < 510)
cptr->flags |= FLAGS_NONL;
else
- DBufClear(&cptr->recvQ);
+ DBufClear(&(cli_recvQ(cptr)));
}
else if (CPTR_KILLED == client_dopacket(cptr, dolen))
return CPTR_KILLED;
/*
* ...room for writing, empty some queue then...
*/
- cptr->flags &= ~FLAGS_BLOCKED;
+ cli_flags(cptr) &= ~FLAGS_BLOCKED;
if (IsConnecting(cptr)) {
if (!completed_connection(cptr))
return 0;
}
- else if (cptr->listing && MsgQLength(&cptr->sendQ) < 2048)
+ else if (cli_listing(cptr) && MsgQLength(&(cli_sendQ(cptr))) < 2048)
list_next_channels(cptr, 64);
send_queued(cptr);
return 1;
for (i = HighestFd; -1 < i; --i) {
if ((cptr = LocalClientArray[i])) {
- if (DBufLength(&cptr->recvQ))
+ if (DBufLength(&(cli_recvQ(cptr))))
delay2 = 1;
- if (DBufLength(&cptr->recvQ) < 4088 || IsServer(cptr)) {
+ if (DBufLength(&(cli_recvQ(cptr))) < 4088 || IsServer(cptr)) {
PFD_SETR(i);
}
- if (MsgQLength(&cptr->sendQ) || IsConnecting(cptr) ||
- (cptr->listing && MsgQLength(&cptr->sendQ) < 2048)) {
+ if (MsgQLength(&(cli_sendQ(cptr))) || IsConnecting(cptr) ||
+ (cli_listing(cptr) && MsgQLength(&(cli_sendQ(cptr))) < 2048)) {
PFD_SETW(i);
}
}
if (EINTR == errno)
return -1;
- report_error(POLL_ERROR_MSG, me.name, errno);
+ report_error(POLL_ERROR_MSG, cli_name(&me), errno);
++res;
if (res > 5)
server_restart("too many poll errors");
}
if (write_ready) {
if (!on_write_unblocked(cptr) || IsDead(cptr)) {
- const char* msg = (cptr->error) ? strerror(cptr->error) : cptr->info;
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : cli_info(cptr);
if (!msg)
msg = "Unknown error";
exit_client(cptr, cptr, &me, msg);
flush_connections(poll_cptr[i]);
#endif
if (IsDead(cptr)) {
- const char* msg = (cptr->error) ? strerror(cptr->error) : cptr->info;
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : cli_info(cptr);
if (!msg)
msg = "Unknown error";
exit_client(cptr, cptr, &me, (char*) msg);
}
if (length > 0)
continue;
- cptr->flags |= FLAGS_DEADSOCKET;
+ cli_flags(cptr) |= FLAGS_DEADSOCKET;
/*
* ...hmm, with non-blocking sockets we might get
* here from quite valid reasons, although.. why
*/
Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", pfd->fd, errno, length));
- if ((IsServer(cptr) || IsHandshake(cptr)) && cptr->error == 0 && length == 0)
+ if ((IsServer(cptr) || IsHandshake(cptr)) && cli_error(cptr) == 0 && length == 0)
exit_client_msg(cptr, cptr, &me, "Server %s closed the connection (%s)",
- cptr->name, cptr->serv->last_error_msg);
+ cli_name(cptr), cli_serv(cptr)->last_error_msg);
else {
- const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : "EOF from client";
if (!msg)
msg = "Unknown error";
exit_client_msg(cptr, cptr, &me, "Read error: %s", msg);
for (i = HighestFd; i > -1; --i) {
if ((cptr = LocalClientArray[i])) {
- if (DBufLength(&cptr->recvQ))
+ if (DBufLength(&(cli_recvQ(cptr))))
delay2 = 1;
- if (DBufLength(&cptr->recvQ) < 4088 || IsServer(cptr))
+ if (DBufLength(&(cli_recvq(cptr))) < 4088 || IsServer(cptr))
FD_SET(i, &read_set);
- if (MsgQLength(&cptr->sendQ) || IsConnecting(cptr) ||
- (cptr->listing && MsgQLength(&cptr->sendQ) < 2048))
+ if (MsgQLength(&(cli_sendq(cptr))) || IsConnecting(cptr) ||
+ (cli_listing(cptr) && MsgQLength(&(cli_sendQ(cptr))) < 2048))
FD_SET(i, &write_set);
}
}
if (errno == EINTR)
return -1;
- report_error(SELECT_ERROR_MSG, me.name, errno);
+ report_error(SELECT_ERROR_MSG, cli_name(&me), errno);
if (++res > 5)
server_restart("too many select errors");
sleep(1);
if (FD_ISSET(i, &write_set)) {
--nfds;
if (!on_write_unblocked(cptr) || IsDead(cptr)) {
- const char* msg = (cptr->error) ? strerror(cptr->error) : cptr->info;
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : cli_info(cptr);
if (!msg)
msg = "Unknown error";
if (FD_ISSET(i, &read_set))
continue;
}
if (IsDead(cptr)) {
- const char* msg = (cptr->error) ? strerror(cptr->error) : cptr->info;
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : cli_info(cptr);
if (!msg)
msg = "Unknown error";
exit_client(cptr, cptr, &me, msg);
* in due course, select() returns that fd as ready
* for reading even though it ends up being an EOF. -avalon
*/
- Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", i, cptr->error, length));
+ Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", i, cli_error(cptr), length));
- if ((IsServer(cptr) || IsHandshake(cptr)) && cptr->error == 0 && length == 0)
+ if ((IsServer(cptr) || IsHandshake(cptr)) && cli_error(cptr) == 0 && length == 0)
exit_client_msg(cptr, cptr, &me, "Server %s closed the connection (%s)",
- cptr->name, cptr->serv->last_error_msg);
+ cli_name(cptr), cli_serv(cptr)->last_error_msg);
else {
- const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
+ const char* msg = (cli_error(cptr)) ? strerror(cli_error(cptr)) : "EOF from client";
if (!msg)
msg = "Unknown error";
exit_client_msg(cptr, cptr, &me, "Read error: %s", msg);
if ((cptr = FindClient(aconf->name))) {
if (IsServer(cptr) || IsMe(cptr)) {
sendto_opmask_butone(0, SNO_OLDSNO, "Server %s already present from %s",
- aconf->name, cptr->from->name);
+ aconf->name, cli_name(cli_from(cptr)));
if (by && IsUser(by) && !MyUser(by)) {
sendcmdto_one(&me, CMD_NOTICE, by, "%C :Server %s already present "
- "from %s", by, aconf->name, cptr->from->name);
+ "from %s", by, aconf->name, cli_name(cli_from(cptr)));
}
return 0;
}
else if (IsHandshake(cptr) || IsConnecting(cptr)) {
if (by && IsUser(by)) {
sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connection to %s already in "
- "progress", by, cptr->name);
+ "progress", by, cli_name(cptr));
}
return 0;
}
cptr = make_client(NULL, STAT_UNKNOWN_SERVER);
if (reply)
++reply->ref_count;
- cptr->dns_reply = reply;
+ cli_dns_reply(cptr) = reply;
/*
* Copy these in so we have something for error detection.
*/
- ircd_strncpy(cptr->name, aconf->name, HOSTLEN);
- ircd_strncpy(cptr->sockhost, aconf->host, HOSTLEN);
+ ircd_strncpy(cli_name(cptr), aconf->name, HOSTLEN);
+ ircd_strncpy(cli_sockhost(cptr), aconf->host, HOSTLEN);
/*
* Attach config entries to client here rather than in
*/
attach_confs_byhost(cptr, aconf->host, CONF_SERVER);
- if (!find_conf_byhost(cptr->confs, aconf->host, CONF_SERVER)) {
+ if (!find_conf_byhost(cli_confs(cptr), aconf->host, CONF_SERVER)) {
sendto_opmask_butone(0, SNO_OLDSNO, "Host %s is not enabled for "
"connecting: no C-line", aconf->name);
if (by && IsUser(by) && !MyUser(by)) {
if (!connect_inet(aconf, cptr)) {
if (by && IsUser(by) && !MyUser(by)) {
sendcmdto_one(&me, CMD_NOTICE, by, "%C :Couldn't connect to %s", by,
- cptr->name);
+ cli_name(cptr));
}
det_confs_butmask(cptr, 0);
free_client(cptr);
*/
make_server(cptr);
if (by && IsUser(by)) {
- sprintf_irc(cptr->serv->by, "%s%s", NumNick(by));
- assert(0 == cptr->serv->user);
- cptr->serv->user = by->user;
+ sprintf_irc(cli_serv(cptr)->by, "%s%s", NumNick(by));
+ assert(0 == cli_serv(cptr)->user);
+ cli_serv(cptr)->user = by->user;
by->user->refcnt++;
}
else {
- *cptr->serv->by = '\0';
+ *(cli_serv(cptr))->by = '\0';
/* strcpy(cptr->serv->by, "Auto"); */
}
- cptr->serv->up = &me;
+ cli_serv(cptr)->up = &me;
SetConnecting(cptr);
- if (cptr->fd > HighestFd)
- HighestFd = cptr->fd;
+ if (cli_fd(cptr) > HighestFd)
+ HighestFd = cli_fd(cptr);
- LocalClientArray[cptr->fd] = cptr;
+ LocalClientArray[cli_fd(cptr)] = cptr;
Count_newunknown(UserStats);
/* Actually we lie, the connect hasn't succeeded yet, but we have a valid
const struct LocalConf* conf = conf_get_local();
assert(0 != conf);
- ircd_strncpy(me.name, conf->name, HOSTLEN);
+ ircd_strncpy(cli_name(&me), conf->name, HOSTLEN);
SetYXXServerName(&me, conf->numeric);
}
assert(0 != cptr);
assert(0 < aconf->clients);
- lp = &(cptr->confs);
+ lp = &(cli_confs(cptr));
while (*lp) {
if ((*lp)->value.aconf == aconf) {
struct SLink* next;
assert(0 != cptr);
- for (link = cptr->confs; link; link = next) {
+ for (link = cli_confs(cptr); link; link = next) {
next = link->next;
if ((link->value.aconf->status & mask) == 0)
detach_conf(cptr, link->value.aconf);
assert(0 != cptr);
- if (cptr->dns_reply)
- hp = cptr->dns_reply->hp;
+ if (cli_dns_reply(cptr))
+ hp = cli_dns_reply(cptr)->hp;
for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
if (aconf->status != CONF_CLIENT)
continue;
- if (aconf->port && aconf->port != cptr->listener->port)
+ if (aconf->port && aconf->port != cli_listener(cptr)->port)
continue;
if (!aconf->host || !aconf->name)
continue;
ircd_strncpy(fullname, hname, HOSTLEN);
fullname[HOSTLEN] = '\0';
- Debug((DEBUG_DNS, "a_il: %s->%s", cptr->sockhost, fullname));
+ Debug((DEBUG_DNS, "a_il: %s->%s", cli_sockhost(cptr), fullname));
if (strchr(aconf->name, '@')) {
- strcpy(uhost, cptr->username);
+ strcpy(uhost, cli_username(cptr));
strcat(uhost, "@");
}
else
uhost[sizeof(uhost) - 1] = 0;
if (0 == match(aconf->name, uhost)) {
if (strchr(uhost, '@'))
- cptr->flags |= FLAGS_DOID;
+ cli_flags(cptr) |= FLAGS_DOID;
return check_limit_and_attach(cptr, aconf);
}
}
}
if (strchr(aconf->host, '@')) {
- ircd_strncpy(uhost, cptr->username, sizeof(uhost) - 2);
+ ircd_strncpy(uhost, cli_username(cptr), sizeof(uhost) - 2);
uhost[sizeof(uhost) - 2] = 0;
strcat(uhost, "@");
}
else
*uhost = '\0';
- strncat(uhost, cptr->sock_ip, sizeof(uhost) - 1 - strlen(uhost));
+ strncat(uhost, cli_sock_ip(cptr), sizeof(uhost) - 1 - strlen(uhost));
uhost[sizeof(uhost) - 1] = 0;
if (match(aconf->host, uhost))
continue;
if (strchr(uhost, '@'))
- cptr->flags |= FLAGS_DOID;
+ cli_flags(cptr) |= FLAGS_DOID;
return check_limit_and_attach(cptr, aconf);
}
/*
* XXX - shouldn't be setting these directly here
*/
- ircd_strncpy(me.info, fields[3], REALLEN);
+ ircd_strncpy(cli_info(&me), fields[3], REALLEN);
set_virtual_host(localConf.vhost_address);
}
assert(0 != cptr);
- if (!cptr->user)
+ if (!cli_user(cptr))
return 0;
- host = cptr->sockhost;
- name = cptr->user->username;
+ host = cli_sockhost(cptr);
+ name = cli_user(cptr)->username;
assert(strlen(host) <= HOSTLEN);
assert((name ? strlen(name) : 0) <= HOSTLEN);
if (deny->ip_kill) { /* k: by IP */
Debug((DEBUG_DEBUG, "ip: %08x network: %08x/%i mask: %08x",
- cptr->ip.s_addr, deny->s_addr, deny->bits, NETMASK(deny->bits)));
- if ((cptr->ip.s_addr & NETMASK(deny->bits)) == deny->s_addr)
+ cli_ip(cptr).s_addr, deny->s_addr, deny->bits, NETMASK(deny->bits)));
+ if ((cli_ip(cptr).s_addr & NETMASK(deny->bits)) == deny->s_addr)
break;
}
else if (0 == match(deny->hostmask, host))
if ((acr = attach_iline(cptr))) {
Debug((DEBUG_DNS, "ch_cl: access denied: %s[%s]",
- cptr->name, cptr->sockhost));
+ cli_name(cptr), cli_sockhost(cptr)));
return acr;
}
return ACR_OK;
struct SLink* lp;
Debug((DEBUG_DNS, "sv_cl: check access for %s[%s]",
- cptr->name, cptr->sockhost));
+ cli_name(cptr), cli_sockhost(cptr)));
- if (IsUnknown(cptr) && !attach_confs_byname(cptr, cptr->name, CONF_SERVER)) {
- Debug((DEBUG_DNS, "No C/N lines for %s", cptr->sockhost));
+ if (IsUnknown(cptr) && !attach_confs_byname(cptr, cli_name(cptr), CONF_SERVER)) {
+ Debug((DEBUG_DNS, "No C/N lines for %s", cli_sockhost(cptr)));
return -1;
}
- lp = cptr->confs;
+ lp = cli_confs(cptr);
/*
* We initiated this connection so the client should have a C and N
* line already attached after passing through the connect_server()
* function earlier.
*/
if (IsConnecting(cptr) || IsHandshake(cptr)) {
- c_conf = find_conf_byname(lp, cptr->name, CONF_SERVER);
+ c_conf = find_conf_byname(lp, cli_name(cptr), CONF_SERVER);
if (!c_conf) {
sendto_opmask_butone(0, SNO_OLDSNO, "Connect Error: lost C:line for %s",
- cptr->name);
+ cli_name(cptr));
det_confs_butmask(cptr, 0);
return -1;
}
ClearAccess(cptr);
if (!c_conf) {
- if (cptr->dns_reply) {
+ if (cli_dns_reply(cptr)) {
int i;
- struct hostent* hp = cptr->dns_reply->hp;
+ struct hostent* hp = cli_dns_reply(cptr)->hp;
const char* name = hp->h_name;
/*
* If we are missing a C or N line from above, search for
*/
for (i = 0; name; name = hp->h_aliases[i++]) {
if ((c_conf = find_conf_byhost(lp, name, CONF_SERVER))) {
- ircd_strncpy(cptr->sockhost, name, HOSTLEN);
+ ircd_strncpy(cli_sockhost(cptr), name, HOSTLEN);
break;
}
}
* of the host the server runs on. This also checks the case where
* there is a server connecting from 'localhost'.
*/
- c_conf = find_conf_byhost(lp, cptr->sockhost, CONF_SERVER);
+ c_conf = find_conf_byhost(lp, cli_sockhost(cptr), CONF_SERVER);
}
}
/*
* happen when using DNS in the way the irc server does. -avalon
*/
if (!c_conf)
- c_conf = find_conf_byip(lp, (const char*) &cptr->ip, CONF_SERVER);
+ c_conf = find_conf_byip(lp, (const char*) &(cli_ip(cptr)), CONF_SERVER);
/*
* detach all conf lines that got attached by attach_confs()
*/
*/
if (!c_conf) {
Debug((DEBUG_DNS, "sv_cl: access denied: %s[%s@%s]",
- cptr->name, cptr->username, cptr->sockhost));
+ cli_name(cptr), cli_username(cptr), cli_sockhost(cptr)));
return -1;
}
- ircd_strncpy(cptr->name, c_conf->name, HOSTLEN);
+ ircd_strncpy(cli_name(cptr), c_conf->name, HOSTLEN);
/*
* attach the C and N lines to the client structure for later use.
*/
attach_conf(cptr, c_conf);
- attach_confs_byname(cptr, cptr->name, CONF_HUB | CONF_LEAF | CONF_UWORLD);
+ attach_confs_byname(cptr, cli_name(cptr), CONF_HUB | CONF_LEAF | CONF_UWORLD);
if (INADDR_NONE == c_conf->ipnum.s_addr)
- c_conf->ipnum.s_addr = cptr->ip.s_addr;
+ c_conf->ipnum.s_addr = cli_ip(cptr).s_addr;
- Debug((DEBUG_DNS, "sv_cl: access ok: %s[%s]", cptr->name, cptr->sockhost));
+ Debug((DEBUG_DNS, "sv_cl: access ok: %s[%s]", cli_name(cptr), cli_sockhost(cptr)));
return 0;
}
*/
void send_usage(struct Client *cptr, char *nick)
{
- os_get_rusage(cptr, CurrentTime - me.since, debug_enumerator);
+ os_get_rusage(cptr, CurrentTime - cli_since(&me), debug_enumerator);
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":DBUF alloc %d used %d",
DBufAllocCount, DBufUsedCount);
wwm += sizeof(struct Whowas) * NICKNAMEHISTORYLENGTH;
wwm += sizeof(struct Whowas *) * WW_MAX;
- for (acptr = GlobalClientList; acptr; acptr = acptr->next)
+ for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr))
{
if (MyConnect(acptr))
{
lc++;
- for (link = acptr->confs; link; link = link->next)
+ for (link = cli_confs(acptr); link; link = link->next)
lcc++;
}
else
rc++;
- if (acptr->user)
+ if (cli_user(acptr))
{
us++;
- for (link = acptr->user->invited; link; link = link->next)
+ for (link = cli_user(acptr)->invited; link; link = link->next)
usi++;
- for (member = acptr->user->channel; member; member = member->next_channel)
+ for (member = cli_user(acptr)->channel; member; member = member->next_channel)
++memberships;
- if (acptr->user->away)
+ if (cli_user(acptr)->away)
{
aw++;
- awm += (strlen(acptr->user->away) + 1);
+ awm += (strlen(cli_user(acptr)->away) + 1);
}
}
}
if (MyConnect(sptr)) {
if (showip)
- sprintf_irc(nbuf, "%s[%s@%s]", sptr->name,
- (IsIdented(sptr)) ? sptr->username : "", sptr->sock_ip);
+ sprintf_irc(nbuf, "%s[%s@%s]", cli_name(sptr),
+ (IsIdented(sptr)) ? cli_username(sptr) : "", cli_sock_ip(sptr));
else
- return sptr->name;
+ return cli_name(sptr);
return nbuf;
}
- return sptr->name;
+ return cli_name(sptr);
}
const char *get_client_host(const struct Client *cptr)
s++;
else
s = host;
- ircd_strncpy(cptr->sockhost, s, HOSTLEN);
+ ircd_strncpy(cli_sockhost(cptr), s, HOSTLEN);
}
/*
{
struct SLink *lp;
- if (bcptr->serv && bcptr->serv->client_list) /* Was SetServerYXX called ? */
+ if (cli_serv(bcptr) && cli_serv(bcptr)->client_list) /* Was SetServerYXX called ? */
ClearServerYXX(bcptr); /* Removes server from server_list[] */
if (IsUser(bcptr)) {
/*
/*
* Stop a running /LIST clean
*/
- if (MyUser(bcptr) && bcptr->listing) {
- bcptr->listing->chptr->mode.mode &= ~MODE_LISTED;
- MyFree(bcptr->listing);
- bcptr->listing = NULL;
+ if (MyUser(bcptr) && cli_listing(bcptr)) {
+ cli_listing(bcptr)->chptr->mode.mode &= ~MODE_LISTED;
+ MyFree(cli_listing(bcptr));
+ cli_listing(bcptr) = NULL;
}
/*
* If a person is on a channel, send a QUIT notice
remove_user_from_all_channels(bcptr);
/* Clean up invitefield */
- while ((lp = bcptr->user->invited))
+ while ((lp = cli_user(bcptr)->invited))
del_invite(bcptr, lp->value.chptr);
/* Clean up silencefield */
- while ((lp = bcptr->user->silence))
+ while ((lp = cli_user(bcptr)->silence))
del_silence(bcptr, lp->value.cp);
if (IsInvisible(bcptr))
else if (IsServer(bcptr))
{
/* Remove downlink list node of uplink */
- remove_dlink(&bcptr->serv->up->serv->down, bcptr->serv->updown);
- bcptr->serv->updown = 0;
+ remove_dlink(&(cli_serv(cli_serv(bcptr)->up))->down, cli_serv(bcptr)->updown);
+ cli_serv(bcptr)->updown = 0;
if (MyConnect(bcptr))
Count_serverdisconnects(UserStats);
* Remove from serv->client_list
* NOTE: user is *always* NULL if this is a server
*/
- if (bcptr->user) {
+ if (cli_user(bcptr)) {
assert(!IsServer(bcptr));
/* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
- RemoveYXXClient(bcptr->user->server, bcptr->yxx);
+ RemoveYXXClient(cli_user(bcptr)->server, cli_yxx(bcptr));
}
/* Remove bcptr from the client list */
#ifdef DEBUGMODE
if (hRemClient(bcptr) != 0)
Debug((DEBUG_ERROR, "%p !in tab %s[%s] %p %p %p %d %d %p",
- bcptr, bcptr->name, bcptr->from ? bcptr->from->sockhost : "??host",
- bcptr->from, bcptr->next, bcptr->prev, bcptr->fd,
- bcptr->status, bcptr->user));
+ bcptr, cli_name(bcptr), cli_from(bcptr) ? cli_sockhost(cli_from(bcptr)) : "??host",
+ cli_from(bcptr), cli_next(bcptr), cli_prev(bcptr), cli_fd(bcptr),
+ cli_status(bcptr), cli_user(bcptr)));
#else
hRemClient(bcptr);
#endif
int i;
/* Run over all its downlinks */
- for (lp = cptr->serv->down; lp; lp = next)
+ for (lp = cli_serv(cptr)->down; lp; lp = next)
{
next = lp->next;
acptr = lp->value.cptr;
exit_one_client(acptr, me.name);
}
/* Remove all clients of this server */
- acptrp = cptr->serv->client_list;
- for (i = 0; i <= cptr->serv->nn_mask; ++acptrp, ++i) {
+ acptrp = cli_serv(cptr)->client_list;
+ for (i = 0; i <= cli_serv(cptr)->nn_mask; ++acptrp, ++i) {
if (*acptrp)
exit_one_client(*acptrp, comment);
}
char comment1[HOSTLEN + HOSTLEN + 2];
assert(killer);
if (MyConnect(victim)) {
- victim->flags |= FLAGS_CLOSING;
+ cli_flags(victim) |= FLAGS_CLOSING;
update_load();
- on_for = CurrentTime - victim->firsttime;
+ on_for = CurrentTime - cli_firsttime(victim);
if (IsUser(victim))
log_write(LS_USER, L_TRACE, 0, "%s (%3d:%02d:%02d): %s@%s (%s)",
- myctime(victim->firsttime), on_for / 3600,
- (on_for % 3600) / 60, on_for % 60, victim->user->username,
- victim->sockhost, victim->name);
+ myctime(cli_firsttime(victim)), on_for / 3600,
+ (on_for % 3600) / 60, on_for % 60, cli_user(victim)->username,
+ cli_sockhost(victim), cli_name(victim));
- if (victim != killer->from /* The source knows already */
+ if (victim != cli_from(killer) /* The source knows already */
&& IsClient(victim)) /* Not a Ping struct or Log file */
{
if (IsServer(victim) || IsHandshake(victim))
- sendcmdto_one(killer, CMD_SQUIT, victim, "%s 0 :%s", me.name, comment);
+ sendcmdto_one(killer, CMD_SQUIT, victim, "%s 0 :%s", cli_name(&me), comment);
else if (!IsConnecting(victim)) {
if (!IsDead(victim))
sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)",
- victim->name, killer->name, comment);
+ cli_name(victim), cli_name(killer), comment);
}
if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) &&
(killer == &me || (IsServer(killer) &&
* Note: check user == user needed to make sure we have the same
* client
*/
- if (victim->serv->user && *victim->serv->by &&
- (acptr = findNUser(victim->serv->by))) {
- if (acptr->user == victim->serv->user) {
+ if (cli_serv(victim)->user && *(cli_serv(victim))->by &&
+ (acptr = findNUser(cli_serv(victim)->by))) {
+ if (cli_user(acptr) == cli_serv(victim)->user) {
sendcmdto_one(&me, CMD_NOTICE, acptr,
"%C :Link with %s cancelled: %s", acptr,
- victim->name, comment);
+ cli_name(victim), comment);
}
else {
/*
* not right client, set by to empty string
*/
acptr = 0;
- *victim->serv->by = '\0';
+ *(cli_serv(victim))->by = '\0';
}
}
if (killer == &me)
sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s cancelled: %s",
- victim->name, comment);
+ cli_name(victim), comment);
}
}
/*
if (IsServer(victim))
{
- strcpy(comment1, victim->serv->up->name);
+ strcpy(comment1, cli_name(cli_serv(victim)->up));
strcat(comment1, " ");
- strcat(comment1, victim->name);
+ strcat(comment1, cli_name(victim));
if (IsUser(killer))
sendto_opmask_butone(killer, SNO_OLDSNO, "%s SQUIT by %s [%s]:",
- (killer->user->server == victim ||
- killer->user->server == victim->serv->up) ?
+ (cli_user(killer)->server == victim ||
+ cli_user(killer)->server == cli_serv(victim)->up) ?
"Local" : "Remote",
get_client_name(killer, HIDE_IP),
- killer->user->server->name);
- else if (killer != &me && victim->serv->up != killer)
+ cli_name(cli_user(killer)->server));
+ else if (killer != &me && cli_serv(victim)->up != killer)
sendto_opmask_butone(0, SNO_OLDSNO, "Received SQUIT %s from %s :",
- victim->name, IsServer(killer) ? killer->name :
+ cli_name(victim), IsServer(killer) ? cli_name(killer) :
get_client_name(killer, HIDE_IP));
sendto_opmask_butone(0, SNO_NETWORK, "Net break: %s (%s)", comment1,
comment);
* First generate the needed protocol for the other server links
* except the source:
*/
- for (dlp = me.serv->down; dlp; dlp = dlp->next) {
- if (dlp->value.cptr != killer->from && dlp->value.cptr != victim) {
+ for (dlp = cli_serv(&me)->down; dlp; dlp = dlp->next) {
+ if (dlp->value.cptr != cli_from(killer) && dlp->value.cptr != victim) {
if (IsServer(victim))
sendcmdto_one(killer, CMD_SQUIT, dlp->value.cptr, "%s %Tu :%s",
- victim->name, victim->serv->timestamp, comment);
- else if (IsUser(victim) && 0 == (victim->flags & FLAGS_KILLED))
+ cli_name(victim), cli_serv(victim)->timestamp, comment);
+ else if (IsUser(victim) && 0 == (cli_flags(victim) & FLAGS_KILLED))
sendcmdto_one(victim, CMD_QUIT, dlp->value.cptr, ":%s", comment);
}
}
continue;
if (IsServer(acptr))
{
- sp->is_sbs += acptr->sendB;
- sp->is_sbr += acptr->receiveB;
- sp->is_sks += acptr->sendK;
- sp->is_skr += acptr->receiveK;
- sp->is_sti += CurrentTime - acptr->firsttime;
+ sp->is_sbs += cli_sendB(acptr);
+ sp->is_sbr += cli_receiveB(acptr);
+ sp->is_sks += cli_sendK(acptr);
+ sp->is_skr += cli_receiveK(acptr);
+ sp->is_sti += CurrentTime - cli_firsttime(acptr);
sp->is_sv++;
if (sp->is_sbs > 1023)
{
}
else if (IsUser(acptr))
{
- sp->is_cbs += acptr->sendB;
- sp->is_cbr += acptr->receiveB;
- sp->is_cks += acptr->sendK;
- sp->is_ckr += acptr->receiveK;
- sp->is_cti += CurrentTime - acptr->firsttime;
+ sp->is_cbs += cli_sendB(acptr);
+ sp->is_cbr += cli_receiveB(acptr);
+ sp->is_cks += cli_sendK(acptr);
+ sp->is_ckr += cli_receiveK(acptr);
+ sp->is_cti += CurrentTime - cli_firsttime(acptr);
sp->is_cl++;
if (sp->is_cbs > 1023)
{
else
acptr = (nnn) ? (findNUser(parv[1])) : (FindUser(parv[1]));
- if (((!acptr) || (acptr->from == cptr)) && !achptr)
+ if (((!acptr) || (cli_from(acptr) == cptr)) && !achptr)
return 0;
/* Remap low number numerics, not that I understand WHY.. --Nemesi */
unsigned int max_connection_count = 0;
unsigned int max_client_count = 0;
-#if 0
-int exit_new_server(struct Client* cptr, struct Client* sptr,
- const char* host, time_t timestamp, const char* fmt, ...)
-{
- va_list vl;
- char *buf =
- (char*) MyMalloc(strlen(me.name) + strlen(host) + 22 + strlen(fmt));
- assert(0 != buf);
- va_start(vl, fmt);
- if (!IsServer(sptr))
- return vexit_client_msg(cptr, cptr, &me, fmt, vl);
- sprintf_irc(buf, ":%s " TOK_SQUIT " %s " TIME_T_FMT " :", me.name, host, timestamp);
- strcat(buf, fmt);
- vsendto_one(cptr, buf, vl); /* XXX DEAD */
- va_end(vl);
- MyFree(buf);
- return 0;
-}
-#endif /* 0 */
int exit_new_server(struct Client *cptr, struct Client *sptr, const char *host,
time_t timestamp, const char *pattern, ...)
int a_kills_b_too(struct Client *a, struct Client *b)
{
- for (; b != a && b != &me; b = b->serv->up);
+ for (; b != a && b != &me; b = cli_serv(b)->up);
return (a == b ? 1 : 0);
}
int split, i;
assert(0 != cptr);
- assert(0 != cptr->local);
+ assert(0 != cli_local(cptr));
- split = (0 != ircd_strcmp(cptr->name, cptr->sockhost)
- && 0 != ircd_strncmp(cptr->info, "JUPE", 4));
- inpath = cptr->name;
+ split = (0 != ircd_strcmp(cli_name(cptr), cli_sockhost(cptr))
+ && 0 != ircd_strncmp(cli_info(cptr), "JUPE", 4));
+ inpath = cli_name(cptr);
if (IsUnknown(cptr)) {
if (aconf->passwd[0])
/*
* Pass my info to the new server
*/
- sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", me.name,
- me.serv->timestamp, cptr->serv->timestamp, MAJOR_PROTOCOL,
- NumServCap(&me), *me.info ? me.info : "IRCers United");
+ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s", cli_name(&me),
+ cli_serv(&me)->timestamp, cli_serv(cptr)->timestamp, MAJOR_PROTOCOL,
+ NumServCap(&me), *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
/*
* Don't charge this IP# for connecting
* XXX - if this comes from a server port, it will not have been added
* to the IP check registry, see add_connection in s_bsd.c
*/
- IPcheck_connect_fail(cptr->ip);
+ IPcheck_connect_fail(cli_ip(cptr));
}
det_confs_butmask(cptr, CONF_LEAF | CONF_HUB | CONF_SERVER | CONF_UWORLD);
if (!IsHandshake(cptr))
hAddClient(cptr);
SetServer(cptr);
- cptr->handler = SERVER_HANDLER;
+ cli_handler(cptr) = SERVER_HANDLER;
Count_unknownbecomesserver(UserStats);
release_dns_reply(cptr);
* NOTE: check for acptr->user == cptr->serv->user is necessary to insure
* that we got the same one... bleah
*/
- if (cptr->serv->user && *cptr->serv->by &&
- (acptr = findNUser(cptr->serv->by))) {
- if (acptr->user == cptr->serv->user) {
+ if (cli_serv(cptr)->user && *(cli_serv(cptr))->by &&
+ (acptr = findNUser(cli_serv(cptr)->by))) {
+ if (cli_user(acptr) == cli_serv(cptr)->user) {
sendcmdto_one(&me, CMD_NOTICE, acptr, "%C :Link with %s established.",
acptr, inpath);
}
* if not the same client, set by to empty string
*/
acptr = 0;
- *cptr->serv->by = '\0';
+ *(cli_serv(cptr))->by = '\0';
}
}
sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s established.", inpath);
- cptr->serv->up = &me;
- cptr->serv->updown = add_dlink(&me.serv->down, cptr);
- sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s", me.name,
- cptr->name);
+ cli_serv(cptr)->up = &me;
+ cli_serv(cptr)->updown = add_dlink(&(cli_serv(&me))->down, cptr);
+ sendto_opmask_butone(0, SNO_NETWORK, "Net junction: %s %s", cli_name(&me),
+ cli_name(cptr));
SetJunction(cptr);
/*
* Old sendto_serv_but_one() call removed because we now
if (!(acptr = LocalClientArray[i]) || !IsServer(acptr) ||
acptr == cptr || IsMe(acptr))
continue;
- if (!match(me.name, cptr->name))
+ if (!match(cli_name(&me), cli_name(cptr)))
continue;
if (ajupe)
sendcmdto_one(&me, CMD_SERVER, acptr,
- "%s 2 0 %Tu J%02u %s%s 0 %%%Tu :%s", cptr->name,
- cptr->serv->timestamp, Protocol(cptr), NumServCap(cptr),
- JupeLastMod(ajupe), cptr->info);
+ "%s 2 0 %Tu J%02u %s%s 0 %%%Tu :%s", cli_name(cptr),
+ cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
+ JupeLastMod(ajupe), cli_info(cptr));
else
sendcmdto_one(&me, CMD_SERVER, acptr,
- "%s 2 0 %Tu J%02u %s%s 0 :%s", cptr->name,
- cptr->serv->timestamp, Protocol(cptr), NumServCap(cptr),
- cptr->info);
+ "%s 2 0 %Tu J%02u %s%s 0 :%s", cli_name(cptr),
+ cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr),
+ cli_info(cptr));
}
/*
* a race condition, not the normal way of operation...
*/
- for (acptr = &me; acptr; acptr = acptr->prev) {
+ for (acptr = &me; acptr; acptr = cli_prev(acptr)) {
/* acptr->from == acptr for acptr == cptr */
- if (acptr->from == cptr)
+ if (cli_from(acptr) == cptr)
continue;
if (IsServer(acptr)) {
const char* protocol_str;
else
protocol_str = IsBurst(acptr) ? "J0" : "P0";
- if (0 == match(me.name, acptr->name))
+ if (0 == match(cli_name(&me), cli_name(acptr)))
continue;
split = (MyConnect(acptr) &&
- 0 != ircd_strcmp(acptr->name, acptr->sockhost) &&
- 0 != ircd_strncmp(acptr->info, "JUPE", 4));
- if ((ajupe = jupe_find(acptr->name)) && !JupeIsLocal(ajupe))
- sendcmdto_one(acptr->serv->up, CMD_SERVER, cptr,
- "%s %d 0 %Tu %s%u %s%s 0 %%%Tu :%s", acptr->name,
- acptr->hopcount + 1, acptr->serv->timestamp,
+ 0 != ircd_strcmp(cli_name(acptr), cli_sockhost(acptr)) &&
+ 0 != ircd_strncmp(cli_info(acptr), "JUPE", 4));
+ if ((ajupe = jupe_find(cli_name(acptr))) && !JupeIsLocal(ajupe))
+ sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
+ "%s %d 0 %Tu %s%u %s%s 0 %%%Tu :%s", cli_name(acptr),
+ cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
protocol_str, Protocol(acptr), NumServCap(acptr),
- JupeLastMod(ajupe), acptr->info);
+ JupeLastMod(ajupe), cli_info(acptr));
else
- sendcmdto_one(acptr->serv->up, CMD_SERVER, cptr,
- "%s %d 0 %Tu %s%u %s%s 0 :%s", acptr->name,
- acptr->hopcount + 1, acptr->serv->timestamp,
+ sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr,
+ "%s %d 0 %Tu %s%u %s%s 0 :%s", cli_name(acptr),
+ cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp,
protocol_str, Protocol(acptr), NumServCap(acptr),
- acptr->info);
+ cli_info(acptr));
}
}
- for (acptr = &me; acptr; acptr = acptr->prev)
+ for (acptr = &me; acptr; acptr = cli_prev(acptr))
{
/* acptr->from == acptr for acptr == cptr */
- if (acptr->from == cptr)
+ if (cli_from(acptr) == cptr)
continue;
if (IsUser(acptr))
{
char *s = umode_str(acptr);
struct Gline *agline = 0;
if ((agline = gline_lookup(acptr, GLINE_GLOBAL | GLINE_LASTMOD)))
- sendcmdto_one(acptr->user->server, CMD_NICK, cptr,
+ sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr,
"%s %d %Tu %s %s %s%s%s%%%Tu:%s@%s %s %s%s :%s",
- acptr->name, acptr->hopcount + 1, acptr->lastnick,
- acptr->user->username, acptr->user->host,
+ cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr),
+ cli_user(acptr)->username, cli_user(acptr)->host,
*s ? "+" : "", s, *s ? " " : "",
GlineLastMod(agline), GlineUser(agline),
GlineHost(agline),
- inttobase64(xxx_buf, ntohl(acptr->ip.s_addr), 6),
- NumNick(acptr), acptr->info);
+ inttobase64(xxx_buf, ntohl(cli_ip(acptr).s_addr), 6),
+ NumNick(acptr), cli_info(acptr));
else
- sendcmdto_one(acptr->user->server, CMD_NICK, cptr,
+ sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr,
"%s %d %Tu %s %s %s%s%s%s %s%s :%s",
- acptr->name, acptr->hopcount + 1, acptr->lastnick,
- acptr->user->username, acptr->user->host,
+ cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr),
+ cli_user(acptr)->username, cli_user(acptr)->host,
*s ? "+" : "", s, *s ? " " : "",
- inttobase64(xxx_buf, ntohl(acptr->ip.s_addr), 6),
- NumNick(acptr), acptr->info);
+ inttobase64(xxx_buf, ntohl(cli_ip(acptr).s_addr), 6),
+ NumNick(acptr), cli_info(acptr));
}
}
/*
{
assert(0 != cptr);
- if (!cptr->user) {
- cptr->user = (struct User*) MyMalloc(sizeof(struct User));
- assert(0 != cptr->user);
+ if (!cli_user(cptr)) {
+ cli_user(cptr) = (struct User*) MyMalloc(sizeof(struct User));
+ assert(0 != cli_user(cptr));
/* All variables are 0 by default */
- memset(cptr->user, 0, sizeof(struct User));
+ memset(cli_user(cptr), 0, sizeof(struct User));
#ifdef DEBUGMODE
++userCount;
#endif
- cptr->user->refcnt = 1;
+ cli_user(cptr)->refcnt = 1;
}
- return cptr->user;
+ return cli_user(cptr);
}
/*
next = FindClient(ch);
next = next ? next : tmp;
- if (tmp->prev == next)
+ if (cli_prev(tmp) == next)
return NULL;
if (next != tmp)
return next;
- for (; next; next = next->next)
- if (!match(ch, next->name))
+ for (; next; next = cli_next(next))
+ if (!match(ch, cli_name(next)))
break;
return next;
}
if (0 == (acptr = FindClient(to)))
return HUNTED_NOSUCH;
- if (acptr->user)
- acptr = acptr->user->server;
+ if (cli_user(acptr))
+ acptr = cli_user(acptr)->server;
} else if (!(acptr = find_match_server(to))) {
send_reply(from, ERR_NOSUCHSERVER, to);
return (HUNTED_NOSUCH);
short digits = 0;
short badid = 0;
short digitgroups = 0;
- struct User* user = sptr->user;
+ struct User* user = cli_user(sptr);
char ip_base64[8];
char featurebuf[512];
user->last = CurrentTime;
- parv[0] = sptr->name;
+ parv[0] = cli_name(sptr);
parv[1] = parv[2] = NULL;
if (MyConnect(sptr))
get_client_name(sptr, HIDE_IP));
}
++ServerStats->is_ref;
- IPcheck_connect_fail(sptr->ip);
+ IPcheck_connect_fail(cli_ip(sptr));
return exit_client(cptr, sptr, &me,
"Sorry, your connection class is full - try "
"again later or try another server");
/* Can this ever happen? */
case ACR_BAD_SOCKET:
++ServerStats->is_ref;
- IPcheck_connect_fail(sptr->ip);
+ IPcheck_connect_fail(cli_ip(sptr));
return exit_client(cptr, sptr, &me, "Unknown error -- Try again");
}
- ircd_strncpy(user->host, sptr->sockhost, HOSTLEN);
- aconf = sptr->confs->value.aconf;
+ ircd_strncpy(user->host, cli_sockhost(sptr), HOSTLEN);
+ aconf = cli_confs(sptr)->value.aconf;
clean_user_id(user->username,
- (sptr->flags & FLAGS_GOTID) ? sptr->username : username,
- (sptr->flags & FLAGS_DOID) && !(sptr->flags & FLAGS_GOTID));
+ (cli_flags(sptr) & FLAGS_GOTID) ? cli_username(sptr) : username,
+ (cli_flags(sptr) & FLAGS_DOID) && !(cli_flags(sptr) & FLAGS_GOTID));
if ((user->username[0] == '\0')
|| ((user->username[0] == '~') && (user->username[1] == '\000')))
if (!EmptyString(aconf->passwd)
&& !(IsDigit(*aconf->passwd) && !aconf->passwd[1])
- && strcmp(sptr->passwd, aconf->passwd))
+ && strcmp(cli_passwd(sptr), aconf->passwd))
{
ServerStats->is_ref++;
- IPcheck_connect_fail(sptr->ip);
+ IPcheck_connect_fail(cli_ip(sptr));
send_reply(sptr, ERR_PASSWDMISMATCH);
return exit_client(cptr, sptr, &me, "Bad Password");
}
- memset(sptr->passwd, 0, sizeof(sptr->passwd));
+ memset(cli_passwd(sptr), 0, sizeof(cli_passwd(sptr)));
/*
* following block for the benefit of time-dependent K:-lines
*/
if (find_kill(sptr)) {
ServerStats->is_ref++;
- IPcheck_connect_fail(sptr->ip);
+ IPcheck_connect_fail(cli_ip(sptr));
return exit_client(cptr, sptr, &me, "K-lined");
}
/*
badid = 1;
}
if (badid && (!(sptr->flags & FLAGS_GOTID) ||
- strcmp(sptr->username, username) != 0))
+ strcmp(cli_username(sptr), username) != 0))
{
ServerStats->is_ref++;
++UserStats.opers;
if (MyConnect(sptr)) {
- sptr->handler = CLIENT_HANDLER;
+ cli_handler(sptr) = CLIENT_HANDLER;
release_dns_reply(sptr);
send_reply(sptr, RPL_WELCOME, nick);
/*
* This is a duplicate of the NOTICE but see below...
*/
- send_reply(sptr, RPL_YOURHOST, me.name, version);
+ send_reply(sptr, RPL_YOURHOST, cli_name(&me), version);
send_reply(sptr, RPL_CREATED, creation);
- send_reply(sptr, RPL_MYINFO, me.name, version);
+ send_reply(sptr, RPL_MYINFO, cli_name(&me), version);
sprintf_irc(featurebuf,FEATURES,FEATURESVALUES);
send_reply(sptr, RPL_ISUPPORT, featurebuf);
m_lusers(sptr, sptr, 1, parv);
motd_signon(sptr);
nextping = CurrentTime;
if (sptr->snomask & SNO_NOISY)
- set_snomask(sptr, sptr->snomask & SNO_NOISY, SNO_ADD);
+ set_snomask(sptr, cli_snomask(sptr) & SNO_NOISY, SNO_ADD);
IPcheck_connect_succeeded(sptr);
}
else
struct Client *acptr;
acptr = user->server;
- if (acptr->from != sptr->from)
+ if (cli_from(acptr) != cli_from(sptr))
{
sendcmdto_one(&me, CMD_KILL, cptr, "%C :%s (%s != %s[%s])",
- sptr, me.name, user->server->name, acptr->from->name,
- acptr->from->sockhost);
- sptr->flags |= FLAGS_KILLED;
+ sptr, cli_name(&me), cli_name(user->server), cli_name(cli_from(acptr)),
+ cli_sockhost(cli_from(acptr)));
+ cli_flags(sptr) |= FLAGS_KILLED;
return exit_client(cptr, sptr, &me, "NICK server wrong direction");
}
else
- sptr->flags |= (acptr->flags & FLAGS_TS8);
+ cli_flags(sptr) |= (cli_flags(acptr) & FLAGS_TS8);
/*
* Check to see if this user is being propogated
* FIXME: This can be speeded up - its stupid to check it for
* every NICK message in a burst again --Run.
*/
- for (acptr = user->server; acptr != &me; acptr = acptr->serv->up) {
+ for (acptr = user->server; acptr != &me; acptr = cli_serv(acptr)->up) {
if (IsBurst(acptr) || Protocol(acptr) < 10)
break;
}
* We ran out of bits to count this
*/
sendcmdto_one(&me, CMD_KILL, sptr, "%C :%s (Too many connections from your host -- Ghost)",
- sptr, me.name);
+ sptr, cli_name(&me));
return exit_client(cptr, sptr, &me,"Too many connections from your host -- throttled");
}
}
if (agline)
sendcmdto_serv_butone(user->server, CMD_NICK, cptr,
"%s %d %Tu %s %s %s%s%s%%%Tu:%s@%s %s %s%s :%s",
- nick, sptr->hopcount + 1, sptr->lastnick,
+ nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
user->username, user->host,
*tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
GlineLastMod(agline), GlineUser(agline),
GlineHost(agline),
- inttobase64(ip_base64, ntohl(sptr->ip.s_addr), 6),
- NumNick(sptr), sptr->info);
+ inttobase64(ip_base64, ntohl(cli_ip(sptr).s_addr), 6),
+ NumNick(sptr), cli_info(sptr));
else
sendcmdto_serv_butone(user->server, CMD_NICK, cptr,
"%s %d %Tu %s %s %s%s%s%s %s%s :%s",
- nick, sptr->hopcount + 1, sptr->lastnick,
+ nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
user->username, user->host,
*tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
- inttobase64(ip_base64, ntohl(sptr->ip.s_addr), 6),
- NumNick(sptr), sptr->info);
+ inttobase64(ip_base64, ntohl(cli_ip(sptr).s_addr), 6),
+ NumNick(sptr), cli_info(sptr));
/* Send umode to client */
if (MyUser(sptr))
{
send_umode(cptr, sptr, 0, ALL_UMODES);
- if (sptr->snomask != SNO_DEFAULT && (sptr->flags & FLAGS_SERVNOTICE))
- send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask);
+ if (cli_snomask(sptr) != SNO_DEFAULT && (cli_flags(sptr) & FLAGS_SERVNOTICE))
+ send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
}
return 0;
#define USERMODELIST_SIZE sizeof(userModeList) / sizeof(struct UserMode)
-#if 0
-static int user_modes[] = {
- FLAGS_OPER, 'o',
- FLAGS_LOCOP, 'O',
- FLAGS_INVISIBLE, 'i',
- FLAGS_WALLOP, 'w',
- FLAGS_SERVNOTICE, 's',
- FLAGS_DEAF, 'd',
- FLAGS_CHSERV, 'k',
- FLAGS_DEBUG, 'g',
- 0, 0
-};
-#endif
-
/*
* XXX - find a way to get rid of this
*/
struct Client* new_client = make_client(cptr, STAT_UNKNOWN);
assert(0 != new_client);
- new_client->hopcount = atoi(parv[2]);
- new_client->lastnick = atoi(parv[3]);
+ cli_hopcount(new_client) = atoi(parv[2]);
+ cli_lastnick(new_client) = atoi(parv[3]);
if (Protocol(cptr) > 9 && parc > 7 && *parv[6] == '+') {
for (p = parv[6] + 1; *p; p++) {
for (i = 0; i < USERMODELIST_SIZE; ++i) {
if (userModeList[i].c == *p) {
- new_client->flags |= userModeList[i].flag;
+ cli_flags(new_client) |= userModeList[i].flag;
break;
}
}
/*
* Set new nick name.
*/
- strcpy(new_client->name, nick);
- new_client->user = make_user(new_client);
- new_client->user->server = sptr;
+ strcpy(cli_name(new_client), nick);
+ cli_user(new_client) = make_user(new_client);
+ cli_user(new_client)->server = sptr;
SetRemoteNumNick(new_client, parv[parc - 2]);
/*
* IP# of remote client
*/
- new_client->ip.s_addr = htonl(base64toint(parv[parc - 3]));
+ cli_ip(new_client).s_addr = htonl(base64toint(parv[parc - 3]));
add_client_to_list(new_client);
hAddClient(new_client);
- sptr->serv->ghost = 0; /* :server NICK means end of net.burst */
- ircd_strncpy(new_client->username, parv[4], USERLEN);
- ircd_strncpy(new_client->user->host, parv[5], HOSTLEN);
- ircd_strncpy(new_client->info, parv[parc - 1], REALLEN);
+ cli_serv(sptr)->ghost = 0; /* :server NICK means end of net.burst */
+ ircd_strncpy(cli_username(new_client), parv[4], USERLEN);
+ ircd_strncpy(cli_user(new_client)->host, parv[5], HOSTLEN);
+ ircd_strncpy(cli_info(new_client), parv[parc - 1], REALLEN);
/* Deal with GLINE parameters... */
if (*parv[parc - 4] == '%' && (t = strchr(parv[parc - 4] + 1, ':'))) {
&& GlineLastMod(agline) > lastmod && !IsBurstOrBurstAck(cptr))
gline_resend(cptr, agline);
}
- return register_user(cptr, new_client, new_client->name, parv[4], agline);
+ return register_user(cptr, new_client, cli_name(new_client), parv[4], agline);
}
- else if (sptr->name[0]) {
+ else if ((cli_name(sptr))[0]) {
/*
* Client changing its nick
*
* however, allow to do two nick changes immedately after another
* before limiting the nick flood. -Run
*/
- if (CurrentTime < cptr->nextnick) {
- cptr->nextnick += 2;
+ if (CurrentTime < cli_nextnick(cptr)) {
+ cli_nextnick(cptr) += 2;
send_reply(cptr, ERR_NICKTOOFAST, parv[1],
- cptr->nextnick - CurrentTime);
+ cli_nextnick(cptr) - CurrentTime);
/* Send error message */
- sendcmdto_one(cptr, CMD_NICK, cptr, "%s", cptr->name);
+ sendcmdto_one(cptr, CMD_NICK, cptr, "%s", cli_name(cptr));
/* bounce NICK to user */
return 0; /* ignore nick change! */
}
else {
/* Limit total to 1 change per NICK_DELAY seconds: */
- cptr->nextnick += NICK_DELAY;
+ cli_nextnick(cptr) += NICK_DELAY;
/* However allow _maximal_ 1 extra consecutive nick change: */
- if (cptr->nextnick < CurrentTime)
- cptr->nextnick = CurrentTime;
+ if (cli_nextnick(cptr) < CurrentTime)
+ cli_nextnick(cptr) = CurrentTime;
}
}
/*
* Also set 'lastnick' to current time, if changed.
*/
if (0 != ircd_strcmp(parv[0], nick))
- sptr->lastnick = (sptr == cptr) ? TStime() : atoi(parv[2]);
+ cli_lastnick(sptr) = (sptr == cptr) ? TStime() : atoi(parv[2]);
/*
* Client just changing his/her nick. If he/she is
sendcmdto_common_channels(sptr, CMD_NICK, ":%s", nick);
add_history(sptr, 1);
sendcmdto_serv_butone(sptr, CMD_NICK, cptr, "%s %Tu", nick,
- sptr->lastnick);
+ cli_lastnick(sptr));
}
else
sendcmdto_one(sptr, CMD_NICK, sptr, ":%s", nick);
- if (sptr->name[0])
+ if ((cli_name(sptr))[0])
hRemClient(sptr);
- strcpy(sptr->name, nick);
+ strcpy(cli_name(sptr), nick);
hAddClient(sptr);
}
else {
/* Local client setting NICK the first time */
- strcpy(sptr->name, nick);
- if (!sptr->user) {
- sptr->user = make_user(sptr);
- sptr->user->server = &me;
+ strcpy(cli_name(sptr), nick);
+ if (!cli_user(sptr)) {
+ cli_user(sptr) = make_user(sptr);
+ cli_user(sptr)->server = &me;
}
SetLocalNumNick(sptr);
hAddClient(sptr);
* If the client hasn't gotten a cookie-ping yet,
* choose a cookie and send it. -record!jegelhof@cloud9.net
*/
- if (!sptr->cookie) {
+ if (!cli_cookie(sptr)) {
do {
- sptr->cookie = (ircrandom() & 0x7fffffff);
- } while (!sptr->cookie);
+ cli_cookie(sptr) = (ircrandom() & 0x7fffffff);
+ } while (!cli_cookie(sptr));
sendrawto_one(cptr, MSG_PING " :%u", sptr->cookie);
}
- else if (*sptr->user->host && sptr->cookie == COOKIE_VERIFIED) {
+ else if (*(cli_user(sptr))->host && cli_cookie(sptr) == COOKIE_VERIFIED) {
/*
* USER and PONG already received, now we have NICK.
* register_user may reject the client and call exit_client
* for it - must test this and exit m_nick too !
*/
- sptr->lastnick = TStime(); /* Always local client */
- if (register_user(cptr, sptr, nick, sptr->user->username, 0) == CPTR_KILLED)
+ cli_lastnick(sptr) = TStime(); /* Always local client */
+ if (register_user(cptr, sptr, nick, cli_user(sptr)->username, 0) == CPTR_KILLED)
return CPTR_KILLED;
}
}
unsigned char* targets;
int i;
assert(0 != sptr);
- assert(sptr->local);
+ assert(cli_local(sptr));
- targets = sptr->targets;
+ targets = cli_targets(sptr);
/*
* Already in table?
*/
unsigned char* targets;
assert(0 != sptr);
- assert(sptr->local);
- targets = sptr->targets;
+ assert(cli_local(sptr));
+ targets = cli_targets(sptr);
/*
* Same target as last time?
* New target
*/
if (!created) {
- if (CurrentTime < sptr->nexttarget) {
- if (sptr->nexttarget - CurrentTime < TARGET_DELAY + 8) {
+ if (CurrentTime < cli_nexttarget(sptr)) {
+ if (cli_nexttarget(sptr) - CurrentTime < TARGET_DELAY + 8) {
/*
* No server flooding
*/
- sptr->nexttarget += 2;
+ cli_nexttarget(sptr) += 2;
send_reply(sptr, ERR_TARGETTOOFAST, name,
- sptr->nexttarget - CurrentTime);
+ cli_nexttarget(sptr) - CurrentTime);
}
return 1;
}
else {
-#ifdef GODMODE
- /* XXX Let's get rid of GODMODE */
- sendto_one(sptr, ":%s NOTICE %s :New target: %s; ft " TIME_T_FMT, /* XXX Possibly DEAD */
- me.name, sptr->name, name, (CurrentTime - sptr->nexttarget) / TARGET_DELAY);
-#endif
- sptr->nexttarget += TARGET_DELAY;
- if (sptr->nexttarget < CurrentTime - (TARGET_DELAY * (MAXTARGETS - 1)))
- sptr->nexttarget = CurrentTime - (TARGET_DELAY * (MAXTARGETS - 1));
+ cli_nexttarget(sptr) += TARGET_DELAY;
+ if (cli_nexttarget(sptr) < CurrentTime - (TARGET_DELAY * (MAXTARGETS - 1)))
+ cli_nexttarget(sptr) = CurrentTime - (TARGET_DELAY * (MAXTARGETS - 1));
}
}
memmove(&targets[1], &targets[0], MAXTARGETS - 1);
* since the link is the same, this should be a little faster for channels
* with a lot of users
*/
- for (membership = source->user->channel; membership; membership = membership->next_channel) {
+ for (membership = cli_user(source)->channel; membership; membership = membership->next_channel) {
if (chptr == membership->channel)
break;
}
/*
* lookup channel in destination
*/
- assert(0 != dest->user);
- for (membership = dest->user->channel; membership; membership = membership->next_channel) {
+ assert(0 != cli_user(dest));
+ for (membership = cli_user(dest)->channel; membership; membership = membership->next_channel) {
if (chptr == membership->channel)
break;
}
if (0 == membership || IsZombie(membership)) {
- return send_reply(source, ERR_USERNOTINCHANNEL, dest->name, chptr->chname);
+ return send_reply(source, ERR_USERNOTINCHANNEL, cli_name(dest), chptr->chname);
}
if (is_silenced(source, dest))
return 0;
- if (dest->user->away)
- send_reply(source, RPL_AWAY, dest->name, dest->user->away);
+ if (cli_user(dest)->away)
+ send_reply(source, RPL_AWAY, cli_name(dest), cli_user(dest)->away);
if (is_notice)
sendcmdto_one(source, CMD_NOTICE, dest, "%C :%s", dest, text);
else
for (i = HighestFd; i >= 0; i--) {
if ((acptr = LocalClientArray[i]) && IsServer(acptr) &&
(acptr != cptr) && (acptr != sptr) && *umodeBuf)
- sendcmdto_one(sptr, CMD_MODE, acptr, "%s :%s", sptr->name, umodeBuf);
+ sendcmdto_one(sptr, CMD_MODE, acptr, "%s :%s", cli_name(sptr), umodeBuf);
}
if (cptr && MyUser(cptr))
send_umode(cptr, sptr, old, ALL_UMODES);
assert(0 != names);
assert(0 != fmt);
- mb = msgq_make(sptr, rpl_str(rpl), me.name, sptr->name);
+ mb = msgq_make(sptr, rpl_str(rpl), cli_name(&me), cli_name(sptr));
for (name = ircd_strtok(&p, names, " "); name; name = ircd_strtok(&p, 0, " ")) {
if ((acptr = FindUser(name))) {
if (IsServer(cptr))
sendcmdto_flag_butone(&me, CMD_WALLOPS, 0, FLAGS_WALLOP,
":MODE for User %s from %s!%s", parv[1],
- cptr->name, sptr->name);
+ cli_name(cptr), cli_name(sptr));
else
send_reply(sptr, ERR_USERSDONTMATCH);
return 0;
m = buf;
*m++ = '+';
for (i = 0; i < USERMODELIST_SIZE; ++i) {
- if ( (userModeList[i].flag & sptr->flags))
+ if ( (userModeList[i].flag & cli_flags(sptr)))
*m++ = userModeList[i].c;
}
*m = '\0';
send_reply(sptr, RPL_UMODEIS, buf);
- if ((sptr->flags & FLAGS_SERVNOTICE) && MyConnect(sptr)
- && sptr->snomask !=
+ if ((cli_flags(sptr) & FLAGS_SERVNOTICE) && MyConnect(sptr)
+ && cli_snomask(sptr) !=
(unsigned int)(IsOper(sptr) ? SNO_OPERDEFAULT : SNO_DEFAULT))
- send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask);
+ send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
return 0;
}
* find flags already set for user
* why not just copy them?
*/
- setflags = sptr->flags;
-#if 0
- setflags = 0;
- for (i = 0; i < USERMODELIST_SIZE; ++i) {
- if (sptr->flags & userModeList[i].flag)
- setflags |= userModeList[i].flag;
- }
-#endif
+ setflags = cli_flags(sptr);
+
if (MyConnect(sptr))
- tmpmask = sptr->snomask;
+ tmpmask = cli_snomask(sptr);
/*
* parse mode change string(s)
tmpmask = (what == MODE_ADD) ?
(IsAnOper(sptr) ? SNO_OPERDEFAULT : SNO_DEFAULT) : 0;
if (tmpmask)
- sptr->flags |= FLAGS_SERVNOTICE;
+ cli_flags(sptr) |= FLAGS_SERVNOTICE;
else
- sptr->flags &= ~FLAGS_SERVNOTICE;
+ cli_flags(sptr) &= ~FLAGS_SERVNOTICE;
break;
case 'w':
if (what == MODE_ADD)
if (what == MODE_ADD)
SetOper(sptr);
else {
- sptr->flags &= ~(FLAGS_OPER | FLAGS_LOCOP);
+ cli_flags(sptr) &= ~(FLAGS_OPER | FLAGS_LOCOP);
if (MyConnect(sptr)) {
- tmpmask = sptr->snomask & ~SNO_OPER;
- sptr->handler = CLIENT_HANDLER;
+ tmpmask = cli_snomask(sptr) & ~SNO_OPER;
+ cli_handler(sptr) = CLIENT_HANDLER;
}
}
break;
if (what == MODE_ADD)
SetLocOp(sptr);
else {
- sptr->flags &= ~(FLAGS_OPER | FLAGS_LOCOP);
+ cli_flags(sptr) &= ~(FLAGS_OPER | FLAGS_LOCOP);
if (MyConnect(sptr)) {
- tmpmask = sptr->snomask & ~SNO_OPER;
- sptr->handler = CLIENT_HANDLER;
+ tmpmask = cli_snomask(sptr) & ~SNO_OPER;
+ cli_handler(sptr) = CLIENT_HANDLER;
}
}
break;
if ((setflags & (FLAGS_OPER | FLAGS_LOCOP)) && !IsAnOper(sptr))
det_confs_butmask(sptr, CONF_CLIENT & ~CONF_OPS);
- if (tmpmask != sptr->snomask)
+ if (tmpmask != cli_snomask(sptr))
set_snomask(sptr, tmpmask, SNO_SET);
- if (sptr->snomask && snomask_given)
- send_reply(sptr, RPL_SNOMASK, sptr->snomask, sptr->snomask);
+ if (cli_snomask(sptr) && snomask_given)
+ send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
}
/*
* Compare new flags with old flags and send string which
int i;
int c_flags;
- c_flags = cptr->flags & SEND_UMODES; /* cleaning up the original code */
+ c_flags = cli_flags(cptr) & SEND_UMODES; /* cleaning up the original code */
for (i = 0; i < USERMODELIST_SIZE; ++i) {
if ( (c_flags & userModeList[i].flag))
flag = userModeList[i].flag;
if (MyUser(sptr) && !(flag & sendmask))
continue;
- if ( (flag & old) && !(sptr->flags & flag))
+ if ( (flag & old) && !(cli_flags(sptr) & flag))
{
if (what == MODE_DEL)
*m++ = userModeList[i].c;
}
*m = '\0';
if (*umodeBuf && cptr)
- sendcmdto_one(sptr, CMD_MODE, cptr, "%s :%s", sptr->name, umodeBuf);
+ sendcmdto_one(sptr, CMD_MODE, cptr, "%s :%s", cli_name(sptr), umodeBuf);
}
/*
int i;
struct SLink *tmp;
- oldmask = cptr->snomask;
+ oldmask = cli_snomask(cptr);
if (what == SNO_ADD)
newmask |= oldmask;
delfrom_list(cptr, &opsarray[i]);
}
}
- cptr->snomask = newmask;
+ cli_snomask(cptr) = newmask;
}
/*
static char sender[HOSTLEN + NICKLEN + USERLEN + 5];
static char senderip[16 + NICKLEN + USERLEN + 5];
- if (!(acptr->user) || !(lp = acptr->user->silence) || !(user = sptr->user))
+ if (!cli_user(acptr) || !(lp = cli_user(acptr)->silence) || !(user = cli_user(sptr)))
return 0;
- sprintf_irc(sender, "%s!%s@%s", sptr->name, user->username, user->host);
- sprintf_irc(senderip, "%s!%s@%s", sptr->name, user->username,
- ircd_ntoa((const char*) &sptr->ip));
+ sprintf_irc(sender, "%s!%s@%s", cli_name(sptr), user->username, user->host);
+ sprintf_irc(senderip, "%s!%s@%s", cli_name(sptr), user->username,
+ ircd_ntoa((const char*) &(cli_ip(sptr))));
for (; lp; lp = lp->next)
{
if ((!(lp->flags & CHFL_SILENCE_IPMASK) && !match(lp->value.cp, sender)) ||
{
if (!MyConnect(sptr))
{
- sendcmdto_one(acptr, CMD_SILENCE, sptr->from, "%C %s", sptr,
+ sendcmdto_one(acptr, CMD_SILENCE, cli_from(sptr), "%C %s", sptr,
lp->value.cp);
}
return 1;
struct SLink *tmp;
int ret = -1;
- for (lp = &sptr->user->silence; *lp;) {
+ for (lp = &(cli_user(sptr))->silence; *lp;) {
if (!mmatch(mask, (*lp)->value.cp))
{
tmp = *lp;
int cnt = 0, len = strlen(mask);
char *ip_start;
- for (lpp = &sptr->user->silence, lp = *lpp; lp;)
+ for (lpp = &(cli_user(sptr))->silence, lp = *lpp; lp;)
{
if (0 == ircd_strcmp(mask, lp->value.cp))
return -1;
}
lp = make_link();
memset(lp, 0, sizeof(struct SLink));
- lp->next = sptr->user->silence;
+ lp->next = cli_user(sptr)->silence;
lp->value.cp = (char*) MyMalloc(strlen(mask) + 1);
assert(0 != lp->value.cp);
strcpy(lp->value.cp, mask);
if ((ip_start = strrchr(mask, '@')) && check_if_ipmask(ip_start + 1))
lp->flags = CHFL_SILENCE_IPMASK;
- sptr->user->silence = lp;
+ cli_user(sptr)->silence = lp;
return 0;
}
static void dead_link(struct Client *to, char *notice)
{
- to->flags |= FLAGS_DEADSOCKET;
+ cli_flags(to) |= FLAGS_DEADSOCKET;
/*
* If because of BUFFERPOOL problem then clean dbuf's now so that
* notices don't hurt operators below.
*/
- DBufClear(&to->recvQ);
- MsgQClear(&to->sendQ);
+ DBufClear(&(cli_recvQ(to)));
+ MsgQClear(&(cli_sendQ(to)));
/*
* Keep a copy of the last comment, for later use...
*/
- ircd_strncpy(to->info, notice, REALLEN);
+ ircd_strncpy(cli_info(to), notice, REALLEN);
- if (!IsUser(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
- sendto_opmask_butone(0, SNO_OLDSNO, "%s for %s", to->info, to->name);
- Debug((DEBUG_ERROR, to->info));
+ if (!IsUser(to) && !IsUnknown(to) && !(cli_flags(to) & FLAGS_CLOSING))
+ sendto_opmask_butone(0, SNO_OLDSNO, "%s for %s", cli_info(to), cli_name(to));
+ Debug((DEBUG_ERROR, cli_info(to)));
}
static int can_send(struct Client* to)
{
assert(0 != to);
- return (IsDead(to) || IsMe(to) || -1 == to->fd) ? 0 : 1;
+ return (IsDead(to) || IsMe(to) || -1 == cli_fd(to)) ? 0 : 1;
}
/*
void send_queued(struct Client *to)
{
assert(0 != to);
- assert(0 != to->local);
+ assert(0 != cli_local(to));
if (IsBlocked(to) || !can_send(to))
return; /* Don't bother */
- while (MsgQLength(&to->sendQ) > 0) {
+ while (MsgQLength(&(cli_sendQ(to))) > 0) {
unsigned int len;
- if ((len = deliver_it(to, &to->sendQ))) {
- msgq_delete(&to->sendQ, len);
- to->lastsq = MsgQLength(&to->sendQ) / 1024;
+ if ((len = deliver_it(to, &(cli_sendQ(to))))) {
+ msgq_delete(&(cli_sendQ(to)), len);
+ to->lastsq = MsgQLength(&(cli_sendQ(to))) / 1024;
if (IsBlocked(to))
break;
}
else {
if (IsDead(to)) {
char tmp[512];
- sprintf(tmp,"Write error: %s",(strerror(to->error)) ? (strerror(to->error)) : "Unknown error" );
+ sprintf(tmp,"Write error: %s",(strerror(cli_error(to))) ? (strerror(cli_error(to))) : "Unknown error" );
dead_link(to, tmp);
}
break;
assert(0 != to);
assert(0 != buf);
- if (to->from)
- to = to->from;
+ if (cli_from(to))
+ to = cli_from(to);
if (!can_send(to))
/*
*/
return;
- if (MsgQLength(&to->sendQ) > get_sendq(to)) {
+ if (MsgQLength(&(cli_sendQ(to))) > get_sendq(to)) {
if (IsServer(to))
sendto_opmask_butone(0, SNO_OLDSNO, "Max SendQ limit exceeded for %C: "
- "%zu > %zu", to, MsgQLength(&to->sendQ),
+ "%zu > %zu", to, MsgQLength(&(cli_sendQ(to))),
get_sendq(to));
dead_link(to, "Max sendQ exceeded");
return;
}
- Debug((DEBUG_SEND, "Sending [%p] to %s", buf, to->name));
+ Debug((DEBUG_SEND, "Sending [%p] to %s", buf, cli_name(to)));
- msgq_add(&to->sendQ, buf, prio);
+ msgq_add(&(cli_sendQ(to)), buf, prio);
/*
* Update statistics. The following is slightly incorrect
* because it counts messages even if queued, but bytes
* only really sent. Queued bytes get updated in SendQueued.
*/
- ++to->sendM;
- ++me.sendM;
+ ++(cli_sendM(to));
+ ++(cli_sendM(&me));
/*
* This little bit is to stop the sendQ from growing too large when
* there is no need for it to. Thus we call send_queued() every time
* trying to flood that link with data (possible during the net
* relinking done by servers with a large load).
*/
- if (MsgQLength(&to->sendQ) / 1024 > to->lastsq)
+ if (MsgQLength(&(cli_sendQ(to))) / 1024 > cli_lastsq(to))
send_queued(to);
}
switch (what)
{
case MATCH_HOST:
- return (match(mask, one->user->host) == 0);
+ return (match(mask, cli_user(one)->host) == 0);
case MATCH_SERVER:
default:
- return (match(mask, one->user->server->name) == 0);
+ return (match(mask, cli_name(cli_user(one)->server)) == 0);
}
}
struct VarData vd;
struct MsgBuf *mb;
- to = to->from;
+ to = cli_from(to);
vd.vd_format = pattern; /* set up the struct VarData for %v */
vd.vd_args = vl;
/* send it to our downlinks */
for (lp = me.serv->down; lp; lp = lp->next) {
- if (one && lp->value.cptr == one->from)
+ if (one && lp->value.cptr == cli_from(one))
continue;
send_buffer(lp->value.cptr, mb, 0);
}
struct Membership *member;
assert(0 != from);
- assert(0 != from->from);
+ assert(0 != cli_from(from));
assert(0 != pattern);
assert(!IsServer(from) && !IsMe(from));
va_end(vd.vd_args);
sentalong_marker++;
- if (-1 < from->from->fd)
- sentalong[from->from->fd] = sentalong_marker;
+ if (-1 < cli_fd(cli_from(from)))
+ sentalong[cli_fd(cli_from(from))] = sentalong_marker;
/*
* loop through from's channels, and the members on their channels
*/
- for (chan = from->user->channel; chan; chan = chan->next_channel)
+ for (chan = cli_user(from)->channel; chan; chan = chan->next_channel)
for (member = chan->channel->members; member;
member = member->next_member)
- if (MyConnect(member->user) && -1 < member->user->from->fd &&
- sentalong[member->user->from->fd] != sentalong_marker) {
- sentalong[member->user->from->fd] = sentalong_marker;
+ if (MyConnect(member->user) && -1 < cli_fd(cli_from(member->user)) &&
+ sentalong[cli_fd(cli_from(member->user))] != sentalong_marker) {
+ sentalong[cli_fd(cli_from(member->user))] = sentalong_marker;
send_buffer(member->user, mb, 0);
}
sentalong_marker++;
for (member = to->members; member; member = member->next_member) {
/* skip one, zombies, and deaf users... */
- if (member->user->from == one || IsZombie(member) ||
+ if (cli_from(member->user) == one || IsZombie(member) ||
(skip & SKIP_DEAF && IsDeaf(member->user)) ||
(skip & SKIP_NONOPS && !IsChanOp(member)) ||
- (skip & SKIP_BURST && IsBurstOrBurstAck(member->user->from)) ||
- member->user->from->fd < 0 ||
- sentalong[member->user->from->fd] == sentalong_marker)
+ (skip & SKIP_BURST && IsBurstOrBurstAck(cli_from(member->user))) ||
+ cli_fd(cli_from(member->user)) < 0 ||
+ sentalong[cli_fd(cli_from(member->user))] == sentalong_marker)
continue;
- sentalong[member->user->from->fd] = sentalong_marker;
+ sentalong[cli_fd(cli_from(member->user))] = sentalong_marker;
if (MyConnect(member->user)) /* pick right buffer to send */
send_buffer(member->user, user_mb, 0);
/* send buffer along! */
sentalong_marker++;
- for (cptr = GlobalClientList; cptr; cptr = cptr->next) {
- if (cptr->from == one || IsServer(cptr) || !(cptr->flags & flag) ||
- cptr->from->fd < 0 || sentalong[cptr->from->fd] == sentalong_marker)
+ for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
+ if (cli_from(cptr) == one || IsServer(cptr) || !(cli_flags(cptr) & flag) ||
+ cli_fd(cli_from(cptr)) < 0 ||
+ sentalong[cli_fd(cli_from(cptr))] == sentalong_marker)
continue; /* skip it */
- sentalong[cptr->from->fd] = sentalong_marker;
+ sentalong[cli_fd(cli_from(cptr))] = sentalong_marker;
if (MyConnect(cptr)) /* send right buffer */
send_buffer(cptr, user_mb, 1);
/* send buffer along */
sentalong_marker++;
for (cptr = GlobalClientList; cptr; cptr = cptr->next) {
- if (cptr->from == one || IsServer(cptr) || IsMe(cptr) ||
- !match_it(cptr, to, who) || cptr->from->fd < 0 ||
- sentalong[cptr->from->fd] == sentalong_marker)
+ if (cli_from(cptr) == one || IsServer(cptr) || IsMe(cptr) ||
+ !match_it(cptr, to, who) || cli_fd(cli_from(cptr)) < 0 ||
+ sentalong[cli_fd(cli_from(cptr))] == sentalong_marker)
continue; /* skip it */
- sentalong[cptr->from->fd] = sentalong_marker;
+ sentalong[cli_fd(cli_from(cptr))] = sentalong_marker;
if (MyConnect(cptr)) /* send right buffer */
send_buffer(cptr, user_mb, 0);
!IsChannelService(acptr))
{
struct Membership* chan;
- for (chan = acptr->user->channel; chan && !chptr; chan = chan->next_channel)
+ for (chan = cli_user(acptr)->channel; chan && !chptr; chan = chan->next_channel)
if (PubChannel(chan->channel) &&
(acptr == sptr || !IsZombie(chan)))
chptr = chan->channel;
if (!fields || (fields & WHO_FIELD_UID))
{
- char *p2 = acptr->user->username;
+ char *p2 = cli_user(acptr)->username;
*(p1++) = ' ';
while ((*p2) && (*(p1++) = *(p2++)));
}
if (fields & WHO_FIELD_NIP)
{
- const char* p2 = ircd_ntoa((const char*) &acptr->ip);
+ const char* p2 = ircd_ntoa((const char*) &(cli_ip(acptr)));
*(p1++) = ' ';
while ((*p2) && (*(p1++) = *(p2++)));
}
if (!fields || (fields & WHO_FIELD_HOS))
{
- char *p2 = acptr->user->host;
+ char *p2 = cli_user(acptr)->host;
*(p1++) = ' ';
while ((*p2) && (*(p1++) = *(p2++)));
}
if (!fields || (fields & WHO_FIELD_SER))
{
- char *p2 = acptr->user->server->name;
+ char *p2 = cli_name(cli_user(acptr)->server);
*(p1++) = ' ';
while ((*p2) && (*(p1++) = *(p2++)));
}
if (!fields || (fields & WHO_FIELD_NIC))
{
- char *p2 = acptr->name;
+ char *p2 = cli_name(acptr);
*(p1++) = ' ';
while ((*p2) && (*(p1++) = *(p2++)));
}
if (!fields || (fields & WHO_FIELD_FLA))
{
*(p1++) = ' ';
- if (acptr->user->away)
+ if (cli_user(acptr)->away)
*(p1++) = 'G';
else
*(p1++) = 'H';
*p1++ = ' ';
if (!fields)
*p1++ = ':'; /* Place colon here for default reply */
- p1 = sprintf_irc(p1, "%d", acptr->hopcount);
+ p1 = sprintf_irc(p1, "%d", cli_hopcount(acptr));
}
if (fields & WHO_FIELD_IDL)
{
*p1++ = ' ';
if (MyUser(acptr)) {
- p1 = sprintf_irc(p1, "%d", CurrentTime - acptr->user->last);
+ p1 = sprintf_irc(p1, "%d", CurrentTime - cli_user(acptr)->last);
}
else {
*p1++ = '0';
if (!fields || (fields & WHO_FIELD_REN))
{
- char *p2 = acptr->info;
+ char *p2 = cli_info(acptr);
*p1++ = ' ';
if (fields)
*p1++ = ':'; /* Place colon here for special reply */
}
/* Initialize aWhoWas struct `newww' */
- ww.newww->hashv = hash_whowas_name(cptr->name);
+ ww.newww->hashv = hash_whowas_name(cli_name(cptr));
ww.newww->logoff = CurrentTime;
- DupString(ww.newww->name, cptr->name);
- DupString(ww.newww->username, cptr->user->username);
- DupString(ww.newww->hostname, cptr->user->host);
+ DupString(ww.newww->name, cli_name(cptr));
+ DupString(ww.newww->username, cli_user(cptr)->username);
+ DupString(ww.newww->hostname, cli_user(cptr)->host);
/* Should be changed to server numeric */
- DupString(ww.newww->servername, cptr->user->server->name);
- DupString(ww.newww->realname, cptr->info);
+ DupString(ww.newww->servername, cli_name(cli_user(cptr)->server));
+ DupString(ww.newww->realname, cli_info(cptr));
if (cptr->user->away)
- DupString(ww.newww->away, cptr->user->away);
+ DupString(ww.newww->away, cli_user(cptr)->away);
else
ww.newww->away = NULL;
{
ww.newww->online = cptr;
/* Add struct Whowas struct `newww' to start of 'online list': */
- if ((ww.newww->cnext = cptr->whowas))
+ if ((ww.newww->cnext = cli_whowas(cptr)))
ww.newww->cnext->cprevnextp = &ww.newww->cnext;
- ww.newww->cprevnextp = &cptr->whowas;
- cptr->whowas = ww.newww;
+ ww.newww->cprevnextp = &(cli_whowas(cptr));
+ cli_whowas(cptr) = ww.newww;
}
else /* User quitting */
ww.newww->online = NULL;
{
struct Whowas *temp;
- for (temp = cptr->whowas; temp; temp = temp->cnext)
+ for (temp = cli_whowas(cptr); temp; temp = temp->cnext)
temp->online = NULL;
}