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

Comparing ircd-hybrid/trunk/src/s_user.c (file contents):
Revision 2691 by michael, Tue Dec 17 18:55:59 2013 UTC vs.
Revision 3117 by michael, Fri Mar 7 19:28:54 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_user.c: User related functions.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_user.c
23 > * \brief User related functions.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 29 | Line 31
31   #include "channel.h"
32   #include "channel_mode.h"
33   #include "client.h"
32 #include "fdlist.h"
34   #include "hash.h"
35   #include "irc_string.h"
35 #include "s_bsd.h"
36   #include "ircd.h"
37   #include "listener.h"
38   #include "motd.h"
# Line 42 | Line 42
42   #include "s_serv.h"
43   #include "send.h"
44   #include "supported.h"
45 #include "whowas.h"
45   #include "memory.h"
46   #include "packet.h"
47   #include "rng_mt.h"
48   #include "userhost.h"
50 #include "hook.h"
49   #include "s_misc.h"
50   #include "parse.h"
51   #include "watch.h"
# Line 171 | Line 169 | assemble_umode_buffer(void)
169   void
170   show_lusers(struct Client *source_p)
171   {
174  const char *from, *to;
175
176  if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
177  {
178    from = me.id;
179    to = source_p->id;
180  }
181  else
182  {
183    from = me.name;
184    to = source_p->name;
185  }
186
172    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
173 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT),
174 <               from, to, (Count.total-Count.invisi),
190 <               Count.invisi, dlink_list_length(&global_serv_list));
173 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi),
174 >                       Count.invisi, dlink_list_length(&global_serv_list));
175    else
176 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
177 <               (Count.total-Count.invisi), Count.invisi, 1);
176 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT,
177 >                       (Count.total-Count.invisi), Count.invisi, 1);
178  
179    if (Count.oper > 0)
180 <    sendto_one(source_p, form_str(RPL_LUSEROP),
197 <               from, to, Count.oper);
180 >    sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper);
181  
182    if (dlink_list_length(&unknown_list) > 0)
183 <    sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
201 <               from, to, dlink_list_length(&unknown_list));
183 >    sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list));
184  
185    if (dlink_list_length(&global_channel_list) > 0)
186 <    sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
205 <               from, to, dlink_list_length(&global_channel_list));
186 >    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list));
187  
188    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
189    {
190 <    sendto_one(source_p, form_str(RPL_LUSERME),
191 <               from, to, Count.local, Count.myserver);
211 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
212 <               from, to, Count.local, Count.max_loc);
190 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.local, Count.myserver);
191 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc);
192    }
193    else
194    {
195 <    sendto_one(source_p, form_str(RPL_LUSERME),
196 <               from, to, Count.total, 0);
218 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
219 <               from, to, Count.total, Count.max_tot);
195 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.total, 0);
196 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot);
197    }
198  
199 <  sendto_one(source_p, form_str(RPL_GLOBALUSERS),
223 <             from, to, Count.total, Count.max_tot);
199 >  sendto_one_numeric(source_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot);
200  
201    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
202 <    sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
203 <               Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount);
202 >    sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con,
203 >                       Count.max_loc_cli, Count.totalrestartcount);
204  
205    if (Count.local > Count.max_loc_cli)
206      Count.max_loc_cli = Count.local;
# Line 245 | Line 221 | show_isupport(struct Client *source_p)
221    const dlink_node *ptr = NULL;
222  
223    DLINK_FOREACH(ptr, support_list_lines.head)
224 <    sendto_one(source_p, form_str(RPL_ISUPPORT), me.name,
249 <               source_p->name, ptr->data);
224 >    sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data);
225   }
226  
227   /*
# Line 312 | Line 287 | register_local_user(struct Client *sourc
287  
288    if (!valid_hostname(source_p->host))
289    {
290 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
291 <               "character in your hostname", me.name, source_p->name);
290 >    sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal "
291 >                      "character in your hostname");
292      strlcpy(source_p->host, source_p->sockhost,
293              sizeof(source_p->host));
294    }
# Line 329 | Line 304 | register_local_user(struct Client *sourc
304      if (IsNeedIdentd(conf))
305      {
306        ++ServerStats.is_ref;
307 <      sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
308 <                 "identd to use this server", me.name, source_p->name);
307 >      sendto_one_notice(source_p, &me, ":*** Notice -- You need to install "
308 >                        "identd to use this server");
309        exit_client(source_p, &me, "Install identd");
310        return;
311      }
# Line 355 | Line 330 | register_local_user(struct Client *sourc
330      if (!match_conf_password(pass, conf))
331      {
332        ++ServerStats.is_ref;
333 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
334 <                 me.name, source_p->name);
333 >
334 >      sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
335        exit_client(source_p, &me, "Bad Password");
336        return;
337      }
# Line 469 | Line 444 | register_local_user(struct Client *sourc
444   *              - username to register as
445   *              - host name to register as
446   *              - server name
472 *              - realname (gecos)
447   * output       - NONE
448   * side effects - This function is called when a remote client
449   *                is introduced by a server.
450   */
451   void
452 < register_remote_user(struct Client *source_p,
453 <                     const char *username, const char *host, const char *server,
480 <                     const char *realname)
452 > register_remote_user(struct Client *source_p, const char *username,
453 >                     const char *host, const char *server)
454   {
455    struct Client *target_p = NULL;
456  
# Line 748 | Line 721 | report_and_set_user_flags(struct Client
721   {
722    /* If this user is being spoofed, tell them so */
723    if (IsConfDoSpoofIp(conf))
724 <    sendto_one(source_p,
752 <               ":%s NOTICE %s :*** Spoofing your IP. Congrats.",
753 <               me.name, source_p->name);
724 >    sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats.");
725  
726    /* If this user is in the exception class, Set it "E lined" */
727    if (IsConfExemptKline(conf))
728    {
729      SetExemptKline(source_p);
730 <    sendto_one(source_p,
760 <               ":%s NOTICE %s :*** You are exempt from K/D/G lines. Congrats.",
761 <               me.name, source_p->name);
730 >    sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats.");
731    }
732  
733    /*
# Line 768 | Line 737 | report_and_set_user_flags(struct Client
737    else if (IsConfExemptGline(conf))
738    {
739      SetExemptGline(source_p);
740 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines. Congrats.",
772 <               me.name, source_p->name);
740 >    sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats.");
741    }
742  
743    if (IsConfExemptResv(conf))
744    {
745      SetExemptResv(source_p);
746 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs. Congrats.",
779 <               me.name, source_p->name);
746 >    sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats.");
747    }
748  
749    /* If this user is exempt from user limits set it "F lined" */
750    if (IsConfExemptLimits(conf))
751    {
752      SetExemptLimits(source_p);
753 <    sendto_one(source_p,
787 <               ":%s NOTICE %s :*** You are exempt from user limits. Congrats.",
788 <               me.name,source_p->name);
753 >    sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats.");
754    }
755  
756    if (IsConfCanFlood(conf))
757    {
758      SetCanFlood(source_p);
759 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
760 <               "protection, aren't you fearsome.",
796 <               me.name, source_p->name);
759 >    sendto_one_notice(source_p, &me, ":*** You are exempt from flood "
760 >                      "protection, aren't you fearsome.");
761    }
762   }
763  
# Line 818 | Line 782 | set_user_mode(struct Client *client_p, s
782    if ((target_p = find_person(client_p, parv[1])) == NULL)
783    {
784      if (MyConnect(source_p))
785 <      sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
822 <                 me.name, source_p->name, parv[1]);
785 >      sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
786      return;
787    }
788  
789    if (source_p != target_p)
790    {
791 <     sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
829 <                me.name, source_p->name);
791 >     sendto_one_numeric(source_p, &me, ERR_USERSDONTMATCH);
792       return;
793    }
794  
# Line 840 | Line 802 | set_user_mode(struct Client *client_p, s
802          *m++ = (char)i;
803      *m = '\0';
804  
805 <    sendto_one(source_p, form_str(RPL_UMODEIS),
844 <               me.name, source_p->name, buf);
805 >    sendto_one_numeric(source_p, &me, RPL_UMODEIS, buf);
806      return;
807    }
808  
# Line 922 | Line 883 | set_user_mode(struct Client *client_p, s
883    }
884  
885    if (badflag)
886 <    sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
926 <               me.name, source_p->name);
886 >    sendto_one_numeric(source_p, &me, ERR_UMODEUNKNOWNFLAG);
887  
888    if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) &&
889        !HasOFlag(source_p, OPER_FLAG_ADMIN))
890    {
891 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
932 <               me.name, source_p->name);
891 >    sendto_one_notice(source_p, &me, ":*** You have no admin flag;");
892      DelUMode(source_p, UMODE_ADMIN);
893    }
894  
# Line 1079 | Line 1038 | user_set_hostmask(struct Client *target_
1038  
1039    if (MyClient(target_p))
1040    {
1041 <    sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name,
1083 <               target_p->name, target_p->host);
1041 >    sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host);
1042      clear_ban_cache_client(target_p);
1043    }
1044  
# Line 1150 | Line 1108 | user_welcome(struct Client *source_p)
1108    if (HasFlag(source_p, FLAGS_SSL))
1109    {
1110      AddUMode(source_p, UMODE_SSL);
1111 <    sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1112 <               me.name, source_p->name,
1155 <               ssl_get_cipher(source_p->localClient->fd.ssl));
1111 >    sendto_one_notice(source_p, &me, ":*** Connected securely via %s",
1112 >                      ssl_get_cipher(source_p->localClient->fd.ssl));
1113    }
1114   #endif
1115  
1116 <  sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1117 <             ServerInfo.network_name, source_p->name);
1118 <  sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1119 <             get_listener_name(source_p->localClient->listener), ircd_version);
1120 <  sendto_one(source_p, form_str(RPL_CREATED),
1121 <             me.name, source_p->name, built_date);
1165 <  sendto_one(source_p, form_str(RPL_MYINFO),
1166 <             me.name, source_p->name, me.name, ircd_version, umode_buffer);
1116 >  sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name,
1117 >                     source_p->name);
1118 >  sendto_one_numeric(source_p, &me, RPL_YOURHOST,
1119 >                     get_listener_name(source_p->localClient->listener), ircd_version);
1120 >  sendto_one_numeric(source_p, &me, RPL_CREATED, built_date);
1121 >  sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer);
1122    show_isupport(source_p);
1123  
1124    if (source_p->id[0] != '\0')
1125 <    sendto_one(source_p, form_str(RPL_YOURID), me.name,
1171 <               source_p->name, source_p->id);
1125 >    sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id);
1126  
1127    show_lusers(source_p);
1128    motd_signon(source_p);
# Line 1249 | Line 1203 | oper_up(struct Client *source_p)
1203    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
1204                         get_oper_name(source_p));
1205    send_umode_out(source_p, source_p, old);
1206 <  sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1206 >  sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
1207   }
1208  
1209   static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
# Line 1450 | Line 1404 | rebuild_isupport_message_line(void)
1404    int n = 0;
1405    int tokens = 0;
1406    size_t len = 0;
1407 <  size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1407 >  size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT));
1408  
1409    DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1410    {

Diff Legend

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