source: trunk/server/librpc/ndr/ndr_ntprinting.c

Last change on this file was 862, checked in by Silvan Scherrer, 11 years ago

Samba Server: update trunk to 3.6.23

File size: 2.7 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 routines for marshalling/unmarshalling special ntprinting structures
5
6 Copyright (C) Guenther Deschner 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 "includes.h"
23#include "../librpc/gen_ndr/ndr_ntprinting.h"
24
25_PUBLIC_ uint32_t ndr_ntprinting_string_flags(uint32_t string_flags)
26{
27 uint32_t flags = LIBNDR_FLAG_STR_NULLTERM;
28
29 if (string_flags & LIBNDR_FLAG_STR_ASCII) {
30 flags |= LIBNDR_FLAG_STR_ASCII;
31 } else {
32 flags |= LIBNDR_FLAG_STR_UTF8;
33 }
34
35 return flags;
36}
37
38_PUBLIC_ enum ndr_err_code ndr_pull_ntprinting_printer(struct ndr_pull *ndr, int ndr_flags, struct ntprinting_printer *r)
39{
40 uint32_t _ptr_devmode;
41 TALLOC_CTX *_mem_save_devmode_0;
42 {
43 uint32_t _flags_save_STRUCT = ndr->flags;
44 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
45 if (ndr_flags & NDR_SCALARS) {
46 NDR_CHECK(ndr_pull_align(ndr, 5));
47 NDR_CHECK(ndr_pull_ntprinting_printer_info(ndr, NDR_SCALARS, &r->info));
48 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode));
49 if (_ptr_devmode) {
50 NDR_PULL_ALLOC(ndr, r->devmode);
51 } else {
52 r->devmode = NULL;
53 }
54 }
55 if (ndr_flags & NDR_BUFFERS) {
56 if (r->devmode) {
57 _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr);
58 NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0);
59 r->devmode->string_flags = r->info.string_flags;
60 NDR_CHECK(ndr_pull_ntprinting_devicemode(ndr, NDR_SCALARS|NDR_BUFFERS, r->devmode));
61 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0);
62 }
63 }
64 if (ndr_flags & NDR_SCALARS) {
65 r->count = 0;
66 NDR_PULL_ALLOC_N(ndr, r->printer_data, r->count);
67 while (ndr->offset + 4 <= ndr->data_size) {
68 uint32_t ptr = 0;
69 ptr = IVAL(ndr->data, ndr->offset);
70 if (ptr == 0) {
71 ndr->offset = ndr->offset + 4;
72 break;
73 }
74 r->printer_data = talloc_realloc(ndr, r->printer_data, struct ntprinting_printer_data, r->count + 1);
75 NDR_ERR_HAVE_NO_MEMORY(r->printer_data);
76 r->printer_data[r->count].string_flags = r->info.string_flags;
77 NDR_CHECK(ndr_pull_ntprinting_printer_data(ndr, NDR_SCALARS, &r->printer_data[r->count]));
78 r->count++;
79 }
80 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
81 }
82 ndr->flags = _flags_save_STRUCT;
83 }
84 return NDR_ERR_SUCCESS;
85}
Note: See TracBrowser for help on using the repository browser.