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-7.2/modules/m_who.c (file contents), Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC vs.
ircd-hybrid-8/modules/m_who.c (file contents), Revision 1243 by michael, Fri Sep 30 10:47:53 2011 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 37 | Line 35
35   #include "irc_string.h"
36   #include "sprintf_irc.h"
37   #include "s_conf.h"
40 #include "msg.h"
38   #include "parse.h"
39   #include "modules.h"
40  
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, 0, MFLG_SLOW, 0,
50  {m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore}
51 };
52
53 #ifndef STATIC_MODULES
54 void
55 _modinit(void)
56 {
57  mod_add_cmd(&who_msgtab);
58 }
59
60 void
61 _moddeinit(void)
62 {
63  mod_del_cmd(&who_msgtab);
64 }
65
66 const char *_version = "$Revision$";
67 #endif
68
41   static void who_global(struct Client *, char *, int);
42   static void do_who(struct Client *, struct Client *,
43                     const char *, const char *);
# Line 106 | Line 78 | m_who(struct Client *client_p, struct Cl
78      if ((lp = source_p->channel.head) != NULL)
79      {
80        struct Channel *mychannel = ((struct Membership *)lp->data)->chptr;
81 <      do_who_on_channel(source_p, mychannel, mychannel->chname, YES,
81 >      do_who_on_channel(source_p, mychannel, mychannel->chname, 1,
82                          server_oper);
83      }
84  
# Line 121 | 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),
# Line 132 | Line 104 | m_who(struct Client *client_p, struct Cl
104    }
105  
106    /* '/who nick' */
107 <  if (((target_p = find_client(mask)) != NULL) &&
108 <      IsClient(target_p) && (!server_oper || IsOper(target_p)))
107 >  if (((target_p = hash_find_client(mask)) != NULL) &&
108 >      IsClient(target_p) && (!server_oper || HasUMode(target_p, UMODE_OPER)))
109    {
110      DLINK_FOREACH(lp, target_p->channel.head)
111      {
# Line 144 | Line 116 | m_who(struct Client *client_p, struct Cl
116  
117      if (lp != NULL)
118        do_who(source_p, target_p, chptr->chname,
119 <             get_member_status(lp->data, NO));
119 >             get_member_status(lp->data, !!HasCap(source_p, CAP_MULTI_PREFIX)));
120      else
121        do_who(source_p, target_p, NULL, "");
122  
# Line 159 | Line 131 | m_who(struct Client *client_p, struct Cl
131    else
132      who_global(source_p, mask, server_oper);
133  
134 < /* Wasn't a nick, wasn't a channel, wasn't a '*' so ... */
134 >  /* Wasn't a nick, wasn't a channel, wasn't a '*' so ... */
135    sendto_one(source_p, form_str(RPL_ENDOFWHO),
136               me.name, source_p->name, mask);
137   }
# Line 186 | Line 158 | who_common_channel(struct Client *source
158    {
159      target_p = ((struct Membership *)ptr->data)->client_p;
160  
161 <    if (!IsInvisible(target_p) || IsMarked(target_p))
161 >    if (!HasUMode(target_p, UMODE_INVISIBLE) || HasFlag(target_p, FLAGS_MARK))
162        continue;
163  
164 <    if (server_oper && !IsOper(target_p))
164 >    if (server_oper && !HasUMode(target_p, UMODE_OPER))
165        continue;
166  
167 <    SetMark(target_p);
167 >    AddFlag(target_p, FLAGS_MARK);
168  
169      assert(target_p->servptr != NULL);
170  
171      if ((mask == NULL) ||
172        match(mask, target_p->name) || match(mask, target_p->username) ||
173        match(mask, target_p->host) ||
174 <      ((!ConfigServerHide.hide_servers || IsOper(source_p)) &&
174 >      ((!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) &&
175         match(mask, target_p->servptr->name)) ||
176        match(mask, target_p->info))
177      {
# Line 233 | Line 205 | who_global(struct Client *source_p, char
205    dlink_node *gcptr;
206    dlink_node *gcptr_next;
207    int maxmatches = 500;
208 +  static time_t last_used = 0;
209  
210 <  if (!IsOper(source_p))
210 >  if (!HasUMode(source_p, UMODE_OPER))
211    {
212      if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
213      {
# Line 261 | Line 234 | who_global(struct Client *source_p, char
234      if (!IsClient(target_p))
235        continue;
236  
237 <    if (IsInvisible(target_p))
237 >    if (HasUMode(target_p, UMODE_INVISIBLE))
238      {
239 <      ClearMark(target_p);
239 >      DelFlag(target_p, FLAGS_MARK);
240        continue;
241      }
242  
243 <    if (server_oper && !IsOper(target_p))
243 >    if (server_oper && !HasUMode(target_p, UMODE_OPER))
244        continue;
245  
246      assert(target_p->servptr != NULL);
# Line 312 | Line 285 | do_who_on_channel(struct Client *source_
285      ms = ptr->data;
286      target_p = ms->client_p;
287  
288 <    if (member || !IsInvisible(target_p))
288 >    if (member || !HasUMode(target_p, UMODE_INVISIBLE))
289      {
290 <      if (server_oper && !IsOper(target_p))
290 >      if (server_oper && !HasUMode(target_p, UMODE_OPER))
291          continue;
292 <      do_who(source_p, target_p, chname, get_member_status(ms, NO));
292 >      do_who(source_p, target_p, chname, get_member_status(ms, !!HasCap(source_p, CAP_MULTI_PREFIX)));
293      }
294    }
295   }
# Line 334 | Line 307 | static void
307   do_who(struct Client *source_p, struct Client *target_p,
308         const char *chname, const char *op_flags)
309   {
310 <  char status[6];
310 >  char status[8]; /* G*#@%+\0 */
311  
312 <  if (IsOper(source_p))
313 <    ircsprintf(status, "%c%s%s%s", target_p->away ? 'G' : 'H',
314 <               IsOper(target_p) ? "*" : "", IsCaptured(target_p) ? "#" : "", op_flags);
312 >  if (HasUMode(source_p, UMODE_OPER))
313 >    snprintf(status, sizeof(status), "%c%s%s%s", target_p->away ? 'G' : 'H',
314 >             HasUMode(target_p, UMODE_OPER) ? "*" : "",
315 >             IsCaptured(target_p) ? "#" : "", op_flags);
316    else
317 <    ircsprintf(status, "%c%s%s", target_p->away ? 'G' : 'H',
318 <               IsOper(target_p) ? "*" : "", op_flags);
317 >    snprintf(status, sizeof(status), "%c%s%s", target_p->away ? 'G' : 'H',
318 >             HasUMode(target_p, UMODE_OPER) ? "*" : "", op_flags);
319  
320    if (ConfigServerHide.hide_servers)
321    {
322      sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, source_p->name,
323                 (chname) ? (chname) : "*",
324                 target_p->username, target_p->host,
325 <               IsOper(source_p) ? target_p->servptr->name : "*",
325 >               HasUMode(source_p, UMODE_OPER) ? target_p->servptr->name : "*",
326                 target_p->name, status, 0, target_p->info);
327    }
328    else
# Line 359 | Line 333 | do_who(struct Client *source_p, struct C
333                 status, target_p->hopcount, target_p->info);
334    }
335   }
336 +
337 + static struct Message who_msgtab = {
338 +  "WHO", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
339 +  {m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore}
340 + };
341 +
342 + static void
343 + module_init(void)
344 + {
345 +  mod_add_cmd(&who_msgtab);
346 + }
347 +
348 + static void
349 + module_exit(void)
350 + {
351 +  mod_del_cmd(&who_msgtab);
352 + }
353 +
354 + struct module module_entry = {
355 +  .node    = { NULL, NULL, NULL },
356 +  .name    = NULL,
357 +  .version = "$Revision$",
358 +  .handle  = NULL,
359 +  .modinit = module_init,
360 +  .modexit = module_exit,
361 +  .flags   = 0
362 + };

Diff Legend

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