/* parser auto-generated by pidl */

#include "includes.h"

NTSTATUS ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, struct dom_sid *r)
{
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_push_struct_start(ndr));
	NDR_CHECK(ndr_push_align(ndr, 4));
	NDR_CHECK(ndr_push_uint8(ndr, r->sid_rev_num));
	NDR_CHECK(ndr_push_uint8(ndr, r->num_auths));
		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
		NDR_CHECK(ndr_push_array_uint32(ndr, NDR_SCALARS, r->sub_auths, r->num_auths));
	ndr_push_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_BUFFERS, r->id_auth, 6));
		NDR_CHECK(ndr_push_array_uint32(ndr, NDR_BUFFERS, r->sub_auths, r->num_auths));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_push_security_ace(struct ndr_push *ndr, int ndr_flags, struct security_ace *r)
{
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_push_struct_start(ndr));
	NDR_CHECK(ndr_push_align(ndr, 4));
	NDR_CHECK(ndr_push_uint8(ndr, r->type));
	NDR_CHECK(ndr_push_uint8(ndr, r->flags));
	NDR_CHECK(ndr_push_uint32(ndr, r->access_mask));
	NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, &r->trustee));
	ndr_push_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_push_dom_sid(ndr, NDR_BUFFERS, &r->trustee));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_push_security_acl(struct ndr_push *ndr, int ndr_flags, struct security_acl *r)
{
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_push_struct_start(ndr));
	NDR_CHECK(ndr_push_align(ndr, 4));
	NDR_CHECK(ndr_push_uint16(ndr, r->revision));
	NDR_CHECK(ndr_push_uint32(ndr, r->num_aces));
		NDR_CHECK(ndr_push_array(ndr, NDR_SCALARS, r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_push_flags_fn_t)ndr_push_security_ace));
	ndr_push_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_push_array(ndr, NDR_BUFFERS, r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_push_flags_fn_t)ndr_push_security_ace));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_push_security_descriptor(struct ndr_push *ndr, int ndr_flags, struct security_descriptor *r)
{
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_push_struct_start(ndr));
	NDR_CHECK(ndr_push_align(ndr, 4));
	NDR_CHECK(ndr_push_uint8(ndr, r->revision));
	NDR_CHECK(ndr_push_uint16(ndr, r->type));
	NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->owner_sid, (ndr_push_const_fn_t) ndr_push_dom_sid));
	NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->group_sid, (ndr_push_const_fn_t) ndr_push_dom_sid));
	NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->sacl, (ndr_push_const_fn_t) ndr_push_security_acl));
	NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->dacl, (ndr_push_const_fn_t) ndr_push_security_acl));
	ndr_push_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
	if (r->owner_sid) {
	NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, r->owner_sid, (ndr_push_const_fn_t) ndr_push_dom_sid));
	}
	if (r->group_sid) {
	NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, r->group_sid, (ndr_push_const_fn_t) ndr_push_dom_sid));
	}
	if (r->sacl) {
	NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, r->sacl, (ndr_push_const_fn_t) ndr_push_security_acl));
	}
	if (r->dacl) {
	NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, r->dacl, (ndr_push_const_fn_t) ndr_push_security_acl));
	}
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_dom_sid(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *r)
{
	NDR_CHECK(ndr_pull_struct_start(ndr));
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_align(ndr, 4));
	NDR_CHECK(ndr_pull_uint8(ndr, &r->sid_rev_num));
	NDR_CHECK(ndr_pull_uint8(ndr, &r->num_auths));
		NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
		NDR_ALLOC_N_SIZE(ndr, r->sub_auths, r->num_auths, sizeof(r->sub_auths[0]));
		NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS, r->sub_auths, r->num_auths));
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_BUFFERS, r->id_auth, 6));
		NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_BUFFERS, r->sub_auths, r->num_auths));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_security_ace(struct ndr_pull *ndr, int ndr_flags, struct security_ace *r)
{
	NDR_CHECK(ndr_pull_struct_start(ndr));
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_align(ndr, 4));
	NDR_CHECK(ndr_pull_uint8(ndr, &r->type));
	NDR_CHECK(ndr_pull_uint8(ndr, &r->flags));
	NDR_CHECK(ndr_pull_uint32(ndr, &r->access_mask));
	NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, &r->trustee));
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_BUFFERS, &r->trustee));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_security_acl(struct ndr_pull *ndr, int ndr_flags, struct security_acl *r)
{
	NDR_CHECK(ndr_pull_struct_start(ndr));
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_align(ndr, 4));
	NDR_CHECK(ndr_pull_uint16(ndr, &r->revision));
	NDR_CHECK(ndr_pull_uint32(ndr, &r->num_aces));
		NDR_ALLOC_N_SIZE(ndr, r->aces, r->num_aces, sizeof(r->aces[0]));
		NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS, (void **)r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_pull_flags_fn_t)ndr_pull_security_ace));
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
		NDR_CHECK(ndr_pull_array(ndr, NDR_BUFFERS, (void **)r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_pull_flags_fn_t)ndr_pull_security_ace));
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r)
{
	NDR_CHECK(ndr_pull_struct_start(ndr));
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_align(ndr, 4));
	NDR_CHECK(ndr_pull_uint8(ndr, &r->revision));
	NDR_CHECK(ndr_pull_uint16(ndr, &r->type));
	NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->owner_sid, sizeof(*r->owner_sid), (ndr_pull_flags_fn_t)ndr_pull_dom_sid));
	NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->group_sid, sizeof(*r->group_sid), (ndr_pull_flags_fn_t)ndr_pull_dom_sid));
	NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->sacl, sizeof(*r->sacl), (ndr_pull_flags_fn_t)ndr_pull_security_acl));
	NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->dacl, sizeof(*r->dacl), (ndr_pull_flags_fn_t)ndr_pull_security_acl));
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
done:
	return NT_STATUS_OK;
}

void ndr_print_security_ace(struct ndr_print *ndr, const char *name, struct security_ace *r)
{
	ndr_print_struct(ndr, name, "security_ace");
	ndr->depth++;
	ndr_print_uint8(ndr, "type", r->type);
	ndr_print_uint8(ndr, "flags", r->flags);
	ndr_print_uint32(ndr, "access_mask", r->access_mask);
	ndr_print_dom_sid(ndr, "trustee", &r->trustee);
	ndr->depth--;
}

void ndr_print_security_acl(struct ndr_print *ndr, const char *name, struct security_acl *r)
{
	ndr_print_struct(ndr, name, "security_acl");
	ndr->depth++;
	ndr_print_uint16(ndr, "revision", r->revision);
	ndr_print_uint32(ndr, "num_aces", r->num_aces);
	ndr_print_ptr(ndr, "aces", r->aces);
	ndr->depth++;
		ndr_print_array(ndr, "aces", r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_print_fn_t)ndr_print_security_ace);
	ndr->depth--;
	ndr->depth--;
}

void ndr_print_security_descriptor(struct ndr_print *ndr, const char *name, struct security_descriptor *r)
{
	ndr_print_struct(ndr, name, "security_descriptor");
	ndr->depth++;
	ndr_print_uint8(ndr, "revision", r->revision);
	ndr_print_uint16(ndr, "type", r->type);
	ndr_print_ptr(ndr, "owner_sid", r->owner_sid);
	ndr->depth++;
	if (r->owner_sid) {
		ndr_print_dom_sid(ndr, "owner_sid", r->owner_sid);
	}
	ndr->depth--;
	ndr_print_ptr(ndr, "group_sid", r->group_sid);
	ndr->depth++;
	if (r->group_sid) {
		ndr_print_dom_sid(ndr, "group_sid", r->group_sid);
	}
	ndr->depth--;
	ndr_print_ptr(ndr, "sacl", r->sacl);
	ndr->depth++;
	if (r->sacl) {
		ndr_print_security_acl(ndr, "sacl", r->sacl);
	}
	ndr->depth--;
	ndr_print_ptr(ndr, "dacl", r->dacl);
	ndr->depth++;
	if (r->dacl) {
		ndr_print_security_acl(ndr, "dacl", r->dacl);
	}
	ndr->depth--;
	ndr->depth--;
}