#include <sys/appleapiopts.h>
#include <sys/types.h>
#include <sys/acl.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "aclvar.h"
int
acl_add_flag_np(acl_flagset_t flags, acl_flag_t flag)
{
flags->af_flags |= flag;
return(0);
}
int
acl_clear_flags_np(acl_flagset_t flags)
{
flags->af_flags = 0;
return(0);
}
int
acl_delete_flag_np(acl_flagset_t flags, acl_flag_t flag)
{
flags->af_flags &= ~flag;
return(0);
}
int
acl_get_flag_np(acl_flagset_t flagset, acl_flag_t flag)
{
return((flag & flagset->af_flags) ? 1 : 0);
}
int
acl_get_flagset_np(void *obj, acl_flagset_t *flagset_p)
{
struct _acl *ap = (struct _acl *)obj;
struct _acl_entry *ep = (struct _acl_entry *)obj;
if (_ACL_VALID_ACL(ap)) {
*flagset_p = (acl_flagset_t)&ap->a_flags;
} else if (_ACL_VALID_ENTRY(ep)) {
*flagset_p = (acl_flagset_t)&ep->ae_flags;
} else {
errno = EINVAL;
return(-1);
}
return(0);
}
int
acl_set_flagset_np(void *obj, acl_flagset_t flagset)
{
struct _acl *ap = (struct _acl *)obj;
struct _acl_entry *ep = (struct _acl_entry *)obj;
if (_ACL_VALID_ACL(ap)) {
ap->a_flags = flagset->af_flags;
} else if (_ACL_VALID_ENTRY(ep)) {
ep->ae_flags = flagset->af_flags;
} else {
errno = EINVAL;
return(-1);
}
return(0);
}