s3:winbind: Add async wb_lookupsid
[sfrench/samba-autobuild/.git] / source3 / librpc / gen_ndr / cli_wbint.c
1 /*
2  * Unix SMB/CIFS implementation.
3  * client auto-generated by pidl. DO NOT MODIFY!
4  */
5
6 #include "includes.h"
7 #include "librpc/gen_ndr/cli_wbint.h"
8
9 struct rpccli_wbint_Ping_state {
10         struct wbint_Ping orig;
11         struct wbint_Ping tmp;
12         TALLOC_CTX *out_mem_ctx;
13         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
14 };
15
16 static void rpccli_wbint_Ping_done(struct tevent_req *subreq);
17
18 struct tevent_req *rpccli_wbint_Ping_send(TALLOC_CTX *mem_ctx,
19                                           struct tevent_context *ev,
20                                           struct rpc_pipe_client *cli,
21                                           uint32_t _in_data /* [in]  */,
22                                           uint32_t *_out_data /* [out] [ref] */)
23 {
24         struct tevent_req *req;
25         struct rpccli_wbint_Ping_state *state;
26         struct tevent_req *subreq;
27
28         req = tevent_req_create(mem_ctx, &state,
29                                 struct rpccli_wbint_Ping_state);
30         if (req == NULL) {
31                 return NULL;
32         }
33         state->out_mem_ctx = NULL;
34         state->dispatch_recv = cli->dispatch_recv;
35
36         /* In parameters */
37         state->orig.in.in_data = _in_data;
38
39         /* Out parameters */
40         state->orig.out.out_data = _out_data;
41
42         if (DEBUGLEVEL >= 10) {
43                 NDR_PRINT_IN_DEBUG(wbint_Ping, &state->orig);
44         }
45
46         state->out_mem_ctx = talloc_named_const(state, 0,
47                              "rpccli_wbint_Ping_out_memory");
48         if (tevent_req_nomem(state->out_mem_ctx, req)) {
49                 return tevent_req_post(req, ev);
50         }
51
52         /* make a temporary copy, that we pass to the dispatch function */
53         state->tmp = state->orig;
54
55         subreq = cli->dispatch_send(state, ev, cli,
56                                     &ndr_table_wbint,
57                                     NDR_WBINT_PING,
58                                     &state->tmp);
59         if (tevent_req_nomem(subreq, req)) {
60                 return tevent_req_post(req, ev);
61         }
62         tevent_req_set_callback(subreq, rpccli_wbint_Ping_done, req);
63         return req;
64 }
65
66 static void rpccli_wbint_Ping_done(struct tevent_req *subreq)
67 {
68         struct tevent_req *req = tevent_req_callback_data(
69                 subreq, struct tevent_req);
70         struct rpccli_wbint_Ping_state *state = tevent_req_data(
71                 req, struct rpccli_wbint_Ping_state);
72         NTSTATUS status;
73         TALLOC_CTX *mem_ctx;
74
75         if (state->out_mem_ctx) {
76                 mem_ctx = state->out_mem_ctx;
77         } else {
78                 mem_ctx = state;
79         }
80
81         status = state->dispatch_recv(subreq, mem_ctx);
82         TALLOC_FREE(subreq);
83         if (!NT_STATUS_IS_OK(status)) {
84                 tevent_req_nterror(req, status);
85                 return;
86         }
87
88         /* Copy out parameters */
89         *state->orig.out.out_data = *state->tmp.out.out_data;
90
91         /* Reset temporary structure */
92         ZERO_STRUCT(state->tmp);
93
94         if (DEBUGLEVEL >= 10) {
95                 NDR_PRINT_OUT_DEBUG(wbint_Ping, &state->orig);
96         }
97
98         tevent_req_done(req);
99 }
100
101 NTSTATUS rpccli_wbint_Ping_recv(struct tevent_req *req,
102                                 TALLOC_CTX *mem_ctx)
103 {
104         struct rpccli_wbint_Ping_state *state = tevent_req_data(
105                 req, struct rpccli_wbint_Ping_state);
106         NTSTATUS status;
107
108         if (tevent_req_is_nterror(req, &status)) {
109                 tevent_req_received(req);
110                 return status;
111         }
112
113         /* Steal possbile out parameters to the callers context */
114         talloc_steal(mem_ctx, state->out_mem_ctx);
115
116         tevent_req_received(req);
117         return NT_STATUS_OK;
118 }
119
120 NTSTATUS rpccli_wbint_Ping(struct rpc_pipe_client *cli,
121                            TALLOC_CTX *mem_ctx,
122                            uint32_t in_data /* [in]  */,
123                            uint32_t *out_data /* [out] [ref] */)
124 {
125         struct wbint_Ping r;
126         NTSTATUS status;
127
128         /* In parameters */
129         r.in.in_data = in_data;
130
131         if (DEBUGLEVEL >= 10) {
132                 NDR_PRINT_IN_DEBUG(wbint_Ping, &r);
133         }
134
135         status = cli->dispatch(cli,
136                                 mem_ctx,
137                                 &ndr_table_wbint,
138                                 NDR_WBINT_PING,
139                                 &r);
140
141         if (!NT_STATUS_IS_OK(status)) {
142                 return status;
143         }
144
145         if (DEBUGLEVEL >= 10) {
146                 NDR_PRINT_OUT_DEBUG(wbint_Ping, &r);
147         }
148
149         if (NT_STATUS_IS_ERR(status)) {
150                 return status;
151         }
152
153         /* Return variables */
154         *out_data = *r.out.out_data;
155
156         /* Return result */
157         return NT_STATUS_OK;
158 }
159
160 struct rpccli_wbint_LookupSid_state {
161         struct wbint_LookupSid orig;
162         struct wbint_LookupSid tmp;
163         TALLOC_CTX *out_mem_ctx;
164         NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
165 };
166
167 static void rpccli_wbint_LookupSid_done(struct tevent_req *subreq);
168
169 struct tevent_req *rpccli_wbint_LookupSid_send(TALLOC_CTX *mem_ctx,
170                                                struct tevent_context *ev,
171                                                struct rpc_pipe_client *cli,
172                                                struct dom_sid *_sid /* [in] [ref] */,
173                                                enum lsa_SidType *_type /* [out] [ref] */,
174                                                const char **_domain /* [out] [ref,charset(UTF8)] */,
175                                                const char **_name /* [out] [ref,charset(UTF8)] */)
176 {
177         struct tevent_req *req;
178         struct rpccli_wbint_LookupSid_state *state;
179         struct tevent_req *subreq;
180
181         req = tevent_req_create(mem_ctx, &state,
182                                 struct rpccli_wbint_LookupSid_state);
183         if (req == NULL) {
184                 return NULL;
185         }
186         state->out_mem_ctx = NULL;
187         state->dispatch_recv = cli->dispatch_recv;
188
189         /* In parameters */
190         state->orig.in.sid = _sid;
191
192         /* Out parameters */
193         state->orig.out.type = _type;
194         state->orig.out.domain = _domain;
195         state->orig.out.name = _name;
196
197         /* Result */
198         ZERO_STRUCT(state->orig.out.result);
199
200         if (DEBUGLEVEL >= 10) {
201                 NDR_PRINT_IN_DEBUG(wbint_LookupSid, &state->orig);
202         }
203
204         state->out_mem_ctx = talloc_named_const(state, 0,
205                              "rpccli_wbint_LookupSid_out_memory");
206         if (tevent_req_nomem(state->out_mem_ctx, req)) {
207                 return tevent_req_post(req, ev);
208         }
209
210         /* make a temporary copy, that we pass to the dispatch function */
211         state->tmp = state->orig;
212
213         subreq = cli->dispatch_send(state, ev, cli,
214                                     &ndr_table_wbint,
215                                     NDR_WBINT_LOOKUPSID,
216                                     &state->tmp);
217         if (tevent_req_nomem(subreq, req)) {
218                 return tevent_req_post(req, ev);
219         }
220         tevent_req_set_callback(subreq, rpccli_wbint_LookupSid_done, req);
221         return req;
222 }
223
224 static void rpccli_wbint_LookupSid_done(struct tevent_req *subreq)
225 {
226         struct tevent_req *req = tevent_req_callback_data(
227                 subreq, struct tevent_req);
228         struct rpccli_wbint_LookupSid_state *state = tevent_req_data(
229                 req, struct rpccli_wbint_LookupSid_state);
230         NTSTATUS status;
231         TALLOC_CTX *mem_ctx;
232
233         if (state->out_mem_ctx) {
234                 mem_ctx = state->out_mem_ctx;
235         } else {
236                 mem_ctx = state;
237         }
238
239         status = state->dispatch_recv(subreq, mem_ctx);
240         TALLOC_FREE(subreq);
241         if (!NT_STATUS_IS_OK(status)) {
242                 tevent_req_nterror(req, status);
243                 return;
244         }
245
246         /* Copy out parameters */
247         *state->orig.out.type = *state->tmp.out.type;
248         *state->orig.out.domain = *state->tmp.out.domain;
249         *state->orig.out.name = *state->tmp.out.name;
250
251         /* Copy result */
252         state->orig.out.result = state->tmp.out.result;
253
254         /* Reset temporary structure */
255         ZERO_STRUCT(state->tmp);
256
257         if (DEBUGLEVEL >= 10) {
258                 NDR_PRINT_OUT_DEBUG(wbint_LookupSid, &state->orig);
259         }
260
261         tevent_req_done(req);
262 }
263
264 NTSTATUS rpccli_wbint_LookupSid_recv(struct tevent_req *req,
265                                      TALLOC_CTX *mem_ctx,
266                                      NTSTATUS *result)
267 {
268         struct rpccli_wbint_LookupSid_state *state = tevent_req_data(
269                 req, struct rpccli_wbint_LookupSid_state);
270         NTSTATUS status;
271
272         if (tevent_req_is_nterror(req, &status)) {
273                 tevent_req_received(req);
274                 return status;
275         }
276
277         /* Steal possbile out parameters to the callers context */
278         talloc_steal(mem_ctx, state->out_mem_ctx);
279
280         /* Return result */
281         *result = state->orig.out.result;
282
283         tevent_req_received(req);
284         return NT_STATUS_OK;
285 }
286
287 NTSTATUS rpccli_wbint_LookupSid(struct rpc_pipe_client *cli,
288                                 TALLOC_CTX *mem_ctx,
289                                 struct dom_sid *sid /* [in] [ref] */,
290                                 enum lsa_SidType *type /* [out] [ref] */,
291                                 const char **domain /* [out] [ref,charset(UTF8)] */,
292                                 const char **name /* [out] [ref,charset(UTF8)] */)
293 {
294         struct wbint_LookupSid r;
295         NTSTATUS status;
296
297         /* In parameters */
298         r.in.sid = sid;
299
300         if (DEBUGLEVEL >= 10) {
301                 NDR_PRINT_IN_DEBUG(wbint_LookupSid, &r);
302         }
303
304         status = cli->dispatch(cli,
305                                 mem_ctx,
306                                 &ndr_table_wbint,
307                                 NDR_WBINT_LOOKUPSID,
308                                 &r);
309
310         if (!NT_STATUS_IS_OK(status)) {
311                 return status;
312         }
313
314         if (DEBUGLEVEL >= 10) {
315                 NDR_PRINT_OUT_DEBUG(wbint_LookupSid, &r);
316         }
317
318         if (NT_STATUS_IS_ERR(status)) {
319                 return status;
320         }
321
322         /* Return variables */
323         *type = *r.out.type;
324         *domain = *r.out.domain;
325         *name = *r.out.name;
326
327         /* Return result */
328         return r.out.result;
329 }
330