]> jfr.im git - irc/quakenet/newserv.git/blame - trusts2_search/formats.c
Merge.
[irc/quakenet/newserv.git] / trusts2_search / formats.c
CommitLineData
e2527cba
P
1#include <stdio.h>
2
3#include "../newsearch/newsearch.h"
4#include "../control/control.h"
5#include "../lib/stringbuf.h"
6#include "../trusts2/trusts.h"
7
8char *trusts_timetostr(time_t t) {
9 static char buf[100];
10
11 if ( t == 0 ) {
12 return "<none>";
13 }
14
15 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&t));
16
17 return buf;
18}
19
20void printtg(searchCtx *ctx, nick *sender, trustgroup_t *tg) {
21 ctx->reply(sender,"%lu", tg->id);
22}
23
24void printth(searchCtx *ctx, nick *sender, trusthost_t *th) {
25 ctx->reply(sender,"%lu: %s", th->id, IPtostr(((patricia_node_t *)th->node)->prefix->sin));
26}
27
28void printtgfull(searchCtx *ctx, nick *sender, trustgroup_t *g) {
29 trusthost_t* thptr;
30 trusthost_t *tgh = NULL;
31 patricia_node_t *parent;
32
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));
40
41 ctx->reply(sender,"Owner : %lu", g->ownerid);
42 ctx->reply(sender,"Type : %d", g->type);
43
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",
50 thptr->id,
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,
54 thptr->maxused,
55 trusts_timetostr(thptr->lastused),
56 trusts_timetostr(thptr->expire));
57
58 parent = ((patricia_node_t *)thptr->node)->parent;
59 while (parent) {
60 if(parent->exts)
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);
64 }
65 parent = parent->parent;
66 }
67 }
68}