r3339: allow tdbtool to be built
[Samba/nascimento.git] / source / rpc_client / cli_shutdown.c
blob0bf6e90ad271900de51f14402ef1ff3a8857cf88
1 /*
2 Unix SMB/CIFS implementation.
3 RPC Pipe client
5 Copyright (C) Andrew Tridgell 1992-1998,
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
7 Copyright (C) Paul Ashton 1997-1998.
8 Copyright (C) Jeremy Allison 1999,
9 Copyright (C) Simo Sorce 2001,
10 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "includes.h"
29 /* Shutdown a server */
31 NTSTATUS cli_shutdown_init(struct cli_state * cli, TALLOC_CTX *mem_ctx,
32 const char *msg, uint32 timeout, BOOL do_reboot,
33 BOOL force)
35 prs_struct qbuf;
36 prs_struct rbuf;
37 SHUTDOWN_Q_INIT q_s;
38 SHUTDOWN_R_INIT r_s;
39 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
41 if (msg == NULL) return NT_STATUS_INVALID_PARAMETER;
43 ZERO_STRUCT (q_s);
44 ZERO_STRUCT (r_s);
46 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
47 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
49 /* Marshall data and send request */
51 init_shutdown_q_init(&q_s, msg, timeout, do_reboot, force);
53 if (!shutdown_io_q_init("", &q_s, &qbuf, 0) ||
54 !rpc_api_pipe_req(cli, SHUTDOWN_INIT, &qbuf, &rbuf))
55 goto done;
57 /* Unmarshall response */
59 if(shutdown_io_r_init("", &r_s, &rbuf, 0))
60 result = r_s.status;
62 done:
63 prs_mem_free(&rbuf);
64 prs_mem_free(&qbuf);
66 return result;
70 /* Abort a server shutdown */
72 NTSTATUS cli_shutdown_abort(struct cli_state * cli, TALLOC_CTX *mem_ctx)
74 prs_struct rbuf;
75 prs_struct qbuf;
76 SHUTDOWN_Q_ABORT q_s;
77 SHUTDOWN_R_ABORT r_s;
78 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
80 ZERO_STRUCT (q_s);
81 ZERO_STRUCT (r_s);
83 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
84 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
86 /* Marshall data and send request */
88 init_shutdown_q_abort(&q_s);
90 if (!shutdown_io_q_abort("", &q_s, &qbuf, 0) ||
91 !rpc_api_pipe_req(cli, SHUTDOWN_ABORT, &qbuf, &rbuf))
92 goto done;
94 /* Unmarshall response */
96 if (shutdown_io_r_abort("", &r_s, &rbuf, 0))
97 result = r_s.status;
99 done:
100 prs_mem_free(&rbuf);
101 prs_mem_free(&qbuf );
103 return result;