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

Comparing ircd-hybrid/trunk/src/client.c (file contents):
Revision 3186 by michael, Thu Mar 20 18:09:34 2014 UTC vs.
Revision 3247 by michael, Sun Mar 30 17:54:34 2014 UTC

# Line 119 | Line 119 | make_client(struct Client *from)
119  
120    memset(client_p, 0, sizeof(*client_p));
121  
122 <  if (from == NULL)
122 >  if (!from)
123    {
124      client_p->from                      = client_p; /* 'from' of local client is self! */
125      client_p->localClient               = mp_pool_get(lclient_pool);
# Line 156 | Line 156 | make_client(struct Client *from)
156   static void
157   free_client(struct Client *client_p)
158   {
159 <  assert(client_p != NULL);
159 >  assert(client_p);
160    assert(client_p != &me);
161    assert(client_p->hnext == client_p);
162    assert(client_p->idhnext == client_p);
# Line 315 | Line 315 | check_pings_list(dlink_list *list)
315   static void
316   check_unknowns_list(void)
317   {
318 <  dlink_node *ptr, *next_ptr;
318 >  dlink_node *ptr = NULL, *ptr_next = NULL;
319  
320 <  DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head)
320 >  DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head)
321    {
322      struct Client *client_p = ptr->data;
323  
# Line 354 | Line 354 | check_conf_klines(void)
354        continue;
355  
356      if ((conf = find_dline_conf(&client_p->localClient->ip,
357 <                                  client_p->localClient->aftype)) != NULL)
357 >                                  client_p->localClient->aftype)))
358      {
359        if (conf->type == CONF_EXEMPT)
360          continue;
# Line 513 | Line 513 | find_person(const struct Client *const s
513  
514    if (IsDigit(*name))
515    {
516 <    if (IsServer(source_p->from) || HasFlag(source_p->from, FLAGS_SERVICE))
516 >    if (IsServer(source_p->from))
517        target_p = hash_find_id(name);
518    }
519    else
# Line 525 | Line 525 | find_person(const struct Client *const s
525   /*
526   * find_chasing - find the client structure for a nick name (name)
527   *      using history mechanism if necessary. If the client is not found,
528 < *      an error message (NO SUCH NICK) is generated. If the client was found
529 < *      through the history, chasing will be 1 and otherwise 0.
528 > *      an error message (NO SUCH NICK) is generated.
529   */
530   struct Client *
531 < find_chasing(struct Client *source_p, const char *name, int *const chasing)
531 > find_chasing(struct Client *source_p, const char *name)
532   {
533    struct Client *who = find_person(source_p, name);
534  
536  if (chasing)
537    *chasing = 0;
538
535    if (who)
536      return who;
537  
# Line 550 | Line 546 | find_chasing(struct Client *source_p, co
546      return NULL;
547    }
548  
553  if (chasing)
554    *chasing = 1;
555
549    return who;
550   }
551  
# Line 575 | Line 568 | find_chasing(struct Client *source_p, co
568   *        to modify what it points!!!
569   */
570   const char *
571 < get_client_name(const struct Client *client, enum addr_mask_type type)
571 > get_client_name(const struct Client *client_p, enum addr_mask_type type)
572   {
573    static char nbuf[HOSTLEN * 2 + USERLEN + 5];
574  
575 <  assert(client != NULL);
575 >  assert(client_p);
576  
577 <  if (!MyConnect(client))
578 <    return client->name;
577 >  if (!MyConnect(client_p))
578 >    return client_p->name;
579  
580 <  if (IsServer(client) || IsConnecting(client) || IsHandshake(client))
580 >  if (IsServer(client_p) || IsConnecting(client_p) || IsHandshake(client_p))
581    {
582 <    if (!irccmp(client->name, client->host))
583 <      return client->name;
582 >    if (!irccmp(client_p->name, client_p->host))
583 >      return client_p->name;
584      else if (ConfigServerHide.hide_server_ips)
585        type = MASK_IP;
586    }
587  
588    if (ConfigFileEntry.hide_spoof_ips)
589 <    if (type == SHOW_IP && IsIPSpoof(client))
589 >    if (type == SHOW_IP && IsIPSpoof(client_p))
590        type = MASK_IP;
591  
592    /* And finally, let's get the host information, ip or name */
# Line 601 | Line 594 | get_client_name(const struct Client *cli
594    {
595      case SHOW_IP:
596        snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
597 <               client->name,
598 <               client->username, client->sockhost);
597 >               client_p->name,
598 >               client_p->username, client_p->sockhost);
599        break;
600      case MASK_IP:
601 <      if (client->localClient->aftype == AF_INET)
601 >      if (client_p->localClient->aftype == AF_INET)
602          snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
603 <                 client->name, client->username);
603 >                 client_p->name, client_p->username);
604        else
605          snprintf(nbuf, sizeof(nbuf), "%s[%s@ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]",
606 <                 client->name, client->username);
606 >                 client_p->name, client_p->username);
607        break;
608      default:
609        snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
610 <               client->name,
611 <               client->username, client->host);
610 >               client_p->name,
611 >               client_p->username, client_p->host);
612    }
613  
614    return nbuf;
# Line 643 | Line 636 | free_exited_clients(void)
636   static void
637   exit_one_client(struct Client *source_p, const char *quitmsg)
638   {
639 <  dlink_node *lp = NULL, *next_lp = NULL;
639 >  dlink_node *ptr = NULL, *ptr_next = NULL;
640  
641    assert(!IsMe(source_p));
642  
643    if (IsClient(source_p))
644    {
645 <    if (source_p->servptr->serv != NULL)
653 <      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
645 >    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
646  
647      /*
648       * If a person is on a channel, send a QUIT notice
# Line 661 | Line 653 | exit_one_client(struct Client *source_p,
653      sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s",
654                                   source_p->name, source_p->username,
655                                   source_p->host, quitmsg);
656 <    DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
657 <      remove_user_from_channel(lp->data);
656 >    DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->channel.head)
657 >      remove_user_from_channel(ptr->data);
658  
659      whowas_add_history(source_p, 0);
660      whowas_off_history(source_p);
# Line 672 | Line 664 | exit_one_client(struct Client *source_p,
664      if (MyConnect(source_p))
665      {
666        /* Clean up invitefield */
667 <      DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head)
668 <        del_invite(lp->data, source_p);
667 >      DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->localClient->invited.head)
668 >        del_invite(ptr->data, source_p);
669  
670        del_all_accepts(source_p);
671      }
# Line 682 | Line 674 | exit_one_client(struct Client *source_p,
674    {
675      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
676  
677 <    if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
678 <      free_dlink_node(lp);
677 >    if ((ptr = dlinkFindDelete(&global_serv_list, source_p)))
678 >      free_dlink_node(ptr);
679    }
680  
681    /* Remove source_p from the client lists */
682 <  if (HasID(source_p))
682 >  if (source_p->id[0])
683      hash_del_id(source_p);
684    if (source_p->name[0])
685      hash_del_client(source_p);
# Line 699 | Line 691 | exit_one_client(struct Client *source_p,
691     * NOTE: source_p->node.next cannot be NULL if the client is added
692     *       to global_client_list (there is always &me at its end)
693     */
694 <  if (source_p->node.next != NULL) /* XXX: not needed? */
694 >  if (source_p->node.next) /* XXX: not needed? */
695      dlinkDelete(&source_p->node, &global_client_list);
696  
697    update_client_exit_stats(source_p);
# Line 721 | Line 713 | exit_one_client(struct Client *source_p,
713   static void
714   recurse_remove_clients(struct Client *source_p, const char *quitmsg)
715   {
716 <  dlink_node *ptr, *next;
716 >  dlink_node *ptr = NULL, *ptr_next = NULL;
717  
718 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head)
718 >  DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->client_list.head)
719      exit_one_client(ptr->data, quitmsg);
720  
721 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
721 >  DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->server_list.head)
722    {
723      recurse_remove_clients(ptr->data, quitmsg);
724      exit_one_client(ptr->data, quitmsg);
# Line 754 | Line 746 | void
746   exit_client(struct Client *source_p, const char *comment)
747   {
748    dlink_node *m = NULL;
757  /* Store the direction to source_p, close_connection sets it to NULL */
758  struct Client *client_p = source_p->from;
749  
750    if (MyConnect(source_p))
751    {
# Line 792 | Line 782 | exit_client(struct Client *source_p, con
782        Count.local--;
783  
784        if (HasUMode(source_p, UMODE_OPER))
785 <        if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL)
785 >        if ((m = dlinkFindDelete(&oper_list, source_p)))
786            free_dlink_node(m);
787  
788        assert(dlinkFind(&local_client_list, source_p));
789        dlinkDelete(&source_p->localClient->lclient_node, &local_client_list);
790  
791 <      if (source_p->localClient->list_task != NULL)
791 >      if (source_p->localClient->list_task)
792          free_list_task(source_p->localClient->list_task, source_p);
793  
794        watch_del_watch_list(source_p);
# Line 863 | Line 853 | exit_client(struct Client *source_p, con
853      char splitstr[HOSTLEN + HOSTLEN + 2] = "";
854  
855      /* This shouldn't ever happen */
856 <    assert(source_p->serv != NULL && source_p->servptr != NULL);
856 >    assert(source_p->serv && source_p->servptr);
857  
858      if (ConfigServerHide.hide_servers)
859        /*
# Line 882 | Line 872 | exit_client(struct Client *source_p, con
872      /* Now exit the clients internally */
873      recurse_remove_clients(source_p, splitstr);
874  
875 <    if (source_p->servptr == &me)
875 >    if (MyConnect(source_p))
876      {
877        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
878                             "%s was connected for %d seconds.  %llu/%llu sendK/recvK.",
# Line 896 | Line 886 | exit_client(struct Client *source_p, con
886      }
887    }
888    else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED))
889 <    sendto_server(client_p, NOCAPS, NOCAPS, ":%s QUIT :%s",
889 >    sendto_server(source_p->from, NOCAPS, NOCAPS, ":%s QUIT :%s",
890                    source_p->id, comment);
891  
892    /* The client *better* be off all of the lists */
# Line 1105 | Line 1095 | accept_message(struct Client *source,
1095   void
1096   del_all_accepts(struct Client *client_p)
1097   {
1098 <  dlink_node *ptr = NULL, *next_ptr = NULL;
1098 >  dlink_node *ptr = NULL, *ptr_next = NULL;
1099  
1100 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head)
1100 >  DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->acceptlist.head)
1101      del_accept(ptr->data, client_p);
1102   }
1103  
# Line 1136 | Line 1126 | idle_time_get(const struct Client *sourc
1126    else
1127      idle = CurrentTime - target_p->localClient->last_privmsg;
1128  
1129 <  if (max_idle == 0)
1129 >  if (!max_idle)
1130      idle = 0;
1131    else
1132      idle %= max_idle;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)