]>
jfr.im git - irc/quakenet/newserv.git/blob - whowas/whowas_commands.c
3 #include "../core/hooks.h"
4 #include "../control/control.h"
5 #include "../irc/irc.h"
6 #include "../lib/irc_string.h"
7 #include "../lib/version.h"
12 static int whowas_cmdwhowas ( void * source
, int cargc
, char ** cargv
) {
13 nick
* sender
= source
;
18 char hostmask
[ WW_MASKLEN
+ 1 ];
19 int matches
= 0 , limit
= 500 ;
27 limit
= strtol ( cargv
[ 1 ], NULL
, 10 );
29 for ( i
= whowasoffset
; i
< whowasoffset
+ WW_MAXENTRIES
; i
++) {
30 ww
= & whowasrecs
[ i
% WW_MAXENTRIES
];
32 if ( ww
-> type
== WHOWAS_UNUSED
)
36 snprintf ( hostmask
, sizeof ( hostmask
), " %s ! %s @ %s " , np
-> nick
, np
-> ident
, np
-> host
-> name
-> content
);
38 if ( match2strings ( pattern
, hostmask
)) {
42 controlreply ( sender
, " %s " , whowas_format ( ww
));
43 else if ( matches
== limit
+ 1 )
44 controlreply ( sender
, "--- More than %d matches, skipping the rest" , limit
);
48 controlreply ( sender
, "--- Found %d entries." , matches
);
53 static int whowas_cmdwhowaschase ( void * source
, int cargc
, char ** cargv
) {
54 nick
* sender
= source
;
60 ww
= whowas_chase ( cargv
[ 0 ], 900 );
63 controlreply ( sender
, "No whowas record found." );
67 controlreply ( sender
, " %s " , whowas_format ( ww
));
68 controlreply ( sender
, "Done." );
74 registercontrolhelpcmd ( "whowas" , NO_OPER
, 2 , & whowas_cmdwhowas
, "Usage: whowas <mask> ?limit? \n Looks up information about recently disconnected users." );
75 registercontrolhelpcmd ( "whowaschase" , NO_OPER
, 2 , & whowas_cmdwhowaschase
, "Usage: whowaschase <nick> \n Finds most-recent whowas record for a nick." );
79 deregistercontrolcmd ( "whowas" , & whowas_cmdwhowas
);
80 deregistercontrolcmd ( "whowaschase" , & whowas_cmdwhowaschase
);