#include <sys/stat.h>
#include <unistd.h>
-static void exit_one_client(struct Client *, char *);
static char *months[] = {
"January", "February", "March", "April",
ircd_strncpy(cptr->sockhost, s, HOSTLEN);
}
+/*
+ * Exit one client, local or remote. Assuming for local client that
+ * all dependants already have been removed, and socket is closed.
+ *
+ * Rewritten by Run - 24 sept 94
+ *
+ * bcptr : client being (s)quitted
+ * sptr : The source (prefix) of the QUIT or SQUIT
+ *
+ * --Run
+ */
+static void exit_one_client(struct Client* bcptr, const char* comment)
+{
+ struct SLink *lp;
+
+ if (bcptr->serv && bcptr->serv->client_list) /* Was SetServerYXX called ? */
+ ClearServerYXX(bcptr); /* Removes server from server_list[] */
+ if (IsUser(bcptr)) {
+ /*
+ * clear out uping requests
+ */
+ if (IsUPing(bcptr))
+ uping_cancel(bcptr, 0);
+ /*
+ * Stop a running /LIST clean
+ */
+ if (MyUser(bcptr) && bcptr->listing) {
+ bcptr->listing->chptr->mode.mode &= ~MODE_LISTED;
+ MyFree(bcptr->listing);
+ bcptr->listing = NULL;
+ }
+ /*
+ * If a person is on a channel, send a QUIT notice
+ * to every client (person) on the same channel (so
+ * that the client can show the "**signoff" message).
+ * (Note: The notice is to the local clients *only*)
+ */
+ sendto_common_channels(bcptr, ":%s QUIT :%s", bcptr->name, comment);
+
+ remove_user_from_all_channels(bcptr);
+
+ /* Clean up invitefield */
+ while ((lp = bcptr->user->invited))
+ del_invite(bcptr, lp->value.chptr);
+
+ /* Clean up silencefield */
+ while ((lp = bcptr->user->silence))
+ del_silence(bcptr, lp->value.cp);
+
+ if (IsInvisible(bcptr))
+ --UserStats.inv_clients;
+ if (IsOper(bcptr))
+ --UserStats.opers;
+ if (MyConnect(bcptr))
+ Count_clientdisconnects(bcptr, UserStats);
+ else
+ Count_remoteclientquits(UserStats, 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;
+
+ if (MyConnect(bcptr))
+ Count_serverdisconnects(UserStats);
+ else
+ Count_remoteserverquits(UserStats);
+ }
+ else if (IsMe(bcptr))
+ {
+ sendto_ops("ERROR: tried to exit me! : %s", comment);
+ return; /* ...must *never* exit self! */
+ }
+ else if (IsUnknown(bcptr) || IsConnecting(bcptr) || IsHandshake(bcptr))
+ Count_unknowndisconnects(UserStats);
+
+ /*
+ * Update IPregistry
+ */
+ if (IsIPChecked(bcptr))
+ IPcheck_disconnect(bcptr);
+
+ /*
+ * Remove from serv->client_list
+ * NOTE: user is *always* NULL if this is a server
+ */
+ if (bcptr->user) {
+ assert(!IsServer(bcptr));
+ /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
+ RemoveYXXClient(bcptr->user->server, bcptr->yxx);
+ }
+
+ /* 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));
+#else
+ hRemClient(bcptr);
+#endif
+ remove_client_from_list(bcptr);
+}
/*
* exit_downlinks - added by Run 25-9-94
*
struct Client* victim, /* Client being killed */
struct Client* killer, /* The client that made the decision
to remove this one, never NULL */
- char *comment) /* Reason for the exit */
+ const char* comment) /* Reason for the exit */
{
struct Client* acptr = 0;
struct DLink *dlp;
* Exit client with formatted message, added 25-9-94 by Run
*/
int vexit_client_msg(struct Client *cptr, struct Client *bcptr, struct Client *sptr,
- char *pattern, va_list vl)
+ const char *pattern, va_list vl)
{
char msgbuf[1024];
vsprintf_irc(msgbuf, pattern, vl);
}
int exit_client_msg(struct Client *cptr, struct Client *bcptr,
- struct Client *sptr, char *pattern, ...)
+ struct Client *sptr, const char *pattern, ...)
{
va_list vl;
char msgbuf[1024];
return exit_client(cptr, bcptr, sptr, msgbuf);
}
-/*
- * Exit one client, local or remote. Assuming for local client that
- * all dependants already have been removed, and socket is closed.
- *
- * Rewritten by Run - 24 sept 94
- *
- * bcptr : client being (s)quitted
- * sptr : The source (prefix) of the QUIT or SQUIT
- *
- * --Run
- */
-static void exit_one_client(struct Client *bcptr, char *comment)
-{
- struct SLink *lp;
-
- if (bcptr->serv && bcptr->serv->client_list) /* Was SetServerYXX called ? */
- ClearServerYXX(bcptr); /* Removes server from server_list[] */
- if (IsUser(bcptr)) {
- /*
- * clear out uping requests
- */
- if (IsUPing(bcptr))
- uping_cancel(bcptr, 0);
- /*
- * Stop a running /LIST clean
- */
- if (MyUser(bcptr) && bcptr->listing) {
- bcptr->listing->chptr->mode.mode &= ~MODE_LISTED;
- MyFree(bcptr->listing);
- bcptr->listing = NULL;
- }
- /*
- * If a person is on a channel, send a QUIT notice
- * to every client (person) on the same channel (so
- * that the client can show the "**signoff" message).
- * (Note: The notice is to the local clients *only*)
- */
- sendto_common_channels(bcptr, ":%s QUIT :%s", bcptr->name, comment);
-
- remove_user_from_all_channels(bcptr);
-
- /* Clean up invitefield */
- while ((lp = bcptr->user->invited))
- del_invite(bcptr, lp->value.chptr);
-
- /* Clean up silencefield */
- while ((lp = bcptr->user->silence))
- del_silence(bcptr, lp->value.cp);
-
- if (IsInvisible(bcptr))
- --UserStats.inv_clients;
- if (IsOper(bcptr))
- --UserStats.opers;
- if (MyConnect(bcptr))
- Count_clientdisconnects(bcptr, UserStats);
- else
- Count_remoteclientquits(UserStats, 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;
-
- if (MyConnect(bcptr))
- Count_serverdisconnects(UserStats);
- else
- Count_remoteserverquits(UserStats);
- }
- else if (IsMe(bcptr))
- {
- sendto_ops("ERROR: tried to exit me! : %s", comment);
- return; /* ...must *never* exit self! */
- }
- else if (IsUnknown(bcptr) || IsConnecting(bcptr) || IsHandshake(bcptr))
- Count_unknowndisconnects(UserStats);
-
- /*
- * Update IPregistry
- */
- if (IsIPChecked(bcptr))
- IPcheck_disconnect(bcptr);
-
- /*
- * Remove from serv->client_list
- * NOTE: user is *always* NULL if this is a server
- */
- if (bcptr->user) {
- assert(!IsServer(bcptr));
- /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
- RemoveYXXClient(bcptr->user->server, bcptr->yxx);
- }
-
- /* 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));
-#else
- hRemClient(bcptr);
-#endif
- remove_client_from_list(bcptr);
-}
-
-
void initstats(void)
{
memset(&ircst, 0, sizeof(ircst));
DBufClear(&to->recvQ);
DBufClear(&to->sendQ);
- /* Keep a copy of the last comment, for later use... */
- ircd_strncpy(LastDeadComment(to), notice, sizeof(LastDeadComment(to) - 1));
- LastDeadComment(to)[sizeof(LastDeadComment(to)) - 1] = '\0';
+ /*
+ * Keep a copy of the last comment, for later use...
+ */
+ ircd_strncpy(to->info, notice, REALLEN);
if (!IsUser(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
- sendto_ops("%s for %s", LastDeadComment(to), to->name);
- Debug((DEBUG_ERROR, LastDeadComment(to)));
+ sendto_ops("%s for %s", to->info, to->name);
+ Debug((DEBUG_ERROR, to->info));
}
static int can_send(struct Client* to)
int i;
int flag=-1;
+ assert(0 != cmd);
/*
* Precalculate the buffers we sent to the clients instead of doing an
* expensive sprintf() per member that we send to. We still have to
*/
if (IsServer(from)) {
sprintf(userbuf,":%s %s %s :%s",
- from->name,
- ((cmd[0] == 'P') ? MSG_PRIVATE : MSG_NOTICE),
- chname, msg);
- sprintf(servbuf,"%s " TOK_PRIVATE " %s :%s",
- NumServ(from), chname, msg);
- } else {
+ from->name, ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
+ sprintf(servbuf,"%s %s %s :%s", NumServ(from), cmd, chname, msg);
+ }
+ else {
sprintf(userbuf,":%s!%s@%s %s %s :%s",
- from->name, from->username, from->user->host,
- ((cmd[0] == 'P') ? MSG_PRIVATE : MSG_NOTICE),
- chname, msg);
- sprintf(servbuf,"%s%s %s %s :%s",
- NumNick(from),
- ((cmd[0] == 'P') ? TOK_PRIVATE : TOK_NOTICE),
- chname, msg);
+ from->name, from->username, from->user->host,
+ ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
+ sprintf(servbuf,"%s%s %s %s :%s", NumNick(from), cmd, chname, msg);
}
++sentalong_marker;