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