3 trustgroup_t
*trustgroupidtable
[TRUSTS_HASH_GROUPSIZE
];
4 trustgroup_t
*trustgroupnametable
[TRUSTS_HASH_GROUPSIZE
];
5 trusthost_t
*trusthostidtable
[TRUSTS_HASH_HOSTSIZE
];
6 trusthost_t
*trusthostgroupidtable
[TRUSTS_HASH_HOSTSIZE
];
7 trustgroupidentcount_t
*trustgroupidentcounttable
[TRUSTS_HASH_IDENTSIZE
];
9 void trusts_hash_init() {
10 memset(trustgroupidtable
,0,sizeof(trustgroupidtable
));
11 memset(trustgroupnametable
,0,sizeof(trustgroupnametable
));
12 memset(trusthostidtable
,0,sizeof(trusthostidtable
));
13 memset(trusthostgroupidtable
,0,sizeof(trusthostgroupidtable
));
16 void trusts_hash_fini() {
19 void trusts_addtrusthosttohash(trusthost_t
*newhost
)
22 hash
= trusts_gettrusthostidhash(newhost
->id
);
23 newhost
->nextbyid
= trusthostidtable
[hash
];
24 trusthostidtable
[hash
] = newhost
;
26 hash
= trusts_gettrusthostgroupidhash(newhost
->trustgroup
->id
);
27 newhost
->nextbygroupid
= trusthostgroupidtable
[hash
];
28 trusthostgroupidtable
[hash
] = newhost
;
31 void trusts_removetrusthostfromhash(trusthost_t
*t
)
35 for(tgh
=&(trusthostidtable
[trusts_gettrusthostidhash(t
->id
)]);*tgh
;tgh
=(trusthost_t
**)&((*tgh
)->nextbyid
)) {
37 (*tgh
)=(trusthost_t
*)t
->nextbyid
;
43 Error("trusts",ERR_ERROR
,"Unable to remove trusthost id %lu from hashtable", t
->id
);
45 for(tgh
=&(trusthostgroupidtable
[trusts_gettrusthostgroupidhash(t
->trustgroup
->id
)]);*tgh
;tgh
=(trusthost_t
**)&((*tgh
)->nextbygroupid
)) {
47 (*tgh
)=(trusthost_t
*)t
->nextbygroupid
;
53 Error("trusts",ERR_ERROR
,"Unable to remove trusthost groupid %lu from hashtable", t
->trustgroup
->id
);
56 void trusts_addtrustgrouptohash(trustgroup_t
*newgroup
)
59 hash
= trusts_gettrustgroupidhash(newgroup
->id
);
60 newgroup
->nextbyid
= trustgroupidtable
[hash
];
61 trustgroupidtable
[hash
] = newgroup
;
64 trustgroup_t
* findtrustgroupbyid(int id
) {
67 for(tl
=trustgroupidtable
[trusts_gettrustgroupidhash(id
)]; tl
; tl
= (trustgroup_t
*)tl
->nextbyid
) {
75 trustgroup_t
* findtrustgroupbyownerid(int ownerid
) {
79 for ( i
= 0; i
< TRUSTS_HASH_GROUPSIZE
; i
++ ) {
80 for ( tg
= trustgroupidtable
[i
]; tg
; tg
= tg
-> nextbyid
) {
81 if(tg
->ownerid
== ownerid
) {
90 void trusts_removetrustgroupfromhash(trustgroup_t
*t
)
94 for(tg
=&(trustgroupidtable
[trusts_gettrustgroupidhash(t
->id
)]);*tg
;tg
=(trustgroup_t
**)&((*tg
)->nextbyid
)) {
96 (*tg
)=(trustgroup_t
*)t
->nextbyid
;
102 Error("trusts",ERR_ERROR
,"Unable to remove trustgroup ID %lu from hashtable",t
->id
);
105 void trusts_addtrustgroupidenttohash(trustgroupidentcount_t
*newident
)
108 hash
= trusts_gettrustgroupidenthash(newident
->ident
->content
);
109 newident
->next
= trustgroupidentcounttable
[hash
];
110 trustgroupidentcounttable
[hash
] = newident
;
113 void trusts_removetrustgroupidentfromhash(trustgroupidentcount_t
*t
)
115 trustgroupidentcount_t
**thi
;
116 for(thi
=&(trustgroupidentcounttable
[trusts_gettrustgroupidenthash(t
->ident
->content
)]);*thi
;thi
=(trustgroupidentcount_t
**)&((*thi
)->next
)) {
118 (*thi
)=(trustgroupidentcount_t
*)t
->next
;
122 Error("trusts",ERR_ERROR
,"Unable to remove trustgroup ident %s from group %lu from hashtable",t
->ident
->content
, t
->trustgroup
->id
);
125 trustgroupidentcount_t
* findtrustgroupcountbyident(char *ident
, trustgroup_t
*t
) {
126 trustgroupidentcount_t
* tgi
;
128 for(tgi
=trustgroupidentcounttable
[trusts_gettrustgroupidenthash(ident
)]; tgi
; tgi
= (trustgroupidentcount_t
*)tgi
->next
) {
129 if(tgi
->trustgroup
== t
) {
130 if(strcmp(tgi
->ident
->content
,ident
)==0) {