Fix duplicate define for named properties
[jelmer/openchange.git] / ndr_mapi.c
1 /* 
2    OpenChange implementation.
3
4    libndr mapi support
5
6    Copyright (C) Julien Kerihuel 2005-2010
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "libmapi/libmapi.h"
23 #include "libmapi/libmapi_private.h"
24 #include <ndr.h>
25 #include "gen_ndr/ndr_exchange.h"
26
27 #define MIN(a,b) ((a)<(b)?(a):(b))
28
29 _PUBLIC_ void obfuscate_data(uint8_t *data, uint32_t size, uint8_t salt)
30 {
31         uint32_t i;
32
33         for (i=0; i<size; i++) {
34                 data[i] ^= salt;
35         }
36 }
37
38 ssize_t lzxpress_compress(const uint8_t *input,
39                           uint32_t input_size,
40                           uint8_t *output,
41                           uint32_t max_output_size);
42
43 ssize_t lzxpress_decompress(const uint8_t *input,
44                             uint32_t input_size,
45                             uint8_t *output,
46                             uint32_t max_output_size);
47
48 /**
49    \details Compress a LZXPRESS chunk
50
51    \param ndrpush pointer to the compressed data to return
52    \param ndrpull pointer to the uncompressed data used for compression
53    \param last pointer on boolean to define whether or not this is the
54    last chunk
55
56    \return NDR_ERR_SUCCESS on success, otherwise NDR error
57  */
58 static enum ndr_err_code ndr_push_lxpress_chunk(struct ndr_push *ndrpush,
59                                                 struct ndr_pull *ndrpull,
60                                                 bool *last)
61 {
62         DATA_BLOB       comp_chunk;
63         DATA_BLOB       plain_chunk;
64         uint32_t        plain_chunk_size;
65         uint32_t        plain_chunk_offset;
66         uint32_t        max_plain_size = 0x00010000;
67         uint32_t        max_comp_size = 0x00020000 + 2; /* TODO: use the correct value here */
68         ssize_t         ret;
69
70         /* Step 1. Retrieve the uncompressed buf */
71         plain_chunk_size = MIN(max_plain_size, ndrpull->data_size - ndrpull->offset);
72         plain_chunk_offset = ndrpull->offset;
73         NDR_CHECK(ndr_pull_advance(ndrpull, plain_chunk_size));
74
75         plain_chunk.data = ndrpull->data + plain_chunk_offset;
76         plain_chunk.length = plain_chunk_size;
77         
78         if (plain_chunk_size < max_plain_size) {
79                 *last = true;
80         };
81
82         NDR_CHECK(ndr_push_expand(ndrpush, max_comp_size));
83
84         comp_chunk.data = ndrpush->data + ndrpush->offset;
85         comp_chunk.length = max_comp_size;
86
87         /* Compressing the buffer using LZ Xpress algorithm */
88         ret = lzxpress_compress(plain_chunk.data,
89                                 plain_chunk.length,
90                                 comp_chunk.data,
91                                 comp_chunk.length);
92
93         if (ret < 0) {
94                 return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION,
95                                       "XPRESS lzxpress_compress() returned %d\n",
96                                       (int)ret);
97         }
98         comp_chunk.length = ret;
99
100         ndrpush->offset += comp_chunk.length;
101         return NDR_ERR_SUCCESS;
102 }
103
104 static enum ndr_err_code ndr_pull_lxpress_chunk(struct ndr_pull *ndrpull,
105                                                 struct ndr_push *ndrpush,
106                                                 ssize_t decompressed_len,
107                                                 bool *last)
108 {
109         DATA_BLOB       comp_chunk;
110         DATA_BLOB       plain_chunk;
111         uint32_t        plain_chunk_offset;
112         int             ret;
113
114         /* Step 1. Retrieve the compressed buf */
115         comp_chunk.length = ndrpull->data_size;
116         comp_chunk.data = ndrpull->data;
117
118         plain_chunk_offset = ndrpush->offset;
119         NDR_CHECK(ndr_push_zero(ndrpush, decompressed_len));
120         plain_chunk.length = decompressed_len;
121         plain_chunk.data = ndrpush->data + plain_chunk_offset;
122
123         ret = lzxpress_decompress(comp_chunk.data,
124                                   comp_chunk.length,
125                                   plain_chunk.data,
126                                   plain_chunk.length);
127         if (ret < 0) {
128                 return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION,
129                                       "XPRESS lzxpress_decompress() returned %d\n",
130                                       (int)ret);
131         }
132         plain_chunk.length = ret;
133         ndrpush->offset = ret;
134
135         if ((decompressed_len < 0x00010000) || (ndrpull->offset+4 >= ndrpull->data_size)) {
136                 /* this is the last chunk */
137                 *last = true;
138         }
139
140         return NDR_ERR_SUCCESS;
141 }
142
143 _PUBLIC_ enum ndr_err_code ndr_pull_lzxpress_decompress(struct ndr_pull *subndr,
144                                                         struct ndr_pull **_comndr,
145                                                         ssize_t decompressed_len)
146 {
147         struct ndr_push *ndrpush;
148         struct ndr_pull *comndr;
149         DATA_BLOB       uncompressed;
150         bool            last = false;
151
152         ndrpush = ndr_push_init_ctx(subndr);
153         NDR_ERR_HAVE_NO_MEMORY(ndrpush);
154
155         while (!last) {
156                 NDR_CHECK(ndr_pull_lxpress_chunk(subndr, ndrpush, decompressed_len, &last));
157         }
158
159         uncompressed = ndr_push_blob(ndrpush);
160         if (uncompressed.length != decompressed_len) {
161                 return ndr_pull_error(subndr, NDR_ERR_COMPRESSION,
162                                       "Bad uncompressed_len [%u] != [%u](0x%08X) (PULL)",
163                                       (int)uncompressed.length,
164                                       (int)decompressed_len,
165                                       (int)decompressed_len);
166         }
167
168         comndr = talloc_zero(subndr, struct ndr_pull);
169         NDR_ERR_HAVE_NO_MEMORY(comndr);
170         comndr->flags = subndr->flags;
171         comndr->current_mem_ctx = subndr->current_mem_ctx;
172         comndr->data = uncompressed.data;
173         comndr->data_size = uncompressed.length;
174         comndr->offset = 0;
175
176         *_comndr = comndr;
177         return NDR_ERR_SUCCESS;
178 }
179
180 /**
181    \details Push a compressed LZXPRESS blob
182
183    \param subndr pointer to the compressed blob the function returns
184    \param _uncomndr pointer on pointer to the uncompressed DATA blob
185
186    \return NDR_ERR_SUCCESS on success, otherwise NDR error
187  */
188 _PUBLIC_ enum ndr_err_code ndr_push_lzxpress_compress(struct ndr_push *subndr,
189                                                       struct ndr_push *uncomndr)
190 {
191         struct ndr_pull *ndrpull;
192         bool            last = false;
193
194         ndrpull = talloc_zero(uncomndr, struct ndr_pull);
195         NDR_ERR_HAVE_NO_MEMORY(ndrpull);
196         ndrpull->flags = uncomndr->flags;
197         ndrpull->data = uncomndr->data;
198         ndrpull->data_size = uncomndr->offset;
199         ndrpull->offset = 0;
200
201         while (!last) {
202                 NDR_CHECK(ndr_push_lxpress_chunk(subndr, ndrpull, &last));
203         }
204
205         return NDR_ERR_SUCCESS;
206 }
207
208
209 _PUBLIC_ enum ndr_err_code ndr_pull_mapi2k7_request(struct ndr_pull *ndr, int ndr_flags, struct mapi2k7_request *r)
210 {
211         if (ndr_flags & NDR_SCALARS) {
212                 NDR_CHECK(ndr_pull_align(ndr, 4));
213                 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr, NDR_SCALARS, &r->header));
214                 {
215                         uint32_t _flags_save_mapi_request = ndr->flags;
216                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING|LIBNDR_FLAG_NOALIGN);
217                         {
218                                 struct ndr_pull *_ndr_buffer;
219
220                                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
221                                         NDR_PULL_ALLOC(ndr, r->mapi_request);
222                                 }
223
224                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_buffer, 0, -1));
225                                 {
226                                         if (r->header.Flags & RHEF_Compressed) {
227                                                 struct ndr_pull *_ndr_data_compressed = NULL;
228
229                                                 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer, &_ndr_data_compressed, r->header.SizeActual));
230                                                 NDR_CHECK(ndr_pull_mapi_request(_ndr_data_compressed, NDR_SCALARS|NDR_BUFFERS, r->mapi_request));
231                                         } else if (r->header.Flags & RHEF_XorMagic) {
232                                                 obfuscate_data(_ndr_buffer->data, _ndr_buffer->data_size, 0xA5);
233                                                 NDR_CHECK(ndr_pull_mapi_request(_ndr_buffer, NDR_SCALARS|NDR_BUFFERS, r->mapi_request));
234                                         } else {
235                                                 NDR_CHECK(ndr_pull_mapi_request(_ndr_buffer, NDR_SCALARS|NDR_BUFFERS, r->mapi_request));
236                                                 
237                                         }
238                                 }
239                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_buffer, 0, -1));
240                         }
241                         ndr->flags = _flags_save_mapi_request;
242                 }
243         }
244
245         return NDR_ERR_SUCCESS;
246 }
247
248
249 _PUBLIC_ enum ndr_err_code ndr_pull_mapi2k7_response(struct ndr_pull *ndr, int ndr_flags, struct mapi2k7_response *r)
250 {
251         if (ndr_flags & NDR_SCALARS) {
252                 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr, NDR_SCALARS, &r->header));
253                 {
254                         uint32_t _flags_save_mapi_response = ndr->flags;
255                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_REMAINING);
256                         {
257                                 struct ndr_pull *_ndr_buffer;
258                                 
259                                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
260                                         NDR_PULL_ALLOC(ndr, r->mapi_response);
261                                 }
262                                 
263                                 NDR_CHECK((ndr_pull_subcontext_start(ndr, &_ndr_buffer, 0, r->header.Size)));
264                                 {
265                                         if (r->header.Flags & RHEF_Compressed) {
266                                                 struct ndr_pull *_ndr_data_compressed = NULL;
267                                                 
268                                                 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer, &_ndr_data_compressed, r->header.SizeActual));
269                                                 NDR_CHECK(ndr_pull_mapi_response(_ndr_data_compressed, NDR_SCALARS|NDR_BUFFERS, r->mapi_response));
270                                         } else if (r->header.Flags & RHEF_XorMagic) {
271                                                 obfuscate_data(_ndr_buffer->data, _ndr_buffer->data_size, 0xA5);
272                                                 NDR_CHECK(ndr_pull_mapi_response(_ndr_buffer, NDR_SCALARS|NDR_BUFFERS, r->mapi_response));
273                                         } else {
274                                                 NDR_CHECK(ndr_pull_mapi_response(_ndr_buffer, NDR_SCALARS|NDR_BUFFERS, r->mapi_response));                      
275                                         }
276                                 }
277                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_buffer, 0, r->header.Size));
278                         }
279                         ndr->flags = _flags_save_mapi_response;
280                 }
281         }
282
283         return NDR_ERR_SUCCESS;
284 }
285
286
287 _PUBLIC_ void ndr_print_AUX_HEADER(struct ndr_print *ndr, const char *name, const struct AUX_HEADER *r)
288 {
289         ndr_print_struct(ndr, name, "AUX_HEADER");
290         {
291                 uint32_t _flags_save_STRUCT = ndr->flags;
292                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
293                 ndr->depth++;
294                 ndr_print_uint16(ndr, "Size", r->Size);
295                 ndr_print_AUX_VERSION(ndr, "Version", r->Version);
296
297                 switch (r->Version) {
298                 case AUX_VERSION_1:
299                         ndr_print_AUX_HEADER_TYPE_1(ndr, "Type", (enum AUX_HEADER_TYPE_1) r->Type);
300                         ndr_print_set_switch_value(ndr, &r->Payload_1, r->Type);
301                         ndr_print_AUX_HEADER_TYPE_UNION_1(ndr, "Payload", &r->Payload_1);
302                         break;
303                 case AUX_VERSION_2:
304                         ndr_print_AUX_HEADER_TYPE_2(ndr, "Type", (enum AUX_HEADER_TYPE_2) r->Type);
305                         ndr_print_set_switch_value(ndr, &r->Payload_2, r->Type);
306                         ndr_print_AUX_HEADER_TYPE_UNION_2(ndr, "Payload", &r->Payload_2);
307                 }
308                 ndr->depth--;
309                 ndr->flags = _flags_save_STRUCT;
310         }
311 }
312
313
314 _PUBLIC_ enum ndr_err_code ndr_pull_AUX_HEADER(struct ndr_pull *ndr, int ndr_flags, struct AUX_HEADER *r)
315 {
316         struct ndr_pull *_ndr_buffer;
317         uint32_t        _flags_save_STRUCT = ndr->flags;
318
319         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
320         if (ndr_flags & NDR_SCALARS) {
321                 NDR_CHECK(ndr_pull_align(ndr, 4));
322                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->Size));
323
324                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_buffer, 0, r->Size - 2));
325                 {
326                         NDR_CHECK(ndr_pull_AUX_VERSION(_ndr_buffer, NDR_SCALARS, &r->Version));
327                         NDR_CHECK(ndr_pull_uint8(_ndr_buffer, NDR_SCALARS, &r->Type));
328                         switch (r->Version) {
329                         case AUX_VERSION_1:
330                                 NDR_CHECK(ndr_pull_set_switch_value(_ndr_buffer, &r->Payload_1, r->Type));
331                                 NDR_CHECK(ndr_pull_AUX_HEADER_TYPE_UNION_1(_ndr_buffer, NDR_SCALARS, &r->Payload_1));
332                                 break;
333                         case AUX_VERSION_2:
334                                 NDR_CHECK(ndr_pull_set_switch_value(_ndr_buffer, &r->Payload_2, r->Type));
335                                 NDR_CHECK(ndr_pull_AUX_HEADER_TYPE_UNION_2(_ndr_buffer, NDR_SCALARS, &r->Payload_2));
336                                 break;
337                         }
338                 }
339                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_buffer, 0, -1));
340         }
341         if (ndr_flags & NDR_BUFFERS) {
342         }
343         ndr->flags = _flags_save_STRUCT;
344
345         return NDR_ERR_SUCCESS;
346 }
347
348
349 _PUBLIC_ void ndr_print_mapi2k7_AuxInfo(struct ndr_print *ndr, const char *name, const struct mapi2k7_AuxInfo *r)
350 {
351         uint32_t        i;
352
353         if (r && r->AUX_HEADER) {
354                 ndr_print_struct(ndr, name, "mapi2k7_AuxInfo");
355                 ndr->depth++;
356                 ndr_print_RPC_HEADER_EXT(ndr, "RPC_HEADER_EXT", &r->RPC_HEADER_EXT);
357                 for (i = 0; r->AUX_HEADER[i].Size; i++) {
358                         ndr_print_AUX_HEADER(ndr, "AUX_HEADER", &r->AUX_HEADER[i]);
359                 }
360                 ndr->depth--;
361         } else {
362                 ndr_print_pointer(ndr, "mapi2k7_AuxInfo", NULL);
363         }
364 }
365
366
367 _PUBLIC_ enum ndr_err_code ndr_pull_mapi2k7_AuxInfo(struct ndr_pull *ndr, int ndr_flags, struct mapi2k7_AuxInfo *r)
368 {
369         if (ndr_flags & NDR_SCALARS) {
370
371                 /* Sanity Checks */
372                 if (!ndr->data_size) {
373                         r->AUX_HEADER = NULL;
374                         return NDR_ERR_SUCCESS;
375                 }
376
377                 NDR_CHECK(ndr_pull_align(ndr, 4));
378                 NDR_CHECK(ndr_pull_RPC_HEADER_EXT(ndr, NDR_SCALARS, &r->RPC_HEADER_EXT));
379                 {
380                         uint32_t _flags_save_DATA_BLOB = ndr->flags;
381                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_REMAINING);
382                         if (r->RPC_HEADER_EXT.Size) {
383                                 struct ndr_pull *_ndr_buffer;
384                                 TALLOC_CTX      *_mem_save_AUX_HEADER_0;
385                                 uint32_t        cntr_AUX_HEADER_0 = 0;
386
387                                 _mem_save_AUX_HEADER_0 = NDR_PULL_GET_MEM_CTX(ndr);
388
389                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_buffer, 0, r->RPC_HEADER_EXT.Size));
390                                 {
391                                         r->AUX_HEADER = talloc_array(_mem_save_AUX_HEADER_0, struct AUX_HEADER, 2);
392
393                                         /* lzxpress case */
394                                         if (r->RPC_HEADER_EXT.Flags & RHEF_Compressed) {
395                                                 struct ndr_pull *_ndr_data_compressed = NULL;
396
397                                                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
398                                                 NDR_CHECK(ndr_pull_lzxpress_decompress(_ndr_buffer, &_ndr_data_compressed, r->RPC_HEADER_EXT.SizeActual));
399                                                 
400                                                 for (cntr_AUX_HEADER_0 = 0; _ndr_data_compressed->offset < _ndr_data_compressed->data_size; cntr_AUX_HEADER_0++) {
401                                                         NDR_CHECK(ndr_pull_AUX_HEADER(_ndr_data_compressed, NDR_SCALARS, &r->AUX_HEADER[cntr_AUX_HEADER_0]));
402                                                         r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
403                                                 }
404                                                 r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
405                                                 r->AUX_HEADER[cntr_AUX_HEADER_0].Size = 0;
406                                                 
407                                         /* obfuscation case */
408                                         } else if (r->RPC_HEADER_EXT.Flags & RHEF_XorMagic) {
409                                                 obfuscate_data(_ndr_buffer->data, _ndr_buffer->data_size, 0xA5);
410
411                                                 for (cntr_AUX_HEADER_0 = 0; _ndr_buffer->offset < _ndr_buffer->data_size; cntr_AUX_HEADER_0++) {
412                                                         NDR_CHECK(ndr_pull_AUX_HEADER(_ndr_buffer, NDR_SCALARS, &r->AUX_HEADER[cntr_AUX_HEADER_0]));
413                                                         r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
414                                                 }
415                                                 r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
416                                                 r->AUX_HEADER[cntr_AUX_HEADER_0].Size = 0;
417                                         /* plain case */
418                                         } else {
419                                                 for (cntr_AUX_HEADER_0 = 0; _ndr_buffer->offset < _ndr_buffer->data_size; cntr_AUX_HEADER_0++) {
420                                                         NDR_CHECK(ndr_pull_AUX_HEADER(_ndr_buffer, NDR_SCALARS, &r->AUX_HEADER[cntr_AUX_HEADER_0]));
421                                                         r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
422                                                 }
423                                                 r->AUX_HEADER = talloc_realloc(_mem_save_AUX_HEADER_0, r->AUX_HEADER, struct AUX_HEADER, cntr_AUX_HEADER_0 + 2);
424                                                 r->AUX_HEADER[cntr_AUX_HEADER_0].Size = 0;
425                                         }
426                                 }
427                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_buffer, 0, -1));
428                         } else {
429                                 r->AUX_HEADER = NULL;
430                         }
431                         ndr->flags = _flags_save_DATA_BLOB;
432                 }
433         }
434         if (ndr_flags & NDR_BUFFERS) {
435         }
436         return NDR_ERR_SUCCESS;
437 }
438
439 /*
440   print mapi_request / mapi_response structures
441  */
442
443 void ndr_print_mapi_request(struct ndr_print *ndr, const char *name, const struct mapi_request *r)
444 {
445         uint32_t        rlength;
446
447         rlength = r->mapi_len - r->length;
448
449         ndr_print_uint32(ndr, "mapi_len", r->mapi_len);
450         if (r->length && r->length > sizeof(uint16_t)) {
451                 uint32_t cntr_mapi_req_0;
452
453                 ndr_print_uint16(ndr, "length", r->length);
454                 ndr->depth++;
455                 for (cntr_mapi_req_0=0; r->mapi_req[cntr_mapi_req_0].opnum; cntr_mapi_req_0++) {
456                         char    *idx_0 = NULL;
457                         int     ret;
458
459                         ret = asprintf(&idx_0, "[%u]", cntr_mapi_req_0);
460                         if (ret != -1 && idx_0) {
461                                 ndr_print_EcDoRpc_MAPI_REQ(ndr, "mapi_request", &r->mapi_req[cntr_mapi_req_0]);
462                                 free(idx_0);
463                         } 
464                 }
465                 ndr->depth--;
466         }
467
468         if (rlength) {
469                 uint32_t i;
470
471                 ndr->depth++;
472                 ndr->print(ndr, "%-25s: (handles) number=%u", name, rlength / 4);
473                 ndr->depth++;
474                 for (i = 0; i < (rlength / 4); i++) {
475                         ndr_print_uint32(ndr, "handle", r->handles[i]);
476                 }
477                 ndr->depth--;
478         }
479 }
480
481 void ndr_print_mapi_response(struct ndr_print *ndr, const char *name, const struct mapi_response *r)
482 {
483         uint32_t        rlength;
484
485         rlength = r->mapi_len - r->length;
486
487         ndr->print(ndr, "%-25s: length=%u", name, r->length);
488         if (r->length && r->length > sizeof(uint16_t)) {
489                 uint32_t cntr_mapi_repl_0;
490
491                 ndr->print(ndr, "%s: ARRAY(%d)", name, r->length - 2);
492                 ndr->depth++;
493                 for (cntr_mapi_repl_0=0; r->mapi_repl[cntr_mapi_repl_0].opnum; cntr_mapi_repl_0++) {
494                         ndr_print_EcDoRpc_MAPI_REPL(ndr, "mapi_repl", &r->mapi_repl[cntr_mapi_repl_0]);
495                 }
496                 ndr->depth--;
497         }
498
499         ndr->print(ndr, "%-25s: (handles) number=%u", name, rlength / 4);
500         
501         if (rlength) {
502                 uint32_t i;
503
504                 ndr->depth++;
505
506                 for (i = 0; i < (rlength / 4); i++) {
507                         ndr_print_uint32(ndr, "handle id", r->handles[i]);
508                 }
509                 ndr->depth--;
510         }
511 }
512
513
514 /*
515   push mapi_request / mapi_response onto the wire.  
516
517   MAPI length field includes length bytes. 
518   But these bytes do not belong to the mapi content in the user
519   context. We have to add them when pushing mapi content length
520   (uint16_t) and next subtract when pushing the content blob
521 */
522
523 enum ndr_err_code ndr_push_mapi_request(struct ndr_push *ndr, int ndr_flags, const struct mapi_request *r)
524 {
525         uint32_t                cntr_mapi_req_0;
526         uint32_t                count;
527
528         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
529         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length));
530         
531         for (count = 0; ndr->offset < r->length - 2; count++) {
532                 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REQ(ndr, NDR_SCALARS, &r->mapi_req[count]));
533         }
534
535         count = (r->mapi_len - r->length) / sizeof(uint32_t);
536         for (cntr_mapi_req_0=0; cntr_mapi_req_0 < count; cntr_mapi_req_0++) {
537                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->handles[cntr_mapi_req_0]));
538         }
539
540         return NDR_ERR_SUCCESS;
541 }
542
543 enum ndr_err_code ndr_push_mapi_response(struct ndr_push *ndr, int ndr_flags, const struct mapi_response *r)
544 {
545         uint32_t        cntr_mapi_repl_0;
546         uint32_t        count;
547
548         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
549         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length));
550
551         if (r->length > sizeof (uint16_t)) {
552                 for (count = 0; ndr->offset < r->length - 2; count++) {
553                         NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL(ndr, NDR_SCALARS, &r->mapi_repl[count]));
554                 }
555         }
556
557         count = (r->mapi_len - r->length) / sizeof (uint32_t);
558         for (cntr_mapi_repl_0 = 0; cntr_mapi_repl_0 <count; cntr_mapi_repl_0++) {
559                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->handles[cntr_mapi_repl_0]));
560         }
561
562         return NDR_ERR_SUCCESS;
563 }
564
565 /*
566   pull mapi_request / mapi_response from the wire
567 */
568
569 enum ndr_err_code ndr_pull_mapi_request(struct ndr_pull *ndr, int ndr_flags, struct mapi_request *r)
570 {
571         uint32_t length,count;
572         uint32_t cntr_mapi_req_0;
573         TALLOC_CTX *_mem_save_mapi_req_0;
574         TALLOC_CTX *_mem_save_handles_0;
575         struct ndr_pull *_ndr_mapi_req;
576
577         if (ndr->flags & LIBNDR_FLAG_REMAINING) {
578                 length = ndr->data_size - ndr->offset;
579         } else {
580                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length));
581         }
582         r->mapi_len = length;
583
584         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
585
586         /* If length equals length field then skipping subcontext */
587         if (r->length > sizeof (uint16_t)) {
588                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_mapi_req, 0, r->length - 2));
589                 _mem_save_mapi_req_0 = NDR_PULL_GET_MEM_CTX(_ndr_mapi_req);
590                 r->mapi_req = talloc_zero(_mem_save_mapi_req_0, struct EcDoRpc_MAPI_REQ);
591                 for (cntr_mapi_req_0 = 0; _ndr_mapi_req->offset < _ndr_mapi_req->data_size - 2; cntr_mapi_req_0++) {
592                         NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REQ(_ndr_mapi_req, NDR_SCALARS, &r->mapi_req[cntr_mapi_req_0]));
593                         r->mapi_req = talloc_realloc(_mem_save_mapi_req_0, r->mapi_req, struct EcDoRpc_MAPI_REQ, cntr_mapi_req_0 + 2);
594                 }
595                 r->mapi_req = talloc_realloc(_mem_save_mapi_req_0, r->mapi_req, struct EcDoRpc_MAPI_REQ, cntr_mapi_req_0 + 2);
596                 r->mapi_req[cntr_mapi_req_0].opnum = 0;
597                 
598                 if (_ndr_mapi_req->offset != r->length - 2) {
599                         return NDR_ERR_BUFSIZE;
600                 }
601                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_mapi_req, 4, -1));
602         
603                 _mem_save_handles_0 = NDR_PULL_GET_MEM_CTX(ndr);
604                 count = (r->mapi_len - r->length) / sizeof(uint32_t);
605                 r->handles = talloc_array(_mem_save_handles_0, uint32_t, count + 1);
606                 for (cntr_mapi_req_0=0; cntr_mapi_req_0 < count; cntr_mapi_req_0++) {
607                         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->handles[cntr_mapi_req_0]));
608                 }
609         } else {
610                 r->handles = NULL;
611         }
612
613         return NDR_ERR_SUCCESS;
614 }
615
616 enum ndr_err_code ndr_pull_mapi_response(struct ndr_pull *ndr, int ndr_flags, struct mapi_response *r)
617 {
618         uint32_t length,count;
619         uint32_t cntr_mapi_repl_0;
620         TALLOC_CTX *_mem_save_mapi_repl_0;
621         TALLOC_CTX *_mem_save_handles_0;
622         struct ndr_pull *_ndr_mapi_repl;
623
624         if (ndr->flags & LIBNDR_FLAG_REMAINING) {
625                 length = ndr->data_size - ndr->offset;
626         } else {
627                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length));
628         }
629         r->mapi_len = length;
630
631         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length));
632         
633         /* If length equals length field then skipping subcontext */
634         if (r->length > sizeof (uint16_t)) {
635                 _mem_save_mapi_repl_0 = NDR_PULL_GET_MEM_CTX(ndr);
636                 r->mapi_repl = talloc_array(_mem_save_mapi_repl_0, struct EcDoRpc_MAPI_REPL, 2);
637                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_mapi_repl, 0, r->length - 2));
638                 for (cntr_mapi_repl_0 = 0; _ndr_mapi_repl->offset < _ndr_mapi_repl->data_size - 2; cntr_mapi_repl_0++) {
639                         NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL(_ndr_mapi_repl, NDR_SCALARS, &r->mapi_repl[cntr_mapi_repl_0]));
640                         r->mapi_repl = talloc_realloc(_ndr_mapi_repl, r->mapi_repl, struct EcDoRpc_MAPI_REPL, cntr_mapi_repl_0 + 2);
641                 }
642                 r->mapi_repl[cntr_mapi_repl_0].opnum = 0;
643                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_mapi_repl, 4, -1));
644                 talloc_free(_ndr_mapi_repl);
645         }
646
647         _mem_save_handles_0 = NDR_PULL_GET_MEM_CTX(ndr);
648         count = (r->mapi_len - r->length) / sizeof(uint32_t);
649         NDR_PULL_ALLOC_N(ndr, r->handles, count + 1);
650
651         for (cntr_mapi_repl_0=0; cntr_mapi_repl_0 < count; cntr_mapi_repl_0++) {
652                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->handles[cntr_mapi_repl_0]));
653         }
654         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handles_0, LIBNDR_FLAG_REF_ALLOC);
655
656         return NDR_ERR_SUCCESS;
657 }
658
659 /*
660   We stop processing the IDL if MAPISTATUS is different from MAPI_E_SUCCESS
661  */
662
663 _PUBLIC_ enum ndr_err_code ndr_push_EcDoRpc_MAPI_REPL(struct ndr_push *ndr, int ndr_flags, const struct EcDoRpc_MAPI_REPL *r)
664 {
665         if (r->opnum != op_MAPI_Release)
666         {
667                 uint32_t _flags_save_STRUCT = ndr->flags;
668                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
669                 if (ndr_flags & NDR_SCALARS) {
670                         NDR_CHECK(ndr_push_align(ndr, 8));
671                         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->opnum));
672                         if ((r->opnum == op_MAPI_Notify) || (r->opnum == op_MAPI_Pending)) {
673                                 NDR_CHECK(ndr_push_set_switch_value(ndr, &r->u, r->opnum));
674                                 NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));                           
675                         } else {
676                                 NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->handle_idx));
677                                 NDR_CHECK(ndr_push_MAPISTATUS(ndr, NDR_SCALARS, r->error_code));
678                                 if (r->error_code == MAPI_E_SUCCESS) {
679                                         NDR_CHECK(ndr_push_set_switch_value(ndr, &r->u, r->opnum));
680                                         NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));
681                                 } else {
682                                         switch (r->opnum) {
683                                         case op_MAPI_Logon: {
684                                                 if (r->error_code == ecWrongServer) {
685                                                         NDR_CHECK(ndr_push_Logon_redirect(ndr, NDR_SCALARS, &(r->us.mapi_Logon)));
686                                                 }
687                                                 break; }
688                                         case op_MAPI_GetIDsFromNames: {
689                                                 /* MAPI_W_ERRORS_RETURNED still enables the final array to be passed */
690                                                 if (r->error_code == MAPI_W_ERRORS_RETURNED) {
691                                                         NDR_CHECK(ndr_push_set_switch_value(ndr, &r->u, r->opnum));
692                                                         NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));
693                                                 }
694                                                 break; }
695                                         default:
696                                                 break;
697                                         }
698                                 }
699                         }
700                 }
701                 if (ndr_flags & NDR_BUFFERS) {
702                         NDR_CHECK(ndr_push_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_BUFFERS, &r->u));
703                 }
704                 ndr->flags = _flags_save_STRUCT;
705         }
706         return NDR_ERR_SUCCESS;
707 }
708
709 enum ndr_err_code ndr_pull_EcDoRpc_MAPI_REPL(struct ndr_pull *ndr, int ndr_flags, struct EcDoRpc_MAPI_REPL *r)
710 {
711         {
712                 uint32_t _flags_save_STRUCT = ndr->flags;
713                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
714                 if (ndr_flags & NDR_SCALARS) {
715                         NDR_CHECK(ndr_pull_align(ndr, 8));
716                         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->opnum));
717                         if ((r->opnum == op_MAPI_Notify) || (r->opnum == op_MAPI_Pending)) {
718                                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->u, r->opnum));
719                                 NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));
720                         } else {
721                                 NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->handle_idx));
722                                 NDR_CHECK(ndr_pull_MAPISTATUS(ndr, NDR_SCALARS, &r->error_code));
723                                 if ( r->error_code == MAPI_E_SUCCESS) {
724                                         NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->u, r->opnum));
725                                         NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));
726                                 } else {
727                                         switch (r->opnum) {
728                                         case op_MAPI_Logon: {
729                                                 if (r->error_code == ecWrongServer) {
730                                                         NDR_CHECK(ndr_pull_Logon_redirect(ndr, NDR_SCALARS, &(r->us.mapi_Logon)));
731                                                 }
732                                                 break;}
733                                         case op_MAPI_GetIDsFromNames: {
734                                                 /* MAPI_W_ERRORS_RETURNED still enables the final array to be passed */
735                                                 if (r->error_code == MAPI_W_ERRORS_RETURNED) {
736                                                         NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->u, r->opnum));
737                                                         NDR_CHECK(ndr_pull_EcDoRpc_MAPI_REPL_UNION(ndr, NDR_SCALARS, &r->u));
738                                                 }
739                                                 break;}
740                                         default:
741                                                 break;
742                                         }
743                                 }
744                         }
745                 }
746                 if (ndr_flags & NDR_BUFFERS) {
747                         ndr->flags = _flags_save_STRUCT;
748                 }
749         }
750         return NDR_ERR_SUCCESS;
751 }
752
753 void ndr_print_EcDoRpc_MAPI_REPL(struct ndr_print *ndr, const char *name, const struct EcDoRpc_MAPI_REPL *r)
754 {
755         ndr_print_struct(ndr, name, "EcDoRpc_MAPI_REPL");
756         {
757                 uint32_t _flags_save_STRUCT = ndr->flags;
758                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
759                 ndr->depth++;
760                 ndr_print_uint8(ndr, "opnum", r->opnum);
761                 if ((r->opnum != op_MAPI_Notify) && (r->opnum != op_MAPI_Pending)) {
762                         ndr_print_uint8(ndr, "handle_idx", r->handle_idx);
763                         ndr_print_MAPISTATUS(ndr, "error_code", r->error_code);
764                         if (r->error_code == MAPI_E_SUCCESS) {
765                                 ndr_print_set_switch_value(ndr, &r->u, r->opnum);
766                                 ndr_print_EcDoRpc_MAPI_REPL_UNION(ndr, "u", &r->u);
767                         } else {
768                                 switch (r->opnum) {
769                                 case op_MAPI_Logon: {
770                                         if (r->error_code == ecWrongServer) {
771                                                 ndr_print_set_switch_value(ndr, &r->us, r->opnum);
772                                                 ndr_print_EcDoRpc_MAPI_REPL_UNION_SPECIAL(ndr, "us", &r->us);
773                                         }
774                                         break;}
775                                 case op_MAPI_GetIDsFromNames: {
776                                         /* MAPI_W_ERRORS_RETURNED still enables the final array to be passed */
777                                         if (r->error_code == MAPI_W_ERRORS_RETURNED) {
778                                                 ndr_print_set_switch_value(ndr, &r->u, r->opnum);
779                                                 ndr_print_EcDoRpc_MAPI_REPL_UNION(ndr, "u", &r->u);
780                                         }
781                                         break; }
782                                 default:
783                                         break;
784                                 }
785                         }
786                 } else {
787                         ndr_print_set_switch_value(ndr, &r->u, r->opnum);
788                         ndr_print_EcDoRpc_MAPI_REPL_UNION(ndr, "u", &r->u);
789                 }
790                 ndr->depth--;
791                 ndr->flags = _flags_save_STRUCT;
792         }
793 }
794
795
796 _PUBLIC_ enum ndr_err_code ndr_pull_EcDoRpc(struct ndr_pull *ndr, int flags, struct EcDoRpc *r)
797 {
798         TALLOC_CTX *_mem_save_handle_0;
799         TALLOC_CTX *_mem_save_mapi_request_0;
800         TALLOC_CTX *_mem_save_mapi_response_0;
801         TALLOC_CTX *_mem_save_length_0;
802
803         if (flags & NDR_IN) {
804                 ZERO_STRUCT(r->out);
805
806                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
807                         NDR_PULL_ALLOC(ndr, r->in.handle);
808                 }
809                 _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
810                 NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC);
811                 NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
812                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
813                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.size));
814                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offset));
815                 {
816                         uint32_t _flags_save_mapi_request = ndr->flags;
817                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING|LIBNDR_FLAG_NOALIGN);
818                         if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
819                                 NDR_PULL_ALLOC(ndr, r->in.mapi_request);
820                         }
821                         _mem_save_mapi_request_0 = NDR_PULL_GET_MEM_CTX(ndr);
822                         NDR_PULL_SET_MEM_CTX(ndr, r->in.mapi_request, LIBNDR_FLAG_REF_ALLOC);
823                         {
824                                 struct ndr_pull *_ndr_mapi_request;
825                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_mapi_request, 4, -1));
826                                 obfuscate_data(_ndr_mapi_request->data, _ndr_mapi_request->data_size, 0xA5);
827                                 NDR_CHECK(ndr_pull_mapi_request(_ndr_mapi_request, NDR_SCALARS|NDR_BUFFERS, r->in.mapi_request));
828                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_mapi_request, 4, -1));
829                         }
830                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_mapi_request_0, LIBNDR_FLAG_REF_ALLOC);
831                         ndr->flags = _flags_save_mapi_request;
832                 }
833                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
834                         NDR_PULL_ALLOC(ndr, r->in.length);
835                 }
836                 _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr);
837                 NDR_PULL_SET_MEM_CTX(ndr, r->in.length, LIBNDR_FLAG_REF_ALLOC);
838                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->in.length));
839                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, LIBNDR_FLAG_REF_ALLOC);
840                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.max_data));
841                 NDR_PULL_ALLOC(ndr, r->out.handle);
842                 *r->out.handle = *r->in.handle;
843                 NDR_PULL_ALLOC(ndr, r->out.mapi_response);
844                 ZERO_STRUCTP(r->out.mapi_response);
845                 NDR_PULL_ALLOC(ndr, r->out.length);
846                 *r->out.length = *r->in.length;
847         }
848         if (flags & NDR_OUT) {
849                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
850                         NDR_PULL_ALLOC(ndr, r->out.handle);
851                 }
852                 _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
853                 NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC);
854                 NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle));
855                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
856                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.size));
857                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.offset));
858                 {
859                         uint32_t _flags_save_mapi_response = ndr->flags;
860                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING|LIBNDR_FLAG_NOALIGN);
861                         if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
862                                 NDR_PULL_ALLOC(ndr, r->out.mapi_response);
863                         }
864                         _mem_save_mapi_response_0 = NDR_PULL_GET_MEM_CTX(ndr);
865                         NDR_PULL_SET_MEM_CTX(ndr, r->out.mapi_response, LIBNDR_FLAG_REF_ALLOC);
866                         {
867                                 struct ndr_pull *_ndr_mapi_response;
868                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_mapi_response, 4, -1));
869                                 obfuscate_data(_ndr_mapi_response->data, _ndr_mapi_response->data_size, 0xA5);
870                                 NDR_CHECK(ndr_pull_mapi_response(_ndr_mapi_response, NDR_SCALARS|NDR_BUFFERS, r->out.mapi_response));
871                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_mapi_response, 4, -1));
872                         }
873                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_mapi_response_0, LIBNDR_FLAG_REF_ALLOC);
874                         ndr->flags = _flags_save_mapi_response;
875                 }
876                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
877                         NDR_PULL_ALLOC(ndr, r->out.length);
878                 }
879                 _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr);
880                 NDR_PULL_SET_MEM_CTX(ndr, r->out.length, LIBNDR_FLAG_REF_ALLOC);
881                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->out.length));
882                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, LIBNDR_FLAG_REF_ALLOC);
883                 NDR_CHECK(ndr_pull_MAPISTATUS(ndr, NDR_SCALARS, &r->out.result));
884         }
885         return NDR_ERR_SUCCESS;
886 }
887
888
889 _PUBLIC_ enum ndr_err_code ndr_push_EcDoRpc(struct ndr_push *ndr, int flags, const struct EcDoRpc *r)
890 {
891         if (flags & NDR_IN) {
892                 if (r->in.handle == NULL) {
893                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
894                 }
895                 NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
896                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.size));
897                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offset));
898                 {
899                         uint32_t _flags_save_mapi_request = ndr->flags;
900                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING|LIBNDR_FLAG_NOALIGN);
901                         if (r->in.mapi_request == NULL) {
902                                 return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
903                         }
904                         {
905                                 struct ndr_push *_ndr_mapi_request;
906                                 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_mapi_request, 4, -1));
907                                 NDR_CHECK(ndr_push_mapi_request(_ndr_mapi_request, NDR_SCALARS|NDR_BUFFERS, r->in.mapi_request));
908                                 obfuscate_data(_ndr_mapi_request->data, _ndr_mapi_request->offset, 0xA5);
909                                 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_mapi_request, 4, -1));
910                         }
911                         ndr->flags = _flags_save_mapi_request;
912                 }
913                 if (r->in.length == NULL) {
914                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
915                 }
916                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, *r->in.length));
917                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.max_data));
918         }
919         if (flags & NDR_OUT) {
920                 if (r->out.handle == NULL) {
921                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
922                 }
923                 NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle));
924                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.size));
925                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.offset));
926                 {
927                         uint32_t _flags_save_mapi_response = ndr->flags;
928                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING|LIBNDR_FLAG_NOALIGN);
929                         if (r->out.mapi_response == NULL) {
930                                 return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
931                         }
932                         {
933                                 struct ndr_push *_ndr_mapi_response;
934                                 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_mapi_response, 4, -1));
935                                 NDR_CHECK(ndr_push_mapi_response(_ndr_mapi_response, NDR_SCALARS|NDR_BUFFERS, r->out.mapi_response));
936                                 obfuscate_data(_ndr_mapi_response->data, _ndr_mapi_response->alloc_size, 0xA5);
937                                 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_mapi_response, 4, -1));
938                         }
939                         ndr->flags = _flags_save_mapi_response;
940                 }
941                 if (r->out.length == NULL) {
942                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
943                 }
944                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, *r->out.length));
945                 NDR_CHECK(ndr_push_MAPISTATUS(ndr, NDR_SCALARS, r->out.result));
946         }
947         return NDR_ERR_SUCCESS;
948 }
949
950
951 _PUBLIC_ enum ndr_err_code ndr_push_EcDoConnectEx(struct ndr_push *ndr, int flags, const struct EcDoConnectEx *r)
952 {
953         uint32_t        cntr_rgwClientVersion_0;
954         uint32_t        cntr_rgwServerVersion_0;
955         uint32_t        cntr_rgwBestVersion_0;
956
957         if (flags & NDR_IN) {
958                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.szUserDN, CH_DOS)));
959                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
960                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.szUserDN, CH_DOS)));
961                 NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.szUserDN, ndr_charset_length(r->in.szUserDN, CH_DOS), sizeof (uint8_t), CH_DOS));
962                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulFlags));
963                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulConMod));
964                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.cbLimit));
965                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulCpid));
966                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulLcidString));
967                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulLcidSort));
968                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulIcxrLink));
969                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.usFCanConvertCodePages));
970                 for (cntr_rgwClientVersion_0 = 0; cntr_rgwClientVersion_0 < 3; cntr_rgwClientVersion_0++) {
971                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.rgwClientVersion[cntr_rgwClientVersion_0]));
972                 }
973                 if (r->in.pulTimeStamp == NULL) {
974                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
975                 }
976                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.pulTimeStamp));
977                 {
978                         uint32_t        _flags_save_mapi2k7_AuxInfo = ndr->flags;
979                         struct ndr_push *_ndr_rgbAuxIn;
980
981                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_REMAINING);
982                         NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_rgbAuxIn, 4, -1));
983
984                         if (r->in.cbAuxIn) {
985                                 if (r->in.rgbAuxIn == NULL) {
986                                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
987                                 }
988                                 NDR_CHECK(ndr_push_mapi2k7_AuxInfo(_ndr_rgbAuxIn, NDR_SCALARS|NDR_BUFFERS, r->in.rgbAuxIn));
989                         }
990                         NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_rgbAuxIn, 4, -1));
991                         ndr->flags = _flags_save_mapi2k7_AuxInfo;
992                 }
993                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.cbAuxIn));
994                 if (r->in.pcbAuxOut == NULL) {
995                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
996                 }
997                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.pcbAuxOut));
998         }               
999
1000         if (flags & NDR_OUT) {
1001                 if (r->out.handle == NULL) {
1002                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1003                 }
1004                 NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle));
1005                 if (r->out.pcmsPollsMax == NULL) {
1006                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1007                 }
1008                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.pcmsPollsMax));
1009                 if (r->out.pcRetry == NULL) {
1010                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1011                 }
1012                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.pcRetry));
1013                 if (r->out.pcmsRetryDelay == NULL) {
1014                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1015                 }
1016                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.pcmsRetryDelay));
1017                 if (r->out.picxr == NULL) {
1018                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1019                 }
1020                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.picxr));
1021                 if (r->out.szDNPrefix == NULL) {
1022                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1023                 }
1024                 NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.szDNPrefix));
1025                 if (r->out.szDNPrefix) {
1026                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.szDNPrefix, CH_DOS)));
1027                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
1028                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.szDNPrefix, CH_DOS)));
1029                         NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, *r->out.szDNPrefix, ndr_charset_length(*r->out.szDNPrefix, CH_DOS), sizeof(uint8_t), CH_DOS));
1030                 }
1031                 if (r->out.szDisplayName == NULL) {
1032                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1033                 }
1034                 NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.szDisplayName));
1035                 if (*r->out.szDisplayName) {
1036                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.szDisplayName, CH_DOS)));
1037                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
1038                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.szDisplayName, CH_DOS)));
1039                         NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, *r->out.szDisplayName, ndr_charset_length(*r->out.szDisplayName, CH_DOS), sizeof(uint8_t), CH_DOS));
1040                 }
1041                 for (cntr_rgwServerVersion_0 = 0; cntr_rgwServerVersion_0 < 3; cntr_rgwServerVersion_0++) {
1042                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->out.rgwServerVersion[cntr_rgwServerVersion_0]));
1043                 }
1044                 for (cntr_rgwBestVersion_0 = 0; cntr_rgwBestVersion_0 < 3; cntr_rgwBestVersion_0++) {
1045                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->out.rgwBestVersion[cntr_rgwBestVersion_0]));
1046                 }
1047                 if (r->out.pulTimeStamp == NULL) {
1048                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1049                 }
1050                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.pulTimeStamp));
1051                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, *r->out.pcbAuxOut));
1052                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0));
1053                 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, *r->out.pcbAuxOut));                              
1054                 /* Only try to fetch rgbAuxOut if pcbAuxOut is > 0 */
1055                 if (r->out.pcbAuxOut && *r->out.pcbAuxOut) {
1056                         NDR_CHECK(ndr_push_mapi2k7_AuxInfo(ndr, NDR_SCALARS, r->out.rgbAuxOut));
1057                 }
1058
1059                 if (r->out.pcbAuxOut == NULL) {
1060                         return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
1061                 }
1062                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.pcbAuxOut));
1063                 NDR_CHECK(ndr_push_MAPISTATUS(ndr, NDR_SCALARS, r->out.result));
1064         }
1065         return NDR_ERR_SUCCESS;
1066 }
1067
1068 _PUBLIC_ enum ndr_err_code ndr_pull_EcDoConnectEx(struct ndr_pull *ndr, int flags, struct EcDoConnectEx *r)
1069 {
1070         uint32_t        _ptr_szDNPrefix;
1071         uint32_t        _ptr_szDisplayName;
1072         uint32_t        cntr_rgwClientVersion_0;
1073         uint32_t        cntr_rgwServerVersion_0;
1074         uint32_t        cntr_rgwBestVersion_0;
1075         TALLOC_CTX      *_mem_save_handle_0;
1076         TALLOC_CTX      *_mem_save_pcmsPollsMax_0;
1077         TALLOC_CTX      *_mem_save_pcRetry_0;
1078         TALLOC_CTX      *_mem_save_pcmsRetryDelay_0;
1079         TALLOC_CTX      *_mem_save_picxr_0;
1080         TALLOC_CTX      *_mem_save_szDNPrefix_0;
1081         TALLOC_CTX      *_mem_save_szDNPrefix_1;
1082         TALLOC_CTX      *_mem_save_szDisplayName_0;
1083         TALLOC_CTX      *_mem_save_szDisplayName_1;
1084         TALLOC_CTX      *_mem_save_pulTimeStamp_0;
1085         TALLOC_CTX      *_mem_save_rgbAuxIn_0;
1086         TALLOC_CTX      *_mem_save_pcbAuxOut_0;
1087         TALLOC_CTX      *_mem_save_rgbAuxOut_1;
1088
1089         if (flags & NDR_IN) {
1090                 ZERO_STRUCT(r->out);
1091
1092                 NDR_CHECK(ndr_pull_array_size(ndr, &r->in.szUserDN));
1093                 NDR_CHECK(ndr_pull_array_length(ndr, &r->in.szUserDN));
1094                 if (ndr_get_array_length(ndr, &r->in.szUserDN) > ndr_get_array_size(ndr, &r->in.szUserDN)) {
1095                         return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.szUserDN), ndr_get_array_length(ndr, &r->in.szUserDN));
1096                 }
1097                 NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.szUserDN), sizeof(uint8_t)));
1098                 NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.szUserDN, ndr_get_array_length(ndr, &r->in.szUserDN), sizeof(uint8_t), CH_DOS));
1099                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulFlags));
1100                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulConMod));
1101                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.cbLimit));
1102                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulCpid));
1103                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulLcidString));
1104                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulLcidSort));
1105                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulIcxrLink));
1106                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.usFCanConvertCodePages));
1107                 for (cntr_rgwClientVersion_0 = 0; cntr_rgwClientVersion_0 < 3; cntr_rgwClientVersion_0++) {
1108                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.rgwClientVersion[cntr_rgwClientVersion_0]));
1109                 }
1110                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1111                         NDR_PULL_ALLOC(ndr, r->in.pulTimeStamp);
1112                 }
1113                 _mem_save_pulTimeStamp_0 = NDR_PULL_GET_MEM_CTX(ndr);
1114                 NDR_PULL_SET_MEM_CTX(ndr, r->in.pulTimeStamp, LIBNDR_FLAG_REF_ALLOC);
1115                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.pulTimeStamp));
1116                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pulTimeStamp_0, LIBNDR_FLAG_REF_ALLOC);
1117                 {
1118                         uint32_t _flags_save_mapi2k7_AuxInfo = ndr->flags;
1119                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_REMAINING);
1120                         if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1121                                 NDR_PULL_ALLOC(ndr, r->in.rgbAuxIn);
1122                         }
1123                         _mem_save_rgbAuxIn_0 = NDR_PULL_GET_MEM_CTX(ndr);
1124                         NDR_PULL_SET_MEM_CTX(ndr, r->in.rgbAuxIn, LIBNDR_FLAG_REF_ALLOC);
1125                         {
1126                                 struct ndr_pull *_ndr_rgbAuxIn;
1127                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_rgbAuxIn, 4, -1));
1128                                 NDR_CHECK(ndr_pull_mapi2k7_AuxInfo(_ndr_rgbAuxIn, NDR_SCALARS|NDR_BUFFERS, r->in.rgbAuxIn));
1129                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_rgbAuxIn, 4, -1));
1130                         }
1131                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rgbAuxIn_0, LIBNDR_FLAG_REF_ALLOC);
1132                         ndr->flags = _flags_save_mapi2k7_AuxInfo;
1133                 }
1134                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.cbAuxIn));
1135                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1136                         NDR_PULL_ALLOC(ndr, r->in.pcbAuxOut);
1137                 }
1138                 _mem_save_pcbAuxOut_0 = NDR_PULL_GET_MEM_CTX(ndr);
1139                 NDR_PULL_SET_MEM_CTX(ndr, r->in.pcbAuxOut, LIBNDR_FLAG_REF_ALLOC);
1140                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.pcbAuxOut));
1141                 if (*r->in.pcbAuxOut > 0x1008) {
1142                         return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
1143                 }
1144                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pcbAuxOut_0, LIBNDR_FLAG_REF_ALLOC);
1145                 NDR_PULL_ALLOC(ndr, r->out.handle);
1146                 ZERO_STRUCTP(r->out.handle);
1147                 NDR_PULL_ALLOC(ndr, r->out.pcmsPollsMax);
1148                 ZERO_STRUCTP(r->out.pcmsPollsMax);
1149                 NDR_PULL_ALLOC(ndr, r->out.pcRetry);
1150                 ZERO_STRUCTP(r->out.pcRetry);
1151                 NDR_PULL_ALLOC(ndr, r->out.pcmsRetryDelay);
1152                 ZERO_STRUCTP(r->out.pcmsRetryDelay);
1153                 NDR_PULL_ALLOC(ndr, r->out.picxr);
1154                 ZERO_STRUCTP(r->out.picxr);
1155                 NDR_PULL_ALLOC(ndr, r->out.szDNPrefix);
1156                 ZERO_STRUCTP(r->out.szDNPrefix);
1157                 NDR_PULL_ALLOC(ndr, r->out.szDisplayName);
1158                 ZERO_STRUCTP(r->out.szDisplayName);
1159                 NDR_PULL_ALLOC(ndr, r->out.pulTimeStamp);
1160                 *r->out.pulTimeStamp = *r->in.pulTimeStamp;
1161                 NDR_PULL_ALLOC(ndr, r->out.pcbAuxOut);
1162                 *r->out.pcbAuxOut = *r->in.pcbAuxOut;
1163         }               
1164
1165         if (flags & NDR_OUT) {
1166                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1167                         NDR_PULL_ALLOC(ndr, r->out.handle);
1168                 }
1169                 _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
1170                 NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC);
1171                 NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle));
1172                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
1173                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1174                         NDR_PULL_ALLOC(ndr, r->out.pcmsPollsMax);
1175                 }
1176                 _mem_save_pcmsPollsMax_0 = NDR_PULL_GET_MEM_CTX(ndr);
1177                 NDR_PULL_SET_MEM_CTX(ndr, r->out.pcmsPollsMax, LIBNDR_FLAG_REF_ALLOC);
1178                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.pcmsPollsMax));
1179                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pcmsPollsMax_0, LIBNDR_FLAG_REF_ALLOC);
1180                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1181                         NDR_PULL_ALLOC(ndr, r->out.pcRetry);
1182                 }
1183                 _mem_save_pcRetry_0 = NDR_PULL_GET_MEM_CTX(ndr);
1184                 NDR_PULL_SET_MEM_CTX(ndr, r->out.pcRetry, LIBNDR_FLAG_REF_ALLOC);
1185                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.pcRetry));
1186                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pcRetry_0, LIBNDR_FLAG_REF_ALLOC);
1187                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1188                         NDR_PULL_ALLOC(ndr, r->out.pcmsRetryDelay);
1189                 }
1190                 _mem_save_pcmsRetryDelay_0 = NDR_PULL_GET_MEM_CTX(ndr);
1191                 NDR_PULL_SET_MEM_CTX(ndr, r->out.pcmsRetryDelay, LIBNDR_FLAG_REF_ALLOC);
1192                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.pcmsRetryDelay));
1193                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pcmsRetryDelay_0, LIBNDR_FLAG_REF_ALLOC);
1194                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1195                         NDR_PULL_ALLOC(ndr, r->out.picxr);
1196                 }
1197                 _mem_save_picxr_0 = NDR_PULL_GET_MEM_CTX(ndr);
1198                 NDR_PULL_SET_MEM_CTX(ndr, r->out.picxr, LIBNDR_FLAG_REF_ALLOC);
1199                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.picxr));
1200                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_picxr_0, LIBNDR_FLAG_REF_ALLOC);
1201
1202                 _mem_save_szDNPrefix_0 = NDR_PULL_GET_MEM_CTX(ndr);
1203                 NDR_PULL_SET_MEM_CTX(ndr, r->out.szDNPrefix, LIBNDR_FLAG_REF_ALLOC);
1204                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_szDNPrefix));
1205                 if (_ptr_szDNPrefix) {
1206                         NDR_PULL_ALLOC(ndr, *r->out.szDNPrefix);
1207                 } else {
1208                         *r->out.szDNPrefix = NULL;
1209                 }
1210                 if (*r->out.szDNPrefix) {
1211                         _mem_save_szDNPrefix_1 = NDR_PULL_GET_MEM_CTX(ndr);
1212                         NDR_PULL_SET_MEM_CTX(ndr, *r->out.szDNPrefix, 0);
1213                         NDR_CHECK(ndr_pull_array_size(ndr, r->out.szDNPrefix));
1214                         NDR_CHECK(ndr_pull_array_length(ndr, r->out.szDNPrefix));
1215                         if (ndr_get_array_length(ndr, r->out.szDNPrefix) > ndr_get_array_size(ndr, r->out.szDNPrefix)) {
1216                                 return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, r->out.szDNPrefix), ndr_get_array_length(ndr, r->out.szDNPrefix));
1217                         }
1218                         NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, r->out.szDNPrefix), sizeof(uint8_t)));
1219                         NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, r->out.szDNPrefix, ndr_get_array_length(ndr, r->out.szDNPrefix), sizeof(uint8_t), CH_DOS));
1220                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_szDNPrefix_1, 0);
1221                 }
1222                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_szDNPrefix_0, LIBNDR_FLAG_REF_ALLOC);
1223
1224                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1225                         NDR_PULL_ALLOC(ndr, r->out.szDisplayName);
1226                 }
1227                 _mem_save_szDisplayName_0 = NDR_PULL_GET_MEM_CTX(ndr);
1228                 NDR_PULL_SET_MEM_CTX(ndr, r->out.szDisplayName, LIBNDR_FLAG_REF_ALLOC);
1229                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_szDisplayName));
1230                 if (_ptr_szDisplayName) {
1231                         NDR_PULL_ALLOC(ndr, *r->out.szDisplayName);
1232                 } else {
1233                         *r->out.szDisplayName = NULL;
1234                 }
1235                 if (*r->out.szDisplayName) {
1236                         _mem_save_szDisplayName_1 = NDR_PULL_GET_MEM_CTX(ndr);
1237                         NDR_PULL_SET_MEM_CTX(ndr, *r->out.szDisplayName, 0);
1238                         NDR_CHECK(ndr_pull_array_size(ndr, r->out.szDisplayName));
1239                         NDR_CHECK(ndr_pull_array_length(ndr, r->out.szDisplayName));
1240                         if (ndr_get_array_length(ndr, r->out.szDisplayName) > ndr_get_array_size(ndr, r->out.szDisplayName)) {
1241                                 return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, r->out.szDisplayName), ndr_get_array_length(ndr, r->out.szDisplayName));
1242                         }
1243                         NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, r->out.szDisplayName), sizeof(uint8_t)));
1244                         NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, r->out.szDisplayName, ndr_get_array_length(ndr, r->out.szDisplayName), sizeof(uint8_t), CH_DOS));
1245                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_szDisplayName_1, 0);
1246                 }
1247                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_szDisplayName_0, LIBNDR_FLAG_REF_ALLOC);
1248
1249                 for (cntr_rgwServerVersion_0 = 0; cntr_rgwServerVersion_0 < 3; cntr_rgwServerVersion_0++) {
1250                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.rgwServerVersion[cntr_rgwServerVersion_0]));
1251                 }
1252                 for (cntr_rgwBestVersion_0 = 0; cntr_rgwBestVersion_0 < 3; cntr_rgwBestVersion_0++) {
1253                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.rgwBestVersion[cntr_rgwBestVersion_0]));
1254                 }
1255                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1256                         NDR_PULL_ALLOC(ndr, r->out.pulTimeStamp);
1257                 }
1258                 _mem_save_pulTimeStamp_0 = NDR_PULL_GET_MEM_CTX(ndr);
1259                 NDR_PULL_SET_MEM_CTX(ndr, r->out.pulTimeStamp, LIBNDR_FLAG_REF_ALLOC);
1260                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.pulTimeStamp));
1261                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pulTimeStamp_0, LIBNDR_FLAG_REF_ALLOC);
1262                 NDR_CHECK(ndr_pull_array_size(ndr, &r->out.rgbAuxOut));
1263                 NDR_CHECK(ndr_pull_array_length(ndr, &r->out.rgbAuxOut));
1264                 if (ndr_get_array_length(ndr, &r->out.rgbAuxOut) > ndr_get_array_size(ndr, &r->out.rgbAuxOut)) {
1265                         return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->out.rgbAuxOut), ndr_get_array_length(ndr, &r->out.rgbAuxOut));
1266                 }
1267                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1268                         NDR_PULL_ALLOC_N(ndr, r->out.rgbAuxOut, ndr_get_array_size(ndr, &r->out.rgbAuxOut));
1269                 }
1270                 /* Only try to pull rgbAuxOut if the fake array size is > 0 */
1271                 if (ndr_get_array_size(ndr, &r->out.rgbAuxOut)) {
1272                         _mem_save_rgbAuxOut_1 = NDR_PULL_GET_MEM_CTX(ndr);
1273                         NDR_PULL_SET_MEM_CTX(ndr, r->out.rgbAuxOut, 0);
1274                         NDR_CHECK(ndr_pull_mapi2k7_AuxInfo(ndr, NDR_SCALARS, r->out.rgbAuxOut));
1275                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rgbAuxOut_1, 0);
1276                 }
1277                 if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
1278                         NDR_PULL_ALLOC(ndr, r->out.pcbAuxOut);
1279                 }
1280                 _mem_save_pcbAuxOut_0 = NDR_PULL_GET_MEM_CTX(ndr);
1281                 NDR_PULL_SET_MEM_CTX(ndr, r->out.pcbAuxOut, LIBNDR_FLAG_REF_ALLOC);
1282                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.pcbAuxOut));
1283                 if (*r->out.pcbAuxOut > 0x1008) {
1284                         return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
1285                 }
1286                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pcbAuxOut_0, LIBNDR_FLAG_REF_ALLOC);
1287                 NDR_CHECK(ndr_pull_MAPISTATUS(ndr, NDR_SCALARS, &r->out.result));
1288         }
1289         return NDR_ERR_SUCCESS;
1290 }
1291
1292 _PUBLIC_ void ndr_print_EcDoConnectEx(struct ndr_print *ndr, const char *name, int flags, const struct EcDoConnectEx *r)
1293 {
1294         uint32_t        cntr_rgwClientVersion_0;
1295         uint32_t        cntr_rgwServerVersion_0;
1296         uint32_t        cntr_rgwBestVersion_0;
1297
1298         ndr_print_struct(ndr, name, "EcDoConnectEx");
1299         ndr->depth++;
1300         if (flags & NDR_SET_VALUES) {
1301                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
1302         }
1303         if (flags & NDR_IN) {
1304                 ndr_print_struct(ndr, "in", "EcDoConnectEx");
1305                 ndr->depth++;
1306                 ndr_print_string(ndr, "szUserDN", r->in.szUserDN);
1307                 ndr_print_uint32(ndr, "ulFlags", r->in.ulFlags);
1308                 ndr_print_uint32(ndr, "ulConMod", r->in.ulConMod);
1309                 ndr_print_uint32(ndr, "cbLimit", r->in.cbLimit);
1310                 ndr_print_uint32(ndr, "ulCpid", r->in.ulCpid);
1311                 ndr_print_uint32(ndr, "ulLcidString", r->in.ulLcidString);
1312                 ndr_print_uint32(ndr, "ulLcidSort", r->in.ulLcidSort);
1313                 ndr_print_uint32(ndr, "ulIcxrLink", r->in.ulIcxrLink);
1314                 ndr_print_uint16(ndr, "usFCanConvertCodePages", r->in.usFCanConvertCodePages);
1315                 ndr->print(ndr, "%s: ARRAY(%d)", "rgwClientVersion", (int)3);
1316                 ndr->depth++;
1317                 for (cntr_rgwClientVersion_0=0;cntr_rgwClientVersion_0<3;cntr_rgwClientVersion_0++) {
1318                         char *idx_0=NULL;
1319                         if (asprintf(&idx_0, "[%d]", cntr_rgwClientVersion_0) != -1) {
1320                                 ndr_print_uint16(ndr, "rgwClientVersion", r->in.rgwClientVersion[cntr_rgwClientVersion_0]);
1321                                 free(idx_0);
1322                         }
1323                 }
1324                 ndr->depth--;
1325                 ndr_print_ptr(ndr, "pulTimeStamp", r->in.pulTimeStamp);
1326                 ndr->depth++;
1327                 ndr_print_uint32(ndr, "pulTimeStamp", *r->in.pulTimeStamp);
1328                 ndr->depth--;
1329                 ndr_print_ptr(ndr, "rgbAuxIn", r->in.rgbAuxIn);
1330                 if (r->in.rgbAuxIn) {
1331                         ndr->depth++;
1332                         ndr_print_mapi2k7_AuxInfo(ndr, "rgbAuxIn", r->in.rgbAuxIn);
1333                         ndr->depth--;
1334                 }
1335                 ndr_print_uint32(ndr, "cbAuxIn", r->in.cbAuxIn);
1336                 ndr_print_ptr(ndr, "pcbAuxOut", r->in.pcbAuxOut);
1337                 ndr->depth++;
1338                 ndr_print_uint32(ndr, "pcbAuxOut", *r->in.pcbAuxOut);
1339                 ndr->depth--;
1340                 ndr->depth--;
1341         }
1342         if (flags & NDR_OUT) {
1343                 ndr_print_struct(ndr, "out", "EcDoConnectEx");
1344                 ndr->depth++;
1345                 ndr_print_ptr(ndr, "handle", r->out.handle);
1346                 ndr->depth++;
1347                 ndr_print_policy_handle(ndr, "handle", r->out.handle);
1348                 ndr->depth--;
1349                 ndr_print_ptr(ndr, "pcmsPollsMax", r->out.pcmsPollsMax);
1350                 ndr->depth++;
1351                 ndr_print_uint32(ndr, "pcmsPollsMax", *r->out.pcmsPollsMax);
1352                 ndr->depth--;
1353                 ndr_print_ptr(ndr, "pcRetry", r->out.pcRetry);
1354                 ndr->depth++;
1355                 ndr_print_uint32(ndr, "pcRetry", *r->out.pcRetry);
1356                 ndr->depth--;
1357                 ndr_print_ptr(ndr, "pcmsRetryDelay", r->out.pcmsRetryDelay);
1358                 ndr->depth++;
1359                 ndr_print_uint32(ndr, "pcmsRetryDelay", *r->out.pcmsRetryDelay);
1360                 ndr->depth--;
1361                 ndr_print_ptr(ndr, "picxr", r->out.picxr);
1362                 ndr->depth++;
1363                 ndr_print_uint32(ndr, "picxr", *r->out.picxr);
1364                 ndr->depth--;
1365                 ndr_print_ptr(ndr, "szDNPrefix", r->out.szDisplayName);
1366                 ndr->depth++;
1367                 if (r->out.szDNPrefix && *r->out.szDNPrefix) {
1368                         ndr_print_ptr(ndr, "szDNPrefix", *r->out.szDNPrefix);
1369                         ndr->depth++;
1370                         ndr_print_string(ndr, "szDNPrefix", *r->out.szDNPrefix);
1371                         ndr->depth--;
1372                 }
1373                 ndr->depth--;
1374                 ndr_print_ptr(ndr, "szDisplayName", r->out.szDisplayName);
1375                 ndr->depth++;
1376                 if (r->out.szDisplayName && *r->out.szDisplayName) {
1377                         ndr_print_ptr(ndr, "szDisplayName", *r->out.szDisplayName);
1378                         ndr->depth++;
1379                         ndr_print_string(ndr, "szDisplayName", *r->out.szDisplayName);
1380                         ndr->depth--;
1381                 }
1382                 ndr->depth--;
1383                 ndr->print(ndr, "%s: ARRAY(%d)", "rgwServerVersion", (int)3);
1384                 ndr->depth++;
1385                 for (cntr_rgwServerVersion_0=0;cntr_rgwServerVersion_0<3;cntr_rgwServerVersion_0++) {
1386                         char *idx_0=NULL;
1387                         if (asprintf(&idx_0, "[%d]", cntr_rgwServerVersion_0) != -1) {
1388                                 ndr_print_uint16(ndr, "rgwServerVersion", r->out.rgwServerVersion[cntr_rgwServerVersion_0]);
1389                                 free(idx_0);
1390                         }
1391                 }
1392                 ndr->depth--;
1393                 ndr->print(ndr, "%s: ARRAY(%d)", "rgwBestVersion", (int)3);
1394                 ndr->depth++;
1395                 for (cntr_rgwBestVersion_0=0;cntr_rgwBestVersion_0<3;cntr_rgwBestVersion_0++) {
1396                         char *idx_0=NULL;
1397                         if (asprintf(&idx_0, "[%d]", cntr_rgwBestVersion_0) != -1) {
1398                                 ndr_print_uint16(ndr, "rgwBestVersion", r->out.rgwBestVersion[cntr_rgwBestVersion_0]);
1399                                 free(idx_0);
1400                         }
1401                 }
1402                 ndr->depth--;
1403                 ndr_print_ptr(ndr, "pulTimeStamp", r->out.pulTimeStamp);
1404                 if (r->out.pulTimeStamp) {
1405                         ndr->depth++;
1406                         ndr_print_uint32(ndr, "pulTimeStamp", *r->out.pulTimeStamp);
1407                         ndr->depth--;
1408                 }
1409                 ndr_print_ptr(ndr, "rgbAuxOut", r->out.rgbAuxOut);
1410                 if (r->out.rgbAuxOut && r->out.pcbAuxOut) {
1411                         ndr->depth++;
1412                         ndr_print_mapi2k7_AuxInfo(ndr, "rgbAuxOut", r->out.rgbAuxOut);
1413                         ndr->depth--;
1414                 }
1415                 ndr_print_ptr(ndr, "pcbAuxOut", r->out.pcbAuxOut);
1416                 if (r->out.pcbAuxOut) {
1417                         ndr->depth++;
1418                         ndr_print_uint32(ndr, "pcbAuxOut", *r->out.pcbAuxOut);
1419                         ndr->depth--;
1420                 }
1421                 ndr_print_MAPISTATUS(ndr, "result", r->out.result);
1422                 ndr->depth--;
1423         }
1424         ndr->depth--;
1425 }
1426
1427 _PUBLIC_ void ndr_print_EcDoRpcExt(struct ndr_print *ndr, const char *name, int flags, const struct EcDoRpcExt *r)
1428 {
1429         DATA_BLOB               rgbIn;
1430         DATA_BLOB               rgbOut;
1431         struct ndr_pull         *ndr_pull;
1432         struct mapi2k7_request  *mapi_request;
1433         struct mapi2k7_response *mapi_response;
1434         TALLOC_CTX              *mem_ctx;
1435
1436         mem_ctx = talloc_named(NULL, 0, "ndr_print_EcDoRpcExt2");
1437
1438         ndr_print_struct(ndr, name, "EcDoRpcExt");
1439         if (r == NULL) { ndr_print_null(ndr); return; }
1440         ndr->depth++;
1441         if (flags & NDR_SET_VALUES) {
1442                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
1443         }
1444         if (flags & NDR_IN) {
1445                 ndr_print_struct(ndr, "in", "EcDoRpcExt");
1446                 ndr->depth++;
1447                 ndr_print_ptr(ndr, "handle", r->in.handle);
1448                 ndr->depth++;
1449                 ndr_print_policy_handle(ndr, "handle", r->in.handle);
1450                 ndr->depth--;
1451                 ndr_print_ptr(ndr, "pulFlags", r->in.pulFlags);
1452                 ndr->depth++;
1453                 ndr_print_uint32(ndr, "pulFlags", *r->in.pulFlags);
1454                 ndr->depth--;
1455
1456                 /* Put MAPI request blob into a ndr_pull structure */
1457                 rgbIn.data = talloc_memdup(mem_ctx, r->in.rgbIn, r->in.cbIn);
1458                 rgbIn.length = r->in.cbIn;
1459                 dump_data(0, rgbIn.data, rgbIn.length);
1460                 ndr_pull = ndr_pull_init_blob(&rgbIn, mem_ctx);
1461                 ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_NOALIGN);
1462                 mapi_request = talloc_zero(mem_ctx, struct mapi2k7_request);
1463                 mapi_request->mapi_request = talloc_zero(mapi_request, struct mapi_request);
1464                 ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request);
1465                 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
1466                 talloc_free(mapi_request);
1467                 talloc_free(ndr_pull);
1468                 talloc_free(rgbIn.data);
1469
1470                 ndr_print_uint32(ndr, "cbIn", r->in.cbIn);
1471                 ndr_print_ptr(ndr, "pcbOut", r->in.pcbOut);
1472                 ndr->depth++;
1473                 ndr_print_uint32(ndr, "pcbOut", *r->in.pcbOut);
1474                 ndr->depth--;
1475                 ndr_print_array_uint8(ndr, "Reserved0", r->in.Reserved0, *r->in.Reserved1);
1476                 ndr_print_ptr(ndr, "Reserved1", r->in.Reserved1);
1477                 ndr->depth++;
1478                 ndr_print_uint32(ndr, "Reserved1", *r->in.Reserved1);
1479                 ndr->depth--;
1480                 ndr->depth--;
1481         }
1482         if (flags & NDR_OUT) {
1483                 ndr_print_struct(ndr, "out", "EcDoRpcExt");
1484                 ndr->depth++;
1485                 ndr_print_ptr(ndr, "handle", r->out.handle);
1486                 ndr->depth++;
1487                 ndr_print_policy_handle(ndr, "handle", r->out.handle);
1488                 ndr->depth--;
1489                 ndr_print_ptr(ndr, "pulFlags", r->out.pulFlags);
1490                 ndr->depth++;
1491                 ndr_print_uint32(ndr, "pulFlags", *r->out.pulFlags);
1492                 ndr->depth--;
1493
1494                 /* Put MAPI response blob into a ndr_pull structure */
1495                 if (*r->out.pcbOut) {
1496                         rgbOut.data = talloc_memdup(mem_ctx, r->out.rgbOut, *r->out.pcbOut);
1497                         rgbOut.length = *r->out.pcbOut;
1498                         ndr_pull = ndr_pull_init_blob(&rgbOut, mem_ctx);
1499                         ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_NOALIGN);
1500                         while (ndr_pull->offset < ndr_pull->data_size) {
1501                                 mapi_response = talloc_zero(NULL, struct mapi2k7_response);
1502                                 mapi_response->mapi_response = talloc_zero(mapi_response, struct mapi_response);
1503                                 ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response);
1504                                 ndr_print_mapi2k7_response(ndr, "mapi_response", 
1505                                                    (const struct mapi2k7_response *)mapi_response);
1506                                 talloc_free(mapi_response);
1507                         }
1508                         talloc_free(ndr_pull);
1509                         talloc_free(rgbOut.data);
1510                 }
1511
1512                 ndr_print_ptr(ndr, "pcbOut", r->out.pcbOut);
1513                 ndr->depth++;
1514                 ndr_print_uint32(ndr, "pcbOut", *r->out.pcbOut);
1515                 ndr->depth--;
1516                 ndr_print_array_uint8(ndr, "Reserved0", r->out.Reserved0, *r->out.Reserved1);
1517                 ndr_print_ptr(ndr, "Reserved1", r->out.Reserved1);
1518                 ndr->depth++;
1519                 ndr_print_uint32(ndr, "Reserved1", *r->out.Reserved1);
1520                 ndr->depth--;
1521                 ndr_print_ptr(ndr, "pulTransTime", r->out.pulTransTime);
1522                 ndr->depth++;
1523                 ndr_print_uint32(ndr, "pulTransTime", *r->out.pulTransTime);
1524                 ndr->depth--;
1525                 ndr_print_MAPISTATUS(ndr, "result", r->out.result);
1526                 ndr->depth--;
1527         }
1528         ndr->depth--;
1529
1530         talloc_free(mem_ctx);
1531 }
1532
1533 _PUBLIC_ void ndr_print_EcDoRpcExt2(struct ndr_print *ndr, const char *name, int flags, const struct EcDoRpcExt2 *r)
1534 {
1535         uint32_t                cntr_rgbAuxOut_0;
1536         DATA_BLOB               rgbIn;
1537         DATA_BLOB               rgbAuxIn;
1538         DATA_BLOB               rgbOut;
1539         struct ndr_pull         *ndr_pull;
1540         struct mapi2k7_request  *mapi_request;
1541         struct mapi2k7_response *mapi_response;
1542         TALLOC_CTX              *mem_ctx;
1543
1544         mem_ctx = talloc_named(NULL, 0, "ndr_print_EcDoRpcExt2");
1545
1546         ndr_print_struct(ndr, name, "EcDoRpcExt2");
1547         ndr->depth++;
1548         if (flags & NDR_SET_VALUES) {
1549                 ndr->flags |= LIBNDR_PRINT_SET_VALUES;
1550         }
1551         if (flags & NDR_IN) {
1552                 ndr_print_struct(ndr, "in", "EcDoRpcExt2");
1553                 ndr->depth++;
1554                 ndr_print_ptr(ndr, "handle", r->in.handle);
1555                 ndr->depth++;
1556                 ndr_print_policy_handle(ndr, "handle", r->in.handle);
1557                 ndr->depth--;
1558                 ndr_print_ptr(ndr, "pulFlags", r->in.pulFlags);
1559                 ndr->depth++;
1560                 ndr_print_uint32(ndr, "pulFlags", *r->in.pulFlags);
1561                 ndr->depth--;
1562
1563                 /* Put MAPI request blob into a ndr_pull structure */
1564                 rgbIn.data = (uint8_t *)talloc_memdup(mem_ctx, r->in.rgbIn, r->in.cbIn);
1565                 rgbIn.length = r->in.cbIn;
1566                 dump_data(0, rgbIn.data, rgbIn.length);
1567                 ndr_pull = ndr_pull_init_blob(&rgbIn, mem_ctx);
1568                 ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_NOALIGN);
1569                 mapi_request = talloc_zero(mem_ctx, struct mapi2k7_request);
1570                 mapi_request->mapi_request = talloc_zero(mapi_request, struct mapi_request);
1571                 ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request);
1572                 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
1573                 talloc_free(mapi_request);
1574                 talloc_free(ndr_pull);
1575                 talloc_free(rgbIn.data);
1576
1577                 ndr_print_uint32(ndr, "cbIn", r->in.cbIn);
1578                 ndr_print_ptr(ndr, "pcbOut", r->in.pcbOut);
1579                 ndr->depth++;
1580                 ndr_print_uint32(ndr, "pcbOut", *r->in.pcbOut);
1581                 ndr->depth--;
1582
1583                 rgbAuxIn.data = r->in.rgbAuxIn;
1584                 rgbAuxIn.length = r->in.cbAuxIn;
1585                 ndr_print_DATA_BLOB(ndr, "rgbAuxIn", rgbAuxIn);
1586                 /* ndr_print_array_uint8(ndr, "rgbAuxIn", r->in.rgbAuxIn, r->in.cbAuxIn); */
1587                 ndr_print_uint32(ndr, "cbAuxIn", r->in.cbAuxIn);
1588                 ndr_print_ptr(ndr, "pcbAuxOut", r->in.pcbAuxOut);
1589                 ndr->depth++;
1590                 ndr_print_uint32(ndr, "pcbAuxOut", *r->in.pcbAuxOut);
1591                 ndr->depth--;
1592                 ndr->depth--;
1593         }
1594         if (flags & NDR_OUT) {
1595                 ndr_print_struct(ndr, "out", "EcDoRpcExt2");
1596                 ndr->depth++;
1597                 ndr_print_ptr(ndr, "handle", r->out.handle);
1598                 ndr->depth++;
1599                 ndr_print_policy_handle(ndr, "handle", r->out.handle);
1600                 ndr->depth--;
1601                 ndr_print_ptr(ndr, "pulFlags", r->out.pulFlags);
1602                 ndr->depth++;
1603                 ndr_print_uint32(ndr, "pulFlags", *r->out.pulFlags);
1604                 ndr->depth--;
1605
1606                 /* Put MAPI response blob into a ndr_pull structure */
1607                 if (*r->out.pcbOut) {
1608                   rgbOut.data = (uint8_t *)talloc_memdup(mem_ctx, r->out.rgbOut, *r->out.pcbOut);
1609                         rgbOut.length = *r->out.pcbOut;
1610                         ndr_pull = ndr_pull_init_blob(&rgbOut, mem_ctx);
1611                         ndr_set_flags(&ndr_pull->flags, LIBNDR_FLAG_NOALIGN);
1612                         while (ndr_pull->offset < ndr_pull->data_size) {
1613                                 mapi_response = talloc_zero(NULL, struct mapi2k7_response);
1614                                 mapi_response->mapi_response = talloc_zero(mapi_response, struct mapi_response);
1615                                 ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response);
1616                                 ndr_print_mapi2k7_response(ndr, "mapi_response", 
1617                                                    (const struct mapi2k7_response *)mapi_response);
1618                                 talloc_free(mapi_response);
1619                         }
1620                         talloc_free(ndr_pull);
1621                         talloc_free(rgbOut.data);
1622                 }
1623                 /* ndr_print_array_uint8(ndr, "rgbOut", r->out.rgbOut, *r->out.pcbOut); */
1624                 ndr_print_ptr(ndr, "pcbOut", r->out.pcbOut);
1625                 ndr->depth++;
1626                 ndr_print_uint32(ndr, "pcbOut", *r->out.pcbOut);
1627                 ndr->depth--;
1628                 if (r->out.rgbAuxOut && r->out.pcbAuxOut) {
1629                         ndr->print(ndr, "%s: ARRAY(%d)", "rgbAuxOut", (int)*r->out.pcbAuxOut);
1630                         ndr->depth++;
1631                         for (cntr_rgbAuxOut_0=0;cntr_rgbAuxOut_0<*r->out.pcbAuxOut;cntr_rgbAuxOut_0++) {
1632                                 char *idx_0=NULL;
1633                                 if (asprintf(&idx_0, "[%d]", cntr_rgbAuxOut_0) != -1) {
1634                                         ndr_print_uint32(ndr, "rgbAuxOut", r->out.rgbAuxOut[cntr_rgbAuxOut_0]);
1635                                         free(idx_0);
1636                                 }
1637                         }
1638                 } else {
1639                         ndr->print(ndr, "%s: NULL", "rgbAuxOut");
1640                 }
1641                 ndr->depth--;
1642                 ndr_print_ptr(ndr, "pcbAuxOut", r->out.pcbAuxOut);
1643                 ndr->depth++;
1644                 ndr_print_uint32(ndr, "pcbAuxOut", *r->out.pcbAuxOut);
1645                 ndr->depth--;
1646                 ndr_print_ptr(ndr, "pulTransTime", r->out.pulTransTime);
1647                 ndr->depth++;
1648                 ndr_print_uint32(ndr, "pulTransTime", *r->out.pulTransTime);
1649                 ndr->depth--;
1650                 ndr_print_MAPISTATUS(ndr, "result", r->out.result);
1651                 ndr->depth--;
1652         }
1653         ndr->depth--;
1654
1655         talloc_free(mem_ctx);
1656 }
1657
1658 /*
1659   We need to pull QueryRows replies on our own:
1660   If we have no results, do not push/pull the DATA_BLOB
1661 */
1662
1663 enum ndr_err_code ndr_push_QueryRows_repl(struct ndr_push *ndr, int ndr_flags, const struct QueryRows_repl *r)
1664 {
1665         {
1666                 uint32_t _flags_save_STRUCT = ndr->flags;
1667                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1668                 if (ndr_flags & NDR_SCALARS) {
1669                         NDR_CHECK(ndr_push_align(ndr, 4));
1670                         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->Origin));
1671                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->RowCount));
1672
1673                         if (r->RowCount) {
1674                                 uint32_t _flags_save_DATA_BLOB = ndr->flags;
1675                                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
1676                                 NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->RowData));
1677                                 ndr->flags = _flags_save_DATA_BLOB;
1678                         }
1679                 }
1680                 if (ndr_flags & NDR_BUFFERS) {
1681                 }
1682                 ndr->flags = _flags_save_STRUCT;
1683         }
1684         return NDR_ERR_SUCCESS;
1685 }
1686
1687 enum ndr_err_code ndr_pull_QueryRows_repl(struct ndr_pull *ndr, int ndr_flags, struct QueryRows_repl *r)
1688 {
1689         {
1690                 uint32_t _flags_save_STRUCT = ndr->flags;
1691                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1692                 if (ndr_flags & NDR_SCALARS) {
1693                         NDR_CHECK(ndr_pull_align(ndr, 4));
1694                         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->Origin));
1695                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->RowCount));
1696
1697                         if (r->RowCount)
1698                         {
1699                                 uint32_t _flags_save_DATA_BLOB = ndr->flags;
1700
1701                                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING);
1702                                 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->RowData));
1703                                 ndr->flags = _flags_save_DATA_BLOB;
1704                         } else {
1705                                 r->RowData.length = 0;
1706                                 r->RowData.data = NULL;
1707                         }
1708                 }
1709                 if (ndr_flags & NDR_BUFFERS) {
1710                 }
1711                 ndr->flags = _flags_save_STRUCT;
1712         }
1713         return NDR_ERR_SUCCESS;
1714 }
1715
1716
1717 enum ndr_err_code ndr_push_Logon_req(struct ndr_push *ndr, int ndr_flags, const struct Logon_req *r)
1718 {
1719         {
1720                 uint32_t _flags_save_STRUCT = ndr->flags;
1721                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1722                 if (ndr_flags & NDR_SCALARS) {
1723                         NDR_CHECK(ndr_push_align(ndr, 4));
1724                         NDR_CHECK(ndr_push_LogonFlags(ndr, NDR_SCALARS, r->LogonFlags));
1725                         NDR_CHECK(ndr_push_OpenFlags(ndr, NDR_SCALARS, r->OpenFlags));
1726                         NDR_CHECK(ndr_push_StoreState(ndr, NDR_SCALARS, r->StoreState));
1727                         if (r->EssDN && r->EssDN[0] != '\0') {
1728                                 uint32_t _flags_save_string = ndr->flags;
1729                                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2);
1730                                 NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->EssDN));
1731                                 ndr->flags = _flags_save_string;
1732                         } else {
1733                                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 0));
1734                         }
1735                 }
1736                 if (ndr_flags & NDR_BUFFERS) {
1737                 }
1738                 ndr->flags = _flags_save_STRUCT;
1739         }
1740         return NDR_ERR_SUCCESS;
1741 }
1742
1743
1744 _PUBLIC_ void ndr_print_SBinary_short(struct ndr_print *ndr, const char *name, const struct SBinary_short *r)
1745 {
1746         ndr->print(ndr, "%-25s: SBinary_short cb=%u", name, (unsigned)r->cb);
1747         {
1748                 uint32_t _flags_save_STRUCT = ndr->flags;
1749                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1750                 ndr->depth++;
1751                 dump_data(0, r->lpb, r->cb);
1752                 ndr->depth--;
1753                 ndr->flags = _flags_save_STRUCT;
1754         }
1755 }
1756
1757 _PUBLIC_ void ndr_print_Binary_r(struct ndr_print *ndr, const char *name, const struct Binary_r *r)
1758 {
1759         ndr->print(ndr, "%-25s: Binary_r cb=%u", name, (unsigned)r->cb);
1760         {
1761                 uint32_t _flags_save_STRUCT = ndr->flags;
1762                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1763                 ndr->depth++;
1764                 dump_data(0, r->lpb, r->cb);
1765                 ndr->depth--;
1766                 ndr->flags = _flags_save_STRUCT;
1767         }
1768 }
1769
1770 _PUBLIC_ void ndr_print_fuzzyLevel(struct ndr_print *ndr, const char *name, uint32_t r)
1771 {
1772         ndr_print_uint32(ndr, name, r);
1773         ndr->depth++;
1774         switch ((r & 0x0000FFFF)) {
1775         case FL_FULLSTRING:
1776                 ndr->print(ndr, "%-25s: FL_FULLSTRING", "lower  16 bits");
1777                 break;
1778         case FL_SUBSTRING:
1779                 ndr->print(ndr, "%-25s: FL_SUBSTRING", "lower  16 bits");
1780                 break;
1781         case FL_PREFIX:
1782                 ndr->print(ndr, "%-25s: FL_PREFIX", "lower  16 bits");
1783                 break;
1784         }
1785         ndr->print(ndr, "%-25s", "higher 16 bits");
1786         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "FL_IGNORECASE", FL_IGNORECASE, r);
1787         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "FL_IGNORENONSPACE", FL_IGNORENONSPACE, r);
1788         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "FL_LOOSE", FL_LOOSE, r);
1789         ndr->depth--;
1790 }
1791
1792 /*
1793  * Fake wrapper over mapi_SRestriction. Workaround the no-pointer deep
1794  * recursion problem in pidl
1795  */
1796 enum ndr_err_code ndr_push_mapi_SRestriction_wrap(struct ndr_push *ndr, int ndr_flags, const struct mapi_SRestriction_wrap *r)
1797 {
1798         return ndr_push_mapi_SRestriction(ndr, ndr_flags, (struct mapi_SRestriction *)r);
1799 }
1800
1801 enum ndr_err_code ndr_pull_mapi_SRestriction_wrap(struct ndr_pull *ndr, int ndr_flags, struct mapi_SRestriction_wrap *r)
1802 {
1803         return ndr_pull_mapi_SRestriction(ndr, ndr_flags, (struct mapi_SRestriction *)r);
1804 }
1805
1806 void ndr_print_mapi_SRestriction_wrap(struct ndr_print *ndr, const char *name, const struct mapi_SRestriction_wrap *r)
1807 {
1808         ndr_print_mapi_SRestriction(ndr, name, (const struct mapi_SRestriction *)r);
1809 }
1810
1811 /*
1812  * Fake wrapper over mapi_SNotRestriction. Workaround the pointer inclusion
1813  * problem in pidl
1814  */
1815 enum ndr_err_code ndr_push_mapi_SNotRestriction(struct ndr_push *ndr, int ndr_flags, const struct mapi_SNotRestriction *r)
1816 {
1817         return ndr_push_mapi_SRestriction(ndr, ndr_flags, r->res);
1818 }
1819
1820 enum ndr_err_code ndr_pull_mapi_SNotRestriction(struct ndr_pull *ndr, int ndr_flags, struct mapi_SNotRestriction *r)
1821 {
1822         return ndr_pull_mapi_SRestriction(ndr, ndr_flags, r->res);
1823 }
1824
1825 void ndr_print_mapi_SNotRestriction(struct ndr_print *ndr, const char *name, const struct mapi_SNotRestriction *r)
1826 {
1827         ndr_print_mapi_SRestriction(ndr, name, r->res);
1828 }
1829
1830 /*
1831  * Fake wrapper over mapi_SPropValue. Workaround the no-pointer deep
1832  * recursion problem in pidl
1833  */
1834 enum ndr_err_code ndr_push_mapi_SPropValue_wrap(struct ndr_push *ndr, int ndr_flags, const struct mapi_SPropValue_wrap *r)
1835 {
1836         NDR_CHECK(ndr_push_align(ndr, 8));
1837         return ndr_push_mapi_SPropValue(ndr, NDR_SCALARS, (const struct mapi_SPropValue *)r);
1838 }
1839
1840 enum ndr_err_code ndr_pull_mapi_SPropValue_wrap(struct ndr_pull *ndr, int ndr_flags, struct mapi_SPropValue_wrap *r)
1841 {
1842         return ndr_pull_mapi_SPropValue(ndr, NDR_SCALARS, (struct mapi_SPropValue *)r);
1843 }
1844
1845 void ndr_print_mapi_SPropValue_wrap(struct ndr_print *ndr, const char *name, const struct mapi_SPropValue_wrap *r)
1846 {
1847         ndr_print_mapi_SPropValue(ndr, name, (const struct mapi_SPropValue *)r);
1848 }
1849
1850
1851 /*
1852  * Fake wrapper over mapi_SPropValue_array. Workaround the no-pointer deep
1853  * recursion problem in pidl
1854  */
1855 enum ndr_err_code ndr_push_mapi_SPropValue_array_wrap(struct ndr_push *ndr, int ndr_flags, const struct mapi_SPropValue_array_wrap *r)
1856 {
1857         NDR_CHECK(ndr_push_align(ndr, 8));
1858         return ndr_push_mapi_SPropValue_array(ndr, NDR_SCALARS, (const struct mapi_SPropValue_array *)r);
1859 }
1860
1861 enum ndr_err_code ndr_pull_mapi_SPropValue_array_wrap(struct ndr_pull *ndr, int ndr_flags, struct mapi_SPropValue_array_wrap *r)
1862 {
1863         return ndr_pull_mapi_SPropValue_array(ndr, NDR_SCALARS, (struct mapi_SPropValue_array *)r);
1864 }
1865
1866 void ndr_print_mapi_SPropValue_array_wrap(struct ndr_print *ndr, const char *name, const struct mapi_SPropValue_array_wrap *r)
1867 {
1868         ndr_print_mapi_SPropValue_array(ndr, name, (const struct mapi_SPropValue_array *)r);
1869 }
1870
1871 enum ndr_err_code ndr_push_RestrictionVariable(struct ndr_push *ndr, int ndr_flags, const union RestrictionVariable *r)
1872 {
1873         {
1874                 uint32_t _flags_save_STRUCT = ndr->flags;
1875                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1876                 if (ndr_flags & NDR_SCALARS) {
1877                         int level = ndr_push_get_switch_value(ndr, r);
1878                         switch (level) {
1879                                 case 0x0: {
1880                                         break; }
1881
1882                                 case 0x1: {
1883                                         NDR_CHECK(ndr_push_mapi_SRestriction_comment(ndr, NDR_SCALARS, &r->res[0]));
1884                                 break; }
1885
1886                                 default:
1887                                         return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
1888                         }
1889                 }
1890                 if (ndr_flags & NDR_BUFFERS) {
1891                         int level = ndr_push_get_switch_value(ndr, r);
1892                         switch (level) {
1893                                 case 0x0:
1894                                 break;
1895
1896                                 case 0x1:
1897                                         if (r->res) {
1898                                                 NDR_CHECK(ndr_push_mapi_SRestriction_comment(ndr, NDR_BUFFERS, &r->res[0]));
1899                                         }
1900                                 break;
1901
1902                                 default:
1903                                         return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
1904                         }
1905                 }
1906                 ndr->flags = _flags_save_STRUCT;
1907         }
1908         return NDR_ERR_SUCCESS;
1909 }
1910
1911 enum ndr_err_code  ndr_pull_RestrictionVariable(struct ndr_pull *ndr, int ndr_flags, union RestrictionVariable *r)
1912 {
1913         int level;
1914         TALLOC_CTX *_mem_save_res_0;
1915         level = ndr_pull_get_switch_value(ndr, r);
1916         {
1917                 uint32_t _flags_save_STRUCT = ndr->flags;
1918                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1919
1920                 if (ndr_flags & NDR_SCALARS) {
1921                         switch (level) {
1922                                 case 0x0: {
1923                                 break; }
1924
1925                                 case 0x1: {
1926                                         NDR_CHECK(ndr_pull_align(ndr, 4));
1927                                         NDR_PULL_ALLOC_N(ndr, r->res, 1);
1928                                         _mem_save_res_0 = NDR_PULL_GET_MEM_CTX(ndr);
1929                                         NDR_PULL_SET_MEM_CTX(ndr, r->res, 0);
1930                                         NDR_CHECK(ndr_pull_mapi_SRestriction_comment(ndr, NDR_SCALARS, &r->res[0]));
1931                                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_res_0, 0);
1932                                 break; }
1933
1934                                 default:
1935                                         return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
1936                         }
1937                 }
1938                 if (ndr_flags & NDR_BUFFERS) {
1939                         switch (level) {
1940                                 case 0x0:
1941                                 break;
1942
1943                                 case 0x1:
1944                                         if (r->res) {
1945                                                 _mem_save_res_0 = NDR_PULL_GET_MEM_CTX(ndr);
1946                                                 NDR_PULL_SET_MEM_CTX(ndr, r->res, 0);
1947                                                 NDR_CHECK(ndr_pull_mapi_SRestriction_comment(ndr, NDR_BUFFERS, &r->res[0]));
1948                                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_res_0, 0);
1949                                 break; }
1950
1951                                 default:
1952                                         return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
1953                         }
1954                 }
1955                 ndr->flags = _flags_save_STRUCT;
1956         }
1957         return NDR_ERR_SUCCESS;
1958 }
1959
1960
1961 _PUBLIC_ void ndr_print_RestrictionVariable(struct ndr_print *ndr, const char *name, const union RestrictionVariable *r)
1962 {
1963         int level;
1964         level = ndr_print_get_switch_value(ndr, r);
1965         ndr_print_union(ndr, name, level, "RestrictionVariable");
1966         switch (level) {
1967                 case 0x0:
1968                 break;
1969
1970                 case 0x1:
1971                         ndr_print_ptr(ndr, "res", r->res);
1972                         ndr->depth++;
1973                         if (r->res) {
1974                                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
1975                                 ndr_print_mapi_SRestriction_comment(ndr, "res", &r->res[0]);
1976                         }
1977                         ndr->depth--;
1978                 break;
1979         }
1980 }
1981
1982 enum ndr_err_code ndr_push_Release_req(struct ndr_push *ndr, int ndr_flags, const struct Release_req *r)
1983 {
1984         return NDR_ERR_SUCCESS;
1985 }
1986
1987 enum ndr_err_code ndr_pull_Release_req(struct ndr_pull *ndr, int ndr_flags, struct Release_req *r)
1988 {
1989         return NDR_ERR_SUCCESS;
1990 }
1991
1992 enum ndr_err_code ndr_push_Release_repl(struct ndr_push *ndr, int ndr_flags, const struct Release_repl *r)
1993 {
1994         return NDR_ERR_SUCCESS;
1995 }
1996
1997 enum ndr_err_code ndr_pull_Release_repl(struct ndr_pull *ndr, int ndr_flags, struct Release_repl *r)
1998 {
1999         return NDR_ERR_SUCCESS;
2000 }
2001
2002
2003 enum ndr_err_code ndr_push_GetSearchCriteria_repl(struct ndr_push *ndr, int ndr_flags, const struct GetSearchCriteria_repl *r)
2004 {
2005         uint32_t cntr_FolderIds_0;
2006         {
2007                 uint32_t _flags_save_STRUCT = ndr->flags;
2008                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
2009                 if (ndr_flags & NDR_SCALARS) {
2010                         NDR_CHECK(ndr_push_align(ndr, 8));
2011                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->RestrictionDataSize));
2012                         if (r->RestrictionDataSize) {
2013                                 struct ndr_push *_ndr_RestrictionData;
2014                                 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_RestrictionData, 0, r->RestrictionDataSize));
2015                                 NDR_CHECK(ndr_push_mapi_SRestriction(_ndr_RestrictionData, NDR_SCALARS|NDR_BUFFERS, &r->RestrictionData));
2016                                 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_RestrictionData, 0, r->RestrictionDataSize));
2017                         }
2018                         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->LogonId));
2019                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->FolderIdCount));
2020                         for (cntr_FolderIds_0 = 0; cntr_FolderIds_0 < r->FolderIdCount; cntr_FolderIds_0++) {
2021                                 NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->FolderIds[cntr_FolderIds_0]));
2022                         }
2023                         NDR_CHECK(ndr_push_SearchFlags(ndr, NDR_SCALARS, r->SearchFlags));
2024                         NDR_CHECK(ndr_push_trailer_align(ndr, 8));
2025                 }
2026                 if (ndr_flags & NDR_BUFFERS) {
2027                 }
2028                 ndr->flags = _flags_save_STRUCT;
2029         }
2030         return NDR_ERR_SUCCESS;
2031 }
2032
2033
2034 enum ndr_err_code ndr_pull_GetSearchCriteria_repl(struct ndr_pull *ndr, int ndr_flags, struct GetSearchCriteria_repl *r)
2035 {
2036         uint32_t cntr_FolderIds_0;
2037         TALLOC_CTX *_mem_save_FolderIds_0;
2038         {
2039                 uint32_t _flags_save_STRUCT = ndr->flags;
2040                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
2041                 if (ndr_flags & NDR_SCALARS) {
2042                         NDR_CHECK(ndr_pull_align(ndr, 8));
2043                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->RestrictionDataSize));
2044                         if (r->RestrictionDataSize) {
2045                                 struct ndr_pull *_ndr_RestrictionData;
2046                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_RestrictionData, 0, r->RestrictionDataSize));
2047                                 NDR_CHECK(ndr_pull_mapi_SRestriction(_ndr_RestrictionData, NDR_SCALARS|NDR_BUFFERS, &r->RestrictionData));
2048                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_RestrictionData, 0, r->RestrictionDataSize));
2049                         }
2050                         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->LogonId));
2051                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->FolderIdCount));
2052                         NDR_PULL_ALLOC_N(ndr, r->FolderIds, r->FolderIdCount);
2053                         _mem_save_FolderIds_0 = NDR_PULL_GET_MEM_CTX(ndr);
2054                         NDR_PULL_SET_MEM_CTX(ndr, r->FolderIds, 0);
2055                         for (cntr_FolderIds_0 = 0; cntr_FolderIds_0 < r->FolderIdCount; cntr_FolderIds_0++) {
2056                                 NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->FolderIds[cntr_FolderIds_0]));
2057                         }
2058                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_FolderIds_0, 0);
2059                         NDR_CHECK(ndr_pull_SearchFlags(ndr, NDR_SCALARS, &r->SearchFlags));
2060                         NDR_CHECK(ndr_pull_trailer_align(ndr, 8));
2061                 }
2062                 if (ndr_flags & NDR_BUFFERS) {
2063                 }
2064                 ndr->flags = _flags_save_STRUCT;
2065         }
2066         return NDR_ERR_SUCCESS;
2067 }
2068
2069
2070 void ndr_print_GetSearchCriteria_repl(struct ndr_print *ndr, const char *name, const struct GetSearchCriteria_repl *r)
2071 {
2072         uint32_t cntr_FolderIds_0;
2073         ndr_print_struct(ndr, name, "GetSearchCriteria_repl");
2074         {
2075                 uint32_t _flags_save_STRUCT = ndr->flags;
2076                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
2077                 ndr->depth++;
2078                 ndr_print_uint16(ndr, "RestrictionDataSize", r->RestrictionDataSize);
2079                 if (r->RestrictionDataSize) {
2080                         ndr_print_mapi_SRestriction(ndr, "RestrictionData", &r->RestrictionData);
2081                 } else {
2082                         ndr_print_uint8(ndr, "RestrictionData", 0);
2083                 }
2084                 ndr_print_uint8(ndr, "LogonId", r->LogonId);
2085                 ndr_print_uint16(ndr, "FolderIdCount", r->FolderIdCount);
2086                 ndr->print(ndr, "%s: ARRAY(%d)", "FolderIds", (int)r->FolderIdCount);
2087                 ndr->depth++;
2088                 for (cntr_FolderIds_0=0;cntr_FolderIds_0<r->FolderIdCount;cntr_FolderIds_0++) {
2089                         char *idx_0=NULL;
2090                         if (asprintf(&idx_0, "[%d]", cntr_FolderIds_0) != -1) {
2091                                 ndr_print_hyper(ndr, "FolderIds", r->FolderIds[cntr_FolderIds_0]);
2092                                 free(idx_0);
2093                         }
2094                 }
2095                 ndr->depth--;
2096                 ndr_print_SearchFlags(ndr, "SearchFlags", r->SearchFlags);
2097                 ndr->depth--;
2098                 ndr->flags = _flags_save_STRUCT;
2099         }
2100 }
2101
2102 enum ndr_err_code ndr_push_Backoff_req(struct ndr_push *ndr, int ndr_flags, const struct Backoff_req *r)
2103 {
2104         return NDR_ERR_SUCCESS;
2105 }
2106
2107 enum ndr_err_code ndr_pull_Backoff_req(struct ndr_pull *ndr, int ndr_flags, struct Backoff_req *r)
2108 {
2109         return NDR_ERR_SUCCESS;
2110 }
2111
2112 enum ndr_err_code ndr_push_Backoff_repl(struct ndr_push *ndr, int ndr_flags, const struct Backoff_repl *r)
2113 {
2114         return NDR_ERR_SUCCESS;
2115 }
2116
2117 enum ndr_err_code ndr_pull_Backoff_repl(struct ndr_pull *ndr, int ndr_flags, struct Backoff_repl *r)
2118 {
2119         return NDR_ERR_SUCCESS;
2120 }
2121
2122 enum ndr_err_code ndr_push_BufferTooSmall_req(struct ndr_push *ndr, int ndr_flags, const struct BufferTooSmall_req *r)
2123 {
2124         return NDR_ERR_SUCCESS;
2125 }
2126
2127 enum ndr_err_code ndr_pull_BufferTooSmall_req(struct ndr_pull *ndr, int ndr_flags, struct BufferTooSmall_req *r)
2128 {
2129         return NDR_ERR_SUCCESS;
2130 }
2131
2132 enum ndr_err_code ndr_push_BufferTooSmall_repl(struct ndr_push *ndr, int ndr_flags, const struct BufferTooSmall_repl *r)
2133 {
2134         return NDR_ERR_SUCCESS;
2135 }
2136
2137 enum ndr_err_code ndr_pull_BufferTooSmall_repl(struct ndr_pull *ndr, int ndr_flags, struct BufferTooSmall_repl *r)
2138 {
2139         return NDR_ERR_SUCCESS;
2140 }