summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/ndr.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-08 11:21:57 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-08 11:21:57 +0000
commit7d212460a5c00b4039440c2db0dde56e7d519d66 (patch)
tree7c14238930104c5edc8711f480b3ba0095d8d687 /source4/librpc/ndr/ndr.c
parent4e4a63d5185d1567c115e7cbf15022b0fbcbc870 (diff)
downloadsamba-7d212460a5c00b4039440c2db0dde56e7d519d66.tar.gz
samba-7d212460a5c00b4039440c2db0dde56e7d519d66.tar.bz2
samba-7d212460a5c00b4039440c2db0dde56e7d519d66.zip
- corrected some lsa idl
- updated lsa parse code from pidl (This used to be commit 3983b2aee77b0e093847bfc02e02b83ab281f5dd)
Diffstat (limited to 'source4/librpc/ndr/ndr.c')
-rw-r--r--source4/librpc/ndr/ndr.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index 4e5f199835..dabe75d5ac 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -185,3 +185,53 @@ NTSTATUS ndr_push_set_offset(struct ndr_push *ndr, uint32 ofs)
ndr->offset = ofs;
return NT_STATUS_OK;
}
+
+/*
+ push a generic array
+*/
+NTSTATUS ndr_push_array(struct ndr_push *ndr, int ndr_flags, void *base,
+ size_t elsize, uint32 count,
+ NTSTATUS (*push_fn)(struct ndr_push *, int, void *))
+{
+ int i;
+ char *p = base;
+ NDR_CHECK(ndr_push_uint32(ndr, count));
+ for (i=0;i<count;i++) {
+ NDR_CHECK(push_fn(ndr, ndr_flags, p));
+ p += elsize;
+ }
+ return NT_STATUS_OK;
+}
+
+/*
+ pull a generic array
+*/
+NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void **base,
+ size_t elsize, uint32 count,
+ NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *))
+{
+ int i;
+ uint32 max_count;
+ char *p;
+ NDR_ALLOC_N_SIZE(ndr, *base, count, elsize);
+ p = *base;
+ NDR_CHECK(ndr_pull_uint32(ndr, &max_count));
+ if (max_count != count) {
+ /* maybe we can cope with this? */
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ for (i=0;i<count;i++) {
+ NDR_CHECK(pull_fn(ndr, NDR_SCALARS, p));
+ p += elsize;
+ }
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+buffers:
+ p = *base;
+ for (i=0;i<count;i++) {
+ NDR_CHECK(pull_fn(ndr, NDR_BUFFERS, p));
+ p += elsize;
+ }
+done:
+ return NT_STATUS_OK;
+}