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

Comparing:
ircd-hybrid-8/modules/m_who.c (file contents), Revision 1178 by michael, Mon Aug 15 08:11:31 2011 UTC vs.
ircd-hybrid/trunk/modules/m_who.c (file contents), Revision 1832 by michael, Fri Apr 19 19:16:09 2013 UTC

# Line 24 | Line 24
24  
25   #include "stdinc.h"
26   #include "list.h"
27 #include "common.h"  
28 #include "handlers.h"
27   #include "client.h"
28   #include "channel.h"
29   #include "channel_mode.h"
# Line 35 | Line 33
33   #include "s_serv.h"
34   #include "send.h"
35   #include "irc_string.h"
36 < #include "sprintf_irc.h"
39 < #include "s_conf.h"
40 < #include "msg.h"
36 > #include "conf.h"
37   #include "parse.h"
38   #include "modules.h"
39  
44 static time_t last_used = 0;
45
46 static void m_who(struct Client *, struct Client *, int, char *[]);
47
48 struct Message who_msgtab = {
49  "WHO", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
50  {m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore}
51 };
52
53 void
54 _modinit(void)
55 {
56  mod_add_cmd(&who_msgtab);
57 }
58
59 void
60 _moddeinit(void)
61 {
62  mod_del_cmd(&who_msgtab);
63 }
64
65 const char *_version = "$Revision$";
66
40   static void who_global(struct Client *, char *, int);
41   static void do_who(struct Client *, struct Client *,
42                     const char *, const char *);
# Line 90 | Line 63 | m_who(struct Client *client_p, struct Cl
63    if (EmptyString(mask))
64    {
65      who_global(source_p, mask, server_oper);
66 <    sendto_one(source_p, form_str(RPL_ENDOFWHO),
66 >    sendto_one(source_p, RPL_ENDOFWHO,
67                 me.name, source_p->name, "*");
68      return;
69    }
# Line 99 | Line 72 | m_who(struct Client *client_p, struct Cl
72    collapse(mask);
73  
74    /* '/who *' */
75 <  if (mask[0] == '*' && !mask[1])
75 >  if (!strcmp(mask, "*"))
76    {
77      if ((lp = source_p->channel.head) != NULL)
78      {
79        struct Channel *mychannel = ((struct Membership *)lp->data)->chptr;
80 <      do_who_on_channel(source_p, mychannel, mychannel->chname, YES,
80 >      do_who_on_channel(source_p, mychannel, mychannel->chname, 1,
81                          server_oper);
82      }
83  
84 <    sendto_one(source_p, form_str(RPL_ENDOFWHO), me.name, source_p->name, "*");
84 >    sendto_one(source_p, RPL_ENDOFWHO,
85 >               me.name, source_p->name, "*");
86      return;
87    }
88  
# Line 119 | Line 93 | m_who(struct Client *client_p, struct Cl
93      if ((chptr = hash_find_channel(mask)) != NULL)
94      {
95        if (IsMember(source_p, chptr))
96 <        do_who_on_channel(source_p, chptr, chptr->chname, YES, server_oper);
96 >        do_who_on_channel(source_p, chptr, chptr->chname, 1, server_oper);
97        else if (!SecretChannel(chptr))
98 <        do_who_on_channel(source_p, chptr, chptr->chname, NO, server_oper);
98 >        do_who_on_channel(source_p, chptr, chptr->chname, 0, server_oper);
99      }
100  
101 <    sendto_one(source_p, form_str(RPL_ENDOFWHO),
101 >    sendto_one(source_p, RPL_ENDOFWHO,
102                 me.name, source_p->name, mask);
103      return;
104    }
105  
106    /* '/who nick' */
107    if (((target_p = hash_find_client(mask)) != NULL) &&
108 <      IsClient(target_p) && (!server_oper || IsOper(target_p)))
108 >      IsClient(target_p) && (!server_oper || HasUMode(target_p, UMODE_OPER)))
109    {
110      DLINK_FOREACH(lp, target_p->channel.head)
111      {
# Line 146 | Line 120 | m_who(struct Client *client_p, struct Cl
120      else
121        do_who(source_p, target_p, NULL, "");
122  
123 <    sendto_one(source_p, form_str(RPL_ENDOFWHO),
123 >    sendto_one(source_p, RPL_ENDOFWHO,
124                 me.name, source_p->name, mask);
125      return;
126    }
127  
128    /* '/who 0' */
129 <  if (mask[0] == '0' && !mask[1])
129 >  if (!strcmp(mask, "0"))
130      who_global(source_p, NULL, server_oper);
131    else
132      who_global(source_p, mask, server_oper);
133  
134    /* Wasn't a nick, wasn't a channel, wasn't a '*' so ... */
135 <  sendto_one(source_p, form_str(RPL_ENDOFWHO),
135 >  sendto_one(source_p, RPL_ENDOFWHO,
136               me.name, source_p->name, mask);
137   }
138  
# Line 177 | Line 151 | static void
151   who_common_channel(struct Client *source_p, struct Channel *chptr,
152                     char *mask, int server_oper, int *maxmatches)
153   {
154 <  dlink_node *ptr;
181 <  struct Client *target_p;
154 >  dlink_node *ptr = NULL;
155  
156    DLINK_FOREACH(ptr, chptr->members.head)
157    {
158 <    target_p = ((struct Membership *)ptr->data)->client_p;
158 >    struct Client *target_p = ((struct Membership *)ptr->data)->client_p;
159  
160 <    if (!IsInvisible(target_p) || IsMarked(target_p))
160 >    if (!HasUMode(target_p, UMODE_INVISIBLE) || HasFlag(target_p, FLAGS_MARK))
161        continue;
162  
163 <    if (server_oper && !IsOper(target_p))
164 <      continue;
163 >    if (server_oper)
164 >      if (!HasUMode(target_p, UMODE_OPER) ||
165 >          (HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER)))
166 >        continue;
167  
168 <    SetMark(target_p);
168 >    AddFlag(target_p, FLAGS_MARK);
169  
170      assert(target_p->servptr != NULL);
171  
172      if ((mask == NULL) ||
173 <      match(mask, target_p->name) || match(mask, target_p->username) ||
174 <      match(mask, target_p->host) ||
175 <      ((!ConfigServerHide.hide_servers || IsOper(source_p)) &&
176 <       match(mask, target_p->servptr->name)) ||
177 <      match(mask, target_p->info))
173 >      !match(mask, target_p->name) || !match(mask, target_p->username) ||
174 >      !match(mask, target_p->host) ||
175 >      ((!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) &&
176 >       !match(mask, target_p->servptr->name)) ||
177 >      !match(mask, target_p->info))
178      {
179        do_who(source_p, target_p, NULL, "");
180  
# Line 231 | Line 206 | who_global(struct Client *source_p, char
206    dlink_node *gcptr;
207    dlink_node *gcptr_next;
208    int maxmatches = 500;
209 +  static time_t last_used = 0;
210  
211 <  if (!IsOper(source_p))
211 >  if (!HasUMode(source_p, UMODE_OPER))
212    {
213      if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
214      {
215        /* safe enough to give this on a local connect only */
216 <      sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
216 >      sendto_one(source_p, RPL_LOAD2HI, me.name, source_p->name);
217        return;
218      }
219  
# Line 259 | Line 235 | who_global(struct Client *source_p, char
235      if (!IsClient(target_p))
236        continue;
237  
238 <    if (IsInvisible(target_p))
238 >    if (HasUMode(target_p, UMODE_INVISIBLE))
239      {
240 <      ClearMark(target_p);
240 >      DelFlag(target_p, FLAGS_MARK);
241        continue;
242      }
243  
244 <    if (server_oper && !IsOper(target_p))
245 <      continue;
244 >    if (server_oper)
245 >      if (!HasUMode(target_p, UMODE_OPER) ||
246 >          (HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER)))
247 >        continue;
248  
249      assert(target_p->servptr != NULL);
250  
251      if (!mask ||
252 <        match(mask, target_p->name) || match(mask, target_p->username) ||
253 <        match(mask, target_p->host) || match(mask, target_p->servptr->name) ||
254 <        match(mask, target_p->info))
252 >        !match(mask, target_p->name) || !match(mask, target_p->username) ||
253 >        !match(mask, target_p->host) || !match(mask, target_p->servptr->name) ||
254 >        !match(mask, target_p->info))
255      {
256        do_who(source_p, target_p, NULL, "");
257  
# Line 310 | Line 288 | do_who_on_channel(struct Client *source_
288      ms = ptr->data;
289      target_p = ms->client_p;
290  
291 <    if (member || !IsInvisible(target_p))
291 >    if (member || !HasUMode(target_p, UMODE_INVISIBLE))
292      {
293 <      if (server_oper && !IsOper(target_p))
294 <        continue;
293 >      if (server_oper)
294 >        if (!HasUMode(target_p, UMODE_OPER) ||
295 >            (HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER)))
296 >          continue;
297        do_who(source_p, target_p, chname, get_member_status(ms, !!HasCap(source_p, CAP_MULTI_PREFIX)));
298      }
299    }
# Line 332 | Line 312 | static void
312   do_who(struct Client *source_p, struct Client *target_p,
313         const char *chname, const char *op_flags)
314   {
315 <  char status[8]; /* G*#@%+\0 */
315 >  char status[7]; /* G*@%+\0 */
316  
317 <  if (IsOper(source_p))
318 <    snprintf(status, sizeof(status), "%c%s%s%s", target_p->away ? 'G' : 'H',
319 <               IsOper(target_p) ? "*" : "", IsCaptured(target_p) ? "#" : "", op_flags);
317 >  if (HasUMode(source_p, UMODE_OPER))
318 >    snprintf(status, sizeof(status), "%c%s%s", target_p->away[0] ? 'G' : 'H',
319 >             HasUMode(target_p, UMODE_OPER) ? "*" : "", op_flags);
320    else
321 <    snprintf(status, sizeof(status), "%c%s%s", target_p->away ? 'G' : 'H',
322 <               IsOper(target_p) ? "*" : "", op_flags);
321 >    snprintf(status, sizeof(status), "%c%s%s", target_p->away[0] ? 'G' : 'H',
322 >             HasUMode(target_p, UMODE_OPER) &&
323 >             !HasUMode(target_p, UMODE_HIDDEN) ? "*" : "", op_flags);
324  
325    if (ConfigServerHide.hide_servers)
326    {
327 <    sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
327 >    sendto_one(source_p, RPL_WHOREPLY, me.name, source_p->name,
328                 (chname) ? (chname) : "*",
329                 target_p->username, target_p->host,
330 <               IsOper(source_p) ? target_p->servptr->name : "*",
330 >               HasUMode(source_p, UMODE_OPER) ? target_p->servptr->name : "*",
331                 target_p->name, status, 0, target_p->info);
332    }
333    else
334    {
335 <    sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
335 >    sendto_one(source_p, RPL_WHOREPLY, me.name, source_p->name,
336                 (chname) ? (chname) : "*", target_p->username,
337                 target_p->host, target_p->servptr->name, target_p->name,
338                 status, target_p->hopcount, target_p->info);
339    }
340   }
341 +
342 + static struct Message who_msgtab = {
343 +  "WHO", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
344 +  {m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore}
345 + };
346 +
347 + static void
348 + module_init(void)
349 + {
350 +  mod_add_cmd(&who_msgtab);
351 + }
352 +
353 + static void
354 + module_exit(void)
355 + {
356 +  mod_del_cmd(&who_msgtab);
357 + }
358 +
359 + struct module module_entry = {
360 +  .node    = { NULL, NULL, NULL },
361 +  .name    = NULL,
362 +  .version = "$Revision$",
363 +  .handle  = NULL,
364 +  .modinit = module_init,
365 +  .modexit = module_exit,
366 +  .flags   = 0
367 + };

Diff Legend

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