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

Comparing:
ircd-hybrid-7.2/modules/m_ison.c (file contents), Revision 875 by michael, Tue Oct 23 11:40:09 2007 UTC vs.
ircd-hybrid/trunk/modules/m_ison.c (file contents), Revision 1793 by michael, Sun Mar 31 14:06:08 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 – #include "handlers.h"
26   #include "client.h"
27   #include "irc_string.h"
29 – #include "sprintf_irc.h"
28   #include "ircd.h"
29   #include "numeric.h"
30   #include "send.h"
33 – #include "msg.h"
31   #include "parse.h"
32   #include "modules.h"
36 – #include "s_conf.h" /* ConfigFileEntry */
37 – #include "s_serv.h" /* uplink/IsCapable */
33  
39 – static void do_ison(struct Client *, struct Client *, struct Client *, int, char *[]);
40 – static void m_ison(struct Client *, struct Client *, int, char *[]);
41 – static void ms_ison(struct Client *, struct Client *, int, char *[]);
42 –
43 – struct Message ison_msgtab = {
44 –  "ISON", 0, 0, 1, 1, MFLG_SLOW, 0,
45 –  {m_unregistered, m_ison, ms_ison, m_ignore, m_ison, m_ignore}
46 – };
47 –
48 – #ifndef STATIC_MODULES
49 – void
50 – _modinit(void)
51 – {
52 –  mod_add_cmd(&ison_msgtab);
53 – }
54 –
55 – void
56 – _moddeinit(void)
57 – {
58 –  mod_del_cmd(&ison_msgtab);
59 – }
60 – const char *_version = "$Revision$";
61 – #endif
62 –
63 –
64 –
65 – /*
66 – * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
67 – * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
68 – * clients. Designed to reduce number of whois requests. Can process
69 – * nicknames in batches as long as the maximum buffer length.
70 – *
71 – * format:
72 – * ISON :nicklist
73 – */
74 – static void
75 – m_ison(struct Client *client_p, struct Client *source_p,
76 –       int parc, char *parv[])
77 – {
78 –  struct Client *up = NULL;
79 –
80 –  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
81 –    up = uplink;
82 –
83 –  do_ison(client_p, up, source_p, parc, parv);
84 – }
85 –
86 – /*
87 – * ms_ison added by David Taylor 04/01/2000 to handle relayed ISON requests.
88 – * It's slightly less bandwidth efficient than a normal ISON, but it's
89 – * only ever going to get relayed over one link...
90 – * Plus, we'll only ever relay each nick once in it's lifetime, if it
91 – * exists...
92 – * ISON :nicklist
93 – */
94 – static void
95 – ms_ison(struct Client *client_p, struct Client *source_p,
96 –        int parc, char *parv[])
97 – {
98 –  if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
99 –    do_ison(client_p, NULL, source_p, parc, parv);
100 – }
34  
35   static void
36 < do_ison(struct Client *client_p, struct Client *up, struct Client *source_p,
36 > do_ison(struct Client *client_p, struct Client *source_p,
37          int parc, char *parv[])
38   {
39    struct Client *target_p = NULL;
40    char *nick;
41    char *p = NULL;
42 <  char *current_insert_point, *current_insert_point2;
42 >  char *current_insert_point = NULL;
43    char buf[IRCD_BUFSIZE];
111 –  char buf2[IRCD_BUFSIZE];
44    int len;
45    int i;
46    int done = 0;
115 –  int relay_to_hub = 0;
116 –
117 –  current_insert_point2 = buf2;
118 –  *buf2 = '\0';
47  
48 <  len = ircsprintf(buf, form_str(RPL_ISON), me.name, parv[0]);
48 >  len = snprintf(buf, sizeof(buf), form_str(RPL_ISON), me.name, source_p->name);
49    current_insert_point = buf + len;
50  
51 <  /* rfc1459 is ambigious about how to handle ISON
51 >  /*
52 >   * rfc1459 is ambigious about how to handle ISON
53     * this should handle both interpretations.
54     */
55    for (i = 1; i < parc; i++)
56    {
57      for (nick = strtoken(&p, parv[i], " "); nick;
58 <         nick = strtoken(&p, NULL, " "))
58 >         nick = strtoken(&p,    NULL, " "))
59      {
60        if ((target_p = find_person(client_p, nick)))
61        {
# Line 144 | Line 73 | do_ison(struct Client *client_p, struct
73            break;
74          }
75        }
147 –
148 –      if (up)
149 –      {
150 –        /* Build up a single list, for use if we relay.. */
151 –        len = strlen(nick);
152 –
153 –        if ((current_insert_point2 + len + 5) < (buf2 + sizeof(buf2)))
154 –        {
155 –          memcpy(current_insert_point2, nick, len);
156 –          current_insert_point2 += len;
157 –          *current_insert_point2++ = ' ';
158 –        }
159 –
160 –        if (target_p == NULL)
161 –        {
162 –          /*
163 –           * XXX Ick. we need to ask our hub if nick is online.
164 –           * it's probably safest to relay the whole command,
165 –           * unless we can answer it fully ourselves.
166 –           * -davidt
167 –           */
168 –          relay_to_hub = 1;
169 –
170 –          /* Also cache info about nick */
171 –          sendto_one(up, ":%s NBURST %s", ID_or_name(&me, up), nick);
172 –        }
173 –      }
76      }
77  
78      if (done)
79        break;
80    }
81  
82 <  /*  current_insert_point--;
82 >  /*
83 >   *  current_insert_point--;
84     *  Do NOT take out the trailing space, it breaks ircII
85 <   *  --Rodder */
86 <
85 >   *  --Rodder
86 >   */
87    *current_insert_point  = '\0';
88 <  *current_insert_point2 = '\0';
89 <  
187 <  if (relay_to_hub)
188 <    sendto_one(up, ":%s ISON :%s", ID_or_name(source_p, up), buf2);
189 <  else
190 <    sendto_one(source_p, "%s", buf);
88 >
89 >  sendto_one(source_p, "%s", buf);
90   }
91 +
92 + /*
93 + * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
94 + * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
95 + * clients. Designed to reduce number of whois requests. Can process
96 + * nicknames in batches as long as the maximum buffer length.
97 + *
98 + * format:
99 + * ISON :nicklist
100 + */
101 + static void
102 + m_ison(struct Client *client_p, struct Client *source_p,
103 +       int parc, char *parv[])
104 + {
105 +  do_ison(client_p, source_p, parc, parv);
106 + }
107 +
108 + static struct Message ison_msgtab = {
109 +  "ISON", 0, 0, 2, 1, MFLG_SLOW, 0,
110 +  {m_unregistered, m_ison, m_ignore, m_ignore, m_ison, m_ignore}
111 + };
112 +
113 + static void
114 + module_init(void)
115 + {
116 +  mod_add_cmd(&ison_msgtab);
117 + }
118 +
119 + static void
120 + module_exit(void)
121 + {
122 +  mod_del_cmd(&ison_msgtab);
123 + }
124 +
125 + struct module module_entry = {
126 +  .node    = { NULL, NULL, NULL },
127 +  .name    = NULL,
128 +  .version = "$Revision$",
129 +  .handle  = NULL,
130 +  .modinit = module_init,
131 +  .modexit = module_exit,
132 +  .flags   = 0
133 + };

Diff Legend

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