From 631aa1f0efa75924c4d8ba639de80527fb8da7b5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Mar 2005 18:34:18 +0000 Subject: r5661: Be a little stricter on syntax regarding arrays. A pointer to an array can now only be : type *name[]; rather then : type *name; which was supported in the past. Warnings will be given when the first syntax is used. Reasons for this change in behaviour include improved readability and the fact that the second format makes dealing with multiple levels of pointers harder. (This used to be commit a416de5825c540fd3741731c4be05e9a659a6fdb) --- source4/librpc/ndr/libndr.h | 2 ++ source4/librpc/ndr/ndr.c | 26 ++++++++++++++++++++++++++ source4/librpc/ndr/ndr_spoolss_buf.c | 6 ++++-- 3 files changed, 32 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr') diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 4880df43bd..e2ac4279f1 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -49,6 +49,7 @@ struct ndr_pull { struct ndr_token_list *relative_list; struct ndr_token_list *array_size_list; struct ndr_token_list *array_length_list; + struct ndr_token_list *switch_list; /* this is used to ensure we generate unique reference IDs between request and reply */ @@ -68,6 +69,7 @@ struct ndr_push { uint32_t alloc_size; uint32_t offset; + struct ndr_token_list *switch_list; struct ndr_token_list *relative_list; /* this is used to ensure we generate unique reference IDs */ diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 549230bb29..2e350aa0da 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -641,6 +641,32 @@ NTSTATUS ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length) return NT_STATUS_OK; } +/* + store a switch value + */ +NTSTATUS ndr_push_set_switch_value(struct ndr_push *ndr, void *p, uint32_t val) +{ + return ndr_token_store(ndr, &ndr->switch_list, p, val); +} + +NTSTATUS ndr_pull_set_switch_value(struct ndr_pull *ndr, void *p, uint32_t val) +{ + return ndr_token_store(ndr, &ndr->switch_list, p, val); +} + +/* + retrieve a switch value + */ +uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, void *p) +{ + return ndr_token_peek(&ndr->switch_list, p); +} + +uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, void *p) +{ + return ndr_token_peek(&ndr->switch_list, p); +} + /* pull a relative object - stage1 called during SCALARS processing diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index e13e912b68..4b1483709a 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -39,7 +39,8 @@ for (i=0;iout.count;i++) {\ ndr2->data += ndr2->offset;\ ndr2->offset = 0;\ - NDR_CHECK(ndr_push_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, r->in.level, &(*r->out.info)[i]));\ + NDR_CHECK(ndr_push_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \ + NDR_CHECK(ndr_push_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\ }\ if (*r->in.buf_size >= ndr2->offset) {\ buffer = data_blob_const(ndr2->data, ndr2->offset);\ @@ -94,7 +95,8 @@ for (i=0;iout.count;i++) {\ ndr2->data += ndr2->offset;\ ndr2->offset = 0;\ - NDR_CHECK(ndr_pull_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, r->in.level, &(*r->out.info)[i]));\ + NDR_CHECK(ndr_pull_set_switch_value(ndr2, &(*r->out.info)[i], r->in.level)); \ + NDR_CHECK(ndr_pull_##type(ndr2, NDR_SCALARS|NDR_BUFFERS, &(*r->out.info)[i]));\ }\ }\ } while(0) -- cgit