Make 3.0.x in sync with 3.2 here.
[Samba.git] / source / rpc_client / cli_shutdown.c
blobc06586e98abc15acc9a9061b67c4a1fba056c4de
1 /*
2 Unix SMB/CIFS implementation.
3 RPC Pipe client
5 Copyright (C) Andrew Tridgell 1992-1998,
6 Largely rewritten by Jeremy Allison (C) 2005.
7 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "includes.h"
26 /* Shutdown a server */
28 NTSTATUS rpccli_shutdown_init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
29 const char *msg, uint32 timeout, BOOL do_reboot,
30 BOOL force)
32 prs_struct qbuf;
33 prs_struct rbuf;
34 SHUTDOWN_Q_INIT q;
35 SHUTDOWN_R_INIT r;
36 WERROR result = WERR_GENERAL_FAILURE;
38 if (msg == NULL)
39 return NT_STATUS_INVALID_PARAMETER;
41 ZERO_STRUCT (q);
42 ZERO_STRUCT (r);
44 /* Marshall data and send request */
46 init_shutdown_q_init(&q, msg, timeout, do_reboot, force);
48 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT,
49 q, r,
50 qbuf, rbuf,
51 shutdown_io_q_init,
52 shutdown_io_r_init,
53 NT_STATUS_UNSUCCESSFUL);
55 result = r.status;
56 return werror_to_ntstatus(result);
59 /* Shutdown a server */
61 NTSTATUS rpccli_shutdown_init_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
62 const char *msg, uint32 timeout, BOOL do_reboot,
63 BOOL force, uint32 reason)
65 prs_struct qbuf;
66 prs_struct rbuf;
67 SHUTDOWN_Q_INIT_EX q;
68 SHUTDOWN_R_INIT_EX r;
69 WERROR result = WERR_GENERAL_FAILURE;
71 if (msg == NULL)
72 return NT_STATUS_INVALID_PARAMETER;
74 ZERO_STRUCT (q);
75 ZERO_STRUCT (r);
77 /* Marshall data and send request */
79 init_shutdown_q_init_ex(&q, msg, timeout, do_reboot, force, reason);
81 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT_EX,
82 q, r,
83 qbuf, rbuf,
84 shutdown_io_q_init_ex,
85 shutdown_io_r_init_ex,
86 NT_STATUS_UNSUCCESSFUL);
88 result = r.status;
89 return werror_to_ntstatus(result);
93 /* Abort a server shutdown */
95 NTSTATUS rpccli_shutdown_abort(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
97 prs_struct rbuf;
98 prs_struct qbuf;
99 SHUTDOWN_Q_ABORT q;
100 SHUTDOWN_R_ABORT r;
101 WERROR result = WERR_GENERAL_FAILURE;
103 ZERO_STRUCT (q);
104 ZERO_STRUCT (r);
106 /* Marshall data and send request */
108 init_shutdown_q_abort(&q);
110 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_ABORT,
111 q, r,
112 qbuf, rbuf,
113 shutdown_io_q_abort,
114 shutdown_io_r_abort,
115 NT_STATUS_UNSUCCESSFUL);
117 result = r.status;
118 return werror_to_ntstatus(result);