]> jfr.im git - irc/quakenet/newserv.git/blobdiff - whowas/whowas.c
Merge default.
[irc/quakenet/newserv.git] / whowas / whowas.c
index b79fcb7deca0642036edb949a807bac8c656f25e..5764ecac0bd154b3a9e5da11d1a6741796f77f53 100644 (file)
@@ -16,6 +16,7 @@ whowas *whowas_fromnick(nick *np, int standalone) {
   whowas *ww;
   nick *wnp;
   struct irc_in_addr ipaddress_canonical;
+  void *args[2];
 
   /* Create a new record. */
   if (standalone)
@@ -66,6 +67,10 @@ whowas *whowas_fromnick(nick *np, int standalone) {
   ww->timestamp = getnettime();
   ww->type = WHOWAS_USED;
 
+  args[0] = ww;
+  args[1] = np;
+  triggerhook(HOOK_WHOWAS_NEWRECORD, args);
+
   return ww;
 }
 
@@ -75,6 +80,8 @@ void whowas_clean(whowas *ww) {
   if (!ww || ww->type == WHOWAS_UNUSED)
     return;
 
+  triggerhook(HOOK_WHOWAS_LOSTRECORD, ww);
+
   np = &ww->nick;
   freesstring(np->host->name);
   freehost(np->host);
@@ -172,7 +179,7 @@ const char *whowas_format(whowas *ww) {
   snprintf(hostmask, sizeof(hostmask), "%s!%s@%s%s%s [%s] (%s)",
            np->nick, np->ident, np->host->name->content,
            np->auth ? "/" : "", np->auth ? np->authname : "",
-           IPtostr(np->p_ipaddr),
+           IPtostr(np->ipaddress),
            printflags(np->umodes, umodeflags));
   strftime(timebuf, sizeof(timebuf), "%d/%m/%y %H:%M:%S", localtime(&(ww->timestamp)));
 
@@ -184,6 +191,32 @@ const char *whowas_format(whowas *ww) {
   return buf;
 }
 
+const char *whowas_formatchannels(whowas *ww) {
+  static char buf[512];
+  int i, first = 1;
+
+  strcpy(buf, "Channels: ");
+
+  for (i = 0; i < WW_MAXCHANNELS; i++) {
+    if (!ww->channels[i])
+      break;
+
+    if (!first)
+      strncat(buf, ", ", sizeof(buf));
+    else
+      first = 0;
+
+    strncat(buf, ww->channels[i]->name->content, sizeof(buf));
+  }
+
+  if (!ww->channels[0])
+    strncat(buf, "(No channels.)", sizeof(buf));
+
+  buf[sizeof(buf) - 1] = '\0';
+
+  return buf;
+}
+
 unsigned int nextwhowasmarker() {
   whowas *ww;
   int i;
@@ -205,6 +238,8 @@ unsigned int nextwhowasmarker() {
 }
 
 void _init(void) {
+  memset(whowasrecs, 0, sizeof(whowasrecs));
+
   registerhook(HOOK_NICK_QUIT, whowas_handlequitorkill);
   registerhook(HOOK_NICK_KILL, whowas_handlequitorkill);
   registerhook(HOOK_NICK_RENAME, whowas_handlerename);