From 3406ac309252fc978fcfcbf39f85d7e9483b2758 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Oct 2004 12:18:54 +0000 Subject: r3036: Add function to pull an array of structures. Abstracts away the individual routines in ndr_spoolss_buf.c. (This used to be commit e080a2483da61ee95d21b0355471a4af13c20a81) --- source4/librpc/ndr/ndr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 4f6f135cd6..02eb3e95ba 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -249,6 +249,27 @@ done: return NT_STATUS_OK; } +/* + pull a constant size array of structures +*/ +NTSTATUS ndr_pull_struct_array(struct ndr_pull *ndr, uint32_t count, + size_t elsize, void **info, + NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) +{ + int i; + char *base; + + NDR_ALLOC_N_SIZE(ndr, *info, count, elsize); + base = (char *)*info; + + for (i = 0; i < count; i++) { + ndr->data += ndr->offset; + ndr->offset = 0; + NDR_CHECK(pull_fn(ndr, NDR_SCALARS|NDR_BUFFERS, &base[count * elsize])); + } + + return NT_STATUS_OK; +} /* print a generic array -- cgit