]>
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
;
17 char hostmask
[ WW_MASKLEN
+ 1 ];
18 int matches
= 0 , limit
= 500 ;
26 limit
= strtol ( cargv
[ 1 ], NULL
, 10 );
28 for ( ww
= whowas_head
; ww
; ww
= ww
-> next
) {
30 snprintf ( hostmask
, sizeof ( hostmask
), " %s ! %s @ %s " , np
-> nick
, np
-> ident
, np
-> host
-> name
-> content
);
32 if ( match2strings ( pattern
, hostmask
)) {
36 controlreply ( sender
, " %s " , whowas_format ( ww
));
37 else if ( matches
== limit
+ 1 )
38 controlreply ( sender
, "--- More than %d matches, skipping the rest" , limit
);
42 controlreply ( sender
, "--- Found %d entries." , matches
);
47 static int whowas_cmdwhowaschase ( void * source
, int cargc
, char ** cargv
) {
48 nick
* sender
= source
;
54 ww
= whowas_chase ( cargv
[ 0 ], 900 );
57 controlreply ( sender
, "No whowas record found." );
61 controlreply ( sender
, " %s " , whowas_format ( ww
));
62 controlreply ( sender
, "Done." );
68 registercontrolhelpcmd ( "whowas" , NO_OPER
, 2 , & whowas_cmdwhowas
, "Usage: whowas <mask> ?limit? \n Looks up information about recently disconnected users." );
69 registercontrolhelpcmd ( "whowaschase" , NO_OPER
, 2 , & whowas_cmdwhowaschase
, "Usage: whowaschase <nick> \n Finds most-recent whowas record for a nick." );
73 deregistercontrolcmd ( "whowas" , & whowas_cmdwhowas
);
74 deregistercontrolcmd ( "whowaschase" , & whowas_cmdwhowaschase
);