git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / source4 / librpc / gen_ndr / ndr_winsrepl_c.c
1 /* client functions auto-generated by pidl */
2
3 #include "includes.h"
4 #include <tevent.h>
5 #include "lib/util/tevent_ntstatus.h"
6 #include "bin/default/source4/librpc/gen_ndr/ndr_winsrepl.h"
7 #include "bin/default/source4/librpc/gen_ndr/ndr_winsrepl_c.h"
8
9 /* wrepl - client functions generated by pidl */
10
11 struct dcerpc_decode_winsrepl_r_state {
12         TALLOC_CTX *out_mem_ctx;
13 };
14
15 static void dcerpc_decode_winsrepl_r_done(struct tevent_req *subreq);
16
17 struct tevent_req *dcerpc_decode_winsrepl_r_send(TALLOC_CTX *mem_ctx,
18         struct tevent_context *ev,
19         struct dcerpc_binding_handle *h,
20         struct decode_winsrepl *r)
21 {
22         struct tevent_req *req;
23         struct dcerpc_decode_winsrepl_r_state *state;
24         struct tevent_req *subreq;
25
26         req = tevent_req_create(mem_ctx, &state,
27                                 struct dcerpc_decode_winsrepl_r_state);
28         if (req == NULL) {
29                 return NULL;
30         }
31
32         state->out_mem_ctx = NULL;
33
34         subreq = dcerpc_binding_handle_call_send(state, ev, h,
35                         NULL, &ndr_table_wrepl,
36                         NDR_DECODE_WINSREPL, state, r);
37         if (tevent_req_nomem(subreq, req)) {
38                 return tevent_req_post(req, ev);
39         }
40         tevent_req_set_callback(subreq, dcerpc_decode_winsrepl_r_done, req);
41
42         return req;
43 }
44
45 static void dcerpc_decode_winsrepl_r_done(struct tevent_req *subreq)
46 {
47         struct tevent_req *req =
48                 tevent_req_callback_data(subreq,
49                 struct tevent_req);
50         NTSTATUS status;
51
52         status = dcerpc_binding_handle_call_recv(subreq);
53         TALLOC_FREE(subreq);
54         if (tevent_req_nterror(req, status)) {
55                 return;
56         }
57
58         tevent_req_done(req);
59 }
60
61 NTSTATUS dcerpc_decode_winsrepl_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
62 {
63         struct dcerpc_decode_winsrepl_r_state *state =
64                 tevent_req_data(req,
65                 struct dcerpc_decode_winsrepl_r_state);
66         NTSTATUS status;
67
68         if (tevent_req_is_nterror(req, &status)) {
69                 tevent_req_received(req);
70                 return status;
71         }
72
73         talloc_steal(mem_ctx, state->out_mem_ctx);
74
75         tevent_req_received(req);
76         return NT_STATUS_OK;
77 }
78
79 NTSTATUS dcerpc_decode_winsrepl_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct decode_winsrepl *r)
80 {
81         NTSTATUS status;
82
83         status = dcerpc_binding_handle_call(h,
84                         NULL, &ndr_table_wrepl,
85                         NDR_DECODE_WINSREPL, mem_ctx, r);
86
87         return status;
88 }
89
90 struct dcerpc_decode_winsrepl_state {
91         struct decode_winsrepl orig;
92         struct decode_winsrepl tmp;
93         TALLOC_CTX *out_mem_ctx;
94 };
95
96 static void dcerpc_decode_winsrepl_done(struct tevent_req *subreq);
97
98 struct tevent_req *dcerpc_decode_winsrepl_send(TALLOC_CTX *mem_ctx,
99                                                struct tevent_context *ev,
100                                                struct dcerpc_binding_handle *h,
101                                                struct wrepl_wrap _p /* [in]  */)
102 {
103         struct tevent_req *req;
104         struct dcerpc_decode_winsrepl_state *state;
105         struct tevent_req *subreq;
106
107         req = tevent_req_create(mem_ctx, &state,
108                                 struct dcerpc_decode_winsrepl_state);
109         if (req == NULL) {
110                 return NULL;
111         }
112         state->out_mem_ctx = NULL;
113
114         /* In parameters */
115         state->orig.in.p = _p;
116
117         /* Out parameters */
118
119         /* make a temporary copy, that we pass to the dispatch function */
120         state->tmp = state->orig;
121
122         subreq = dcerpc_decode_winsrepl_r_send(state, ev, h, &state->tmp);
123         if (tevent_req_nomem(subreq, req)) {
124                 return tevent_req_post(req, ev);
125         }
126         tevent_req_set_callback(subreq, dcerpc_decode_winsrepl_done, req);
127         return req;
128 }
129
130 static void dcerpc_decode_winsrepl_done(struct tevent_req *subreq)
131 {
132         struct tevent_req *req = tevent_req_callback_data(
133                 subreq, struct tevent_req);
134         struct dcerpc_decode_winsrepl_state *state = tevent_req_data(
135                 req, struct dcerpc_decode_winsrepl_state);
136         NTSTATUS status;
137         TALLOC_CTX *mem_ctx;
138
139         if (state->out_mem_ctx) {
140                 mem_ctx = state->out_mem_ctx;
141         } else {
142                 mem_ctx = state;
143         }
144
145         status = dcerpc_decode_winsrepl_r_recv(subreq, mem_ctx);
146         TALLOC_FREE(subreq);
147         if (tevent_req_nterror(req, status)) {
148                 return;
149         }
150
151         /* Copy out parameters */
152
153         /* Reset temporary structure */
154         ZERO_STRUCT(state->tmp);
155
156         tevent_req_done(req);
157 }
158
159 NTSTATUS dcerpc_decode_winsrepl_recv(struct tevent_req *req,
160                                      TALLOC_CTX *mem_ctx)
161 {
162         struct dcerpc_decode_winsrepl_state *state = tevent_req_data(
163                 req, struct dcerpc_decode_winsrepl_state);
164         NTSTATUS status;
165
166         if (tevent_req_is_nterror(req, &status)) {
167                 tevent_req_received(req);
168                 return status;
169         }
170
171         /* Steal possible out parameters to the callers context */
172         talloc_steal(mem_ctx, state->out_mem_ctx);
173
174         tevent_req_received(req);
175         return NT_STATUS_OK;
176 }
177
178 NTSTATUS dcerpc_decode_winsrepl(struct dcerpc_binding_handle *h,
179                                 TALLOC_CTX *mem_ctx,
180                                 struct wrepl_wrap _p /* [in]  */)
181 {
182         struct decode_winsrepl r;
183         NTSTATUS status;
184
185         /* In parameters */
186         r.in.p = _p;
187
188         status = dcerpc_decode_winsrepl_r(h, mem_ctx, &r);
189         if (!NT_STATUS_IS_OK(status)) {
190                 return status;
191         }
192
193         /* Return variables */
194
195         /* Return result */
196
197         return NT_STATUS_OK;
198 }
199