]> jfr.im git - irc/quakenet/newserv.git/blame - trusts/trusts.h
Whoops, left some printf statements in there :(.
[irc/quakenet/newserv.git] / trusts / trusts.h
CommitLineData
2b6e02e2
CP
1#ifndef __TRUSTS_H
2#define __TRUSTS_H
3
4#include <time.h>
65f34016 5#include <stdint.h>
1bbe1ac3 6#include "../nick/nick.h"
2b6e02e2
CP
7#include "../lib/sstring.h"
8
9#define MIGRATION_STOPPED -1
83bccee3 10#define MIGRATION_LASTERROR -2
2b6e02e2
CP
11
12#define CONTACTLEN 100
13#define COMMENTLEN 300
be2823bc
CP
14#define TRUSTNAMELEN 100
15#define TRUSTHOSTLEN 100
2129448c 16#define MAXTGEXTS 5
2b6e02e2 17
35449aa5
CP
18#define TABLES_REGULAR 0
19#define TABLES_MIGRATION 1
20#define TABLES_REPLICATION 2
21
2b6e02e2
CP
22struct trustmigration;
23
1bbe1ac3
CP
24struct trusthost;
25
be2823bc 26typedef struct trusthost {
9bf9e8a1
CP
27 unsigned int id;
28
65f34016 29 uint32_t ip, mask;
4be1aaf2 30 unsigned int maxusage;
be2823bc
CP
31 time_t lastseen;
32
1bbe1ac3
CP
33 nick *users;
34 struct trustgroup *group;
35
36 unsigned int count;
37
6ebeb438 38
b76fd8e6 39 struct trusthost *parent, *children;
6ebeb438 40 unsigned int marker;
b76fd8e6 41
6ebeb438 42 struct trusthost *nextbychild;
be2823bc
CP
43 struct trusthost *next;
44} trusthost;
45
2b6e02e2
CP
46typedef struct trustgroup {
47 unsigned int id;
48
49 sstring *name;
50 unsigned int trustedfor;
51 int mode;
52 unsigned int maxperident;
4be1aaf2 53 unsigned int maxusage;
2b6e02e2 54 time_t expires;
be2823bc 55 time_t lastseen;
2b6e02e2 56 time_t lastmaxuserreset;
2b6e02e2
CP
57 sstring *createdby, *contact, *comment;
58
be2823bc 59 trusthost *hosts;
1bbe1ac3
CP
60 unsigned int count;
61
6ebeb438
CP
62 unsigned int marker;
63
2b6e02e2 64 struct trustgroup *next;
2129448c
CP
65
66 void *exts[MAXTGEXTS];
2b6e02e2
CP
67} trustgroup;
68
1bbe1ac3
CP
69#define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
70#define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
71#define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
72#define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
73
45e8ce62
CP
74/* trusts.c */
75extern int trusts_thext, trusts_nextuserext;
2129448c
CP
76int findtgext(const char *);
77int registertgext(const char *);
78void releasetgext(int);
45e8ce62 79
5ada3782 80/* db.c */
be2823bc 81extern int trustsdbloaded;
83bccee3
CP
82int trusts_loaddb(void);
83void trusts_closedb(int);
d2c08930
CP
84trustgroup *tg_new(char *name, unsigned int trustedfor, int mode, unsigned int maxperident, time_t expires, char *createdby, char *contact, char *comment);
85trusthost *th_new(trustgroup *tg, char *host);
8a95d3e4
CP
86
87/* formats.c */
88char *trusts_timetostr(time_t);
65f34016
CP
89int trusts_parsecidr(const char *, uint32_t *, short *);
90int trusts_str2cidr(const char *, uint32_t *, uint32_t *);
91char *trusts_cidr2str(uint32_t, uint32_t);
5ada3782
CP
92
93/* data.c */
be2823bc 94extern trustgroup *tglist;
5ada3782
CP
95trustgroup *tg_getbyid(unsigned int);
96void th_free(trusthost *);
d2c08930 97trusthost *th_add(trustgroup *, unsigned int, char *, unsigned int, time_t);
5ada3782 98void tg_free(trustgroup *);
d2c08930
CP
99trustgroup *tg_add(unsigned int, char *, unsigned int, int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *);
100trusthost *th_getbyhost(uint32_t);
9097ab05
CP
101trusthost *th_getbyhostandmask(uint32_t, uint32_t);
102trusthost *th_getsmallestsupersetbyhost(uint32_t, uint32_t);
103trustgroup *tg_strtotg(char *);
104void th_adjusthosts(trusthost *th, trusthost *, trusthost *);
105void th_getsuperandsubsets(uint32_t, uint32_t, trusthost **, trusthost **);
b76fd8e6
CP
106trusthost *th_getsubsetbyhost(uint32_t ip, uint32_t mask);
107trusthost *th_getnextsubsetbyhost(trusthost *th, uint32_t ip, uint32_t mask);
108void th_linktree(void);
6ebeb438
CP
109unsigned int nexttgmarker(void);
110unsigned int nextthmarker(void);
5ada3782
CP
111
112/* migration.c */
113typedef void (*TrustMigrationGroup)(void *, unsigned int, char *, unsigned int, unsigned int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *);
114typedef void (*TrustMigrationHost)(void *, unsigned int, char *, unsigned int, time_t);
115typedef void (*TrustMigrationFini)(void *, int);
2b6e02e2 116
5ada3782
CP
117typedef struct trustmigration {
118 int count, cur;
119 void *schedule;
120 void *tag;
121
122 TrustMigrationGroup group;
123 TrustMigrationHost host;
124 TrustMigrationFini fini;
125} trustmigration;
126
127/* db-migration.c */
5ada3782 128typedef void (*TrustDBMigrationCallback)(int, void *);
2d4ba67d 129
9097ab05
CP
130/* events.c */
131void trusts_newnick(nick *, int);
132void trusts_lostnick(nick *, int);
133
2b6e02e2 134#endif