summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-05-02 13:37:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:26 -0500
commit591ff7675dfe51f30029cb864df47bc8f6266494 (patch)
tree313e307803f243ecb1bec13c6b0fc8eb97be28d7 /source4/librpc/ndr
parentb686e0b9266c0e6029d9f87f187e56c8d2429586 (diff)
downloadsamba-591ff7675dfe51f30029cb864df47bc8f6266494.tar.gz
samba-591ff7675dfe51f30029cb864df47bc8f6266494.tar.bz2
samba-591ff7675dfe51f30029cb864df47bc8f6266494.zip
r6572: add "string_array" as new scalar type for handling SPOOLSS string array's
metze (This used to be commit 23b529ee090e1858fc18794b949f7e466fa82b0e)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/ndr_string.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index ee76508393..aa612eca38 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -497,3 +497,75 @@ uint32_t ndr_size_string(int ret, const char * const* string, int flags)
if(!(*string)) return ret;
return ret+strlen(*string)+1;
}
+
+/*
+ pull a general string array from the wire
+*/
+NTSTATUS ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a)
+{
+ const char **a = *_a;
+ uint32_t count;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NT_STATUS_OK;
+ }
+
+ for (count = 0;; count++) {
+ const char *s = NULL;
+ a = talloc_realloc(ndr, a, const char *, count + 2);
+ NT_STATUS_HAVE_NO_MEMORY(a);
+ a[count] = NULL;
+ a[count+1] = NULL;
+
+ NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+ if (strcmp("", s)==0) {
+ a[count] = NULL;
+ break;
+ } else {
+ a[count] = s;
+ }
+ }
+
+ *_a =a;
+ return NT_STATUS_OK;
+}
+
+/*
+ push a general string array onto the wire
+*/
+NTSTATUS ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a)
+{
+ uint32_t count;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NT_STATUS_OK;
+ }
+
+ for (count = 0; a && a[count]; count++) {
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count]));
+ }
+
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+
+ return NT_STATUS_OK;
+}
+
+void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
+{
+ uint32_t count;
+ uint32_t i;
+
+ for (count = 0; a && a[count]; count++) {}
+
+ ndr->print(ndr, "%s: ARRAY(%d)", name, count);
+ ndr->depth++;
+ for (i=0;i<count;i++) {
+ char *idx=NULL;
+ asprintf(&idx, "[%d]", i);
+ if (idx) {
+ ndr_print_string(ndr, idx, a[i]);
+ free(idx);
+ }
+ }
+ ndr->depth--;
+}