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

Comparing ircd-hybrid-7.2/modules/m_trace.c (file contents):
Revision 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
Revision 889 by michael, Thu Nov 1 12:59:05 2007 UTC

# Line 42 | Line 42
42   #include "s_conf.h"
43   #include "irc_getnameinfo.h"
44  
45 < static void m_trace(struct Client *, struct Client *, int, char **);
46 < static void ms_trace(struct Client*, struct Client*, int, char**);
47 < static void mo_trace(struct Client*, struct Client*, int, char**);
48 < static void do_actual_trace(struct Client *, int, char **);
45 > static void m_trace(struct Client *, struct Client *, int, char *[]);
46 > static void ms_trace(struct Client *, struct Client *, int, char *[]);
47 > static void mo_trace(struct Client *, struct Client *, int, char *[]);
48 > static void do_actual_trace(struct Client *, int, char *[]);
49  
50   struct Message trace_msgtab = {
51    "TRACE", 0, 0, 0, 0, MFLG_SLOW, 0,
52 <  {m_unregistered, m_trace, ms_trace, m_ignore, mo_trace, m_ignore}
52 >  { m_unregistered, m_trace, ms_trace, m_ignore, mo_trace, m_ignore }
53   };
54  
55   #ifndef STATIC_MODULES
# Line 82 | Line 82 | _moddeinit(void)
82   }
83   #endif
84  
85 < static int report_this_status(struct Client *source_p, struct Client *target_p,
86 <                              int dow, int link_u_p, int link_u_s);
85 > static void report_this_status(struct Client *, struct Client *, int);
86 >
87 > static void
88 > trace_get_dependent(int *const server,
89 >                    int *const client, const struct Client *target_p)
90 > {
91 >  const dlink_node *ptr = NULL;
92 >
93 >  (*server)++;
94 >  (*client) += dlink_list_length(&target_p->serv->client_list);
95 >
96 >  DLINK_FOREACH(ptr, target_p->serv->server_list.head)
97 >    trace_get_dependent(server, client, ptr->data);
98 > }
99  
100   /*
101   * m_trace()
# Line 179 | Line 191 | mo_trace(struct Client *client_p, struct
191   }
192  
193   static void
194 < do_actual_trace(struct Client *source_p, int parc, char **parv)
194 > do_actual_trace(struct Client *source_p, int parc, char *parv[])
195   {
196    struct Client *target_p = NULL;
197    struct ConfItem *conf;
198    struct ClassItem *cltmp;
199    int doall = 0;
200 <  int cnt = 0, wilds, dow;
200 >  int wilds, dow;
201    dlink_node *ptr;
202    const char *from, *to, *tname;
203  
# Line 273 | Line 285 | do_actual_trace(struct Client *source_p,
285      if (!dow && irccmp(tname, target_p->name))
286        continue;
287  
288 <    cnt = report_this_status(source_p, target_p, dow, 0, 0);
288 >    report_this_status(source_p, target_p, dow);
289    }
290  
291    DLINK_FOREACH(ptr, serv_list.head)
# Line 285 | Line 297 | do_actual_trace(struct Client *source_p,
297      if (!dow && irccmp(tname, target_p->name))
298        continue;
299  
300 <    cnt = report_this_status(source_p, target_p, dow,
289 <      target_p->serv->dep_users, target_p->serv->dep_servers);
300 >    report_this_status(source_p, target_p, dow);
301    }
302  
303    /* This section is to report the unknowns */
# Line 299 | Line 310 | do_actual_trace(struct Client *source_p,
310      if (!dow && irccmp(tname, target_p->name))
311        continue;
312  
313 <    cnt = report_this_status(source_p, target_p, dow, 0, 0);
313 >    report_this_status(source_p, target_p, dow);
314    }
315  
316    DLINK_FOREACH(ptr, class_items.head)
317    {
318      conf = ptr->data;
319 <    cltmp = (struct ClassItem *)map_to_conf(conf);
319 >    cltmp = map_to_conf(conf);
320 >
321      if (CurrUserCount(cltmp) > 0)
322        sendto_one(source_p, form_str(RPL_TRACECLASS),
323 <                 from, to, conf->name, CurrUserCount(cltmp));
323 >                 from, to, conf->name, CurrUserCount(cltmp));
324    }
325  
326    sendto_one(source_p, form_str(RPL_ENDOFTRACE), from, to, tname);
327   }
328  
317
329   /*
330   ** ms_trace
331   **      parv[0] = sender prefix
# Line 338 | Line 349 | ms_trace(struct Client *client_p, struct
349   * output       - counter of number of hits
350   * side effects - NONE
351   */
352 < static int
353 < report_this_status(struct Client *source_p, struct Client *target_p,
343 <                   int dow, int link_u_p, int link_s_p)
352 > static void
353 > report_this_status(struct Client *source_p, struct Client *target_p, int dow)
354   {
355    const char *name;
356    const char *class_name;
357    const char *from, *to;
358    char ip[HOSTIPLEN];
349  int cnt = 0;
359  
360    if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
361    {
# Line 368 | Line 377 | report_this_status(struct Client *source
377  
378    set_time();
379  
380 <  switch(target_p->status)
380 >  switch (target_p->status)
381    {
382      case STAT_CONNECTING:
383        sendto_one(source_p, form_str(RPL_TRACECONNECTING),
384                   from, to, class_name,
385                   IsOperAdmin(source_p) ? name : target_p->name);
377                  
378      cnt++;
386        break;
387      case STAT_HANDSHAKE:
388        sendto_one(source_p, form_str(RPL_TRACEHANDSHAKE),
389                   from, to, class_name,
390                   IsOperAdmin(source_p) ? name : target_p->name);
384                  
385      cnt++;
391        break;
392      case STAT_ME:
393        break;
# Line 391 | Line 396 | report_this_status(struct Client *source
396        sendto_one(source_p, form_str(RPL_TRACEUNKNOWN),
397                   from, to, class_name, name, ip,
398                   target_p->firsttime ? CurrentTime - target_p->firsttime : -1);
394      cnt++;
399        break;
400      case STAT_CLIENT:
401        /* Only opers see users if there is a wildcard
# Line 446 | Line 450 | report_this_status(struct Client *source
450                           CurrentTime - target_p->lasttime,
451                           CurrentTime - target_p->localClient->last);
452            }
449          cnt++;
453          }
454        break;
455      case STAT_SERVER:
456 <      if(!IsOperAdmin(source_p))
456 >    {
457 >      int clients = 0;
458 >      int servers = 0;
459 >
460 >      trace_get_dependent(&servers, &clients, target_p);
461 >
462 >      if (!IsOperAdmin(source_p))
463          name = get_client_name(target_p, MASK_IP);
464  
465        sendto_one(source_p, form_str(RPL_TRACESERVER),
466 <                 from, to, class_name, link_s_p,
467 <                 link_u_p, name, *(target_p->serv->by) ?
466 >                 from, to, class_name, servers,
467 >                 clients, name, *(target_p->serv->by) ?
468                   target_p->serv->by : "*", "*",
469                   me.name, CurrentTime - target_p->lasttime);
461      cnt++;
470        break;
471 +    }
472        
473      default: /* ...we actually shouldn't come here... --msa */
474        sendto_one(source_p, form_str(RPL_TRACENEWTYPE),
475 <                 from, to, name);
467 <      cnt++;
475 >                 from, to, name);
476        break;
477    }
470
471  return cnt;
478   }

Diff Legend

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