00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "tools.h"
00027 #include "handlers.h"
00028 #include "client.h"
00029 #include "common.h"
00030 #include "irc_string.h"
00031 #include "ircd.h"
00032 #include "listener.h"
00033 #include "s_gline.h"
00034 #include "ircd_handler.h"
00035 #include "msg.h"
00036 #include "hostmask.h"
00037 #include "numeric.h"
00038 #include "send.h"
00039 #include "fdlist.h"
00040 #include "s_bsd.h"
00041 #include "s_conf.h"
00042 #include "s_misc.h"
00043 #include "s_serv.h"
00044 #include "s_stats.h"
00045 #include "s_user.h"
00046 #include "event.h"
00047 #include "dbuf.h"
00048 #include "parse.h"
00049 #include "modules.h"
00050 #include "hook.h"
00051 #include "resv.h"
00052 #include "whowas.h"
00053 #include "list.h"
00054
00055 static void do_stats(struct Client *, int, char **);
00056 static void m_stats(struct Client *, struct Client *, int, char *[]);
00057 static void mo_stats(struct Client *, struct Client *, int, char *[]);
00058 static void ms_stats(struct Client *, struct Client *, int, char *[]);
00059
00060 struct Message stats_msgtab = {
00061 "STATS", 0, 0, 2, 0, MFLG_SLOW, 0,
00062 { m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore }
00063 };
00064
00065 #ifndef STATIC_MODULES
00066 const char *_version = "$Revision: 584 $";
00067 static struct Callback *stats_cb;
00068
00069 static void *
00070 va_stats(va_list args)
00071 {
00072 struct Client *source_p = va_arg(args, struct Client *);
00073 int parc = va_arg(args, int);
00074 char **parv = va_arg(args, char **);
00075
00076 do_stats(source_p, parc, parv);
00077 return NULL;
00078 }
00079
00080 void
00081 _modinit(void)
00082 {
00083 stats_cb = register_callback("doing_stats", va_stats);
00084 mod_add_cmd(&stats_msgtab);
00085 }
00086
00087 void
00088 _moddeinit(void)
00089 {
00090 mod_del_cmd(&stats_msgtab);
00091 uninstall_hook(stats_cb, va_stats);
00092 }
00093 #endif
00094
00095 static char *parse_stats_args(int, char **, int *, int *);
00096 static void stats_L(struct Client *, char *, int, int, char);
00097 static void stats_L_list(struct Client *s, char *, int, int, dlink_list *, char);
00098
00099 static void stats_dns_servers(struct Client *);
00100 static void stats_connect(struct Client *);
00101 static void stats_deny(struct Client *);
00102 static void stats_tdeny(struct Client *);
00103 static void stats_exempt(struct Client *);
00104 static void stats_events(struct Client *);
00105 static void stats_pending_glines(struct Client *);
00106 static void stats_glines(struct Client *);
00107 static void stats_gdeny(struct Client *);
00108 static void stats_hubleaf(struct Client *);
00109 static void stats_auth(struct Client *);
00110 static void stats_tklines(struct Client *);
00111 static void stats_klines(struct Client *);
00112 static void stats_messages(struct Client *);
00113 static void stats_oper(struct Client *);
00114 static void stats_operedup(struct Client *);
00115 static void stats_ports(struct Client *);
00116 static void stats_resv(struct Client *);
00117 static void stats_usage(struct Client *);
00118 static void stats_tstats(struct Client *);
00119 static void stats_uptime(struct Client *);
00120 static void stats_shared(struct Client *);
00121 static void stats_servers(struct Client *);
00122 static void stats_gecos(struct Client *);
00123 static void stats_class(struct Client *);
00124 static void stats_memory(struct Client *);
00125 static void stats_servlinks(struct Client *);
00126 static void stats_ltrace(struct Client *, int, char **);
00127 static void stats_ziplinks(struct Client *);
00128
00129
00130
00131
00132 static const struct StatsStruct
00133 {
00134 const unsigned char letter;
00135 void (*handler)();
00136 const unsigned int need_oper;
00137 const unsigned int need_admin;
00138 } stats_cmd_table[] = {
00139
00140 { 'a', stats_dns_servers, 1, 1, },
00141 { 'A', stats_dns_servers, 1, 1, },
00142 { 'c', stats_connect, 1, 0, },
00143 { 'C', stats_connect, 1, 0, },
00144 { 'd', stats_tdeny, 1, 0, },
00145 { 'D', stats_deny, 1, 0, },
00146 { 'e', stats_exempt, 1, 0, },
00147 { 'E', stats_events, 1, 1, },
00148 { 'f', fd_dump, 1, 1, },
00149 { 'F', fd_dump, 1, 1, },
00150 { 'g', stats_pending_glines, 1, 0, },
00151 { 'G', stats_glines, 1, 0, },
00152 { 'h', stats_hooks, 1, 1, },
00153 { 'H', stats_hubleaf, 1, 0, },
00154 { 'i', stats_auth, 0, 0, },
00155 { 'I', stats_auth, 0, 0, },
00156 { 'k', stats_tklines, 0, 0, },
00157 { 'K', stats_klines, 0, 0, },
00158 { 'l', stats_ltrace, 1, 0, },
00159 { 'L', stats_ltrace, 1, 0, },
00160 { 'm', stats_messages, 0, 0, },
00161 { 'M', stats_messages, 0, 0, },
00162 { 'o', stats_oper, 0, 0, },
00163 { 'O', stats_oper, 0, 0, },
00164 { 'p', stats_operedup, 0, 0, },
00165 { 'P', stats_ports, 0, 0, },
00166 { 'q', stats_resv, 1, 0, },
00167 { 'Q', stats_resv, 1, 0, },
00168 { 'r', stats_usage, 1, 0, },
00169 { 'R', stats_usage, 1, 0, },
00170 { 't', stats_tstats, 1, 0, },
00171 { 'T', stats_tstats, 1, 0, },
00172 { 'u', stats_uptime, 0, 0, },
00173 { 'U', stats_shared, 1, 0, },
00174 { 'v', stats_servers, 1, 0, },
00175 { 'V', stats_gdeny, 1, 0, },
00176 { 'x', stats_gecos, 1, 0, },
00177 { 'X', stats_gecos, 1, 0, },
00178 { 'y', stats_class, 1, 0, },
00179 { 'Y', stats_class, 1, 0, },
00180 { 'z', stats_memory, 1, 0, },
00181 { 'Z', stats_ziplinks, 1, 0, },
00182 { '?', stats_servlinks, 0, 0, },
00183 { '\0', (void(*)())0, 0, 0, }
00184 };
00185
00186 const char *from, *to;
00187
00188 static void
00189 do_stats(struct Client *source_p, int parc, char **parv)
00190 {
00191 char statchar = *parv[1];
00192 int i;
00193
00194 if (statchar == '\0')
00195 {
00196 sendto_one(source_p, form_str(RPL_ENDOFSTATS),
00197 from, to, '*');
00198 return;
00199 }
00200
00201 for (i = 0; stats_cmd_table[i].handler; i++)
00202 {
00203 if (stats_cmd_table[i].letter == statchar)
00204 {
00205
00206 if ((stats_cmd_table[i].need_admin && !IsAdmin(source_p)) ||
00207 (stats_cmd_table[i].need_oper && !IsOper(source_p)))
00208 {
00209 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00210 from, to);
00211 break;
00212 }
00213
00214
00215 if (statchar == 'L' || statchar == 'l')
00216 stats_cmd_table[i].handler(source_p, parc, parv);
00217 else
00218 stats_cmd_table[i].handler(source_p);
00219
00220 break;
00221 }
00222 }
00223
00224 sendto_one(source_p, form_str(RPL_ENDOFSTATS),
00225 from, to, statchar);
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 static void
00238 m_stats(struct Client *client_p, struct Client *source_p,
00239 int parc, char *parv[])
00240 {
00241 static time_t last_used = 0;
00242
00243
00244 if (!ConfigFileEntry.disable_remote)
00245 if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME)
00246 return;
00247
00248 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
00249 {
00250 from = me.id;
00251 to = source_p->id;
00252 }
00253 else
00254 {
00255 from = me.name;
00256 to = source_p->name;
00257 }
00258
00259
00260 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
00261 {
00262 sendto_one(source_p,form_str(RPL_LOAD2HI),
00263 from, to);
00264 return;
00265 }
00266 else
00267 last_used = CurrentTime;
00268
00269 #ifdef STATIC_MODULES
00270 do_stats(source_p, parc, parv);
00271 #else
00272 execute_callback(stats_cb, source_p, parc, parv);
00273 #endif
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 static void
00286 mo_stats(struct Client *client_p, struct Client *source_p,
00287 int parc, char *parv[])
00288 {
00289 if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2,
00290 parc, parv) != HUNTED_ISME)
00291 return;
00292
00293 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
00294 {
00295 from = me.id;
00296 to = source_p->id;
00297 }
00298 else
00299 {
00300 from = me.name;
00301 to = source_p->name;
00302 }
00303
00304 #ifdef STATIC_MODULES
00305 do_stats(source_p, parc, parv);
00306 #else
00307 execute_callback(stats_cb, source_p, parc, parv);
00308 #endif
00309 }
00310
00311
00312
00313
00314
00315
00316
00317
00318 static void
00319 send_usage(struct Client *source_p)
00320 {
00321 #ifndef _WIN32
00322 struct rusage rus;
00323 time_t secs;
00324 time_t rup;
00325 #ifdef hz
00326 # define hzz hz
00327 #else
00328 # ifdef HZ
00329 # define hzz HZ
00330 # else
00331 int hzz = 1;
00332 # endif
00333 #endif
00334
00335 if (getrusage(RUSAGE_SELF, &rus) == -1)
00336 {
00337 sendto_one(source_p, ":%s NOTICE %s :Getruseage error: %s",
00338 me.name, source_p->name, strerror(errno));
00339 return;
00340 }
00341
00342 secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
00343
00344 if (secs == 0)
00345 secs = 1;
00346
00347 rup = (CurrentTime - me.since) * hzz;
00348
00349 if (rup == 0)
00350 rup = 1;
00351
00352 sendto_one(source_p,
00353 ":%s %d %s R :CPU Secs %d:%d User %d:%d System %d:%d",
00354 me.name, RPL_STATSDEBUG, source_p->name, (int)(secs/60), (int)(secs%60),
00355 (int)(rus.ru_utime.tv_sec/60), (int)(rus.ru_utime.tv_sec%60),
00356 (int)(rus.ru_stime.tv_sec/60), (int)(rus.ru_stime.tv_sec%60));
00357 sendto_one(source_p, ":%s %d %s R :RSS %ld ShMem %ld Data %ld Stack %ld",
00358 me.name, RPL_STATSDEBUG, source_p->name, rus.ru_maxrss,
00359 (rus.ru_ixrss / rup), (rus.ru_idrss / rup),
00360 (rus.ru_isrss / rup));
00361 sendto_one(source_p, ":%s %d %s R :Swaps %d Reclaims %d Faults %d",
00362 me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nswap,
00363 (int)rus.ru_minflt, (int)rus.ru_majflt);
00364 sendto_one(source_p, ":%s %d %s R :Block in %d out %d",
00365 me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_inblock,
00366 (int)rus.ru_oublock);
00367 sendto_one(source_p, ":%s %d %s R :Msg Rcv %d Send %d",
00368 me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_msgrcv,
00369 (int)rus.ru_msgsnd);
00370 sendto_one(source_p, ":%s %d %s R :Signals %d Context Vol. %d Invol %d",
00371 me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals,
00372 (int)rus.ru_nvcsw, (int)rus.ru_nivcsw);
00373 #endif
00374 }
00375
00376 static void
00377 count_memory(struct Client *source_p)
00378 {
00379 const dlink_node *gptr = NULL;
00380 const dlink_node *dlink = NULL;
00381
00382 int local_client_conf_count = 0;
00383 int users_counted = 0;
00384
00385 int channel_users = 0;
00386 int channel_invites = 0;
00387 int channel_bans = 0;
00388 int channel_except = 0;
00389 int channel_invex = 0;
00390
00391 int wwu = 0;
00392 int class_count = 0;
00393 int users_invited_count = 0;
00394 int aways_counted = 0;
00395 int number_ips_stored;
00396
00397 unsigned long channel_memory = 0;
00398 size_t channel_ban_memory = 0;
00399 size_t channel_except_memory = 0;
00400 size_t channel_invex_memory = 0;
00401
00402 unsigned int safelist_count = 0;
00403 size_t safelist_memory = 0;
00404
00405 unsigned long away_memory = 0;
00406 unsigned long wwm = 0;
00407 unsigned long conf_memory = 0;
00408 unsigned long mem_ips_stored;
00409
00410 unsigned long client_hash_table_size = 0;
00411 unsigned long channel_hash_table_size = 0;
00412 unsigned long resv_hash_table_size = 0;
00413 unsigned long id_hash_table_size = 0;
00414 unsigned long total_channel_memory = 0;
00415 unsigned long totww = 0;
00416
00417 unsigned int local_client_count = 0;
00418 unsigned int remote_client_count = 0;
00419
00420 unsigned int local_client_memory_used = 0;
00421 unsigned int remote_client_memory_used = 0;
00422
00423 unsigned long total_memory = 0;
00424 unsigned int topic_count = 0;
00425
00426 count_whowas_memory(&wwu, &wwm);
00427
00428 DLINK_FOREACH(gptr, global_client_list.head)
00429 {
00430 struct Client *target_p = gptr->data;
00431
00432 if (MyConnect(target_p))
00433 {
00434 ++local_client_count;
00435 local_client_conf_count += dlink_list_length(&target_p->localClient->confs);
00436 users_invited_count += dlink_list_length(&target_p->localClient->invited);
00437 }
00438 else
00439 ++remote_client_count;
00440
00441 if (IsClient(target_p))
00442 {
00443 ++users_counted;
00444
00445 if (target_p->away != NULL)
00446 {
00447 ++aways_counted;
00448 away_memory += strlen(target_p->away) + 1;
00449 }
00450 }
00451 }
00452
00453
00454 channel_memory = dlink_list_length(&global_channel_list) *
00455 sizeof(struct Channel);
00456 DLINK_FOREACH(gptr, global_channel_list.head)
00457 {
00458 struct Ban *actualBan;
00459 struct Channel *chptr = gptr->data;
00460
00461 channel_users += dlink_list_length(&chptr->members);
00462 channel_invites += dlink_list_length(&chptr->invites);
00463
00464 if (chptr->topic != NULL)
00465 ++topic_count;
00466
00467 if ((channel_bans = dlink_list_length(&chptr->banlist)))
00468 {
00469 channel_ban_memory = channel_bans * sizeof(struct Ban);
00470
00471 DLINK_FOREACH(dlink, chptr->banlist.head)
00472 {
00473 actualBan = dlink->data;
00474 assert(actualBan->who);
00475
00476 channel_ban_memory += actualBan->len + 3;
00477 channel_ban_memory += strlen(actualBan->who) + 1;
00478 }
00479 }
00480
00481 if ((channel_except = dlink_list_length(&chptr->exceptlist)))
00482 {
00483 channel_except_memory = channel_except * sizeof(struct Ban);
00484
00485 DLINK_FOREACH(dlink, chptr->exceptlist.head)
00486 {
00487 actualBan = dlink->data;
00488 assert(actualBan->who);
00489
00490 channel_except_memory += actualBan->len + 3;
00491 channel_except_memory += strlen(actualBan->who) + 1;
00492 }
00493 }
00494
00495 if ((channel_invex = dlink_list_length(&chptr->invexlist)))
00496 {
00497 channel_invex_memory = channel_invex * sizeof(struct Ban);
00498
00499 DLINK_FOREACH(dlink, chptr->invexlist.head)
00500 {
00501 actualBan = dlink->data;
00502 assert(actualBan->who);
00503
00504 channel_invex_memory += actualBan->len + 3;
00505 channel_invex_memory += strlen(actualBan->who) + 1;
00506 }
00507 }
00508 }
00509
00510 if ((safelist_count = dlink_list_length(&listing_client_list)))
00511 {
00512 safelist_memory = safelist_count * sizeof(struct ListTask);
00513 DLINK_FOREACH(gptr, listing_client_list.head)
00514 {
00515 struct Client *acptr = gptr->data;
00516
00517 DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head)
00518 safelist_memory += strlen(dlink->data);
00519
00520 DLINK_FOREACH(dlink, acptr->localClient->list_task->hide_mask.head)
00521 safelist_memory += strlen(dlink->data);
00522 }
00523 }
00524
00525 #if 0
00526
00527
00528 DLINK_FOREACH(dlink, ConfigItemList.head)
00529 {
00530 aconf = dlink->data;
00531 conf_memory += aconf->host ? strlen(aconf->host)+1 : 0;
00532 conf_memory += aconf->passwd ? strlen(aconf->passwd)+1 : 0;
00533 conf_memory += aconf->name ? strlen(aconf->name)+1 : 0;
00534 conf_memory += sizeof(struct AccessItem);
00535 }
00536 #endif
00537
00538 class_count = dlink_list_length(&class_items);
00539
00540 sendto_one(source_p, ":%s %d %s z :Clients %u(%lu) Invites %u(%lu)",
00541 me.name, RPL_STATSDEBUG, source_p->name, users_counted,
00542 (unsigned long)(users_counted * sizeof(struct Client)),
00543 users_invited_count, (unsigned long)(users_invited_count * sizeof(dlink_node)));
00544
00545 sendto_one(source_p, ":%s %d %s z :User aways %u(%d)",
00546 me.name, RPL_STATSDEBUG, source_p->name,
00547 aways_counted, (int)away_memory);
00548
00549 sendto_one(source_p, ":%s %d %s z :Attached confs %u(%lu)",
00550 me.name, RPL_STATSDEBUG, source_p->name,
00551 local_client_conf_count,
00552 (unsigned long)(local_client_conf_count * sizeof(dlink_node)));
00553
00554
00555 #if 0
00556 sendto_one(source_p, ":%s %d %s z :Conflines %lu(%d)",
00557 me.name, RPL_STATSDEBUG, source_p->name,
00558 dlink_list_length(&ConfigItemList), (int) conf_memory);
00559 #endif
00560
00561 sendto_one(source_p, ":%s %d %s z :Resv channels %lu(%lu) nicks %lu(%lu)",
00562 me.name, RPL_STATSDEBUG, source_p->name,
00563 dlink_list_length(&resv_channel_list),
00564 dlink_list_length(&resv_channel_list) * sizeof(struct ResvChannel),
00565 dlink_list_length(&nresv_items),
00566 dlink_list_length(&nresv_items) * sizeof(struct MatchItem));
00567
00568 sendto_one(source_p, ":%s %d %s z :Classes %u(%lu)",
00569 me.name, RPL_STATSDEBUG, source_p->name,
00570 class_count, (unsigned long)(class_count * sizeof(struct ClassItem)));
00571
00572 sendto_one(source_p, ":%s %d %s z :Channels %lu(%lu) Topics %u(%d)",
00573 me.name, RPL_STATSDEBUG, source_p->name,
00574 dlink_list_length(&global_channel_list),
00575 channel_memory, topic_count, topic_count *
00576 (TOPICLEN + 1 + USERHOST_REPLYLEN));
00577
00578 sendto_one(source_p, ":%s %d %s z :Bans %u(%u)",
00579 me.name, RPL_STATSDEBUG, source_p->name,
00580 channel_bans, channel_ban_memory);
00581
00582 sendto_one(source_p, ":%s %d %s z :Exceptions %u(%u)",
00583 me.name, RPL_STATSDEBUG, source_p->name,
00584 channel_except, channel_except_memory);
00585
00586 sendto_one(source_p, ":%s %d %s z :Invex %u(%u)",
00587 me.name, RPL_STATSDEBUG, source_p->name,
00588 channel_invex, channel_invex_memory);
00589
00590 sendto_one(source_p, ":%s %d %s z :Channel members %u(%lu) invite %u(%lu)",
00591 me.name, RPL_STATSDEBUG, source_p->name, channel_users,
00592 (unsigned long)(channel_users * sizeof(struct Membership)),
00593 channel_invites, (unsigned long)channel_invites *
00594 sizeof(dlink_node));
00595
00596 total_channel_memory = channel_memory + channel_ban_memory +
00597 channel_users * sizeof(struct Membership) +
00598 channel_invites * sizeof(dlink_node);
00599
00600 sendto_one(source_p, ":%s %d %s z :Safelist %u(%u)",
00601 me.name, RPL_STATSDEBUG, source_p->name,
00602 safelist_count, safelist_memory);
00603
00604 sendto_one(source_p, ":%s %d %s z :Whowas users %u(%lu)",
00605 me.name, RPL_STATSDEBUG, source_p->name,
00606 wwu, (unsigned long)(wwu * sizeof(struct Client)));
00607
00608 sendto_one(source_p, ":%s %d %s z :Whowas array %u(%d)",
00609 me.name, RPL_STATSDEBUG, source_p->name,
00610 NICKNAMEHISTORYLENGTH, (int)wwm);
00611
00612 totww = wwu * sizeof(struct Client) + wwm;
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626 count_ip_hash(&number_ips_stored,&mem_ips_stored);
00627 sendto_one(source_p, ":%s %d %s z :iphash %u(%d)",
00628 me.name, RPL_STATSDEBUG, source_p->name,
00629 number_ips_stored, (int)mem_ips_stored);
00630
00631 total_memory = totww + total_channel_memory + conf_memory + class_count *
00632 sizeof(struct ClassItem);
00633 total_memory += client_hash_table_size;
00634 total_memory += channel_hash_table_size;
00635 total_memory += resv_hash_table_size;
00636 total_memory += id_hash_table_size;
00637
00638 sendto_one(source_p, ":%s %d %s z :Total: whowas %d channel %d conf %d",
00639 me.name, RPL_STATSDEBUG, source_p->name, (int)totww,
00640 (int)total_channel_memory, (int)conf_memory);
00641
00642 local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser));
00643 total_memory += local_client_memory_used;
00644 sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%d)",
00645 me.name, RPL_STATSDEBUG, source_p->name, local_client_count,
00646 local_client_memory_used);
00647
00648 remote_client_memory_used = remote_client_count * sizeof(struct Client);
00649 total_memory += remote_client_memory_used;
00650 sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%d)",
00651 me.name, RPL_STATSDEBUG, source_p->name, remote_client_count,
00652 remote_client_memory_used);
00653
00654 block_heap_report_stats(source_p);
00655
00656 sendto_one(source_p,
00657 ":%s %d %s z :TOTAL: %d Available: Current max RSS: %lu",
00658 me.name, RPL_STATSDEBUG, source_p->name,
00659 (int)total_memory, get_maxrss());
00660 }
00661
00662 static void
00663 stats_dns_servers(struct Client *source_p)
00664 {
00665 report_dns_servers(source_p);
00666 }
00667
00668 static void
00669 stats_connect(struct Client *source_p)
00670 {
00671 report_confitem_types(source_p, SERVER_TYPE, 0);
00672 }
00673
00674
00675
00676
00677
00678
00679
00680 static void
00681 stats_deny(struct Client *source_p)
00682 {
00683 struct AddressRec *arec;
00684 struct ConfItem *conf;
00685 struct AccessItem *aconf;
00686 int i;
00687
00688 for (i = 0; i < ATABLE_SIZE; i++)
00689 {
00690 for (arec = atable[i]; arec; arec=arec->next)
00691 {
00692 if (arec->type == CONF_DLINE)
00693 {
00694 aconf = arec->aconf;
00695
00696
00697 if (aconf->flags & CONF_FLAGS_TEMPORARY)
00698 continue;
00699
00700 conf = unmap_conf_item(aconf);
00701
00702 sendto_one(source_p, form_str(RPL_STATSDLINE),
00703 from, to, 'D', aconf->host, aconf->reason,
00704 aconf->oper_reason);
00705 }
00706 }
00707 }
00708 }
00709
00710
00711
00712
00713
00714
00715
00716 static void
00717 stats_tdeny(struct Client *source_p)
00718 {
00719 struct AddressRec *arec;
00720 struct ConfItem *conf;
00721 struct AccessItem *aconf;
00722 int i;
00723
00724 for (i = 0; i < ATABLE_SIZE; i++)
00725 {
00726 for (arec = atable[i]; arec; arec=arec->next)
00727 {
00728 if (arec->type == CONF_DLINE)
00729 {
00730 aconf = arec->aconf;
00731
00732
00733 if (!(aconf->flags & CONF_FLAGS_TEMPORARY))
00734 continue;
00735
00736 conf = unmap_conf_item(aconf);
00737
00738 sendto_one(source_p, form_str(RPL_STATSDLINE),
00739 from, to, 'd', aconf->host, aconf->reason,
00740 aconf->oper_reason);
00741 }
00742 }
00743 }
00744 }
00745
00746
00747
00748
00749
00750
00751
00752 static void
00753 stats_exempt(struct Client *source_p)
00754 {
00755 struct AddressRec *arec;
00756 struct ConfItem *conf;
00757 struct AccessItem *aconf;
00758 int i;
00759
00760 if (ConfigFileEntry.stats_e_disabled)
00761 {
00762 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00763 from, to);
00764 return;
00765 }
00766
00767 for (i = 0; i < ATABLE_SIZE; i++)
00768 {
00769 for (arec = atable[i]; arec; arec=arec->next)
00770 {
00771 if (arec->type == CONF_EXEMPTDLINE)
00772 {
00773 aconf = arec->aconf;
00774
00775 conf = unmap_conf_item(aconf);
00776
00777 sendto_one(source_p, form_str(RPL_STATSDLINE),
00778 from, to, 'e', aconf->host,
00779 aconf->reason, aconf->oper_reason);
00780 }
00781 }
00782 }
00783 }
00784
00785 static void
00786 stats_events(struct Client *source_p)
00787 {
00788 show_events(source_p);
00789 }
00790
00791
00792
00793
00794
00795
00796
00797 static void
00798 stats_pending_glines(struct Client *source_p)
00799 {
00800 #ifdef GLINE_VOTING
00801 dlink_node *pending_node;
00802 struct gline_pending *glp_ptr;
00803 char timebuffer[MAX_DATE_STRING];
00804 struct tm *tmptr;
00805
00806 if (!ConfigFileEntry.glines)
00807 {
00808 sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Lines",
00809 from, to);
00810 return;
00811 }
00812
00813 if (dlink_list_length(&pending_glines) > 0)
00814 sendto_one(source_p, ":%s NOTICE %s :Pending G-lines",
00815 from, to);
00816
00817 DLINK_FOREACH(pending_node, pending_glines.head)
00818 {
00819 glp_ptr = pending_node->data;
00820 tmptr = localtime(&glp_ptr->time_request1);
00821 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
00822
00823 sendto_one(source_p,
00824 ":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
00825 from, to, glp_ptr->oper_nick1,
00826 glp_ptr->oper_user1, glp_ptr->oper_host1,
00827 glp_ptr->oper_server1, timebuffer,
00828 glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
00829
00830 if (glp_ptr->oper_nick2[0] != '\0')
00831 {
00832 tmptr = localtime(&glp_ptr->time_request2);
00833 strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
00834 sendto_one(source_p,
00835 ":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
00836 from, to, glp_ptr->oper_nick2,
00837 glp_ptr->oper_user2, glp_ptr->oper_host2,
00838 glp_ptr->oper_server2, timebuffer,
00839 glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
00840 }
00841 }
00842
00843 sendto_one(source_p, ":%s NOTICE %s :End of Pending G-lines",
00844 from, to);
00845 #else
00846 sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Line voting",
00847 from, to);
00848 #endif
00849 }
00850
00851
00852
00853
00854
00855
00856
00857 static void
00858 stats_glines(struct Client *source_p)
00859 {
00860 struct AddressRec *arec = NULL;
00861 int i = 0;
00862
00863 if (!ConfigFileEntry.glines)
00864 {
00865 sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Lines",
00866 from, to);
00867 return;
00868 }
00869
00870 for (; i < ATABLE_SIZE; ++i)
00871 {
00872 for (arec = atable[i]; arec; arec=arec->next)
00873 {
00874 if (arec->type == CONF_GLINE)
00875 {
00876 const struct AccessItem *aconf = arec->aconf;
00877
00878 sendto_one(source_p, form_str(RPL_STATSKLINE),
00879 from, to, "G",
00880 aconf->host ? aconf->host : "*",
00881 aconf->user ? aconf->user : "*",
00882 aconf->reason ? aconf->reason : "No reason", "" );
00883 }
00884 }
00885 }
00886 }
00887
00888
00889
00890
00891
00892
00893
00894 static void
00895 stats_gdeny(struct Client *source_p)
00896 {
00897 if (!ConfigFileEntry.glines)
00898 {
00899 sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Lines",
00900 from, to);
00901 return;
00902 }
00903
00904 report_confitem_types(source_p, GDENY_TYPE, 0);
00905 }
00906
00907 static void
00908 stats_hubleaf(struct Client *source_p)
00909 {
00910 report_confitem_types(source_p, HUB_TYPE, 0);
00911 report_confitem_types(source_p, LEAF_TYPE, 0);
00912 }
00913
00914 static void
00915 stats_auth(struct Client *source_p)
00916 {
00917
00918 if ((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper(source_p))
00919 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00920 from, to);
00921
00922
00923 else if ((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper(source_p))
00924 {
00925 struct ConfItem *conf;
00926 struct AccessItem *aconf;
00927
00928 if (MyConnect(source_p))
00929 aconf = find_conf_by_address(source_p->host,
00930 &source_p->localClient->ip,
00931 CONF_CLIENT,
00932 source_p->localClient->aftype,
00933 source_p->username,
00934 source_p->localClient->passwd);
00935 else
00936 aconf = find_conf_by_address(source_p->host, NULL, CONF_CLIENT,
00937 0, source_p->username, NULL);
00938
00939 if (aconf == NULL)
00940 return;
00941
00942 conf = unmap_conf_item(aconf);
00943
00944 sendto_one(source_p, form_str(RPL_STATSILINE), from,
00945 to, 'I',
00946 "*", show_iline_prefix(source_p, aconf, aconf->user),
00947 aconf->host, aconf->port,
00948 aconf->class_ptr ? aconf->class_ptr->name : "<default>");
00949 }
00950
00951 else
00952 report_auth(source_p);
00953 }
00954
00955 static void
00956 stats_tklines(struct Client *source_p)
00957 {
00958 struct ConfItem *conf;
00959
00960 if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
00961 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00962 from, to);
00963
00964
00965 else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
00966 {
00967 struct AccessItem *aconf;
00968
00969 if (MyConnect(source_p))
00970 aconf = find_conf_by_address(source_p->host,
00971 &source_p->localClient->ip,
00972 CONF_KILL,
00973 source_p->localClient->aftype,
00974 source_p->username, NULL);
00975 else
00976 aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL,
00977 0, source_p->username, NULL);
00978
00979 if (aconf == NULL)
00980 return;
00981
00982
00983 if (!(aconf->flags & CONF_FLAGS_TEMPORARY))
00984 return;
00985
00986 conf = unmap_conf_item(aconf);
00987
00988 sendto_one(source_p, form_str(RPL_STATSKLINE), from,
00989 to, "k", aconf->host, aconf->user, aconf->reason, "");
00990 }
00991
00992 else {
00993 report_Klines(source_p, 1);
00994 report_confitem_types(source_p, RKLINE_TYPE, 1);
00995 }
00996 }
00997
00998 static void
00999 stats_klines(struct Client *source_p)
01000 {
01001
01002 if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
01003 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
01004 from, to);
01005
01006
01007 else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
01008 {
01009 struct AccessItem *aconf;
01010
01011
01012 if (MyConnect(source_p))
01013 aconf = find_conf_by_address(source_p->host,
01014 &source_p->localClient->ip,
01015 CONF_KILL,
01016 source_p->localClient->aftype,
01017 source_p->username, NULL);
01018 else
01019 aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL,
01020 0, source_p->username, NULL);
01021
01022 if (aconf == NULL)
01023 return;
01024
01025
01026 if (aconf->flags & CONF_FLAGS_TEMPORARY)
01027 return;
01028
01029 sendto_one(source_p, form_str(RPL_STATSKLINE), from,
01030 to, "K", aconf->host, aconf->user, aconf->reason,
01031 aconf->oper_reason);
01032 }
01033
01034 else {
01035 report_Klines(source_p, 0);
01036 report_confitem_types(source_p, RKLINE_TYPE, 0);
01037 }
01038 }
01039
01040 static void
01041 stats_messages(struct Client *source_p)
01042 {
01043 report_messages(source_p);
01044 }
01045
01046 static void
01047 stats_oper(struct Client *source_p)
01048 {
01049 if (!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only)
01050 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
01051 from, to);
01052 else
01053 report_confitem_types(source_p, OPER_TYPE, 0);
01054 }
01055
01056
01057
01058
01059
01060
01061
01062 static void
01063 stats_operedup(struct Client *source_p)
01064 {
01065 dlink_node *ptr;
01066
01067 DLINK_FOREACH(ptr, oper_list.head)
01068 {
01069 const struct Client *target_p = ptr->data;
01070
01071 if (IsOperHidden(target_p) && !IsOper(source_p))
01072 continue;
01073
01074 if (MyClient(source_p) && IsOper(source_p))
01075 sendto_one(source_p, ":%s %d %s p :[%c][%s] %s (%s@%s) Idle: %d",
01076 from, RPL_STATSDEBUG, to,
01077 IsAdmin(target_p) ?
01078 (IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O',
01079 oper_privs_as_string(target_p->localClient->operflags),
01080 target_p->name, target_p->username, target_p->host,
01081 (int)(CurrentTime - target_p->localClient->last));
01082 else
01083 sendto_one(source_p, ":%s %d %s p :[%c] %s (%s@%s) Idle: %d",
01084 from, RPL_STATSDEBUG, to,
01085 IsAdmin(target_p) ?
01086 (IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O',
01087 target_p->name, target_p->username, target_p->host,
01088 (int)(CurrentTime - target_p->localClient->last));
01089 }
01090
01091 sendto_one(source_p, ":%s %d %s p :%lu OPER(s)",
01092 from, RPL_STATSDEBUG, to, dlink_list_length(&oper_list));
01093 }
01094
01095 static void
01096 stats_ports(struct Client *source_p)
01097 {
01098 if (!IsOper(source_p) && ConfigFileEntry.stats_P_oper_only)
01099 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
01100 from, to);
01101 else
01102 show_ports(source_p);
01103 }
01104
01105 static void
01106 stats_resv(struct Client *source_p)
01107 {
01108 report_resv(source_p);
01109 }
01110
01111 static void
01112 stats_usage(struct Client *source_p)
01113 {
01114 send_usage(source_p);
01115 }
01116
01117 static void
01118 stats_tstats(struct Client *source_p)
01119 {
01120 tstats(source_p);
01121 }
01122
01123 static void
01124 stats_uptime(struct Client *source_p)
01125 {
01126 time_t now = CurrentTime - me.since;
01127 sendto_one(source_p, form_str(RPL_STATSUPTIME), from, to,
01128 now/86400, (now/3600)%24, (now/60)%60, now%60);
01129 if (!ConfigFileEntry.disable_remote || IsOper(source_p))
01130 sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
01131 MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
01132 }
01133
01134 static void
01135 stats_shared(struct Client *source_p)
01136 {
01137 report_confitem_types(source_p, ULINE_TYPE, 0);
01138 }
01139
01140
01141
01142
01143
01144
01145
01146 static void
01147 stats_servers(struct Client *source_p)
01148 {
01149 struct Client *target_p;
01150 dlink_node *ptr;
01151 int j = 0;
01152
01153 DLINK_FOREACH(ptr, serv_list.head)
01154 {
01155 target_p = ptr->data;
01156
01157 j++;
01158
01159 sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d",
01160 from, RPL_STATSDEBUG, to,
01161 target_p->name,
01162 (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
01163 "*", "*", (int)(CurrentTime - target_p->lasttime));
01164 }
01165
01166 sendto_one(source_p, ":%s %d %s v :%d Server(s)",
01167 from, RPL_STATSDEBUG, to, j);
01168 }
01169
01170 static void
01171 stats_gecos(struct Client *source_p)
01172 {
01173 report_confitem_types(source_p, XLINE_TYPE, 0);
01174 report_confitem_types(source_p, RXLINE_TYPE, 0);
01175 }
01176
01177 static void
01178 stats_class(struct Client *source_p)
01179 {
01180 report_confitem_types(source_p, CLASS_TYPE, 0);
01181 }
01182
01183 static void
01184 stats_memory(struct Client *source_p)
01185 {
01186 count_memory(source_p);
01187 }
01188
01189 static void
01190 stats_ziplinks(struct Client *source_p)
01191 {
01192 dlink_node *ptr;
01193 struct Client *target_p;
01194 unsigned int sent_data = 0;
01195
01196 DLINK_FOREACH(ptr, serv_list.head)
01197 {
01198 target_p = ptr->data;
01199
01200 if (IsCapable(target_p, CAP_ZIP))
01201 {
01202
01203
01204
01205
01206 struct ZipStats zipstats;
01207 memcpy(&zipstats, &target_p->localClient->zipstats, sizeof (struct ZipStats));
01208
01209 sendto_one(source_p, ":%s %d %s Z :ZipLinks stats for %s send[%.2f%% "
01210 "compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% "
01211 "compression (%lu bytes data/%lu bytes wire)]",
01212 from, RPL_STATSDEBUG, to, target_p->name,
01213 zipstats.out_ratio, zipstats.out, zipstats.out_wire,
01214 zipstats.in_ratio, zipstats.in, zipstats.in_wire);
01215 ++sent_data;
01216 }
01217 }
01218
01219 sendto_one(source_p, ":%s %d %s Z :%u ziplink(s)",
01220 from, RPL_STATSDEBUG, to, sent_data);
01221 }
01222
01223 static void
01224 stats_servlinks(struct Client *source_p)
01225 {
01226 uint64_t sendB = 0, recvB = 0;
01227 time_t uptime = 0;
01228 dlink_node *ptr = NULL;
01229
01230 if (ConfigServerHide.flatten_links && !IsOper(source_p))
01231 {
01232 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
01233 from, to);
01234 return;
01235 }
01236
01237 DLINK_FOREACH(ptr, serv_list.head)
01238 {
01239 struct Client *target_p = ptr->data;
01240
01241 sendB += target_p->localClient->send.bytes;
01242 recvB += target_p->localClient->recv.bytes;
01243
01244
01245 sendto_one(source_p, form_str(RPL_STATSLINKINFO),
01246 from, to,
01247 get_client_name(target_p, IsAdmin(source_p) ? SHOW_IP : MASK_IP),
01248 dbuf_length(&target_p->localClient->buf_sendq),
01249 target_p->localClient->send.messages,
01250 target_p->localClient->send.bytes >> 10,
01251 target_p->localClient->recv.messages,
01252 target_p->localClient->recv.bytes >> 10,
01253 (unsigned)(CurrentTime - target_p->firsttime),
01254 (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since): 0,
01255 IsOper(source_p) ? show_capabilities(target_p) : "TS");
01256 }
01257
01258 sendB >>= 10;
01259 recvB >>= 10;
01260
01261 sendto_one(source_p, ":%s %d %s ? :%u total server(s)",
01262 from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list));
01263 sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s",
01264 from, RPL_STATSDEBUG, to,
01265 _GMKv(sendB), _GMKs(sendB));
01266 sendto_one(source_p, ":%s %d %s ? :Recv total : %7.2f %s",
01267 from, RPL_STATSDEBUG, to,
01268 _GMKv(recvB), _GMKs(recvB));
01269
01270 uptime = (CurrentTime - me.since);
01271
01272 sendto_one(source_p, ":%s %d %s ? :Server send: %7.2f %s (%4.1f K/s)",
01273 from, RPL_STATSDEBUG, to,
01274 _GMKv((me.localClient->send.bytes>>10)),
01275 _GMKs((me.localClient->send.bytes>>10)),
01276 (float)((float)((me.localClient->send.bytes) >> 10) /
01277 (float)uptime));
01278 sendto_one(source_p, ":%s %d %s ? :Server recv: %7.2f %s (%4.1f K/s)",
01279 from, RPL_STATSDEBUG, to,
01280 _GMKv((me.localClient->recv.bytes>>10)),
01281 _GMKs((me.localClient->recv.bytes>>10)),
01282 (float)((float)((me.localClient->recv.bytes) >> 10) /
01283 (float)uptime));
01284 }
01285
01286 static void
01287 stats_ltrace(struct Client *source_p, int parc, char *parv[])
01288 {
01289 int doall = 0;
01290 int wilds = 0;
01291 char *name = NULL;
01292 char statchar;
01293
01294 if ((name = parse_stats_args(parc, parv, &doall, &wilds)) != NULL)
01295 {
01296 statchar = parv[1][0];
01297
01298 stats_L(source_p, name, doall, wilds, statchar);
01299 }
01300 else
01301 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
01302 from, to, "STATS");
01303 }
01304
01305
01306
01307
01308
01309
01310
01311 static void
01312 ms_stats(struct Client *client_p, struct Client *source_p,
01313 int parc, char *parv[])
01314 {
01315 if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME)
01316 return;
01317
01318 if (IsClient(source_p))
01319 mo_stats(client_p, source_p, parc, parv);
01320 }
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331 static void
01332 stats_L(struct Client *source_p,char *name,int doall,
01333 int wilds,char statchar)
01334 {
01335 stats_L_list(source_p, name, doall, wilds, &unknown_list, statchar);
01336 stats_L_list(source_p, name, doall, wilds, &local_client_list, statchar);
01337 stats_L_list(source_p, name, doall, wilds, &serv_list, statchar);
01338 }
01339
01340 static void
01341 stats_L_list(struct Client *source_p,char *name, int doall, int wilds,
01342 dlink_list *list,char statchar)
01343 {
01344 dlink_node *ptr;
01345 struct Client *target_p;
01346
01347
01348
01349
01350
01351
01352
01353 DLINK_FOREACH(ptr, list->head)
01354 {
01355 target_p = ptr->data;
01356
01357 if (IsInvisible(target_p) && (doall || wilds) &&
01358 !(MyConnect(source_p) && IsOper(source_p)) &&
01359 !IsOper(target_p) && (target_p != source_p))
01360 continue;
01361 if (!doall && wilds && !match(name, target_p->name))
01362 continue;
01363 if (!(doall || wilds) && irccmp(name, target_p->name))
01364 continue;
01365
01366
01367
01368 if(MyClient(source_p) && IsOper(source_p) &&
01369 (IsAdmin(source_p) ||
01370 (!IsServer(target_p) && !IsAdmin(target_p) &&
01371 !IsHandshake(target_p) && !IsConnecting(target_p))))
01372 {
01373 sendto_one(source_p, form_str(RPL_STATSLINKINFO),
01374 from, to,
01375 (IsUpper(statchar)) ?
01376 get_client_name(target_p, SHOW_IP) :
01377 get_client_name(target_p, HIDE_IP),
01378 dbuf_length(&target_p->localClient->buf_sendq),
01379 target_p->localClient->send.messages,
01380 target_p->localClient->send.bytes>>10,
01381 target_p->localClient->recv.messages,
01382 target_p->localClient->recv.bytes>>10,
01383 (unsigned)(CurrentTime - target_p->firsttime),
01384 (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
01385 IsServer(target_p) ? show_capabilities(target_p) : "-");
01386 }
01387 else
01388 {
01389
01390 if(IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p)
01391 || IsHandshake(target_p) || IsConnecting(target_p))
01392 sendto_one(source_p, form_str(RPL_STATSLINKINFO),
01393 from, to,
01394 get_client_name(target_p, MASK_IP),
01395 dbuf_length(&target_p->localClient->buf_sendq),
01396 target_p->localClient->send.messages,
01397 target_p->localClient->send.bytes>>10,
01398 target_p->localClient->recv.messages,
01399 target_p->localClient->recv.bytes>>10,
01400 (unsigned)(CurrentTime - target_p->firsttime),
01401 (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
01402 IsServer(target_p) ? show_capabilities(target_p) : "-");
01403 else
01404 sendto_one(source_p, form_str(RPL_STATSLINKINFO),
01405 from, to,
01406 (IsUpper(statchar)) ?
01407 get_client_name(target_p, SHOW_IP) :
01408 get_client_name(target_p, HIDE_IP),
01409 dbuf_length(&target_p->localClient->buf_sendq),
01410 target_p->localClient->send.messages,
01411 target_p->localClient->send.bytes>>10,
01412 target_p->localClient->recv.messages,
01413 target_p->localClient->recv.bytes>>10,
01414 (unsigned)(CurrentTime - target_p->firsttime),
01415 (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
01416 IsServer(target_p) ? show_capabilities(target_p) : "-");
01417 }
01418 }
01419 }
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432 static char *
01433 parse_stats_args(int parc, char *parv[], int *doall, int *wilds)
01434 {
01435 char *name;
01436
01437 if (parc > 2)
01438 {
01439 name = parv[2];
01440
01441 if (!irccmp(name, from))
01442 *doall = 2;
01443 else if (match(name, from))
01444 *doall = 1;
01445
01446 if (strchr(name, '*') ||
01447 strchr(name, '?'))
01448 *wilds = 1;
01449
01450 return(name);
01451 }
01452 else
01453 return(NULL);
01454 }