]>
Commit | Line | Data |
---|---|---|
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 | |
10 | ||
11 | #define CONTACTLEN 100 | |
12 | #define COMMENTLEN 300 | |
be2823bc CP |
13 | #define TRUSTNAMELEN 100 |
14 | #define TRUSTHOSTLEN 100 | |
2b6e02e2 CP |
15 | |
16 | struct trustmigration; | |
17 | ||
1bbe1ac3 CP |
18 | struct trusthost; |
19 | ||
be2823bc | 20 | typedef struct trusthost { |
65f34016 | 21 | uint32_t ip, mask; |
4be1aaf2 | 22 | unsigned int maxusage; |
be2823bc CP |
23 | time_t lastseen; |
24 | ||
1bbe1ac3 CP |
25 | nick *users; |
26 | struct trustgroup *group; | |
27 | ||
28 | unsigned int count; | |
29 | ||
be2823bc CP |
30 | struct trusthost *next; |
31 | } trusthost; | |
32 | ||
2b6e02e2 CP |
33 | typedef struct trustgroup { |
34 | unsigned int id; | |
35 | ||
36 | sstring *name; | |
37 | unsigned int trustedfor; | |
38 | int mode; | |
39 | unsigned int maxperident; | |
4be1aaf2 | 40 | unsigned int maxusage; |
2b6e02e2 | 41 | time_t expires; |
be2823bc | 42 | time_t lastseen; |
2b6e02e2 | 43 | time_t lastmaxuserreset; |
2b6e02e2 CP |
44 | sstring *createdby, *contact, *comment; |
45 | ||
be2823bc CP |
46 | trusthost *hosts; |
47 | ||
1bbe1ac3 CP |
48 | unsigned int count; |
49 | ||
2b6e02e2 CP |
50 | struct trustgroup *next; |
51 | } trustgroup; | |
52 | ||
1bbe1ac3 CP |
53 | /* trusts.c */ |
54 | extern int trusts_thext, trusts_nextuserext; | |
55 | ||
56 | #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext]) | |
57 | #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext]) | |
58 | #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y) | |
59 | #define settrusthost(x, y) (x)->exts[trusts_thext] = (y) | |
60 | ||
5ada3782 | 61 | /* db.c */ |
be2823bc | 62 | extern int trustsdbloaded; |
5ada3782 | 63 | void trusts_reloaddb(void); |
8a95d3e4 CP |
64 | |
65 | /* formats.c */ | |
66 | char *trusts_timetostr(time_t); | |
65f34016 CP |
67 | int trusts_parsecidr(const char *, uint32_t *, short *); |
68 | int trusts_str2cidr(const char *, uint32_t *, uint32_t *); | |
69 | char *trusts_cidr2str(uint32_t, uint32_t); | |
5ada3782 CP |
70 | |
71 | /* data.c */ | |
be2823bc | 72 | extern trustgroup *tglist; |
5ada3782 CP |
73 | void trusts_freeall(void); |
74 | trustgroup *tg_getbyid(unsigned int); | |
75 | void th_free(trusthost *); | |
76 | int th_add(trustgroup *, char *, unsigned int, time_t); | |
77 | void tg_free(trustgroup *); | |
78 | int tg_add(unsigned int, char *, unsigned int, int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); | |
1bbe1ac3 | 79 | trusthost *th_getbyhost(uint32_t host); |
5ada3782 CP |
80 | |
81 | /* migration.c */ | |
82 | typedef void (*TrustMigrationGroup)(void *, unsigned int, char *, unsigned int, unsigned int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); | |
83 | typedef void (*TrustMigrationHost)(void *, unsigned int, char *, unsigned int, time_t); | |
84 | typedef void (*TrustMigrationFini)(void *, int); | |
2b6e02e2 | 85 | |
5ada3782 CP |
86 | typedef struct trustmigration { |
87 | int count, cur; | |
88 | void *schedule; | |
89 | void *tag; | |
90 | ||
91 | TrustMigrationGroup group; | |
92 | TrustMigrationHost host; | |
93 | TrustMigrationFini fini; | |
94 | } trustmigration; | |
95 | ||
96 | /* db-migration.c */ | |
97 | ||
98 | typedef void (*TrustDBMigrationCallback)(int, void *); | |
2d4ba67d | 99 | |
2b6e02e2 | 100 | #endif |