/* client functions auto-generated by pidl */

#include "includes.h"
#include <tevent.h>
#include "lib/util/tevent_ntstatus.h"
#include "bin/default/librpc/gen_ndr/ndr_initshutdown.h"
#include "bin/default/librpc/gen_ndr/ndr_initshutdown_c.h"

/* initshutdown - client functions generated by pidl */

struct dcerpc_initshutdown_Init_r_state {
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_Init_r_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_Init_r_send(TALLOC_CTX *mem_ctx,
	struct tevent_context *ev,
	struct dcerpc_binding_handle *h,
	struct initshutdown_Init *r)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_Init_r_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_Init_r_state);
	if (req == NULL) {
		return NULL;
	}

	state->out_mem_ctx = NULL;

	subreq = dcerpc_binding_handle_call_send(state, ev, h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_INIT, state, r);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_Init_r_done, req);

	return req;
}

static void dcerpc_initshutdown_Init_r_done(struct tevent_req *subreq)
{
	struct tevent_req *req =
		tevent_req_callback_data(subreq,
		struct tevent_req);
	NTSTATUS status;

	status = dcerpc_binding_handle_call_recv(subreq);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_Init_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
{
	struct dcerpc_initshutdown_Init_r_state *state =
		tevent_req_data(req,
		struct dcerpc_initshutdown_Init_r_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	talloc_steal(mem_ctx, state->out_mem_ctx);

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_Init_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct initshutdown_Init *r)
{
	NTSTATUS status;

	status = dcerpc_binding_handle_call(h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_INIT, mem_ctx, r);

	return status;
}

struct dcerpc_initshutdown_Init_state {
	struct initshutdown_Init orig;
	struct initshutdown_Init tmp;
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_Init_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_Init_send(TALLOC_CTX *mem_ctx,
						 struct tevent_context *ev,
						 struct dcerpc_binding_handle *h,
						 uint16_t *_hostname /* [in] [unique] */,
						 struct lsa_StringLarge *_message /* [in] [unique] */,
						 uint32_t _timeout /* [in]  */,
						 uint8_t _force_apps /* [in]  */,
						 uint8_t _do_reboot /* [in]  */)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_Init_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_Init_state);
	if (req == NULL) {
		return NULL;
	}
	state->out_mem_ctx = NULL;

	/* In parameters */
	state->orig.in.hostname = _hostname;
	state->orig.in.message = _message;
	state->orig.in.timeout = _timeout;
	state->orig.in.force_apps = _force_apps;
	state->orig.in.do_reboot = _do_reboot;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(state->orig.out.result);

	/* make a temporary copy, that we pass to the dispatch function */
	state->tmp = state->orig;

	subreq = dcerpc_initshutdown_Init_r_send(state, ev, h, &state->tmp);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_Init_done, req);
	return req;
}

static void dcerpc_initshutdown_Init_done(struct tevent_req *subreq)
{
	struct tevent_req *req = tevent_req_callback_data(
		subreq, struct tevent_req);
	struct dcerpc_initshutdown_Init_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_Init_state);
	NTSTATUS status;
	TALLOC_CTX *mem_ctx;

	if (state->out_mem_ctx) {
		mem_ctx = state->out_mem_ctx;
	} else {
		mem_ctx = state;
	}

	status = dcerpc_initshutdown_Init_r_recv(subreq, mem_ctx);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	/* Copy out parameters */

	/* Copy result */
	state->orig.out.result = state->tmp.out.result;

	/* Reset temporary structure */
	NDR_ZERO_STRUCT(state->tmp);

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_Init_recv(struct tevent_req *req,
				       TALLOC_CTX *mem_ctx,
				       WERROR *result)
{
	struct dcerpc_initshutdown_Init_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_Init_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	/* Steal possible out parameters to the callers context */
	talloc_steal(mem_ctx, state->out_mem_ctx);

	/* Return result */
	*result = state->orig.out.result;

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_Init(struct dcerpc_binding_handle *h,
				  TALLOC_CTX *mem_ctx,
				  uint16_t *_hostname /* [in] [unique] */,
				  struct lsa_StringLarge *_message /* [in] [unique] */,
				  uint32_t _timeout /* [in]  */,
				  uint8_t _force_apps /* [in]  */,
				  uint8_t _do_reboot /* [in]  */,
				  WERROR *result)
{
	struct initshutdown_Init r;
	NTSTATUS status;

	/* In parameters */
	r.in.hostname = _hostname;
	r.in.message = _message;
	r.in.timeout = _timeout;
	r.in.force_apps = _force_apps;
	r.in.do_reboot = _do_reboot;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(r.out.result);

	status = dcerpc_initshutdown_Init_r(h, mem_ctx, &r);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	/* Return variables */

	/* Return result */
	*result = r.out.result;

	return NT_STATUS_OK;
}

struct dcerpc_initshutdown_Abort_r_state {
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_Abort_r_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_Abort_r_send(TALLOC_CTX *mem_ctx,
	struct tevent_context *ev,
	struct dcerpc_binding_handle *h,
	struct initshutdown_Abort *r)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_Abort_r_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_Abort_r_state);
	if (req == NULL) {
		return NULL;
	}

	state->out_mem_ctx = NULL;

	subreq = dcerpc_binding_handle_call_send(state, ev, h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_ABORT, state, r);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_Abort_r_done, req);

	return req;
}

static void dcerpc_initshutdown_Abort_r_done(struct tevent_req *subreq)
{
	struct tevent_req *req =
		tevent_req_callback_data(subreq,
		struct tevent_req);
	NTSTATUS status;

	status = dcerpc_binding_handle_call_recv(subreq);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_Abort_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
{
	struct dcerpc_initshutdown_Abort_r_state *state =
		tevent_req_data(req,
		struct dcerpc_initshutdown_Abort_r_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	talloc_steal(mem_ctx, state->out_mem_ctx);

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_Abort_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct initshutdown_Abort *r)
{
	NTSTATUS status;

	status = dcerpc_binding_handle_call(h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_ABORT, mem_ctx, r);

	return status;
}

struct dcerpc_initshutdown_Abort_state {
	struct initshutdown_Abort orig;
	struct initshutdown_Abort tmp;
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_Abort_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_Abort_send(TALLOC_CTX *mem_ctx,
						  struct tevent_context *ev,
						  struct dcerpc_binding_handle *h,
						  uint16_t *_server /* [in] [unique] */)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_Abort_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_Abort_state);
	if (req == NULL) {
		return NULL;
	}
	state->out_mem_ctx = NULL;

	/* In parameters */
	state->orig.in.server = _server;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(state->orig.out.result);

	/* make a temporary copy, that we pass to the dispatch function */
	state->tmp = state->orig;

	subreq = dcerpc_initshutdown_Abort_r_send(state, ev, h, &state->tmp);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_Abort_done, req);
	return req;
}

static void dcerpc_initshutdown_Abort_done(struct tevent_req *subreq)
{
	struct tevent_req *req = tevent_req_callback_data(
		subreq, struct tevent_req);
	struct dcerpc_initshutdown_Abort_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_Abort_state);
	NTSTATUS status;
	TALLOC_CTX *mem_ctx;

	if (state->out_mem_ctx) {
		mem_ctx = state->out_mem_ctx;
	} else {
		mem_ctx = state;
	}

	status = dcerpc_initshutdown_Abort_r_recv(subreq, mem_ctx);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	/* Copy out parameters */

	/* Copy result */
	state->orig.out.result = state->tmp.out.result;

	/* Reset temporary structure */
	NDR_ZERO_STRUCT(state->tmp);

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_Abort_recv(struct tevent_req *req,
					TALLOC_CTX *mem_ctx,
					WERROR *result)
{
	struct dcerpc_initshutdown_Abort_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_Abort_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	/* Steal possible out parameters to the callers context */
	talloc_steal(mem_ctx, state->out_mem_ctx);

	/* Return result */
	*result = state->orig.out.result;

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_Abort(struct dcerpc_binding_handle *h,
				   TALLOC_CTX *mem_ctx,
				   uint16_t *_server /* [in] [unique] */,
				   WERROR *result)
{
	struct initshutdown_Abort r;
	NTSTATUS status;

	/* In parameters */
	r.in.server = _server;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(r.out.result);

	status = dcerpc_initshutdown_Abort_r(h, mem_ctx, &r);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	/* Return variables */

	/* Return result */
	*result = r.out.result;

	return NT_STATUS_OK;
}

struct dcerpc_initshutdown_InitEx_r_state {
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_InitEx_r_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_InitEx_r_send(TALLOC_CTX *mem_ctx,
	struct tevent_context *ev,
	struct dcerpc_binding_handle *h,
	struct initshutdown_InitEx *r)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_InitEx_r_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_InitEx_r_state);
	if (req == NULL) {
		return NULL;
	}

	state->out_mem_ctx = NULL;

	subreq = dcerpc_binding_handle_call_send(state, ev, h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_INITEX, state, r);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_InitEx_r_done, req);

	return req;
}

static void dcerpc_initshutdown_InitEx_r_done(struct tevent_req *subreq)
{
	struct tevent_req *req =
		tevent_req_callback_data(subreq,
		struct tevent_req);
	NTSTATUS status;

	status = dcerpc_binding_handle_call_recv(subreq);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_InitEx_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
{
	struct dcerpc_initshutdown_InitEx_r_state *state =
		tevent_req_data(req,
		struct dcerpc_initshutdown_InitEx_r_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	talloc_steal(mem_ctx, state->out_mem_ctx);

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_InitEx_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct initshutdown_InitEx *r)
{
	NTSTATUS status;

	status = dcerpc_binding_handle_call(h,
			NULL, &ndr_table_initshutdown,
			NDR_INITSHUTDOWN_INITEX, mem_ctx, r);

	return status;
}

struct dcerpc_initshutdown_InitEx_state {
	struct initshutdown_InitEx orig;
	struct initshutdown_InitEx tmp;
	TALLOC_CTX *out_mem_ctx;
};

static void dcerpc_initshutdown_InitEx_done(struct tevent_req *subreq);

struct tevent_req *dcerpc_initshutdown_InitEx_send(TALLOC_CTX *mem_ctx,
						   struct tevent_context *ev,
						   struct dcerpc_binding_handle *h,
						   uint16_t *_hostname /* [in] [unique] */,
						   struct lsa_StringLarge *_message /* [in] [unique] */,
						   uint32_t _timeout /* [in]  */,
						   uint8_t _force_apps /* [in]  */,
						   uint8_t _do_reboot /* [in]  */,
						   uint32_t _reason /* [in]  */)
{
	struct tevent_req *req;
	struct dcerpc_initshutdown_InitEx_state *state;
	struct tevent_req *subreq;

	req = tevent_req_create(mem_ctx, &state,
				struct dcerpc_initshutdown_InitEx_state);
	if (req == NULL) {
		return NULL;
	}
	state->out_mem_ctx = NULL;

	/* In parameters */
	state->orig.in.hostname = _hostname;
	state->orig.in.message = _message;
	state->orig.in.timeout = _timeout;
	state->orig.in.force_apps = _force_apps;
	state->orig.in.do_reboot = _do_reboot;
	state->orig.in.reason = _reason;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(state->orig.out.result);

	/* make a temporary copy, that we pass to the dispatch function */
	state->tmp = state->orig;

	subreq = dcerpc_initshutdown_InitEx_r_send(state, ev, h, &state->tmp);
	if (tevent_req_nomem(subreq, req)) {
		return tevent_req_post(req, ev);
	}
	tevent_req_set_callback(subreq, dcerpc_initshutdown_InitEx_done, req);
	return req;
}

static void dcerpc_initshutdown_InitEx_done(struct tevent_req *subreq)
{
	struct tevent_req *req = tevent_req_callback_data(
		subreq, struct tevent_req);
	struct dcerpc_initshutdown_InitEx_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_InitEx_state);
	NTSTATUS status;
	TALLOC_CTX *mem_ctx;

	if (state->out_mem_ctx) {
		mem_ctx = state->out_mem_ctx;
	} else {
		mem_ctx = state;
	}

	status = dcerpc_initshutdown_InitEx_r_recv(subreq, mem_ctx);
	TALLOC_FREE(subreq);
	if (tevent_req_nterror(req, status)) {
		return;
	}

	/* Copy out parameters */

	/* Copy result */
	state->orig.out.result = state->tmp.out.result;

	/* Reset temporary structure */
	NDR_ZERO_STRUCT(state->tmp);

	tevent_req_done(req);
}

NTSTATUS dcerpc_initshutdown_InitEx_recv(struct tevent_req *req,
					 TALLOC_CTX *mem_ctx,
					 WERROR *result)
{
	struct dcerpc_initshutdown_InitEx_state *state = tevent_req_data(
		req, struct dcerpc_initshutdown_InitEx_state);
	NTSTATUS status;

	if (tevent_req_is_nterror(req, &status)) {
		tevent_req_received(req);
		return status;
	}

	/* Steal possible out parameters to the callers context */
	talloc_steal(mem_ctx, state->out_mem_ctx);

	/* Return result */
	*result = state->orig.out.result;

	tevent_req_received(req);
	return NT_STATUS_OK;
}

NTSTATUS dcerpc_initshutdown_InitEx(struct dcerpc_binding_handle *h,
				    TALLOC_CTX *mem_ctx,
				    uint16_t *_hostname /* [in] [unique] */,
				    struct lsa_StringLarge *_message /* [in] [unique] */,
				    uint32_t _timeout /* [in]  */,
				    uint8_t _force_apps /* [in]  */,
				    uint8_t _do_reboot /* [in]  */,
				    uint32_t _reason /* [in]  */,
				    WERROR *result)
{
	struct initshutdown_InitEx r;
	NTSTATUS status;

	/* In parameters */
	r.in.hostname = _hostname;
	r.in.message = _message;
	r.in.timeout = _timeout;
	r.in.force_apps = _force_apps;
	r.in.do_reboot = _do_reboot;
	r.in.reason = _reason;

	/* Out parameters */

	/* Result */
	NDR_ZERO_STRUCT(r.out.result);

	status = dcerpc_initshutdown_InitEx_r(h, mem_ctx, &r);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	/* Return variables */

	/* Return result */
	*result = r.out.result;

	return NT_STATUS_OK;
}

