]>
jfr.im git - irc/quakenet/newserv.git/blob - localuser/localuserstats.c
1 /* Functions for retrieving stats from the network to local users */
4 #include "../nick/nick.h"
5 #include "../irc/irc.h"
6 #include "../core/error.h"
7 #include "../lib/version.h"
16 int handleserverstats(void *source
, int cargc
, char **cargv
);
17 int handleserverstatsend(void *source
, int cargc
, char **cargv
);
19 #define RPL_STATSCLINE 213
20 #define RPL_STATSCOMMANDS 212
21 #define RPL_STATSCONN 250
22 #define RPL_STATSDLINE 275
23 #define RPL_STATSENGINE 237
24 #define RPL_STATSHLINE 244
25 #define RPL_STATSILINE 215
26 #define RPL_STATSKLINE 216
27 #define RPL_STATSLINKINFO 211
28 #define RPL_STATSLLINE 241
29 #define RPL_STATSOLINE 243
30 #define RPL_STATSQLINE 228
31 #define RPL_STATSSLINE 398
32 #define RPL_STATSULINE 248
33 #define RPL_STATSUPTIME 242
34 #define RPL_STATSVERBOSE 236
37 const int numerics
[] = { RPL_STATSCLINE
, RPL_STATSCOMMANDS
, RPL_STATSCONN
, RPL_STATSDLINE
,
38 RPL_STATSENGINE
, RPL_STATSHLINE
, RPL_STATSILINE
, RPL_STATSKLINE
,
39 RPL_STATSLINKINFO
, RPL_STATSLLINE
, RPL_STATSOLINE
, RPL_STATSQLINE
,
40 RPL_STATSSLINE
, RPL_STATSULINE
, RPL_STATSUPTIME
, RPL_STATSVERBOSE
,
44 registernumerichandler(219,&handleserverstats
,4);
46 for(i
=&numerics
[0];*i
;i
++)
47 registernumerichandler(*i
,&handleserverstats
,4);
52 deregisternumerichandler(219,&handleserverstats
);
54 for(i
=&numerics
[0];*i
;i
++)
55 deregisternumerichandler(*i
,&handleserverstats
);
58 /* stats look something like:
62 int handleserverstats(void *source
, int cargc
, char **cargv
) {
65 static char outbuffer
[BUFSIZE
* 2 + 5];
66 long numeric
= (long)source
, i
;
72 if (!(target
=getnickbynumeric(numerictolong(cargv
[2],5)))) {
73 Error("localuserchannel",ERR_WARNING
,"Got stats for unknown local user %s.",cargv
[2]);
77 if (homeserver(target
->numeric
) != mylongnum
) {
78 Error("localuserchannel",ERR_WARNING
,"Got stats for non-local user %s.",target
->nick
);
84 /* bloody inefficient */
85 for(i
=3;i
<cargc
;i
++) {
87 strcat(outbuffer
, " ");
89 strcat(outbuffer
, ":");
91 strcat(outbuffer
, cargv
[i
]);
93 outbuffer
[sizeof(outbuffer
) - 1] = '\0';
96 nargs
[0]=(void *)cargv
[0];
97 nargs
[1]=(void *)numeric
;
98 nargs
[2]=(void *)outbuffer
;
100 if (umhandlers
[target
->numeric
&MAXLOCALUSER
]) {
101 (umhandlers
[target
->numeric
&MAXLOCALUSER
])(target
, LU_STATS
, nargs
);
104 if (umhandlers
[target
->numeric
&MAXLOCALUSER
]) {
105 (umhandlers
[target
->numeric
&MAXLOCALUSER
])(target
, LU_STATS_END
, (void *)outbuffer
);