Apply some more of Derrell Lipman's changes.
[ira/wip.git] / source3 / rpc_client / cli_epmapper.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RPC pipe client
4
5    Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 NTSTATUS cli_epm_map(struct cli_state *cli, TALLOC_CTX *mem_ctx,
25                      EPM_HANDLE *handle, EPM_TOWER **tower,
26                      EPM_HANDLE *entry_handle, uint32 *num_towers)
27 {
28         prs_struct qbuf, rbuf;
29         EPM_Q_MAP q;
30         EPM_R_MAP r;
31         BOOL result = False;
32
33         ZERO_STRUCT(q);
34         ZERO_STRUCT(r);
35
36         /* Initialise parse structures */
37
38         prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
39         prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
40
41         /* Marshall data and send request */
42
43         init_epm_q_map(mem_ctx, &q, *tower, *num_towers);
44
45         if (!epm_io_q_map("map_query", &q, &qbuf, 0) ||
46             !rpc_api_pipe_req(cli, EPM_MAP_PIPE_NAME, &qbuf, &rbuf))
47                 goto done;
48
49         /* Unmarshall response */
50
51         if (!epm_io_r_map("map_reply", &r, &rbuf, 0))
52                 goto done;
53
54         result = True;
55
56  done:
57         prs_mem_free(&qbuf);
58         prs_mem_free(&rbuf);
59
60         return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
61 }