few edits
[Samba.git] / source / libsmb / cli_reg.c
blobc09ccabb29f61737dd2d4f8a17dddaf581247c8d
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 /* Opens a SMB connection to the WINREG pipe */
30 struct cli_state *cli_winreg_initialise(struct cli_state *cli,
31 char *system_name,
32 struct ntuser_creds *creds)
34 return cli_pipe_initialise(cli, system_name, PIPE_WINREG, creds);
37 /* Shutdown a server */
39 NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
40 const char *msg, uint32 timeout, uint16 flags)
42 prs_struct qbuf;
43 prs_struct rbuf;
44 REG_Q_SHUTDOWN q_s;
45 REG_R_SHUTDOWN r_s;
46 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
48 if (msg == NULL) return NT_STATUS_INVALID_PARAMETER;
50 ZERO_STRUCT (q_s);
51 ZERO_STRUCT (r_s);
53 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
54 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
56 /* Marshall data and send request */
58 init_reg_q_shutdown(&q_s, msg, timeout, flags);
60 if (!reg_io_q_shutdown("", &q_s, &qbuf, 0) ||
61 !rpc_api_pipe_req(cli, REG_SHUTDOWN, &qbuf, &rbuf))
62 goto done;
64 /* Unmarshall response */
66 if(reg_io_r_shutdown("", &r_s, &rbuf, 0))
67 result = r_s.status;
69 done:
70 prs_mem_free(&rbuf);
71 prs_mem_free(&qbuf);
73 return result;
77 /* Abort a server shutdown */
79 NTSTATUS cli_reg_abort_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx)
81 prs_struct rbuf;
82 prs_struct qbuf;
83 REG_Q_ABORT_SHUTDOWN q_s;
84 REG_R_ABORT_SHUTDOWN r_s;
85 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
87 ZERO_STRUCT (q_s);
88 ZERO_STRUCT (r_s);
90 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
91 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
93 /* Marshall data and send request */
95 init_reg_q_abort_shutdown(&q_s);
97 if (!reg_io_q_abort_shutdown("", &q_s, &qbuf, 0) ||
98 !rpc_api_pipe_req(cli, REG_ABORT_SHUTDOWN, &qbuf, &rbuf))
99 goto done;
101 /* Unmarshall response */
103 if (reg_io_r_abort_shutdown("", &r_s, &rbuf, 0))
104 result = r_s.status;
106 done:
107 prs_mem_free(&rbuf);
108 prs_mem_free(&qbuf );
110 return result;