r10656: BIG merge from trunk. Features not copied over
[Samba/nascimento.git] / source3 / include / rpc_client.h
blob8a83c0f8ae87fc9c18e9b93977b55b989b9788ef
1 /*
2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Gerald (Jerry) Carter 2005.
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.
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.
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.
21 #ifndef _RPC_CLIENT_H
22 #define _RPC_CLIENT_H
24 /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
26 #define CLI_DO_RPC( pcli, ctx, p_idx, opnum, q_in, r_out, \
27 q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
29 SMB_ASSERT(pcli->pipe_idx == p_idx); \
30 if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
31 return NT_STATUS_NO_MEMORY;\
33 if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
34 prs_mem_free( &q_ps );\
35 return NT_STATUS_NO_MEMORY;\
37 if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
38 NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
39 if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
40 prs_mem_free( &q_ps );\
41 prs_mem_free( &r_ps );\
42 return _smb_pipe_stat_;\
44 if (!r_io_fn("", &r_out, &r_ps, 0)) {\
45 prs_mem_free( &q_ps );\
46 prs_mem_free( &r_ps );\
47 return default_error;\
49 } else {\
50 prs_mem_free( &q_ps );\
51 prs_mem_free( &r_ps );\
52 return default_error;\
54 prs_mem_free( &q_ps );\
55 prs_mem_free( &r_ps );\
58 /* Arrrgg. Same but with WERRORS. Needed for registry code. */
60 #define CLI_DO_RPC_WERR( pcli, ctx, p_idx, opnum, q_in, r_out, \
61 q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
63 SMB_ASSERT(pcli->pipe_idx == p_idx); \
64 if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
65 return WERR_NOMEM;\
67 if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
68 prs_mem_free( &q_ps );\
69 return WERR_NOMEM;\
71 if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
72 NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
73 if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
74 prs_mem_free( &q_ps );\
75 prs_mem_free( &r_ps );\
76 return ntstatus_to_werror(_smb_pipe_stat_);\
78 if (!r_io_fn("", &r_out, &r_ps, 0)) {\
79 prs_mem_free( &q_ps );\
80 prs_mem_free( &r_ps );\
81 return default_error;\
83 } else {\
84 prs_mem_free( &q_ps );\
85 prs_mem_free( &r_ps );\
86 return default_error;\
88 prs_mem_free( &q_ps );\
89 prs_mem_free( &r_ps );\
92 #endif /* _RPC_CLIENT_H */