r7415: * big change -- volker's new async winbindd from trunk
[abartlet/samba.git/.git] / source3 / include / rpc_client.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Gerald (Jerry) Carter         2005.
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef _RPC_CLIENT_H
22 #define _RPC_CLIENT_H
23
24 /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
25                    
26 #define CLI_DO_RPC( pcli, ctx, pipe_num, opnum, q_in, r_out, \
27                              q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
28 {       r_out.status = default_error;\
29         prs_init( &q_ps, MAX_PDU_FRAG_LEN, ctx, MARSHALL ); \
30         prs_init( &r_ps, 0, ctx, UNMARSHALL );\
31         if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
32                 if ( rpc_api_pipe_req(pcli, pipe_num, opnum, &q_ps, &r_ps) ) {\
33                         if (!r_io_fn("", &r_out, &r_ps, 0)) {\
34                                 r_out.status = default_error;\
35                         }\
36                 }\
37         }\
38         prs_mem_free( &q_ps );\
39         prs_mem_free( &r_ps );\
40 }
41
42 /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req_int() */
43
44 #define CLI_DO_RPC_EX( pcli, ctx, pipe_num, opnum, q_in, r_out, \
45                              q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
46 {       r_out.status = default_error;\
47         prs_init( &q_ps, MAX_PDU_FRAG_LEN, ctx, MARSHALL ); \
48         prs_init( &r_ps, 0, ctx, UNMARSHALL );\
49         if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
50                 if ( rpc_api_pipe_req_int(pcli, opnum, &q_ps, &r_ps) ) {\
51                         if (!r_io_fn("", &r_out, &r_ps, 0)) {\
52                                 r_out.status = default_error;\
53                         }\
54                 }\
55         }\
56         prs_mem_free( &q_ps );\
57         prs_mem_free( &r_ps );\
58 }
59
60 #endif /* _RPC_CLIENT_H */