first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[samba.git] / source3 / rpc_client / cli_wkssvc.c
1
2 /* 
3  *  Unix SMB/Netbios implementation.
4  *  Version 1.9.
5  *  RPC Pipe client / server routines
6  *  Copyright (C) Andrew Tridgell              1992-1997,
7  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
8  *  Copyright (C) Paul Ashton                       1997.
9  *  Copyright (C) Jeremy Allison                    1999.
10  *  
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.
15  *  
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.
20  *  
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.
24  */
25
26
27 #ifdef SYSLOG
28 #undef SYSLOG
29 #endif
30
31 #include "includes.h"
32
33 extern int DEBUGLEVEL;
34
35 /****************************************************************************
36 do a WKS Open Policy
37 ****************************************************************************/
38 BOOL do_wks_query_info(struct cli_state *cli, 
39                         char *server_name, uint32 switch_value,
40                         WKS_INFO_100 *wks100)
41 {
42         prs_struct rbuf;
43         prs_struct buf; 
44         WKS_Q_QUERY_INFO q_o;
45         WKS_R_QUERY_INFO r_o;
46
47         if (server_name == 0 || wks100 == NULL)
48                 return False;
49
50         prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
51         prs_init(&rbuf, 0, 4, UNMARSHALL );
52
53         /* create and send a MSRPC command with api WKS_QUERY_INFO */
54
55         DEBUG(4,("WKS Query Info\n"));
56
57         /* store the parameters */
58         init_wks_q_query_info(&q_o, server_name, switch_value);
59
60         /* turn parameters into data stream */
61         if(!wks_io_q_query_info("", &q_o, &buf, 0)) {
62                 prs_mem_free(&buf);
63                 prs_mem_free(&rbuf);
64                 return False;
65         }
66
67         /* send the data on \PIPE\ */
68         if (!rpc_api_pipe_req(cli, WKS_QUERY_INFO, &buf, &rbuf)) {
69                 prs_mem_free(&buf);
70                 prs_mem_free(&rbuf);
71                 return False;
72         }
73
74         prs_mem_free(&buf);
75
76         r_o.wks100 = wks100;
77
78         if(!wks_io_r_query_info("", &r_o, &rbuf, 0)) {
79                 prs_mem_free(&rbuf);
80                 return False;
81         }
82
83         if (r_o.status != 0) {
84                 /* report error code */
85                 DEBUG(0,("WKS_R_QUERY_INFO: %s\n", get_nt_error_msg(r_o.status)));
86                 prs_mem_free(&rbuf);
87                 return False;
88         }
89
90         prs_mem_free(&rbuf);
91
92         return True;
93 }