]> jfr.im git - solanum.git/blobdiff - ircd/channel.c
Resolve shfit/reduce conflict in timespec production (#54)
[solanum.git] / ircd / channel.c
index 70eb5c2b21c6cced4d9c92b715d3cbe7792d33b9..c09a717d12c1bf797a3a919b78cac85d90c4e0d4 100644 (file)
@@ -434,6 +434,47 @@ channel_pub_or_secret(struct Channel *chptr)
        return ("*");
 }
 
+int
+iter_comm_channels_step(rb_dlink_node *pos1, rb_dlink_node *pos2,
+               struct membership **ms1, struct membership **ms2,
+               struct Channel **chptr)
+{
+       *ms1 = pos1 ? pos1->data : NULL;
+       *ms2 = pos2 ? pos2->data : NULL;
+
+       /* we're at the end */
+       if (*ms1 == NULL && *ms2 == NULL)
+               return 0;
+
+       /* one side is at the end, keep stepping the other one */
+       if (*ms1 == NULL || *ms2 == NULL)
+       {
+               *chptr = *ms1 != NULL ? (*ms1)->chptr : (*ms2)->chptr;
+               return 1;
+       }
+
+       /* common channel */
+       if ((*ms1)->chptr == (*ms2)->chptr)
+       {
+               *chptr = (*ms1)->chptr;
+               return 1;
+       }
+
+       /* null out the channel that's further ahead; we'll get to it later */
+       if (irccmp((*ms1)->chptr->chname, (*ms2)->chptr->chname) > 0)
+       {
+               *ms1 = NULL;
+               *chptr = (*ms2)->chptr;
+               return 1;
+       }
+       else
+       {
+               *ms2 = NULL;
+               *chptr = (*ms1)->chptr;
+               return 1;
+       }
+}
+
 /* channel_member_names()
  *
  * input       - channel to list, client to list to, show endofnames