ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/channel.c (file contents):
Revision 9264 by michael, Sat Feb 1 13:36:10 2020 UTC vs.
Revision 9265 by michael, Wed Feb 12 16:55:10 2020 UTC

# Line 27 | Line 27
27   #include "stdinc.h"
28   #include "list.h"
29   #include "channel.h"
30 + #include "channel_invite.h"
31   #include "channel_mode.h"
32   #include "client.h"
33   #include "hash.h"
# Line 354 | Line 355 | channel_make(const char *name)
355   void
356   channel_free(struct Channel *channel)
357   {
358 <  clear_invite_list(&channel->invites);
358 >  invite_clear_list(&channel->invites);
359  
360    /* Free ban/exception/invex lists */
361    channel_free_mask_list(&channel->banlist);
# Line 489 | Line 490 | channel_member_names(struct Client *clie
490      sendto_one_numeric(client, &me, RPL_ENDOFNAMES, channel->name);
491   }
492  
492 static struct Invite *
493 find_invite(struct Channel *channel, struct Client *client)
494 {
495  dlink_node *node, *node_next;
496  dlink_list *list;
497
498  /* Take the shortest of the two lists */
499  if (dlink_list_length(&client->connection->invited) < dlink_list_length(&channel->invites))
500    list = &client->connection->invited;
501  else
502    list = &channel->invites;
503
504  DLINK_FOREACH_SAFE(node, node_next, list->head)
505  {
506    struct Invite *invite = node->data;
507
508    if (ConfigChannel.invite_expire_time &&
509        ConfigChannel.invite_expire_time + invite->when < event_base->time.sec_monotonic)
510      del_invite(invite);
511    else if (invite->channel == channel && invite->client == client)
512      return invite;
513  }
514
515  return NULL;
516 }
517
518 /*! \brief Adds client to invite list
519 * \param channel Pointer to channel block
520 * \param client  Pointer to client to add invite to
521 */
522 void
523 add_invite(struct Channel *channel, struct Client *client)
524 {
525  struct Invite *invite = find_invite(channel, client);
526  if (invite)
527    del_invite(invite);
528
529  invite = xcalloc(sizeof(*invite));
530  invite->client = client;
531  invite->channel = channel;
532  invite->when = event_base->time.sec_monotonic;
533
534  /* Delete last link in chain if the list is max length */
535  while (dlink_list_length(&client->connection->invited) &&
536         dlink_list_length(&client->connection->invited) >= ConfigChannel.max_invites)
537    del_invite(client->connection->invited.tail->data);
538
539  /* Add client to channel invite list */
540  dlinkAdd(invite, &invite->chan_node, &channel->invites);
541
542  /* Add channel to the end of the client invite list */
543  dlinkAdd(invite, &invite->user_node, &client->connection->invited);
544 }
545
546 /*! \brief Delete Invite block from channel invite list
547 *         and client invite list
548 * \param invite Pointer to Invite struct
549 */
550 void
551 del_invite(struct Invite *invite)
552 {
553  dlinkDelete(&invite->user_node, &invite->client->connection->invited);
554  dlinkDelete(&invite->chan_node, &invite->channel->invites);
555
556  /* Release memory pointed to by 'invite' */
557  xfree(invite);
558 }
559
560 /*! \brief Removes and frees all Invite blocks from a list
561 * \param list Pointer to a dlink_list
562 */
563 void
564 clear_invite_list(dlink_list *list)
565 {
566  while (list->head)
567    del_invite(list->head->data);
568 }
569
493   /* get_member_status()
494   *
495   * inputs       - pointer to struct ChannelMember
# Line 721 | Line 644 | can_join(struct Client *client, struct C
644      return ERR_OPERONLYCHAN;
645  
646    if (HasCMode(channel, MODE_INVITEONLY))
647 <    if (find_invite(channel, client) == NULL)
647 >    if (invite_find(channel, client) == NULL)
648        if (find_bmask(client, channel, &channel->invexlist, NULL) == false)
649          return ERR_INVITEONLYCHAN;
650  
# Line 1071 | Line 994 | channel_do_join(struct Client *client, c
994                             client->name, client->username,
995                             client->host, client->away);
996  
997 <    struct Invite *invite = find_invite(channel, client);
997 >    struct Invite *invite = invite_find(channel, client);
998      if (invite)
999 <      del_invite(invite);
999 >      invite_del(invite);
1000  
1001      if (channel->topic[0])
1002      {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines