#include "../config/acl.h"
#include "../util/atomic.h"
#include "config.h"
#include "acldata.h"
ACLData* acl_data_new() {
ACLData *dat = malloc(
sizeof(ACLData));
dat->ref =
1;
dat->namedACLs = ucx_map_new(
16);
return dat;
}
void acl_data_ref(ACLData *acldata) {
if(acldata) {
ws_atomic_inc32(&acldata->ref);
}
}
void acl_data_unref(ACLData *acldata) {
uint32_t ref = ws_atomic_dec32(&acldata->ref);
if(ref ==
0) {
UcxMapIterator i = ucx_map_iterator(acldata->namedACLs);
WSAcl *acl;
UCX_MAP_FOREACH(key, acl, i) {
free(acl->ace);
free(acl->ece);
if(acl->acl.authprompt) {
free(acl->acl.authprompt);
}
free(acl);
}
ucx_map_free(acldata->namedACLs);
free(acldata);
}
}
ACLList* acl_get(ACLData *acldata,
char *name) {
ACLList *acl = ucx_map_cstr_get(acldata->namedACLs, name);
return acl;
}