+/** Add a client to the whowas list.
+ * @param[in] cptr Client to add.
+ * @param[in] still_on If non-zero, link the record to the client's personal history.
+ */
+void add_history(struct Client *cptr, int still_on)
+{
+ struct Whowas *ww;
+
+ if (!(ww = whowas_alloc()))
+ return; /* couldn't get a structure */
+
+ ww->hashv = hash_whowas_name(cli_name(cptr)); /* initialize struct */
+ ww->logoff = CurrentTime;
+ DupString(ww->name, cli_name(cptr));
+ DupString(ww->username, cli_user(cptr)->username);
+ DupString(ww->hostname, cli_user(cptr)->host);
+ if (HasHiddenHost(cptr))
+ DupString(ww->realhost, cli_user(cptr)->realhost);
+ DupString(ww->servername, cli_name(cli_user(cptr)->server));
+ DupString(ww->realname, cli_info(cptr));
+ if (cli_user(cptr)->away)
+ DupString(ww->away, cli_user(cptr)->away);
+
+ if (still_on) { /* user changed nicknames... */
+ ww->online = cptr;
+ if ((ww->cnext = cli_whowas(cptr)))
+ ww->cnext->cprevnextp = &ww->cnext;
+ ww->cprevnextp = &(cli_whowas(cptr));
+ cli_whowas(cptr) = ww;
+ } else /* user quit */
+ ww->online = 0;
+
+ /* link new whowas structure to list */
+ ww->wnext = wwList.ww_list;
+ if (wwList.ww_list)
+ wwList.ww_list->wprev = ww;
+ wwList.ww_list = ww;
+
+ if (!wwList.ww_tail) /* update the tail pointer... */
+ wwList.ww_tail = ww;
+
+ /* Now link it into the hash table */
+ if ((ww->hnext = whowashash[ww->hashv]))
+ ww->hnext->hprevnextp = &ww->hnext;
+ ww->hprevnextp = &whowashash[ww->hashv];
+ whowashash[ww->hashv] = ww;
+}
+
+/** Clear all Whowas::online pointers that point to a client.
+ * @param[in] cptr Client who is going offline.