]>
jfr.im git - irc/quakenet/newserv.git/blob - trusts/data.c
3 #include "../lib/sstring.h"
8 void trusts_freeall ( void ) {
12 for ( tg
= tglist
; tg
; tg
= ntg
) {
14 for ( th
= tg
-> hosts
; th
; th
= nth
) {
26 trustgroup
* tg_getbyid ( unsigned int id
) {
29 for ( tg
= tglist
; tg
; tg
= tg
-> next
)
36 void th_free ( trusthost
* th
) {
40 int th_add ( trustgroup
* tg
, char * host
, unsigned int maxseen
, time_t lastseen
) {
44 if (! trusts_str2cidr ( host
, & ip
, & mask
))
47 th
= malloc ( sizeof ( trusthost
));
51 th
-> maxseen
= maxseen
;
52 th
-> lastseen
= lastseen
;
66 void tg_free ( trustgroup
* tg
) {
67 freesstring ( tg
-> name
);
68 freesstring ( tg
-> createdby
);
69 freesstring ( tg
-> contact
);
70 freesstring ( tg
-> comment
);
74 int tg_add ( unsigned int id
, char * name
, unsigned int trustedfor
, int mode
, unsigned int maxperident
, unsigned int maxseen
, time_t expires
, time_t lastseen
, time_t lastmaxuserreset
, char * createdby
, char * contact
, char * comment
) {
75 trustgroup
* tg
= malloc ( sizeof ( trustgroup
));
79 tg
-> name
= getsstring ( name
, TRUSTNAMELEN
);
80 tg
-> createdby
= getsstring ( createdby
, NICKLEN
);
81 tg
-> contact
= getsstring ( contact
, CONTACTLEN
);
82 tg
-> comment
= getsstring ( comment
, COMMENTLEN
);
83 if (! tg
-> name
|| ! tg
-> createdby
|| ! tg
-> contact
|| ! tg
-> comment
) {
89 tg
-> trustedfor
= trustedfor
;
91 tg
-> maxperident
= maxperident
;
92 tg
-> maxseen
= maxseen
;
93 tg
-> expires
= expires
;
94 tg
-> lastseen
= lastseen
;
95 tg
-> lastmaxuserreset
= lastmaxuserreset
;
106 trusthost
* th_getbyhost ( uint32_t host
) {
110 for ( tg
= tglist
; tg
; tg
= tg
-> next
)
111 for ( th
= tg
-> hosts
; th
; th
= th
-> next
)
112 if (( host
& th
-> mask
) == th
-> ip
)