]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts_search/formats.c
3 #include "../newsearch/newsearch.h"
4 #include "../control/control.h"
5 #include "../lib/stringbuf.h"
6 #include "../trusts2/trusts.h"
8 char *trusts_timetostr(time_t t
) {
15 strftime(buf
, sizeof(buf
), "%Y-%m-%d %H:%M:%S", localtime(&t
));
20 void printtg(searchCtx
*ctx
, nick
*sender
, trustgroup_t
*tg
) {
21 ctx
->reply(sender
,"%lu", tg
->id
);
24 void printth(searchCtx
*ctx
, nick
*sender
, trusthost_t
*th
) {
25 ctx
->reply(sender
,"%lu: %s", th
->id
, IPtostr(((patricia_node_t
*)th
->node
)->prefix
->sin
));
28 void printtgfull(searchCtx
*ctx
, nick
*sender
, trustgroup_t
*g
) {
30 trusthost_t
*tgh
= NULL
;
31 patricia_node_t
*parent
;
33 ctx
->reply(sender
,"Trustgroup ID : %lu", g
->id
);
34 ctx
->reply(sender
,"Max Connections : %lu, Max Per Ident: %lu, Max Per IP: %lu", g
->maxclones
, g
->maxperident
, g
->maxperip
);
35 ctx
->reply(sender
,"Curent Usage : %lu/%lu", g
->currenton
,g
->maxusage
);
36 ctx
->reply(sender
,"Enforce Ident : %d", g
->enforceident
);
37 ctx
->reply(sender
,"Start Date : %s", trusts_timetostr(g
->startdate
));
38 ctx
->reply(sender
,"Last Used : %s", trusts_timetostr(g
->lastused
));
39 ctx
->reply(sender
,"Expiry : %s", trusts_timetostr(g
->expire
));
41 ctx
->reply(sender
,"Owner : %lu", g
->ownerid
);
42 ctx
->reply(sender
,"Type : %d", g
->type
);
44 ctx
->reply(sender
,"Trust Hosts:");
45 ctx
->reply(sender
,"ID Host Current Max Last seen Expiry");
46 int hash
= trusts_gettrusthostgroupidhash(g
->id
);
47 for (thptr
= trusthostgroupidtable
[hash
]; thptr
; thptr
= thptr
->nextbygroupid
) {
48 if(thptr
->trustgroup
== g
)
49 ctx
->reply(sender
, "%-5lu %15s/%d %-10lu %-5lu %s %s",
51 IPtostr(((patricia_node_t
*)thptr
->node
)->prefix
->sin
),
52 irc_bitlen(&(((patricia_node_t
*)thptr
->node
)->prefix
->sin
),((patricia_node_t
*)thptr
->node
)->prefix
->bitlen
),
53 thptr
->node
->usercount
,
55 trusts_timetostr(thptr
->lastused
),
56 trusts_timetostr(thptr
->expire
));
58 parent
= ((patricia_node_t
*)thptr
->node
)->parent
;
61 if( parent
->exts
[tgh_ext
]) {
62 tgh
= (trusthost_t
*)parent
->exts
[tgh_ext
];
63 ctx
->reply(sender
, "- Parent Trust Group: %lu", tgh
->trustgroup
->id
);
65 parent
= parent
->parent
;