summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/ndr_basic.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-16 11:36:59 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-16 11:36:59 +0000
commitea266c0625e04a2dc10d25c2fee7b685965fcd3e (patch)
tree3db57fa36d79ab2df9adf6d7faa37f7d644b83b7 /source4/librpc/ndr/ndr_basic.c
parent0c5759a4b2615b9c57ee7de04275ced1fc7d19cb (diff)
downloadsamba-ea266c0625e04a2dc10d25c2fee7b685965fcd3e.tar.gz
samba-ea266c0625e04a2dc10d25c2fee7b685965fcd3e.tar.bz2
samba-ea266c0625e04a2dc10d25c2fee7b685965fcd3e.zip
added support for level1 of EnumPrinters in spoolss. This uses a
number of "magic" add-ons to IDL to make it less painful, hopefully this will make IDL generation useful for horrible systems like spoolss (This used to be commit e18dba7d5a957ef82e8f91733a0bf95d579dcd7a)
Diffstat (limited to 'source4/librpc/ndr/ndr_basic.c')
-rw-r--r--source4/librpc/ndr/ndr_basic.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 31e16b6812..ece496ebde 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -512,3 +512,74 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid)
}
+/*
+ pull a spoolss style "relative string"
+*/
+NTSTATUS ndr_pull_relstr(struct ndr_pull *ndr, int ndr_flags, const char **s)
+{
+ uint32 ofs;
+ int ret;
+ struct ndr_pull_save save;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NT_STATUS_OK;
+ }
+
+ NDR_CHECK(ndr_pull_uint32(ndr, &ofs));
+ ndr_pull_save(ndr, &save);
+ NDR_CHECK(ndr_pull_set_offset(ndr, ofs));
+ ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX,
+ ndr->data+ndr->offset,
+ ndr->data_size - ndr->offset,
+ (const void **)s);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_RELSTR, "Bad relative string");
+ }
+ ndr_pull_restore(ndr, &save);
+ return NT_STATUS_OK;
+}
+
+/*
+ push a spoolss style "relative string"
+*/
+NTSTATUS ndr_push_relstr(struct ndr_push *ndr, int ndr_flags, const char **s)
+{
+ struct ndr_push_save *save;
+ if (ndr_flags & NDR_SCALARS) {
+ save = talloc(ndr->mem_ctx, sizeof(*save));
+ if (!save) return NT_STATUS_NO_MEMORY;
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ ndr_push_save(ndr, save);
+ NDR_CHECK(ndr_push_uint32(ndr, 0xFFFFFFFF));
+ save->next = ndr->relstr_list;
+ ndr->relstr_list = save;
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ struct ndr_push_save save2;
+ uint32 len;
+ int ret;
+ save = ndr->relstr_list;
+ if (!save) {
+ return ndr_push_error(ndr, NDR_ERR_RELSTR, "Empty relstr stack");
+ }
+ ndr->relstr_list = save->next;
+ NDR_CHECK(ndr_push_align(ndr, 2));
+ ndr_push_save(ndr, &save2);
+ ndr_push_restore(ndr, save);
+ NDR_CHECK(ndr_push_uint32(ndr, save2.offset));
+ ndr_push_restore(ndr, &save2);
+ len = 2*(strlen_m(*s)+1);
+ NDR_PUSH_NEED_BYTES(ndr, len);
+ ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len, STR_TERMINATE);
+ if (ret == -1) {
+ return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion");
+ }
+ ndr->offset += len;
+ }
+ return NT_STATUS_OK;
+}
+
+void ndr_print_relstr(struct ndr_print *ndr, const char *name, const char **s)
+{
+ ndr_print_unistr(ndr, name, *s);
+}