r3036: Add function to pull an array of structures. Abstracts away the
authorTim Potter <tpot@samba.org>
Mon, 18 Oct 2004 12:18:54 +0000 (12:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:00:01 +0000 (13:00 -0500)
individual routines in ndr_spoolss_buf.c.
(This used to be commit e080a2483da61ee95d21b0355471a4af13c20a81)

source4/librpc/ndr/ndr.c

index 4f6f135cd6a7383ed437cb7f8bfe6742eb50ae0e..02eb3e95baeaf2c4887be0e7590a58b13fa22416 100644 (file)
@@ -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