r5446: fix pulling of arrays in EnumXXX functions
[samba.git] / source4 / librpc / ndr / ndr_spoolss_buf.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    routines for marshalling/unmarshalling spoolss subcontext buffer structures
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) Tim Potter 2003
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24
25 #include "includes.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27
28 NTSTATUS pull_spoolss_PrinterInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
29                                        uint32_t level, uint32_t count,
30                                        union spoolss_PrinterInfo **info)
31 {
32         int i;
33         struct ndr_pull *ndr;
34         ndr = ndr_pull_init_blob(blob, mem_ctx);
35         if (!ndr) {
36                 return NT_STATUS_NO_MEMORY;
37         }
38         NDR_ALLOC_N(ndr, *info, count);
39         for (i=0;i<count;i++) {
40                 ndr->data += ndr->offset;
41                 ndr->offset = 0;
42                 NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
43         }
44         return NT_STATUS_OK;
45 }
46
47 NTSTATUS pull_spoolss_FormInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
48                                     uint32_t level, uint32_t count,
49                                     union spoolss_FormInfo **info)
50 {
51         int i;
52         struct ndr_pull *ndr;
53         ndr = ndr_pull_init_blob(blob, mem_ctx);
54         if (!ndr) {
55                 return NT_STATUS_NO_MEMORY;
56         }
57         NDR_ALLOC_N(ndr, *info, count);
58         for (i=0;i<count;i++) {
59                 ndr->data += ndr->offset;
60                 ndr->offset = 0;
61                 NDR_CHECK(ndr_pull_spoolss_FormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
62         }
63         return NT_STATUS_OK;
64 }
65
66 NTSTATUS pull_spoolss_JobInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
67                                    uint32_t level, uint32_t count,
68                                    union spoolss_JobInfo **info)
69 {
70         int i;
71         struct ndr_pull *ndr;
72         ndr = ndr_pull_init_blob(blob, mem_ctx);
73         if (!ndr) {
74                 return NT_STATUS_NO_MEMORY;
75         }
76         NDR_ALLOC_N(ndr, *info, count);
77         for (i=0;i<count;i++) {
78                 ndr->data += ndr->offset;
79                 ndr->offset = 0;
80                 NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
81         }
82         return NT_STATUS_OK;
83 }
84
85 NTSTATUS pull_spoolss_DriverInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
86                                       uint32_t level, uint32_t count,
87                                       union spoolss_DriverInfo **info)
88 {
89         int i;
90         struct ndr_pull *ndr;
91         ndr = ndr_pull_init_blob(blob, mem_ctx);
92         if (!ndr) {
93                 return NT_STATUS_NO_MEMORY;
94         }
95         NDR_ALLOC_N(ndr, *info, count);
96         for (i=0;i<count;i++) {
97                 ndr->data += ndr->offset;
98                 ndr->offset = 0;
99                 NDR_CHECK(ndr_pull_spoolss_DriverInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
100         }
101         return NT_STATUS_OK;
102 }
103
104 NTSTATUS pull_spoolss_PortInfoArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
105                                       uint32_t level, uint32_t count,
106                                       union spoolss_PortInfo **info)
107 {
108         int i;
109         struct ndr_pull *ndr;
110         ndr = ndr_pull_init_blob(blob, mem_ctx);
111         if (!ndr) {
112                 return NT_STATUS_NO_MEMORY;
113         }
114         NDR_ALLOC_N(ndr, *info, count);
115         for (i=0;i<count;i++) {
116                 ndr->data += ndr->offset;
117                 ndr->offset = 0;
118                 NDR_CHECK(ndr_pull_spoolss_PortInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));
119         }
120         return NT_STATUS_OK;
121 }