Clean up a comment noticed by Jonathan Shao@Panasas.com and remove an
[Samba/gebeck_regimport.git] / source3 / rpc_client / cli_reg.c
blob5cfbf68fb348603ef1754acfc5c87b53476d2eb1
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
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
28 /* Shutdown a server */
30 NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
31 const char *msg, uint32 timeout, BOOL do_reboot,
32 BOOL force)
34 prs_struct qbuf;
35 prs_struct rbuf;
36 REG_Q_SHUTDOWN q_s;
37 REG_R_SHUTDOWN r_s;
38 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
40 if (msg == NULL) return NT_STATUS_INVALID_PARAMETER;
42 ZERO_STRUCT (q_s);
43 ZERO_STRUCT (r_s);
45 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
46 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
48 /* Marshall data and send request */
50 init_reg_q_shutdown(&q_s, msg, timeout, do_reboot, force);
52 if (!reg_io_q_shutdown("", &q_s, &qbuf, 0) ||
53 !rpc_api_pipe_req(cli, REG_SHUTDOWN, &qbuf, &rbuf))
54 goto done;
56 /* Unmarshall response */
58 if(reg_io_r_shutdown("", &r_s, &rbuf, 0))
59 result = r_s.status;
61 done:
62 prs_mem_free(&rbuf);
63 prs_mem_free(&qbuf);
65 return result;
69 /* Abort a server shutdown */
71 NTSTATUS cli_reg_abort_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx)
73 prs_struct rbuf;
74 prs_struct qbuf;
75 REG_Q_ABORT_SHUTDOWN q_s;
76 REG_R_ABORT_SHUTDOWN r_s;
77 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
79 ZERO_STRUCT (q_s);
80 ZERO_STRUCT (r_s);
82 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
83 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
85 /* Marshall data and send request */
87 init_reg_q_abort_shutdown(&q_s);
89 if (!reg_io_q_abort_shutdown("", &q_s, &qbuf, 0) ||
90 !rpc_api_pipe_req(cli, REG_ABORT_SHUTDOWN, &qbuf, &rbuf))
91 goto done;
93 /* Unmarshall response */
95 if (reg_io_r_abort_shutdown("", &r_s, &rbuf, 0))
96 result = r_s.status;
98 done:
99 prs_mem_free(&rbuf);
100 prs_mem_free(&qbuf );
102 return result;