updated the 3.0 branch from the head branch - ready for alpha18
[sfrench/samba-autobuild/.git] / source3 / rpc_client / cli_wkssvc.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison                    1999.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include "includes.h"
25
26 #undef DBGC_CLASS
27 #define DBGC_CLASS DBGC_RPC_CLI
28
29 /****************************************************************************
30 do a WKS Open Policy
31 ****************************************************************************/
32 BOOL do_wks_query_info(struct cli_state *cli, 
33                         char *server_name, uint32 switch_value,
34                         WKS_INFO_100 *wks100)
35 {
36         prs_struct rbuf;
37         prs_struct buf; 
38         WKS_Q_QUERY_INFO q_o;
39         WKS_R_QUERY_INFO r_o;
40
41         if (server_name == 0 || wks100 == NULL)
42                 return False;
43
44         prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
45         prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
46
47         /* create and send a MSRPC command with api WKS_QUERY_INFO */
48
49         DEBUG(4,("WKS Query Info\n"));
50
51         /* store the parameters */
52         init_wks_q_query_info(&q_o, server_name, switch_value);
53
54         /* turn parameters into data stream */
55         if(!wks_io_q_query_info("", &q_o, &buf, 0)) {
56                 prs_mem_free(&buf);
57                 prs_mem_free(&rbuf);
58                 return False;
59         }
60
61         /* send the data on \PIPE\ */
62         if (!rpc_api_pipe_req(cli, WKS_QUERY_INFO, &buf, &rbuf)) {
63                 prs_mem_free(&buf);
64                 prs_mem_free(&rbuf);
65                 return False;
66         }
67
68         prs_mem_free(&buf);
69
70         r_o.wks100 = wks100;
71
72         if(!wks_io_r_query_info("", &r_o, &rbuf, 0)) {
73                 prs_mem_free(&rbuf);
74                 return False;
75         }
76
77         if (r_o.status != 0) {
78                 /* report error code */
79                 DEBUG(0,("WKS_R_QUERY_INFO: %s\n", nt_errstr(r_o.status)));
80                 prs_mem_free(&rbuf);
81                 return False;
82         }
83
84         prs_mem_free(&rbuf);
85
86         return True;
87 }