* small formatting fixes
[Samba.git] / source / rpc_client / cli_dfs.c
blob7fc27b9c3b2687fcc61ca6354ba0d1c580e315ad
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
4 Copyright (C) Tim Potter 2000-2001,
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
23 /* Query DFS support */
25 NTSTATUS cli_dfs_exist(struct cli_state *cli, TALLOC_CTX *mem_ctx,
26 BOOL *dfs_exists)
28 prs_struct qbuf, rbuf;
29 DFS_Q_DFS_EXIST q;
30 DFS_R_DFS_EXIST r;
31 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
33 ZERO_STRUCT(q);
34 ZERO_STRUCT(r);
36 /* Initialise parse structures */
38 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
39 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
41 /* Marshall data and send request */
43 init_dfs_q_dfs_exist(&q);
45 if (!dfs_io_q_dfs_exist("", &q, &qbuf, 0) ||
46 !rpc_api_pipe_req(cli, DFS_EXIST, &qbuf, &rbuf)) {
47 goto done;
50 /* Unmarshall response */
52 if (!dfs_io_r_dfs_exist("", &r, &rbuf, 0)) {
53 goto done;
56 /* Return result */
58 *dfs_exists = (r.status != 0);
60 result = NT_STATUS_OK;
62 done:
63 prs_mem_free(&qbuf);
64 prs_mem_free(&rbuf);
66 return result;
69 NTSTATUS cli_dfs_add(struct cli_state *cli, TALLOC_CTX *mem_ctx,
70 char *entrypath, char *servername, char *sharename,
71 char *comment, uint32 flags)
73 prs_struct qbuf, rbuf;
74 DFS_Q_DFS_ADD q;
75 DFS_R_DFS_ADD r;
76 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
78 ZERO_STRUCT(q);
79 ZERO_STRUCT(r);
81 /* Initialise parse structures */
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_dfs_q_dfs_add(&q, entrypath, servername, sharename, comment,
89 flags);
91 if (!dfs_io_q_dfs_add("", &q, &qbuf, 0) ||
92 !rpc_api_pipe_req(cli, DFS_ADD, &qbuf, &rbuf)) {
93 goto done;
96 /* Unmarshall response */
98 if (!dfs_io_r_dfs_add("", &r, &rbuf, 0)) {
99 goto done;
102 /* Return result */
104 result = werror_to_ntstatus(r.status);
106 done:
107 prs_mem_free(&qbuf);
108 prs_mem_free(&rbuf);
110 return result;
113 NTSTATUS cli_dfs_remove(struct cli_state *cli, TALLOC_CTX *mem_ctx,
114 char *entrypath, char *servername, char *sharename)
116 prs_struct qbuf, rbuf;
117 DFS_Q_DFS_REMOVE q;
118 DFS_R_DFS_REMOVE r;
119 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
121 ZERO_STRUCT(q);
122 ZERO_STRUCT(r);
124 /* Initialise parse structures */
126 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
127 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
129 /* Marshall data and send request */
131 init_dfs_q_dfs_remove(&q, entrypath, servername, sharename);
133 if (!dfs_io_q_dfs_remove("", &q, &qbuf, 0) ||
134 !rpc_api_pipe_req(cli, DFS_REMOVE, &qbuf, &rbuf)) {
135 goto done;
138 /* Unmarshall response */
140 if (!dfs_io_r_dfs_remove("", &r, &rbuf, 0)) {
141 goto done;
144 /* Return result */
146 result = werror_to_ntstatus(r.status);
148 done:
149 prs_mem_free(&qbuf);
150 prs_mem_free(&rbuf);
152 return result;
155 NTSTATUS cli_dfs_get_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
156 char *entrypath, char *servername, char *sharename,
157 uint32 info_level, DFS_INFO_CTR *ctr)
160 prs_struct qbuf, rbuf;
161 DFS_Q_DFS_GET_INFO q;
162 DFS_R_DFS_GET_INFO r;
163 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
165 ZERO_STRUCT(q);
166 ZERO_STRUCT(r);
168 /* Initialise parse structures */
170 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
171 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
173 /* Marshall data and send request */
175 init_dfs_q_dfs_get_info(&q, entrypath, servername, sharename,
176 info_level);
178 if (!dfs_io_q_dfs_get_info("", &q, &qbuf, 0) ||
179 !rpc_api_pipe_req(cli, DFS_GET_INFO, &qbuf, &rbuf)) {
180 goto done;
183 /* Unmarshall response */
185 if (!dfs_io_r_dfs_get_info("", &r, &rbuf, 0)) {
186 goto done;
189 /* Return result */
191 result = werror_to_ntstatus(r.status);
192 *ctr = r.ctr;
194 done:
195 prs_mem_free(&qbuf);
196 prs_mem_free(&rbuf);
198 return result;
201 /* Enumerate dfs shares */
203 NTSTATUS cli_dfs_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx,
204 uint32 info_level, DFS_INFO_CTR *ctr)
206 prs_struct qbuf, rbuf;
207 DFS_Q_DFS_ENUM q;
208 DFS_R_DFS_ENUM r;
209 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
211 ZERO_STRUCT(q);
212 ZERO_STRUCT(r);
214 /* Initialise parse structures */
216 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
217 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
219 /* Marshall data and send request */
221 init_dfs_q_dfs_enum(&q, info_level, ctr);
223 if (!dfs_io_q_dfs_enum("", &q, &qbuf, 0) ||
224 !rpc_api_pipe_req(cli, DFS_ENUM, &qbuf, &rbuf)) {
225 goto done;
228 /* Unmarshall response */
230 r.ctr = ctr;
232 if (!dfs_io_r_dfs_enum("", &r, &rbuf, 0)) {
233 goto done;
236 /* Return result */
238 result = werror_to_ntstatus(r.status);
240 done:
241 prs_mem_free(&qbuf);
242 prs_mem_free(&rbuf);
244 return result;