git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / librpc / gen_ndr / ndr_backupkey_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/librpc/gen_ndr/ndr_backupkey.h"
7 #include "bin/default/librpc/gen_ndr/ndr_backupkey_c.h"
8
9 /* backupkey - client functions generated by pidl */
10
11 struct dcerpc_bkrp_BackupKey_r_state {
12         TALLOC_CTX *out_mem_ctx;
13 };
14
15 static void dcerpc_bkrp_BackupKey_r_done(struct tevent_req *subreq);
16
17 struct tevent_req *dcerpc_bkrp_BackupKey_r_send(TALLOC_CTX *mem_ctx,
18         struct tevent_context *ev,
19         struct dcerpc_binding_handle *h,
20         struct bkrp_BackupKey *r)
21 {
22         struct tevent_req *req;
23         struct dcerpc_bkrp_BackupKey_r_state *state;
24         struct tevent_req *subreq;
25
26         req = tevent_req_create(mem_ctx, &state,
27                                 struct dcerpc_bkrp_BackupKey_r_state);
28         if (req == NULL) {
29                 return NULL;
30         }
31
32         state->out_mem_ctx = talloc_new(state);
33         if (tevent_req_nomem(state->out_mem_ctx, req)) {
34                 return tevent_req_post(req, ev);
35         }
36
37         subreq = dcerpc_binding_handle_call_send(state, ev, h,
38                         NULL, &ndr_table_backupkey,
39                         NDR_BKRP_BACKUPKEY, state->out_mem_ctx, r);
40         if (tevent_req_nomem(subreq, req)) {
41                 return tevent_req_post(req, ev);
42         }
43         tevent_req_set_callback(subreq, dcerpc_bkrp_BackupKey_r_done, req);
44
45         return req;
46 }
47
48 static void dcerpc_bkrp_BackupKey_r_done(struct tevent_req *subreq)
49 {
50         struct tevent_req *req =
51                 tevent_req_callback_data(subreq,
52                 struct tevent_req);
53         NTSTATUS status;
54
55         status = dcerpc_binding_handle_call_recv(subreq);
56         TALLOC_FREE(subreq);
57         if (tevent_req_nterror(req, status)) {
58                 return;
59         }
60
61         tevent_req_done(req);
62 }
63
64 NTSTATUS dcerpc_bkrp_BackupKey_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
65 {
66         struct dcerpc_bkrp_BackupKey_r_state *state =
67                 tevent_req_data(req,
68                 struct dcerpc_bkrp_BackupKey_r_state);
69         NTSTATUS status;
70
71         if (tevent_req_is_nterror(req, &status)) {
72                 tevent_req_received(req);
73                 return status;
74         }
75
76         talloc_steal(mem_ctx, state->out_mem_ctx);
77
78         tevent_req_received(req);
79         return NT_STATUS_OK;
80 }
81
82 NTSTATUS dcerpc_bkrp_BackupKey_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct bkrp_BackupKey *r)
83 {
84         NTSTATUS status;
85
86         status = dcerpc_binding_handle_call(h,
87                         NULL, &ndr_table_backupkey,
88                         NDR_BKRP_BACKUPKEY, mem_ctx, r);
89
90         return status;
91 }
92
93 struct dcerpc_bkrp_BackupKey_state {
94         struct bkrp_BackupKey orig;
95         struct bkrp_BackupKey tmp;
96         TALLOC_CTX *out_mem_ctx;
97 };
98
99 static void dcerpc_bkrp_BackupKey_done(struct tevent_req *subreq);
100
101 struct tevent_req *dcerpc_bkrp_BackupKey_send(TALLOC_CTX *mem_ctx,
102                                               struct tevent_context *ev,
103                                               struct dcerpc_binding_handle *h,
104                                               struct GUID *_guidActionAgent /* [in] [ref] */,
105                                               uint8_t *_data_in /* [in] [ref,size_is(data_in_len)] */,
106                                               uint32_t _data_in_len /* [in]  */,
107                                               uint8_t **_data_out /* [out] [ref,size_is(,*data_out_len)] */,
108                                               uint32_t *_data_out_len /* [out] [ref] */,
109                                               uint32_t _param /* [in]  */)
110 {
111         struct tevent_req *req;
112         struct dcerpc_bkrp_BackupKey_state *state;
113         struct tevent_req *subreq;
114
115         req = tevent_req_create(mem_ctx, &state,
116                                 struct dcerpc_bkrp_BackupKey_state);
117         if (req == NULL) {
118                 return NULL;
119         }
120         state->out_mem_ctx = NULL;
121
122         /* In parameters */
123         state->orig.in.guidActionAgent = _guidActionAgent;
124         state->orig.in.data_in = _data_in;
125         state->orig.in.data_in_len = _data_in_len;
126         state->orig.in.param = _param;
127
128         /* Out parameters */
129         state->orig.out.data_out = _data_out;
130         state->orig.out.data_out_len = _data_out_len;
131
132         /* Result */
133         ZERO_STRUCT(state->orig.out.result);
134
135         state->out_mem_ctx = talloc_named_const(state, 0,
136                              "dcerpc_bkrp_BackupKey_out_memory");
137         if (tevent_req_nomem(state->out_mem_ctx, req)) {
138                 return tevent_req_post(req, ev);
139         }
140
141         /* make a temporary copy, that we pass to the dispatch function */
142         state->tmp = state->orig;
143
144         subreq = dcerpc_bkrp_BackupKey_r_send(state, ev, h, &state->tmp);
145         if (tevent_req_nomem(subreq, req)) {
146                 return tevent_req_post(req, ev);
147         }
148         tevent_req_set_callback(subreq, dcerpc_bkrp_BackupKey_done, req);
149         return req;
150 }
151
152 static void dcerpc_bkrp_BackupKey_done(struct tevent_req *subreq)
153 {
154         struct tevent_req *req = tevent_req_callback_data(
155                 subreq, struct tevent_req);
156         struct dcerpc_bkrp_BackupKey_state *state = tevent_req_data(
157                 req, struct dcerpc_bkrp_BackupKey_state);
158         NTSTATUS status;
159         TALLOC_CTX *mem_ctx;
160
161         if (state->out_mem_ctx) {
162                 mem_ctx = state->out_mem_ctx;
163         } else {
164                 mem_ctx = state;
165         }
166
167         status = dcerpc_bkrp_BackupKey_r_recv(subreq, mem_ctx);
168         TALLOC_FREE(subreq);
169         if (tevent_req_nterror(req, status)) {
170                 return;
171         }
172
173         /* Copy out parameters */
174         *state->orig.out.data_out = *state->tmp.out.data_out;
175         *state->orig.out.data_out_len = *state->tmp.out.data_out_len;
176
177         /* Copy result */
178         state->orig.out.result = state->tmp.out.result;
179
180         /* Reset temporary structure */
181         ZERO_STRUCT(state->tmp);
182
183         tevent_req_done(req);
184 }
185
186 NTSTATUS dcerpc_bkrp_BackupKey_recv(struct tevent_req *req,
187                                     TALLOC_CTX *mem_ctx,
188                                     WERROR *result)
189 {
190         struct dcerpc_bkrp_BackupKey_state *state = tevent_req_data(
191                 req, struct dcerpc_bkrp_BackupKey_state);
192         NTSTATUS status;
193
194         if (tevent_req_is_nterror(req, &status)) {
195                 tevent_req_received(req);
196                 return status;
197         }
198
199         /* Steal possible out parameters to the callers context */
200         talloc_steal(mem_ctx, state->out_mem_ctx);
201
202         /* Return result */
203         *result = state->orig.out.result;
204
205         tevent_req_received(req);
206         return NT_STATUS_OK;
207 }
208
209 NTSTATUS dcerpc_bkrp_BackupKey(struct dcerpc_binding_handle *h,
210                                TALLOC_CTX *mem_ctx,
211                                struct GUID *_guidActionAgent /* [in] [ref] */,
212                                uint8_t *_data_in /* [in] [ref,size_is(data_in_len)] */,
213                                uint32_t _data_in_len /* [in]  */,
214                                uint8_t **_data_out /* [out] [ref,size_is(,*data_out_len)] */,
215                                uint32_t *_data_out_len /* [out] [ref] */,
216                                uint32_t _param /* [in]  */,
217                                WERROR *result)
218 {
219         struct bkrp_BackupKey r;
220         NTSTATUS status;
221
222         /* In parameters */
223         r.in.guidActionAgent = _guidActionAgent;
224         r.in.data_in = _data_in;
225         r.in.data_in_len = _data_in_len;
226         r.in.param = _param;
227
228         status = dcerpc_bkrp_BackupKey_r(h, mem_ctx, &r);
229         if (!NT_STATUS_IS_OK(status)) {
230                 return status;
231         }
232
233         /* Return variables */
234         *_data_out = *r.out.data_out;
235         *_data_out_len = *r.out.data_out_len;
236
237         /* Return result */
238         *result = r.out.result;
239
240         return NT_STATUS_OK;
241 }
242