-/*
- * 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(aClient *bcptr, char *comment)
-{
- Link *lp;
-
- if (bcptr->serv && bcptr->serv->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;
- RunFree(bcptr->listing);
- bcptr->listing = NULL;
- }
-
- if (AskedPing(bcptr))
- cancel_ping(bcptr, 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);
-
- while ((lp = bcptr->user->channel))
- remove_user_from_channel(bcptr, lp->value.chptr);
-
- /* 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))
- --nrof.inv_clients;
- if (IsOper(bcptr))
- --nrof.opers;
- if (MyConnect(bcptr))
- Count_clientdisconnects(bcptr, nrof);
- else
- Count_remoteclientquits(nrof);
- }
- else if (IsServer(bcptr))
- {
- /* Remove downlink list node of uplink */
- remove_dlink(&bcptr->serv->up->serv->down, bcptr->serv->updown);
-
- if (MyConnect(bcptr))
- Count_serverdisconnects(nrof);
- else
- Count_remoteserverquits(nrof);
- }
- else if (IsPing(bcptr)) /* Apperently, we are closing ALL links */
- {
- del_queries((char *)bcptr);
- end_ping(bcptr);
- return;
- }
- 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(nrof);
-
- /* 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);
- return;
-}
-
-void checklist(void)
-{
- Reg1 aClient *acptr;
- Reg2 int i, j;
-
- if (!(bootopt & BOOT_AUTODIE))
- return;
- for (j = i = 0; i <= highest_fd; i++)
- if (!(acptr = loc_clients[i]))
- continue;
- else if (IsUser(acptr))
- j++;
- if (!j)
- {
-#ifdef USE_SYSLOG
- syslog(LOG_WARNING, "ircd exiting: autodie");
-#endif
- exit(0);
- }
- return;
-}
-