99141bae6ce044937b4ce69378a7f63df5af5eb2
[kamenim/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  *  
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
26 #ifdef SYSLOG
27 #undef SYSLOG
28 #endif
29
30 #include "includes.h"
31
32 extern int DEBUGLEVEL;
33
34 /****************************************************************************
35 do a WKS Open Policy
36 ****************************************************************************/
37 BOOL wks_query_info( char *srv_name, uint32 switch_value,
38                         WKS_INFO_100 *wks100)
39 {
40         prs_struct rbuf;
41         prs_struct buf; 
42         WKS_Q_QUERY_INFO q_o;
43         BOOL valid_info = False;
44         struct cli_connection *con = NULL;
45
46         if (wks100 == NULL) return False;
47
48         if (!cli_connection_init(srv_name, PIPE_WKSSVC, &con))
49         {
50                 return False;
51         }
52
53         prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
54         prs_init(&rbuf, 0   , 4, SAFETY_MARGIN, True );
55
56         /* create and send a MSRPC command with api WKS_QUERY_INFO */
57
58         DEBUG(4,("WKS Query Info\n"));
59
60         /* store the parameters */
61         make_wks_q_query_info(&q_o, srv_name, switch_value);
62
63         /* turn parameters into data stream */
64         wks_io_q_query_info("", &q_o, &buf, 0);
65
66         /* send the data on \PIPE\ */
67         if (rpc_con_pipe_req(con, WKS_QUERY_INFO, &buf, &rbuf))
68         {
69                 WKS_R_QUERY_INFO r_o;
70                 BOOL p;
71
72                 r_o.wks100 = wks100;
73
74                 wks_io_r_query_info("", &r_o, &rbuf, 0);
75                 p = rbuf.offset != 0;
76
77                 if (p && r_o.status != 0)
78                 {
79                         /* report error code */
80                         DEBUG(0,("WKS_R_QUERY_INFO: %s\n", get_nt_error_msg(r_o.status)));
81                         p = False;
82                 }
83
84                 if (p)
85                 {
86                         valid_info = True;
87                 }
88         }
89
90         prs_mem_free(&rbuf);
91         prs_mem_free(&buf );
92
93         cli_connection_unlink(con);
94
95         return valid_info;
96 }
97